Skip to content

Commit e48cebf

Browse files
authored
Merge branch 'ggml-org:master' into master
2 parents b218759 + fae3a28 commit e48cebf

39 files changed

Lines changed: 375 additions & 353 deletions

.devops/vulkan.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apt update && apt install -y git build-essential cmake wget xz-utils
77

88
# Install SSL and Vulkan SDK dependencies
99
RUN apt install -y libssl-dev curl \
10-
libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc
10+
libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc spirv-headers
1111

1212
# Build it
1313
WORKDIR /app

.github/workflows/build-self-hosted.yml

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -141,61 +141,59 @@ jobs:
141141
# amd-smi static
142142
# GG_BUILD_ROCM=1 GG_BUILD_AMDGPU_TARGETS="gfx1101" bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
143143

144-
# TODO: sandbox Mac runners
145-
# ggml-ci-mac-metal:
146-
# runs-on: [self-hosted, macOS, ARM64]
147-
#
148-
# steps:
149-
# - name: Clone
150-
# id: checkout
151-
# uses: actions/checkout@v6
152-
#
153-
# - name: Test
154-
# id: ggml-ci
155-
# run: |
156-
# GG_BUILD_METAL=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
157-
#
158-
# ggml-ci-mac-webgpu:
159-
# runs-on: [self-hosted, macOS, ARM64]
160-
#
161-
# steps:
162-
# - name: Clone
163-
# id: checkout
164-
# uses: actions/checkout@v6
165-
#
166-
# - name: Dawn Dependency
167-
# id: dawn-depends
168-
# run: |
169-
# DAWN_VERSION="v2.0.0"
170-
# DAWN_OWNER="reeselevine"
171-
# DAWN_REPO="dawn"
172-
# DAWN_ASSET_NAME="Dawn-5e9a4865b1635796ccc77dd30057f2b4002a1355-macos-latest-Release"
173-
# echo "Fetching release asset from https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
174-
# curl -L -o artifact.zip \
175-
# "https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
176-
# mkdir dawn
177-
# unzip artifact.zip
178-
# tar -xvf ${DAWN_ASSET_NAME}.tar.gz -C dawn --strip-components=1
179-
#
180-
# - name: Test
181-
# id: ggml-ci
182-
# run: |
183-
# GG_BUILD_WEBGPU=1 GG_BUILD_WEBGPU_DAWN_PREFIX="$GITHUB_WORKSPACE/dawn" \
184-
# bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
185-
#
186-
# ggml-ci-mac-vulkan:
187-
# runs-on: [self-hosted, macOS, ARM64]
188-
#
189-
# steps:
190-
# - name: Clone
191-
# id: checkout
192-
# uses: actions/checkout@v6
193-
#
194-
# - name: Test
195-
# id: ggml-ci
196-
# run: |
197-
# vulkaninfo --summary
198-
# GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
144+
ggml-ci-mac-metal:
145+
runs-on: [self-hosted, macOS, ARM64]
146+
147+
steps:
148+
- name: Clone
149+
id: checkout
150+
uses: actions/checkout@v6
151+
152+
- name: Test
153+
id: ggml-ci
154+
run: |
155+
GG_BUILD_METAL=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
156+
157+
ggml-ci-mac-webgpu:
158+
runs-on: [self-hosted, macOS, ARM64]
159+
160+
steps:
161+
- name: Clone
162+
id: checkout
163+
uses: actions/checkout@v6
164+
165+
- name: Dawn Dependency
166+
id: dawn-depends
167+
run: |
168+
DAWN_VERSION="v20260317.182325"
169+
DAWN_OWNER="google"
170+
DAWN_REPO="dawn"
171+
DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-macos-latest-Release"
172+
echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
173+
curl -L -o artifact.tar.gz \
174+
"https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
175+
mkdir dawn
176+
tar -xvf artifact.tar.gz -C dawn --strip-components=1
177+
178+
- name: Test
179+
id: ggml-ci
180+
run: |
181+
GG_BUILD_WEBGPU=1 GG_BUILD_WEBGPU_DAWN_PREFIX="$GITHUB_WORKSPACE/dawn" \
182+
bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
183+
184+
ggml-ci-mac-vulkan:
185+
runs-on: [self-hosted, macOS, ARM64]
186+
187+
steps:
188+
- name: Clone
189+
id: checkout
190+
uses: actions/checkout@v6
191+
192+
- name: Test
193+
id: ggml-ci
194+
run: |
195+
vulkaninfo --summary
196+
GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
199197
200198
ggml-ci-linux-intel-vulkan:
201199
runs-on: [self-hosted, Linux, Intel]

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ jobs:
318318
id: depends
319319
run: |
320320
sudo apt-get update
321-
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev libssl-dev ninja-build
321+
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
322322
echo "CC=gcc-14" >> "$GITHUB_ENV"
323323
echo "CXX=g++-14" >> "$GITHUB_ENV"
324324

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libssl-dev
203203
else
204204
sudo apt-get update -y
205-
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev libssl-dev ninja-build
205+
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
206206
echo "CC=gcc-14" >> "$GITHUB_ENV"
207207
echo "CXX=g++-14" >> "$GITHUB_ENV"
208208
fi

.github/workflows/server-self-hosted.yml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,42 @@ jobs:
8484
export ${{ matrix.extra_args }}
8585
pytest -v -x -m "not slow"
8686
87-
server-cuda:
88-
runs-on: [self-hosted, llama-server, Linux, NVIDIA]
89-
90-
name: server-cuda (${{ matrix.wf_name }})
91-
strategy:
92-
matrix:
93-
build_type: [Release]
94-
wf_name: ["GPUx1"]
95-
include:
96-
- build_type: Release
97-
extra_args: "LLAMA_ARG_BACKEND_SAMPLING=1"
98-
wf_name: "GPUx1, backend-sampling"
99-
fail-fast: false
100-
101-
steps:
102-
- name: Clone
103-
id: checkout
104-
uses: actions/checkout@v6
105-
with:
106-
fetch-depth: 0
107-
ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
108-
109-
- name: Build
110-
id: cmake_build
111-
run: |
112-
cmake -B build -DGGML_SCHED_NO_REALLOC=ON
113-
cmake --build build --config ${{ matrix.build_type }} -j $(sysctl -n hw.logicalcpu) --target llama-server
114-
115-
- name: Tests
116-
id: server_integration_tests
117-
if: ${{ (!matrix.disabled_on_pr || !github.event.pull_request) }}
118-
run: |
119-
cd tools/server/tests
120-
python3 -m venv venv
121-
source venv/bin/activate
122-
pip install -r requirements.txt
123-
export ${{ matrix.extra_args }}
124-
pytest -v -x -m "not slow"
87+
# TODO: provision CUDA runner
88+
# server-cuda:
89+
# runs-on: [self-hosted, llama-server, Linux, NVIDIA]
90+
#
91+
# name: server-cuda (${{ matrix.wf_name }})
92+
# strategy:
93+
# matrix:
94+
# build_type: [Release]
95+
# wf_name: ["GPUx1"]
96+
# include:
97+
# - build_type: Release
98+
# extra_args: "LLAMA_ARG_BACKEND_SAMPLING=1"
99+
# wf_name: "GPUx1, backend-sampling"
100+
# fail-fast: false
101+
#
102+
# steps:
103+
# - name: Clone
104+
# id: checkout
105+
# uses: actions/checkout@v6
106+
# with:
107+
# fetch-depth: 0
108+
# ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
109+
#
110+
# - name: Build
111+
# id: cmake_build
112+
# run: |
113+
# cmake -B build -DGGML_SCHED_NO_REALLOC=ON
114+
# cmake --build build --config ${{ matrix.build_type }} -j $(sysctl -n hw.logicalcpu) --target llama-server
115+
#
116+
# - name: Tests
117+
# id: server_integration_tests
118+
# if: ${{ (!matrix.disabled_on_pr || !github.event.pull_request) }}
119+
# run: |
120+
# cd tools/server/tests
121+
# python3 -m venv venv
122+
# source venv/bin/activate
123+
# pip install -r requirements.txt
124+
# export ${{ matrix.extra_args }}
125+
# pytest -v -x -m "not slow"

docs/build.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ pacman -S git \
456456
mingw-w64-ucrt-x86_64-gcc \
457457
mingw-w64-ucrt-x86_64-cmake \
458458
mingw-w64-ucrt-x86_64-vulkan-devel \
459-
mingw-w64-ucrt-x86_64-shaderc
459+
mingw-w64-ucrt-x86_64-shaderc \
460+
mingw-w64-ucrt-x86_64-spirv-headers
460461
```
461462

462463
Switch into the `llama.cpp` directory and build using CMake.
@@ -490,9 +491,11 @@ First, follow the official LunarG instructions for the installation and setup of
490491

491492
On Debian / Ubuntu, you can install the required dependencies using:
492493
```sh
493-
sudo apt-get install libvulkan-dev glslc
494+
sudo apt-get install libvulkan-dev glslc spirv-headers
494495
```
495496

497+
SPIRV-Headers (`spirv/unified1/spirv.hpp`) are required for the Vulkan backend and are **not** always pulled in by the Vulkan loader dev package alone. Other distros use names such as `spirv-headers` (Ubuntu / Debian / Arch), or `spirv-headers-devel` (Fedora / openSUSE). On Windows, the LunarG Vulkan SDK’s `Include` directory already contains these headers.
498+
496499
#### Common steps
497500

498501
Second, after verifying that you have followed all of the SDK installation/setup steps, use this command to make sure before proceeding:

ggml/include/ggml-backend.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,53 @@ extern "C" {
348348
// Set a callback to be called for each resulting node during graph compute
349349
GGML_API void ggml_backend_sched_set_eval_callback(ggml_backend_sched_t sched, ggml_backend_sched_eval_callback callback, void * user_data);
350350

351+
//
352+
// Meta backend
353+
//
354+
355+
#define GGML_BACKEND_META_MAX_DEVICES 16
356+
357+
enum ggml_backend_meta_split_axis {
358+
// tensor split by tensor dimensions:
359+
GGML_BACKEND_SPLIT_AXIS_0 = 0,
360+
GGML_BACKEND_SPLIT_AXIS_1 = 1,
361+
GGML_BACKEND_SPLIT_AXIS_2 = 2,
362+
GGML_BACKEND_SPLIT_AXIS_3 = 3,
363+
364+
GGML_BACKEND_SPLIT_AXIS_MIRRORED = 10, // all values on all backends
365+
GGML_BACKEND_SPLIT_AXIS_PARTIAL = 11, // each backend has a partial sum
366+
367+
// for internal bookkeeping only:
368+
GGML_BACKEND_SPLIT_AXIS_NONE = 98,
369+
GGML_BACKEND_SPLIT_AXIS_UNKNOWN = 99,
370+
};
371+
GGML_API const char * ggml_backend_meta_split_axis_name(enum ggml_backend_meta_split_axis split_axis);
372+
373+
struct ggml_backend_meta_split_state {
374+
enum ggml_backend_meta_split_axis axis;
375+
376+
// for tensors with axis >= 0 && axis < GGML_MAX_DIMS:
377+
// - each device has a slice of the tensor along the split axis
378+
// - most tensors have n_segments == 1 and a contiguous slice of the tensor data
379+
// - some tensors have an inhomogenenous data layout along the split axis,
380+
// those tensors are divided into segments which are each individually split across devices
381+
// - ne has one entry per segment and device that add up to ggml_tensor::ne for that axis,
382+
// the outer/inner loops are over segments/devices like [seg0_dev0, seg0_dev1, seg1_dev0, seg1_dev1],
383+
// - for example, a transformer may have a fused QKV matrix rather than 3 matrices, those would be 3 separate segments
384+
// that each need to be split individually across devices so that each device gets a slice of Q, K, and V
385+
int64_t ne[16*GGML_BACKEND_META_MAX_DEVICES];
386+
uint32_t n_segments;
387+
};
388+
389+
// function to assign split states for statically allocated tensors, compute tensor split states will be assigned to be compatible:
390+
typedef struct ggml_backend_meta_split_state(*ggml_backend_meta_get_split_state_t)(const struct ggml_tensor * tensor, void * userdata);
391+
392+
// create a new meta device from "simple" devices, meta buffer type/buffer/backend is then derived from this:
393+
// TODO: this looks a bit strange - a backend API creates a device. I think we should try
394+
// express this as a backend registry functionality instead
395+
GGML_API ggml_backend_dev_t ggml_backend_meta_device(
396+
ggml_backend_dev_t * devs, size_t n_devs, ggml_backend_meta_get_split_state_t get_split_state, void * get_split_state_ud);
397+
351398
//
352399
// Utils
353400
//

ggml/src/ggml-alloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "ggml-backend-impl.h"
33
#include "ggml.h"
44
#include "ggml-impl.h"
5+
56
#include <assert.h>
67
#include <limits.h>
78
#include <stdarg.h>

ggml/src/ggml-backend-meta.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include "ggml-alloc.h"
66
#include "ggml-cpp.h"
77

8-
// TODO: tmp
9-
#include "ggml-ext.h"
10-
118
#include <algorithm>
129
#include <cassert>
1310
#include <cmath>

ggml/src/ggml-ext.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)