dlxj commited on
Commit
682b227
·
1 Parent(s): 2517be1

update to support gemma4

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .devops/cann.Dockerfile +1 -1
  2. .devops/cpu.Dockerfile +8 -5
  3. .devops/cuda-new.Dockerfile +0 -95
  4. .devops/cuda.Dockerfile +8 -5
  5. .devops/intel.Dockerfile +19 -2
  6. .devops/llama-cli-cann.Dockerfile +1 -1
  7. .devops/musa.Dockerfile +1 -1
  8. .devops/nix/package.nix +7 -2
  9. .devops/openvino.Dockerfile +1 -1
  10. .devops/rocm.Dockerfile +6 -6
  11. .devops/vulkan.Dockerfile +11 -8
  12. .editorconfig +8 -8
  13. .gitattributes +17 -7
  14. .github/ISSUE_TEMPLATE/010-bug-compilation.yml +1 -1
  15. .github/ISSUE_TEMPLATE/011-bug-results.yml +1 -1
  16. .github/labeler.yml +13 -0
  17. .github/pull_request_template.md +3 -1
  18. .github/workflows/ai-issues.yml +89 -0
  19. .github/workflows/build-android.yml +23 -62
  20. .github/workflows/build-cann.yml +1 -1
  21. .github/workflows/build-cross.yml +1 -0
  22. .github/workflows/build-msys.yml +1 -1
  23. .github/workflows/build-riscv.yml +7 -29
  24. .github/workflows/build-self-hosted.yml +58 -8
  25. .github/workflows/build-vulkan.yml +3 -2
  26. .github/workflows/build.yml +130 -73
  27. .github/workflows/close-issue.yml +1 -1
  28. .github/workflows/copilot-setup-steps.yml +0 -1
  29. .github/workflows/docker.yml +298 -83
  30. .github/workflows/editorconfig.yml +1 -1
  31. .github/workflows/gguf-publish.yml +3 -3
  32. .github/workflows/hip-quality-check.yml +82 -0
  33. .github/workflows/python-lint.yml +1 -1
  34. .github/workflows/python-type-check.yml +16 -11
  35. .github/workflows/release.yml +138 -67
  36. .github/workflows/server-self-hosted.yml +39 -38
  37. .gitignore +5 -1
  38. AGENTS.md +3 -81
  39. CMakeLists.txt +3 -285
  40. CODEOWNERS +20 -1
  41. CONTRIBUTING.md +3 -191
  42. README.md +3 -595
  43. ci/run.sh +56 -48
  44. cmake/arm64-linux-clang.cmake +17 -0
  45. common/CMakeLists.txt +3 -151
  46. common/arg.cpp +119 -76
  47. common/build-info.cpp.in +34 -3
  48. common/build-info.h +11 -0
  49. common/chat-auto-parser-generator.cpp +149 -125
  50. common/chat-auto-parser-helpers.cpp +18 -1
.devops/cann.Dockerfile CHANGED
@@ -4,7 +4,7 @@
4
 
5
  # Define the CANN base image for easier version updates later
6
  ARG CHIP_TYPE=910b
7
- ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.3.rc2-${CHIP_TYPE}-openeuler24.03-py3.11
8
 
9
  # ==============================================================================
10
  # BUILD STAGE
 
4
 
5
  # Define the CANN base image for easier version updates later
6
  ARG CHIP_TYPE=910b
7
+ ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.5.0-${CHIP_TYPE}-openeuler24.03-py3.11
8
 
9
  # ==============================================================================
10
  # BUILD STAGE
.devops/cpu.Dockerfile CHANGED
@@ -1,11 +1,13 @@
1
- ARG UBUNTU_VERSION=22.04
2
 
3
  FROM ubuntu:$UBUNTU_VERSION AS build
4
 
5
  ARG TARGETARCH
6
 
7
  RUN apt-get update && \
8
- apt-get install -y build-essential git cmake libssl-dev
 
 
9
 
10
  WORKDIR /app
11
 
@@ -34,7 +36,7 @@ RUN mkdir -p /app/full \
34
  FROM ubuntu:$UBUNTU_VERSION AS base
35
 
36
  RUN apt-get update \
37
- && apt-get install -y libgomp1 curl\
38
  && apt autoremove -y \
39
  && apt clean -y \
40
  && rm -rf /tmp/* /var/tmp/* \
@@ -55,8 +57,9 @@ RUN apt-get update \
55
  git \
56
  python3 \
57
  python3-pip \
58
- && pip install --upgrade pip setuptools wheel \
59
- && pip install -r requirements.txt \
 
60
  && apt autoremove -y \
61
  && apt clean -y \
62
  && rm -rf /tmp/* /var/tmp/* \
 
1
+ ARG UBUNTU_VERSION=24.04
2
 
3
  FROM ubuntu:$UBUNTU_VERSION AS build
4
 
5
  ARG TARGETARCH
6
 
7
  RUN apt-get update && \
8
+ apt-get install -y gcc-14 g++-14 build-essential git cmake libssl-dev
9
+
10
+ ENV CC=gcc-14 CXX=g++-14
11
 
12
  WORKDIR /app
13
 
 
36
  FROM ubuntu:$UBUNTU_VERSION AS base
37
 
38
  RUN apt-get update \
39
+ && apt-get install -y libgomp1 curl \
40
  && apt autoremove -y \
41
  && apt clean -y \
42
  && rm -rf /tmp/* /var/tmp/* \
 
57
  git \
58
  python3 \
59
  python3-pip \
60
+ python3-wheel \
61
+ && pip install --break-system-packages --upgrade setuptools \
62
+ && pip install --break-system-packages -r requirements.txt \
63
  && apt autoremove -y \
64
  && apt clean -y \
65
  && rm -rf /tmp/* /var/tmp/* \
.devops/cuda-new.Dockerfile DELETED
@@ -1,95 +0,0 @@
1
- ARG UBUNTU_VERSION=24.04
2
- # This needs to generally match the container host's environment.
3
- ARG CUDA_VERSION=13.1.0
4
- # Target the CUDA build image
5
- ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
6
-
7
- ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
8
-
9
- FROM ${BASE_CUDA_DEV_CONTAINER} AS build
10
-
11
- # CUDA architecture to build for (defaults to all supported archs)
12
- ARG CUDA_DOCKER_ARCH=default
13
-
14
- RUN apt-get update && \
15
- apt-get install -y build-essential cmake python3 python3-pip git libssl-dev libgomp1
16
-
17
- WORKDIR /app
18
-
19
- COPY . .
20
-
21
- RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \
22
- export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \
23
- fi && \
24
- cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
25
- cmake --build build --config Release -j$(nproc)
26
-
27
- RUN mkdir -p /app/lib && \
28
- find build -name "*.so*" -exec cp -P {} /app/lib \;
29
-
30
- RUN mkdir -p /app/full \
31
- && cp build/bin/* /app/full \
32
- && cp *.py /app/full \
33
- && cp -r gguf-py /app/full \
34
- && cp -r requirements /app/full \
35
- && cp requirements.txt /app/full \
36
- && cp .devops/tools.sh /app/full/tools.sh
37
-
38
- ## Base image
39
- FROM ${BASE_CUDA_RUN_CONTAINER} AS base
40
-
41
- RUN apt-get update \
42
- && apt-get install -y libgomp1 curl\
43
- && apt autoremove -y \
44
- && apt clean -y \
45
- && rm -rf /tmp/* /var/tmp/* \
46
- && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
47
- && find /var/cache -type f -delete
48
-
49
- COPY --from=build /app/lib/ /app
50
-
51
- ### Full
52
- FROM base AS full
53
-
54
- COPY --from=build /app/full /app
55
-
56
- WORKDIR /app
57
-
58
- RUN apt-get update \
59
- && apt-get install -y \
60
- git \
61
- python3 \
62
- python3-pip \
63
- python3-wheel \
64
- && pip install --break-system-packages --upgrade setuptools \
65
- && pip install --break-system-packages -r requirements.txt \
66
- && apt autoremove -y \
67
- && apt clean -y \
68
- && rm -rf /tmp/* /var/tmp/* \
69
- && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
70
- && find /var/cache -type f -delete
71
-
72
-
73
- ENTRYPOINT ["/app/tools.sh"]
74
-
75
- ### Light, CLI only
76
- FROM base AS light
77
-
78
- COPY --from=build /app/full/llama-cli /app/full/llama-completion /app
79
-
80
- WORKDIR /app
81
-
82
- ENTRYPOINT [ "/app/llama-cli" ]
83
-
84
- ### Server, Server only
85
- FROM base AS server
86
-
87
- ENV LLAMA_ARG_HOST=0.0.0.0
88
-
89
- COPY --from=build /app/full/llama-server /app
90
-
91
- WORKDIR /app
92
-
93
- HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
94
-
95
- ENTRYPOINT [ "/app/llama-server" ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.devops/cuda.Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- ARG UBUNTU_VERSION=22.04
2
  # This needs to generally match the container host's environment.
3
- ARG CUDA_VERSION=12.4.0
4
  # Target the CUDA build image
5
  ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
6
 
@@ -12,7 +12,9 @@ FROM ${BASE_CUDA_DEV_CONTAINER} AS build
12
  ARG CUDA_DOCKER_ARCH=default
13
 
14
  RUN apt-get update && \
15
- apt-get install -y build-essential cmake python3 python3-pip git libssl-dev libgomp1
 
 
16
 
17
  WORKDIR /app
18
 
@@ -39,7 +41,7 @@ RUN mkdir -p /app/full \
39
  FROM ${BASE_CUDA_RUN_CONTAINER} AS base
40
 
41
  RUN apt-get update \
42
- && apt-get install -y libgomp1 curl\
43
  && apt autoremove -y \
44
  && apt clean -y \
45
  && rm -rf /tmp/* /var/tmp/* \
@@ -60,7 +62,8 @@ RUN apt-get update \
60
  git \
61
  python3 \
62
  python3-pip \
63
- && pip install --upgrade pip setuptools wheel \
 
64
  && pip install --break-system-packages -r requirements.txt \
65
  && apt autoremove -y \
66
  && apt clean -y \
 
1
+ ARG UBUNTU_VERSION=24.04
2
  # This needs to generally match the container host's environment.
3
+ ARG CUDA_VERSION=12.8.1
4
  # Target the CUDA build image
5
  ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
6
 
 
12
  ARG CUDA_DOCKER_ARCH=default
13
 
14
  RUN apt-get update && \
15
+ apt-get install -y gcc-14 g++-14 build-essential cmake python3 python3-pip git libssl-dev libgomp1
16
+
17
+ ENV CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14
18
 
19
  WORKDIR /app
20
 
 
41
  FROM ${BASE_CUDA_RUN_CONTAINER} AS base
42
 
43
  RUN apt-get update \
44
+ && apt-get install -y libgomp1 curl \
45
  && apt autoremove -y \
46
  && apt clean -y \
47
  && rm -rf /tmp/* /var/tmp/* \
 
62
  git \
63
  python3 \
64
  python3-pip \
65
+ python3-wheel \
66
+ && pip install --break-system-packages --upgrade setuptools \
67
  && pip install --break-system-packages -r requirements.txt \
68
  && apt autoremove -y \
69
  && apt clean -y \
.devops/intel.Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- ARG ONEAPI_VERSION=2025.2.2-0-devel-ubuntu24.04
2
 
3
  ## Build Image
4
 
@@ -33,8 +33,25 @@ RUN mkdir -p /app/full \
33
 
34
  FROM intel/deep-learning-essentials:$ONEAPI_VERSION AS base
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  RUN apt-get update \
37
- && apt-get install -y libgomp1 curl\
38
  && apt autoremove -y \
39
  && apt clean -y \
40
  && rm -rf /tmp/* /var/tmp/* \
 
1
+ ARG ONEAPI_VERSION=2025.3.2-0-devel-ubuntu24.04
2
 
3
  ## Build Image
4
 
 
33
 
34
  FROM intel/deep-learning-essentials:$ONEAPI_VERSION AS base
35
 
36
+ ARG IGC_VERSION=v2.30.1
37
+ ARG IGC_VERSION_FULL=2_2.30.1+20950
38
+ ARG COMPUTE_RUNTIME_VERSION=26.09.37435.1
39
+ ARG COMPUTE_RUNTIME_VERSION_FULL=26.09.37435.1-0
40
+ ARG IGDGMM_VERSION=22.9.0
41
+ RUN mkdir /tmp/neo/ && cd /tmp/neo/ \
42
+ && wget https://github.com/intel/intel-graphics-compiler/releases/download/$IGC_VERSION/intel-igc-core-${IGC_VERSION_FULL}_amd64.deb \
43
+ && wget https://github.com/intel/intel-graphics-compiler/releases/download/$IGC_VERSION/intel-igc-opencl-${IGC_VERSION_FULL}_amd64.deb \
44
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/intel-ocloc-dbgsym_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.ddeb \
45
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/intel-ocloc_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.deb \
46
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/intel-opencl-icd-dbgsym_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.ddeb \
47
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/intel-opencl-icd_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.deb \
48
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/libigdgmm12_${IGDGMM_VERSION}_amd64.deb \
49
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/libze-intel-gpu1-dbgsym_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.ddeb \
50
+ && wget https://github.com/intel/compute-runtime/releases/download/$COMPUTE_RUNTIME_VERSION/libze-intel-gpu1_${COMPUTE_RUNTIME_VERSION_FULL}_amd64.deb \
51
+ && dpkg --install *.deb
52
+
53
  RUN apt-get update \
54
+ && apt-get install -y libgomp1 curl \
55
  && apt autoremove -y \
56
  && apt clean -y \
57
  && rm -rf /tmp/* /var/tmp/* \
.devops/llama-cli-cann.Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- ARG ASCEND_VERSION=8.1.RC1.alpha001-910b-openeuler22.03-py3.10
2
 
3
  FROM ascendai/cann:$ASCEND_VERSION AS build
4
 
 
1
+ ARG ASCEND_VERSION=8.5.0-910b-openeuler22.03-py3.10
2
 
3
  FROM ascendai/cann:$ASCEND_VERSION AS build
4
 
.devops/musa.Dockerfile CHANGED
@@ -46,7 +46,7 @@ RUN mkdir -p /app/full \
46
  FROM ${BASE_MUSA_RUN_CONTAINER} AS base
47
 
48
  RUN apt-get update \
49
- && apt-get install -y libgomp1 curl\
50
  && apt autoremove -y \
51
  && apt clean -y \
52
  && rm -rf /tmp/* /var/tmp/* \
 
46
  FROM ${BASE_MUSA_RUN_CONTAINER} AS base
47
 
48
  RUN apt-get update \
49
+ && apt-get install -y libgomp1 curl \
50
  && apt autoremove -y \
51
  && apt clean -y \
52
  && rm -rf /tmp/* /var/tmp/* \
.devops/nix/package.nix CHANGED
@@ -16,8 +16,9 @@
16
  rocmPackages,
17
  vulkan-headers,
18
  vulkan-loader,
19
- curl,
20
  shaderc,
 
21
  useBlas ?
22
  builtins.all (x: !x) [
23
  useCuda
@@ -41,6 +42,7 @@
41
  effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv,
42
  enableStatic ? effectiveStdenv.hostPlatform.isStatic,
43
  precompileMetalShaders ? false,
 
44
  }:
45
 
46
  let
@@ -144,6 +146,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
144
  ninja
145
  pkg-config
146
  git
 
147
  ]
148
  ++ optionals useCuda [
149
  cudaPackages.cuda_nvcc
@@ -159,11 +162,13 @@ effectiveStdenv.mkDerivation (finalAttrs: {
159
  ++ optionals useMpi [ mpi ]
160
  ++ optionals useRocm rocmBuildInputs
161
  ++ optionals useBlas [ blas ]
162
- ++ optionals useVulkan vulkanBuildInputs;
 
163
 
164
  cmakeFlags =
165
  [
166
  (cmakeBool "LLAMA_BUILD_SERVER" true)
 
167
  (cmakeBool "BUILD_SHARED_LIBS" (!enableStatic))
168
  (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
169
  (cmakeBool "GGML_NATIVE" false)
 
16
  rocmPackages,
17
  vulkan-headers,
18
  vulkan-loader,
19
+ openssl,
20
  shaderc,
21
+ spirv-headers,
22
  useBlas ?
23
  builtins.all (x: !x) [
24
  useCuda
 
42
  effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv,
43
  enableStatic ? effectiveStdenv.hostPlatform.isStatic,
44
  precompileMetalShaders ? false,
45
+ useWebUi ? true,
46
  }:
47
 
48
  let
 
146
  ninja
147
  pkg-config
148
  git
149
+ spirv-headers
150
  ]
151
  ++ optionals useCuda [
152
  cudaPackages.cuda_nvcc
 
162
  ++ optionals useMpi [ mpi ]
163
  ++ optionals useRocm rocmBuildInputs
164
  ++ optionals useBlas [ blas ]
165
+ ++ optionals useVulkan vulkanBuildInputs
166
+ ++ [ openssl ];
167
 
168
  cmakeFlags =
169
  [
170
  (cmakeBool "LLAMA_BUILD_SERVER" true)
171
+ (cmakeBool "LLAMA_BUILD_WEBUI" useWebUi)
172
  (cmakeBool "BUILD_SHARED_LIBS" (!enableStatic))
173
  (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
174
  (cmakeBool "GGML_NATIVE" false)
.devops/openvino.Dockerfile CHANGED
@@ -78,7 +78,7 @@ ARG http_proxy
78
  ARG https_proxy
79
 
80
  RUN apt-get update \
81
- && apt-get install -y libgomp1 libtbb12 curl\
82
  && apt autoremove -y \
83
  && apt clean -y \
84
  && rm -rf /tmp/* /var/tmp/* \
 
78
  ARG https_proxy
79
 
80
  RUN apt-get update \
81
+ && apt-get install -y libgomp1 libtbb12 curl \
82
  && apt autoremove -y \
83
  && apt clean -y \
84
  && rm -rf /tmp/* /var/tmp/* \
.devops/rocm.Dockerfile CHANGED
@@ -1,8 +1,8 @@
1
  ARG UBUNTU_VERSION=24.04
2
 
3
  # This needs to generally match the container host's environment.
4
- ARG ROCM_VERSION=7.2
5
- ARG AMDGPU_VERSION=7.2
6
 
7
  # Target the ROCm build image
8
  ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
@@ -12,11 +12,11 @@ FROM ${BASE_ROCM_DEV_CONTAINER} AS build
12
 
13
  # Unless otherwise specified, we make a fat build.
14
  # This is mostly tied to rocBLAS supported archs.
15
- # check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-7.2.0/reference/system-requirements.html
16
  # check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityrad/native_linux/native_linux_compatibility.html
17
  # check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityryz/native_linux/native_linux_compatibility.html
18
 
19
- ARG ROCM_DOCKER_ARCH='gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1151;gfx1150;gfx1200;gfx1201'
20
 
21
  # Set ROCm architectures
22
  ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}
@@ -58,7 +58,7 @@ RUN mkdir -p /app/full \
58
  FROM ${BASE_ROCM_DEV_CONTAINER} AS base
59
 
60
  RUN apt-get update \
61
- && apt-get install -y libgomp1 curl\
62
  && apt autoremove -y \
63
  && apt clean -y \
64
  && rm -rf /tmp/* /var/tmp/* \
@@ -79,7 +79,7 @@ RUN apt-get update \
79
  git \
80
  python3-pip \
81
  python3 \
82
- python3-wheel\
83
  && pip install --break-system-packages --upgrade setuptools \
84
  && pip install --break-system-packages -r requirements.txt \
85
  && apt autoremove -y \
 
1
  ARG UBUNTU_VERSION=24.04
2
 
3
  # This needs to generally match the container host's environment.
4
+ ARG ROCM_VERSION=7.2.1
5
+ ARG AMDGPU_VERSION=7.2.1
6
 
7
  # Target the ROCm build image
8
  ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
 
12
 
13
  # Unless otherwise specified, we make a fat build.
14
  # This is mostly tied to rocBLAS supported archs.
15
+ # check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-7.2.1/reference/system-requirements.html
16
  # check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityrad/native_linux/native_linux_compatibility.html
17
  # check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityryz/native_linux/native_linux_compatibility.html
18
 
19
+ ARG ROCM_DOCKER_ARCH='gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201'
20
 
21
  # Set ROCm architectures
22
  ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}
 
58
  FROM ${BASE_ROCM_DEV_CONTAINER} AS base
59
 
60
  RUN apt-get update \
61
+ && apt-get install -y libgomp1 curl \
62
  && apt autoremove -y \
63
  && apt clean -y \
64
  && rm -rf /tmp/* /var/tmp/* \
 
79
  git \
80
  python3-pip \
81
  python3 \
82
+ python3-wheel \
83
  && pip install --break-system-packages --upgrade setuptools \
84
  && pip install --break-system-packages -r requirements.txt \
85
  && apt autoremove -y \
.devops/vulkan.Dockerfile CHANGED
@@ -7,7 +7,7 @@ RUN apt update && apt install -y git build-essential cmake wget xz-utils
7
 
8
  # Install SSL and Vulkan SDK dependencies
9
  RUN apt install -y libssl-dev curl \
10
- libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc
11
 
12
  # Build it
13
  WORKDIR /app
@@ -49,17 +49,20 @@ COPY --from=build /app/full /app
49
 
50
  WORKDIR /app
51
 
 
 
 
 
52
  RUN apt-get update \
53
  && apt-get install -y \
54
  build-essential \
 
55
  git \
56
- python3.13 \
57
- python3.13-dev \
58
- python3-pip \
59
- python3-wheel \
60
- && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 100 \
61
- && pip install --break-system-packages --upgrade setuptools \
62
- && pip install --break-system-packages -r requirements.txt \
63
  && apt autoremove -y \
64
  && apt clean -y \
65
  && rm -rf /tmp/* /var/tmp/* \
 
7
 
8
  # Install SSL and Vulkan SDK dependencies
9
  RUN apt install -y libssl-dev curl \
10
+ libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc spirv-headers
11
 
12
  # Build it
13
  WORKDIR /app
 
49
 
50
  WORKDIR /app
51
 
52
+ ENV PATH="/root/.venv/bin:/root/.local/bin:${PATH}"
53
+
54
+ # Flag for compatibility with pip
55
+ ARG UV_INDEX_STRATEGY="unsafe-best-match"
56
  RUN apt-get update \
57
  && apt-get install -y \
58
  build-essential \
59
+ curl \
60
  git \
61
+ ca-certificates \
62
+ && curl -LsSf https://astral.sh/uv/install.sh | sh \
63
+ && uv python install 3.13 \
64
+ && uv venv --python 3.13 /root/.venv \
65
+ && uv pip install --python /root/.venv/bin/python -r requirements.txt \
 
 
66
  && apt autoremove -y \
67
  && apt clean -y \
68
  && rm -rf /tmp/* /var/tmp/* \
.editorconfig CHANGED
@@ -21,14 +21,6 @@ indent_style = tab
21
  [prompts/*.txt]
22
  insert_final_newline = unset
23
 
24
- [tools/server/public/*]
25
- indent_size = 2
26
-
27
- [tools/server/public/deps_*]
28
- trim_trailing_whitespace = unset
29
- indent_style = unset
30
- indent_size = unset
31
-
32
  [tools/server/deps_*]
33
  trim_trailing_whitespace = unset
34
  indent_style = unset
@@ -61,6 +53,14 @@ charset = unset
61
  trim_trailing_whitespace = unset
62
  insert_final_newline = unset
63
 
 
 
 
 
 
 
 
 
64
  [benches/**]
65
  indent_style = unset
66
  indent_size = unset
 
21
  [prompts/*.txt]
22
  insert_final_newline = unset
23
 
 
 
 
 
 
 
 
 
24
  [tools/server/deps_*]
25
  trim_trailing_whitespace = unset
26
  indent_style = unset
 
53
  trim_trailing_whitespace = unset
54
  insert_final_newline = unset
55
 
56
+ [tools/server/public/**]
57
+ indent_style = unset
58
+ indent_size = unset
59
+ end_of_line = unset
60
+ charset = unset
61
+ trim_trailing_whitespace = unset
62
+ insert_final_newline = unset
63
+
64
  [benches/**]
65
  indent_style = unset
66
  indent_size = unset
.gitattributes CHANGED
@@ -1,9 +1,12 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
 
 
 
2
  *.gguf filter=lfs diff=lfs merge=lfs -text
3
  *.key filter=lfs diff=lfs merge=lfs -text
4
- *.pdf filter=lfs diff=lfs merge=lfs -text
 
5
  *.arrow filter=lfs diff=lfs merge=lfs -text
6
- *.avro filter=lfs diff=lfs merge=lfs -text
7
  *.bin filter=lfs diff=lfs merge=lfs -text
8
  *.bz2 filter=lfs diff=lfs merge=lfs -text
9
  *.ckpt filter=lfs diff=lfs merge=lfs -text
@@ -13,7 +16,6 @@
13
  *.joblib filter=lfs diff=lfs merge=lfs -text
14
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
15
  *.lz4 filter=lfs diff=lfs merge=lfs -text
16
- *.mds filter=lfs diff=lfs merge=lfs -text
17
  *.mlmodel filter=lfs diff=lfs merge=lfs -text
18
  *.model filter=lfs diff=lfs merge=lfs -text
19
  *.msgpack filter=lfs diff=lfs merge=lfs -text
@@ -58,6 +60,14 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  *.jpg filter=lfs diff=lfs merge=lfs -text
59
  *.jpeg filter=lfs diff=lfs merge=lfs -text
60
  *.webp filter=lfs diff=lfs merge=lfs -text
61
- # Video files - compressed
62
- *.mp4 filter=lfs diff=lfs merge=lfs -text
63
- *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
1
+ # Treat the generated single-file WebUI build as binary for diff purposes.
2
+ # Git's pack-file delta compression still works (byte-level), but this prevents
3
+ # git diff from printing the entire minified file on every change.
4
+ tools/server/public/index.html -diff
5
  *.gguf filter=lfs diff=lfs merge=lfs -text
6
  *.key filter=lfs diff=lfs merge=lfs -text
7
+ *.7z filter=lfs diff=lfs merge=lfs -text
8
+ *.txt filter=lfs diff=lfs merge=lfs -text
9
  *.arrow filter=lfs diff=lfs merge=lfs -text
 
10
  *.bin filter=lfs diff=lfs merge=lfs -text
11
  *.bz2 filter=lfs diff=lfs merge=lfs -text
12
  *.ckpt filter=lfs diff=lfs merge=lfs -text
 
16
  *.joblib filter=lfs diff=lfs merge=lfs -text
17
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
18
  *.lz4 filter=lfs diff=lfs merge=lfs -text
 
19
  *.mlmodel filter=lfs diff=lfs merge=lfs -text
20
  *.model filter=lfs diff=lfs merge=lfs -text
21
  *.msgpack filter=lfs diff=lfs merge=lfs -text
 
60
  *.jpg filter=lfs diff=lfs merge=lfs -text
61
  *.jpeg filter=lfs diff=lfs merge=lfs -text
62
  *.webp filter=lfs diff=lfs merge=lfs -text
63
+ *.pdf filter=lfs diff=lfs merge=lfs -text
64
+ *.epub filter=lfs diff=lfs merge=lfs -text
65
+ *.djvu filter=lfs diff=lfs merge=lfs -text
66
+ *.doc filter=lfs diff=lfs merge=lfs -text
67
+ *.mobi filter=lfs diff=lfs merge=lfs -text
68
+ *.azw3 filter=lfs diff=lfs merge=lfs -text
69
+ *.txt filter=lfs diff=lfs merge=lfs -text
70
+ *.md filter=lfs diff=lfs merge=lfs -text
71
+ *.docx filter=lfs diff=lfs merge=lfs -text
72
+ *.azw3 filter=lfs diff=lfs merge=lfs -text
73
+ *.djvu filter=lfs diff=lfs merge=lfs -text
.github/ISSUE_TEMPLATE/010-bug-compilation.yml CHANGED
@@ -41,7 +41,7 @@ body:
41
  attributes:
42
  label: GGML backends
43
  description: Which GGML backends do you know to be affected?
44
- options: [AMX, BLAS, CANN, CPU, CUDA, Hexagon, HIP, Metal, Musa, OpenCL, RPC, SYCL, VirtGPU, Vulkan, WebGPU, zDNN, ZenDNN]
45
  multiple: true
46
  validations:
47
  required: true
 
41
  attributes:
42
  label: GGML backends
43
  description: Which GGML backends do you know to be affected?
44
+ options: [AMX, BLAS, CANN, CPU, CUDA, Hexagon, HIP, Metal, Musa, OpenCL, OpenVINO, RPC, SYCL, VirtGPU, Vulkan, WebGPU, zDNN, ZenDNN]
45
  multiple: true
46
  validations:
47
  required: true
.github/ISSUE_TEMPLATE/011-bug-results.yml CHANGED
@@ -42,7 +42,7 @@ body:
42
  attributes:
43
  label: GGML backends
44
  description: Which GGML backends do you know to be affected?
45
- options: [AMX, BLAS, CANN, CPU, CUDA, Hexagon, HIP, Metal, Musa, OpenCL, RPC, SYCL, VirtGPU, Vulkan, WebGPU, zDNN, ZenDNN]
46
  multiple: true
47
  validations:
48
  required: true
 
42
  attributes:
43
  label: GGML backends
44
  description: Which GGML backends do you know to be affected?
45
+ options: [AMX, BLAS, CANN, CPU, CUDA, Hexagon, HIP, Metal, Musa, OpenCL, OpenVINO, RPC, SYCL, VirtGPU, Vulkan, WebGPU, zDNN, ZenDNN]
46
  multiple: true
47
  validations:
48
  required: true
.github/labeler.yml CHANGED
@@ -27,6 +27,11 @@ IBM zDNN:
27
  - any-glob-to-any-file:
28
  - ggml/include/ggml-zdnn.h
29
  - ggml/src/ggml-zdnn/**
 
 
 
 
 
30
  documentation:
31
  - changed-files:
32
  - any-glob-to-any-file:
@@ -68,10 +73,18 @@ android:
68
  - changed-files:
69
  - any-glob-to-any-file:
70
  - examples/llama.android/**
 
 
 
 
 
71
  server:
72
  - changed-files:
73
  - any-glob-to-any-file:
74
  - tools/server/**
 
 
 
75
  ggml:
76
  - changed-files:
77
  - any-glob-to-any-file:
 
27
  - any-glob-to-any-file:
28
  - ggml/include/ggml-zdnn.h
29
  - ggml/src/ggml-zdnn/**
30
+ AMD ZenDNN:
31
+ - changed-files:
32
+ - any-glob-to-any-file:
33
+ - ggml/include/ggml-zendnn.h
34
+ - ggml/src/ggml-zendnn/**
35
  documentation:
36
  - changed-files:
37
  - any-glob-to-any-file:
 
73
  - changed-files:
74
  - any-glob-to-any-file:
75
  - examples/llama.android/**
76
+ server/webui:
77
+ - changed-files:
78
+ - any-glob-to-any-file:
79
+ - tools/server/webui/**
80
+ - tools/server/public/**
81
  server:
82
  - changed-files:
83
  - any-glob-to-any-file:
84
  - tools/server/**
85
+
86
+
87
+
88
  ggml:
89
  - changed-files:
90
  - any-glob-to-any-file:
.github/pull_request_template.md CHANGED
@@ -1 +1,3 @@
1
- *Make sure to read the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc3613996e5efd54aa6cfa2bf782d034bb40a7cce82e93850b7d7ac0fc3231ff
3
+ size 757
.github/workflows/ai-issues.yml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: AI review (issues)
2
+
3
+ on:
4
+ issues:
5
+ types: [opened]
6
+
7
+ jobs:
8
+ find-related:
9
+ if: github.event.action == 'opened'
10
+ runs-on: [self-hosted, opencode]
11
+
12
+ permissions:
13
+ contents: read
14
+ issues: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v6
19
+ with:
20
+ fetch-depth: 1
21
+
22
+ - name: Find related
23
+ env:
24
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25
+ OPENCODE_PERMISSION: |
26
+ {
27
+ "bash": {
28
+ "*": "deny",
29
+ "gh issue view*": "allow",
30
+ "gh issue list*": "allow",
31
+ "gh issue comment*": "allow",
32
+ "gh search issues*": "allow"
33
+ },
34
+ "webfetch": "deny"
35
+ }
36
+ run: |
37
+ rm AGENTS.md
38
+ rm CLAUDE.md
39
+
40
+ timeout 5m opencode run -m llama.cpp-dgx/ai-review-issues-find-similar --thinking "A new issue has been created:
41
+
42
+ Issue number: ${{ github.event.issue.number }}
43
+
44
+ Lookup the contents of the issue using the following 'gh' command:
45
+
46
+ gh issue view ${{ github.event.issue.number }} --json title,body,url,number
47
+
48
+ Next, perform the following task and then post a SINGLE comment (if needed).
49
+
50
+ ---
51
+
52
+ TASK : FIND RELATED ISSUES
53
+
54
+ Using the 'gh' CLI tool, search through existing issues on Github.
55
+ Find related or similar issues to the newly created one and list them.
56
+ Do not list the new issue itself (it is #${{ github.event.issue.number }}).
57
+
58
+ Consider:
59
+ 1. Similar titles or descriptions
60
+ 2. Same error messages or symptoms
61
+ 3. Related functionality or components
62
+ 4. Similar feature requests
63
+
64
+ ---
65
+
66
+ POSTING YOUR COMMENT:
67
+
68
+ Based on your findings, post a SINGLE comment on issue #${{ github.event.issue.number }}. Build the comment as follows:
69
+
70
+ - If no related issues were found, do NOT comment at all.
71
+ - If related issues were found, include a section listing them with links using the following format:
72
+
73
+ [comment]
74
+ This issue might be similar or related to the following issue(s):
75
+
76
+ - #12942: [brief description of how they are related]
77
+ - #11234: [brief description of how they are related]
78
+ ...
79
+
80
+ _This comment was auto-generated locally using **$GA_ENGINE** on **$GA_MACHINE**_
81
+ [/comment]
82
+
83
+ Remember:
84
+ - Do not include the comment tags in your actual comment.
85
+ - Post at most ONE comment combining all findings.
86
+ - If you didn't find issues that are related enough, post nothing.
87
+ - You have access only to the 'gh' CLI tool - don't try to use other tools.
88
+ - If the output from a tool call is too long, try to limit down the search.
89
+ "
.github/workflows/build-android.yml CHANGED
@@ -40,13 +40,9 @@ jobs:
40
  steps:
41
  - name: Clone
42
  uses: actions/checkout@v6
43
-
44
- # Disabled due to size (400MB) and always 0 cache hits
45
- # - name: ccache
46
- # uses: ggml-org/ccache-action@v1.2.16
47
- # with:
48
- # key: android-build
49
- # evict-old-files: 1d
50
 
51
  - name: Set up JDK
52
  uses: actions/setup-java@v5
@@ -55,7 +51,7 @@ jobs:
55
  distribution: zulu
56
 
57
  - name: Setup Android SDK
58
- uses: android-actions/setup-android@v3
59
  with:
60
  log-accepted-android-sdk-licenses: false
61
 
@@ -66,10 +62,11 @@ jobs:
66
 
67
  android-ndk:
68
  runs-on: ubuntu-latest
69
-
70
- env:
71
- OPENCL_VERSION: 2025.07.22
72
-
 
73
  strategy:
74
  matrix:
75
  include:
@@ -82,59 +79,23 @@ jobs:
82
  - name: Clone
83
  id: checkout
84
  uses: actions/checkout@v6
 
 
 
85
 
86
- - name: Install OpenCL Headers and Libs
87
- id: install_opencl
88
- if: ${{ matrix.build == 'arm64-snapdragon' }}
89
- run: |
90
- mkdir opencl
91
- curl -L -o opencl/clhpp.tar.gz https://github.com/KhronosGroup/OpenCL-CLHPP/archive/refs/tags/v${OPENCL_VERSION}.tar.gz
92
- curl -L -o opencl/headers.tar.gz https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v${OPENCL_VERSION}.tar.gz
93
- curl -L -o opencl/icd-loader.tar.gz https://github.com/KhronosGroup/OpenCL-ICD-Loader/archive/refs/tags/v${OPENCL_VERSION}.tar.gz
94
- tar -xaf opencl/headers.tar.gz -C opencl
95
- tar -xaf opencl/clhpp.tar.gz -C opencl
96
- tar -xaf opencl/icd-loader.tar.gz -C opencl
97
- sudo cp -r opencl/OpenCL-Headers-${OPENCL_VERSION}/CL ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
98
- sudo cp -r opencl/OpenCL-CLHPP-${OPENCL_VERSION}/include/CL/* ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/CL
99
- cd opencl/OpenCL-ICD-Loader-${OPENCL_VERSION}
100
- cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=31 -DANDROID_STL=c++_shared
101
- cmake --build build
102
- sudo cp build/libOpenCL.so ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
103
- rm -rf opencl
104
-
105
- - name: Install Hexagon SDK
106
- id: install_hexsdk
107
- if: ${{ matrix.build == 'arm64-snapdragon' }}
108
- env:
109
- HEXSDK_VER: 6.4.0.2
110
- HEXTLS_VER: 19.0.04
111
- run: |
112
- curl -L -o hex-sdk.tar.gz https://github.com/snapdragon-toolchain/hexagon-sdk/releases/download/v$HEXSDK_VER/hexagon-sdk-v$HEXSDK_VER-amd64-lnx.tar.xz
113
- mkdir hex-sdk
114
- tar -xaf hex-sdk.tar.gz -C hex-sdk
115
- ls -l hex-sdk
116
- sudo mv hex-sdk /opt/hexagon
117
- echo "HEXAGON_SDK_ROOT=/opt/hexagon/$HEXSDK_VER" >> "$GITHUB_ENV"
118
- echo "HEXAGON_TOOLS_ROOT=/opt/hexagon/$HEXSDK_VER/tools/HEXAGON_Tools/$HEXTLS_VER" >> "$GITHUB_ENV"
119
- echo "DEFAULT_HLOS_ARCH=64" >> "$GITHUB_ENV"
120
- echo "DEFAULT_TOOLS_VARIANT=toolv19" >> "$GITHUB_ENV"
121
- echo "DEFAULT_NO_QURT_INC=0" >> "$GITHUB_ENV"
122
- echo "DEFAULT_DSP_ARCH=v73" >> "$GITHUB_ENV"
123
-
124
- - name: Update CMake presets
125
- id: update_presets
126
- if: ${{ matrix.build == 'arm64-snapdragon' }}
127
- run: |
128
- cp docs/backend/snapdragon/CMakeUserPresets.json .
129
-
130
- - name: Build
131
- id: ndk_build
132
  run: |
 
 
 
133
  cmake ${{ matrix.defines }} -B build
134
  cmake --build build
135
  cmake --install build --prefix pkg-adb/llama.cpp
136
 
137
- - name: Test
138
- id: cmake_test
139
- run: |
140
- echo "FIXME: test on devices"
 
 
 
40
  steps:
41
  - name: Clone
42
  uses: actions/checkout@v6
43
+ with:
44
+ fetch-depth: 0
45
+ lfs: false
 
 
 
 
46
 
47
  - name: Set up JDK
48
  uses: actions/setup-java@v5
 
51
  distribution: zulu
52
 
53
  - name: Setup Android SDK
54
+ uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
55
  with:
56
  log-accepted-android-sdk-licenses: false
57
 
 
62
 
63
  android-ndk:
64
  runs-on: ubuntu-latest
65
+ container:
66
+ image: 'ghcr.io/snapdragon-toolchain/arm64-android:v0.3'
67
+ defaults:
68
+ run:
69
+ shell: bash
70
  strategy:
71
  matrix:
72
  include:
 
79
  - name: Clone
80
  id: checkout
81
  uses: actions/checkout@v6
82
+ with:
83
+ fetch-depth: 0
84
+ lfs: false
85
 
86
+ - name: Build Llama.CPP for Hexagon Android
87
+ id: build_llama_cpp_hexagon_android
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  run: |
89
+ if [[ "${{ matrix.build }}" == "arm64-snapdragon" ]]; then
90
+ cp docs/backend/snapdragon/CMakeUserPresets.json .
91
+ fi
92
  cmake ${{ matrix.defines }} -B build
93
  cmake --build build
94
  cmake --install build --prefix pkg-adb/llama.cpp
95
 
96
+ - name: Upload Llama.CPP Hexagon Android Build Artifact
97
+ if: ${{ always() && steps.build_llama_cpp_hexagon_android.outcome == 'success' }}
98
+ uses: actions/upload-artifact@v6
99
+ with:
100
+ name: llama-cpp-android-${{ matrix.build }}
101
+ path: pkg-adb/llama.cpp
.github/workflows/build-cann.yml CHANGED
@@ -63,7 +63,7 @@ jobs:
63
  - name: Set container image
64
  id: cann-image
65
  run: |
66
- image="ascendai/cann:${{ matrix.chip_type == '910b' && '8.3.rc2-910b-openeuler24.03-py3.11' || '8.3.rc2-310p-openeuler24.03-py3.11' }}"
67
  echo "image=${image}" >> "${GITHUB_OUTPUT}"
68
 
69
  - name: Pull container image
 
63
  - name: Set container image
64
  id: cann-image
65
  run: |
66
+ image="ascendai/cann:${{ matrix.chip_type == '910b' && '8.5.0-910b-openeuler24.03-py3.11' || '8.5.0-310p-openeuler24.03-py3.11' }}"
67
  echo "image=${image}" >> "${GITHUB_OUTPUT}"
68
 
69
  - name: Pull container image
.github/workflows/build-cross.yml CHANGED
@@ -246,6 +246,7 @@ jobs:
246
  apt-get install -y --no-install-recommends \
247
  build-essential \
248
  glslc \
 
249
  gcc-14-loongarch64-linux-gnu \
250
  g++-14-loongarch64-linux-gnu \
251
  libvulkan-dev:loong64
 
246
  apt-get install -y --no-install-recommends \
247
  build-essential \
248
  glslc \
249
+ spirv-headers \
250
  gcc-14-loongarch64-linux-gnu \
251
  g++-14-loongarch64-linux-gnu \
252
  libvulkan-dev:loong64
.github/workflows/build-msys.yml CHANGED
@@ -43,7 +43,7 @@ jobs:
43
  # save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
44
 
45
  - name: Setup ${{ matrix.sys }}
46
- uses: msys2/setup-msys2@v2
47
  with:
48
  update: true
49
  msystem: ${{matrix.sys}}
 
43
  # save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
44
 
45
  - name: Setup ${{ matrix.sys }}
46
+ uses: msys2/setup-msys2@cafece8e6baf9247cf9b1bf95097b0b983cc558d # v2
47
  with:
48
  update: true
49
  msystem: ${{matrix.sys}}
.github/workflows/build-riscv.yml CHANGED
@@ -35,7 +35,7 @@ env:
35
 
36
  jobs:
37
  ubuntu-riscv64-native-sanitizer:
38
- runs-on: RISCV64
39
 
40
  continue-on-error: true
41
 
@@ -47,20 +47,9 @@ jobs:
47
  steps:
48
  - name: Install dependencies
49
  run: |
50
- sudo apt-get update
51
-
52
- # Install necessary packages
53
- sudo apt-get install -y libatomic1 libtsan2 gcc-14 g++-14 rustup cmake build-essential wget ccache git-lfs
54
-
55
  # Set gcc-14 and g++-14 as the default compilers
56
  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
57
  sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
58
- sudo ln -sf /usr/bin/gcc-14 /usr/bin/gcc
59
- sudo ln -sf /usr/bin/g++-14 /usr/bin/g++
60
-
61
- # Install Rust stable version
62
- rustup install stable
63
- rustup default stable
64
 
65
  git lfs install
66
 
@@ -73,23 +62,12 @@ jobs:
73
  id: checkout
74
  uses: actions/checkout@v6
75
 
76
- - name: Setup ccache
77
- run: |
78
- # Unique cache directory per matrix combination
79
- export CCACHE_DIR="$HOME/.ccache/sanitizer-${{ matrix.sanitizer }}-${{ matrix.build_type }}"
80
- mkdir -p "$CCACHE_DIR"
81
-
82
- # Configure ccache
83
- ccache --set-config=max_size=5G
84
- ccache --set-config=compression=true
85
- ccache --set-config=compression_level=6
86
- ccache --set-config=cache_dir="$CCACHE_DIR"
87
- ccache --set-config=sloppiness=file_macro,time_macros,include_file_mtime,include_file_ctime
88
- ccache --set-config=hash_dir=false
89
-
90
- # Export for subsequent steps
91
- echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
92
- echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
93
 
94
  - name: Build
95
  id: cmake_build
 
35
 
36
  jobs:
37
  ubuntu-riscv64-native-sanitizer:
38
+ runs-on: ubuntu-24.04-riscv
39
 
40
  continue-on-error: true
41
 
 
47
  steps:
48
  - name: Install dependencies
49
  run: |
 
 
 
 
 
50
  # Set gcc-14 and g++-14 as the default compilers
51
  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
52
  sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
 
 
 
 
 
 
53
 
54
  git lfs install
55
 
 
62
  id: checkout
63
  uses: actions/checkout@v6
64
 
65
+ - name: ccache
66
+ uses: ggml-org/ccache-action@afde29e5b5422e5da23cb1f639e8baecadeadfc3 # https://github.com/ggml-org/ccache-action/pull/1
67
+ with:
68
+ key: ubuntu-riscv64-native-sanitizer-${{ matrix.sanitizer }}-${{ matrix.build_type }}
69
+ evict-old-files: 1d
70
+ save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  - name: Build
73
  id: cmake_build
.github/workflows/build-self-hosted.yml CHANGED
@@ -97,6 +97,36 @@ jobs:
97
  vulkaninfo --summary
98
  GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  # TODO: provision AMX-compatible machine
101
  #ggml-ci-cpu-amx:
102
  # runs-on: [self-hosted, Linux, CPU, AMX]
@@ -165,16 +195,15 @@ jobs:
165
  - name: Dawn Dependency
166
  id: dawn-depends
167
  run: |
168
- DAWN_VERSION="v2.0.0"
169
- DAWN_OWNER="reeselevine"
170
  DAWN_REPO="dawn"
171
- DAWN_ASSET_NAME="Dawn-5e9a4865b1635796ccc77dd30057f2b4002a1355-macos-latest-Release"
172
- echo "Fetching release asset from https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
173
- curl -L -o artifact.zip \
174
- "https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
175
  mkdir dawn
176
- unzip artifact.zip
177
- tar -xvf ${DAWN_ASSET_NAME}.tar.gz -C dawn --strip-components=1
178
 
179
  - name: Test
180
  id: ggml-ci
@@ -212,6 +241,27 @@ jobs:
212
  vulkaninfo --summary
213
  GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  ggml-ci-intel-openvino-gpu-low-perf:
216
  runs-on: [self-hosted, Linux, Intel, OpenVINO]
217
 
 
97
  vulkaninfo --summary
98
  GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
99
 
100
+ # TODO: investigate slight precision issues in some operations for test-backend-ops on the WebGPU backend.
101
+ #ggml-ci-nvidia-webgpu:
102
+ # runs-on: [self-hosted, Linux, NVIDIA]
103
+
104
+ # steps:
105
+ # - name: Clone
106
+ # id: checkout
107
+ # uses: actions/checkout@v6
108
+
109
+ # - name: Dawn Dependency
110
+ # id: dawn-depends
111
+ # run: |
112
+ # DAWN_VERSION="v20260317.182325"
113
+ # DAWN_OWNER="google"
114
+ # DAWN_REPO="dawn"
115
+ # DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-ubuntu-latest-Release"
116
+ # echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
117
+ # curl -L -o artifact.tar.gz \
118
+ # "https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
119
+ # mkdir dawn
120
+ # tar -xvf artifact.tar.gz -C dawn --strip-components=1
121
+
122
+ # - name: Test
123
+ # id: ggml-ci
124
+ # run: |
125
+ # GG_BUILD_WEBGPU=1 \
126
+ # GG_BUILD_WEBGPU_DAWN_PREFIX="$GITHUB_WORKSPACE/dawn" \
127
+ # GG_BUILD_WEBGPU_DAWN_DIR="$GITHUB_WORKSPACE/dawn/lib64/cmake/Dawn" \
128
+ # bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
129
+
130
  # TODO: provision AMX-compatible machine
131
  #ggml-ci-cpu-amx:
132
  # runs-on: [self-hosted, Linux, CPU, AMX]
 
195
  - name: Dawn Dependency
196
  id: dawn-depends
197
  run: |
198
+ DAWN_VERSION="v20260317.182325"
199
+ DAWN_OWNER="google"
200
  DAWN_REPO="dawn"
201
+ DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-macos-latest-Release"
202
+ echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
203
+ curl -L -o artifact.tar.gz \
204
+ "https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
205
  mkdir dawn
206
+ tar -xvf artifact.tar.gz -C dawn --strip-components=1
 
207
 
208
  - name: Test
209
  id: ggml-ci
 
241
  vulkaninfo --summary
242
  GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cpp
243
 
244
+ ggml-ci-win-intel-vulkan:
245
+ runs-on: [self-hosted, Windows, X64, Intel]
246
+
247
+ steps:
248
+ - name: Clone
249
+ id: checkout
250
+ uses: actions/checkout@v6
251
+
252
+ - name: Test
253
+ id: ggml-ci
254
+ shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -eo pipefail "{0}"
255
+ env:
256
+ MSYSTEM: UCRT64
257
+ CHERE_INVOKING: 1
258
+ PATH: C:\msys64\ucrt64\bin;C:\msys64\usr\bin;C:\Windows\System32;${{ env.PATH }}
259
+ run: |
260
+ vulkaninfo --summary
261
+ # Skip python related tests with GG_BUILD_LOW_PERF=1 since Windows MSYS2 UCRT64 currently fails to create
262
+ # a valid python environment for testing
263
+ LLAMA_FATAL_WARNINGS=OFF GG_BUILD_NINJA=1 GG_BUILD_VULKAN=1 GG_BUILD_LOW_PERF=1 ./ci/run.sh ./results/llama.cpp ./mnt/llama.cpp
264
+
265
  ggml-ci-intel-openvino-gpu-low-perf:
266
  runs-on: [self-hosted, Linux, Intel, OpenVINO]
267
 
.github/workflows/build-vulkan.yml CHANGED
@@ -72,7 +72,7 @@ jobs:
72
 
73
  - name: Setup Vulkan SDK
74
  if: steps.cache-sdk.outputs.cache-hit != 'true'
75
- uses: ./.github/actions/linux-setup-vulkan-llvmpipe
76
  with:
77
  path: ./vulkan_sdk
78
  version: ${{ env.VULKAN_SDK_VERSION }}
@@ -93,4 +93,5 @@ jobs:
93
  export GGML_VK_DISABLE_F16=1
94
  export GGML_VK_DISABLE_COOPMAT=1
95
  # This is using llvmpipe and runs slower than other backends
96
- ctest -L main --verbose --timeout 4800
 
 
72
 
73
  - name: Setup Vulkan SDK
74
  if: steps.cache-sdk.outputs.cache-hit != 'true'
75
+ uses: ./.github/actions/linux-setup-vulkan
76
  with:
77
  path: ./vulkan_sdk
78
  version: ${{ env.VULKAN_SDK_VERSION }}
 
93
  export GGML_VK_DISABLE_F16=1
94
  export GGML_VK_DISABLE_COOPMAT=1
95
  # This is using llvmpipe and runs slower than other backends
96
+ # test-backend-ops is too slow on llvmpipe, skip it
97
+ ctest -L main -E test-backend-ops --verbose --timeout 900
.github/workflows/build.yml CHANGED
@@ -87,7 +87,7 @@ jobs:
87
  -DGGML_METAL_EMBED_LIBRARY=OFF \
88
  -DGGML_METAL_SHADER_DEBUG=ON \
89
  -DGGML_RPC=ON
90
- cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
91
  leaks -atExit -- ./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1
92
 
93
  - name: Test
@@ -124,7 +124,7 @@ jobs:
124
  -DGGML_METAL=OFF \
125
  -DGGML_RPC=ON \
126
  -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
127
- cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
128
 
129
  - name: Test
130
  id: cmake_test
@@ -150,23 +150,22 @@ jobs:
150
  - name: Dawn Dependency
151
  id: dawn-depends
152
  run: |
153
- DAWN_VERSION="v2.0.0"
154
- DAWN_OWNER="reeselevine"
155
  DAWN_REPO="dawn"
156
- DAWN_ASSET_NAME="Dawn-5e9a4865b1635796ccc77dd30057f2b4002a1355-macos-latest-Release"
157
- echo "Fetching release asset from https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
158
- curl -L -o artifact.zip \
159
- "https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
160
  mkdir dawn
161
- unzip artifact.zip
162
- tar -xvf ${DAWN_ASSET_NAME}.tar.gz -C dawn --strip-components=1
163
 
164
  - name: Build
165
  id: cmake_build
166
  run: |
167
  export CMAKE_PREFIX_PATH=dawn
168
- cmake -B build -DGGML_WEBGPU=ON -DGGML_METAL=OFF -DGGML_BLAS=OFF
169
- cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
170
 
171
  - name: Test
172
  id: cmake_test
@@ -181,7 +180,7 @@ jobs:
181
  - build: 'x64'
182
  os: ubuntu-22.04
183
  - build: 'arm64'
184
- os: ubuntu-22.04-arm
185
  - build: 's390x'
186
  os: ubuntu-24.04-s390x
187
  - build: 'ppc64le'
@@ -207,14 +206,22 @@ jobs:
207
  run: |
208
  sudo apt-get update
209
  sudo apt-get install -y --no-install-recommends \
210
- python3 python3-pip python3-dev \
211
  libjpeg-dev build-essential libssl-dev \
212
  git-lfs
213
 
 
 
 
 
 
 
 
214
  - name: Python Dependencies
215
  id: python_depends
216
  run: |
217
- python3 -m pip install --upgrade pip
 
218
  pip3 install ./gguf-py
219
 
220
  - name: Swap Endianness
@@ -231,7 +238,7 @@ jobs:
231
  cmake -B build \
232
  -DLLAMA_FATAL_WARNINGS=ON \
233
  -DGGML_RPC=ON
234
- cmake --build build --config Release -j $(nproc)
235
 
236
  - name: Test
237
  id: cmake_test
@@ -260,6 +267,56 @@ jobs:
260
  wget https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K-be.gguf
261
  ./bin/llama-completion -m stories260K-be.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  ubuntu-latest-rpc:
264
  runs-on: ubuntu-latest
265
 
@@ -274,14 +331,16 @@ jobs:
274
  id: depends
275
  run: |
276
  sudo apt-get update
277
- sudo apt-get install build-essential libssl-dev
278
 
279
  - name: Build
280
  id: cmake_build
281
  run: |
282
  cmake -B build \
 
 
283
  -DGGML_RPC=ON
284
- cmake --build build --config Release -j $(nproc)
285
 
286
  - name: Test
287
  id: cmake_test
@@ -290,7 +349,15 @@ jobs:
290
  ctest -L main --verbose
291
 
292
  ubuntu-24-vulkan:
293
- runs-on: ${{ 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
 
 
 
 
 
 
 
 
294
 
295
  steps:
296
  - name: Clone
@@ -300,12 +367,16 @@ jobs:
300
  - name: Dependencies
301
  id: depends
302
  run: |
303
- sudo apt-get install -y glslc libvulkan-dev libssl-dev
 
 
 
304
 
305
  - name: Configure
306
  id: cmake_configure
307
  run: |
308
  cmake -B build \
 
309
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
310
  -DGGML_BACKEND_DL=ON \
311
  -DGGML_CPU_ALL_VARIANTS=ON \
@@ -314,7 +385,7 @@ jobs:
314
  - name: Build
315
  id: cmake_build
316
  run: |
317
- cmake --build build -j $(nproc)
318
 
319
  ubuntu-24-webgpu:
320
  runs-on: ubuntu-24.04
@@ -336,7 +407,8 @@ jobs:
336
  run: |
337
  sudo add-apt-repository -y ppa:kisak/kisak-mesa
338
  sudo apt-get update -y
339
- sudo apt-get install -y build-essential mesa-vulkan-drivers libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libssl-dev
 
340
 
341
  - name: Get latest Vulkan SDK version
342
  id: vulkan_sdk_version
@@ -361,16 +433,15 @@ jobs:
361
  id: dawn-depends
362
  run: |
363
  sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev libxi-dev
364
- DAWN_VERSION="v2.0.0"
365
- DAWN_OWNER="reeselevine"
366
  DAWN_REPO="dawn"
367
- DAWN_ASSET_NAME="Dawn-5e9a4865b1635796ccc77dd30057f2b4002a1355-ubuntu-latest-Release"
368
- echo "Fetching release asset from https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
369
- curl -L -o artifact.zip \
370
- "https://github.com/${DAWN_OWNER}/${DAWN_REPO}/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.zip"
371
  mkdir dawn
372
- unzip artifact.zip
373
- tar -xvf ${DAWN_ASSET_NAME}.tar.gz -C dawn --strip-components=1
374
 
375
  - name: Build
376
  id: cmake_build
@@ -378,7 +449,7 @@ jobs:
378
  export Dawn_DIR=dawn/lib64/cmake/Dawn
379
  cmake -B build \
380
  -DGGML_WEBGPU=ON
381
- cmake --build build --config Release -j $(nproc)
382
 
383
  - name: Test
384
  id: cmake_test
@@ -404,7 +475,7 @@ jobs:
404
 
405
  - name: Fetch emdawnwebgpu
406
  run: |
407
- DAWN_TAG="v20251027.212519"
408
  EMDAWN_PKG="emdawnwebgpu_pkg-${DAWN_TAG}.zip"
409
  echo "Downloading ${EMDAWN_PKG}"
410
  curl -L -o emdawn.zip \
@@ -415,11 +486,13 @@ jobs:
415
  run: |
416
  source emsdk/emsdk_env.sh
417
  emcmake cmake -B build-wasm \
 
 
418
  -DGGML_WEBGPU=ON \
419
  -DLLAMA_OPENSSL=OFF \
420
  -DEMDAWNWEBGPU_DIR=emdawnwebgpu_pkg
421
 
422
- cmake --build build-wasm --target test-backend-ops -j $(nproc)
423
 
424
  ubuntu-22-hip:
425
  runs-on: ubuntu-22.04
@@ -449,6 +522,7 @@ jobs:
449
  cmake -B build -S . \
450
  -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
451
  -DGGML_HIP_ROCWMMA_FATTN=ON \
 
452
  -DGGML_HIP=ON
453
  cmake --build build --config Release -j $(nproc)
454
 
@@ -479,7 +553,7 @@ jobs:
479
  run: |
480
  cmake -B build -S . \
481
  -DGGML_MUSA=ON
482
- cmake --build build --config Release -j $(nproc)
483
 
484
  ubuntu-22-sycl:
485
  runs-on: ubuntu-22.04
@@ -528,7 +602,7 @@ jobs:
528
  -DGGML_SYCL=ON \
529
  -DCMAKE_C_COMPILER=icx \
530
  -DCMAKE_CXX_COMPILER=icpx
531
- cmake --build build --config Release -j $(nproc)
532
 
533
  ubuntu-22-sycl-fp16:
534
  runs-on: ubuntu-22.04
@@ -551,7 +625,7 @@ jobs:
551
  shell: bash
552
  run: |
553
  sudo apt update
554
- sudo apt install intel-oneapi-compiler-dpcpp-cpp libssl-dev
555
 
556
  - name: install oneAPI MKL library
557
  shell: bash
@@ -574,11 +648,13 @@ jobs:
574
  run: |
575
  source /opt/intel/oneapi/setvars.sh
576
  cmake -B build \
 
 
577
  -DGGML_SYCL=ON \
578
  -DCMAKE_C_COMPILER=icx \
579
  -DCMAKE_CXX_COMPILER=icpx \
580
  -DGGML_SYCL_F16=ON
581
- cmake --build build --config Release -j $(nproc)
582
 
583
  ubuntu-24-openvino:
584
  name: ubuntu-24-openvino-${{ matrix.openvino_device }}
@@ -648,7 +724,7 @@ jobs:
648
  cmake -B build/ReleaseOV -G Ninja \
649
  -DCMAKE_BUILD_TYPE=Release \
650
  -DGGML_OPENVINO=ON
651
- cmake --build build/ReleaseOV --config Release -j $(nproc)
652
 
653
  - name: Test
654
  id: cmake_test
@@ -916,7 +992,7 @@ jobs:
916
  - name: Grab rocWMMA package
917
  id: grab_rocwmma
918
  run: |
919
- curl -o rocwmma.deb "https://repo.radeon.com/rocm/apt/7.2/pool/main/r/rocwmma-dev/rocwmma-dev_2.2.0.70200-43~24.04_amd64.deb"
920
  7z x rocwmma.deb
921
  7z x data.tar
922
 
@@ -959,42 +1035,32 @@ jobs:
959
  cmake -G "Unix Makefiles" -B build -S . `
960
  -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
961
  -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
962
- -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/opt/rocm-7.2.0/include/" `
963
  -DCMAKE_BUILD_TYPE=Release `
964
  -DLLAMA_BUILD_BORINGSSL=ON `
965
  -DROCM_DIR="${env:HIP_PATH}" `
966
  -DGGML_HIP=ON `
967
  -DGGML_HIP_ROCWMMA_FATTN=ON `
 
968
  -DGGML_RPC=ON
969
  cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
970
 
971
  ubuntu-cpu-riscv64-native:
972
- runs-on: RISCV64
973
 
974
  steps:
975
  - name: Install dependencies
976
  run: |
977
- sudo apt-get update
978
-
979
  # Install necessary packages
980
- sudo apt-get install -y libatomic1 libtsan2 gcc-14 g++-14 rustup cmake build-essential libssl-dev wget ccache git-lfs
 
981
 
982
  # Set gcc-14 and g++-14 as the default compilers
983
  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
984
  sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
985
- sudo ln -sf /usr/bin/gcc-14 /usr/bin/gcc
986
- sudo ln -sf /usr/bin/g++-14 /usr/bin/g++
987
-
988
- # Install Rust stable version
989
- rustup install stable
990
- rustup default stable
991
 
992
  git lfs install
993
 
994
- - name: Clone
995
- id: checkout
996
- uses: actions/checkout@v6
997
-
998
  - name: Check environment
999
  run: |
1000
  uname -a
@@ -1004,25 +1070,16 @@ jobs:
1004
  cmake --version
1005
  rustc --version
1006
 
1007
- - name: Setup ccache
1008
- run: |
1009
- # Set unique cache directory for this job
1010
- export CCACHE_DIR="$HOME/.ccache/cpu-cmake-rv64-native"
1011
- mkdir -p "$CCACHE_DIR"
1012
-
1013
- # Configure ccache for optimal performance
1014
- ccache --set-config=max_size=5G
1015
- ccache --set-config=compression=true
1016
- ccache --set-config=compression_level=6
1017
- ccache --set-config=cache_dir="$CCACHE_DIR"
1018
-
1019
- # Enable more aggressive caching
1020
- ccache --set-config=sloppiness=file_macro,time_macros,include_file_mtime,include_file_ctime
1021
- ccache --set-config=hash_dir=false
1022
 
1023
- # Export for subsequent steps
1024
- echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
1025
- echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
 
 
 
1026
 
1027
  - name: Build
1028
  id: cmake_build
@@ -1039,7 +1096,7 @@ jobs:
1039
  -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
1040
  -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14
1041
 
1042
- cmake --build build --config Release -j $(nproc)
1043
 
1044
  - name: Test
1045
  id: cmake_test
 
87
  -DGGML_METAL_EMBED_LIBRARY=OFF \
88
  -DGGML_METAL_SHADER_DEBUG=ON \
89
  -DGGML_RPC=ON
90
+ time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
91
  leaks -atExit -- ./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1
92
 
93
  - name: Test
 
124
  -DGGML_METAL=OFF \
125
  -DGGML_RPC=ON \
126
  -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
127
+ time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
128
 
129
  - name: Test
130
  id: cmake_test
 
150
  - name: Dawn Dependency
151
  id: dawn-depends
152
  run: |
153
+ DAWN_VERSION="v20260317.182325"
154
+ DAWN_OWNER="google"
155
  DAWN_REPO="dawn"
156
+ DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-macos-latest-Release"
157
+ echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
158
+ curl -L -o artifact.tar.gz \
159
+ "https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
160
  mkdir dawn
161
+ tar -xvf artifact.tar.gz -C dawn --strip-components=1
 
162
 
163
  - name: Build
164
  id: cmake_build
165
  run: |
166
  export CMAKE_PREFIX_PATH=dawn
167
+ cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DGGML_WEBGPU=ON -DGGML_METAL=OFF -DGGML_BLAS=OFF
168
+ time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
169
 
170
  - name: Test
171
  id: cmake_test
 
180
  - build: 'x64'
181
  os: ubuntu-22.04
182
  - build: 'arm64'
183
+ os: ubuntu-24.04-arm
184
  - build: 's390x'
185
  os: ubuntu-24.04-s390x
186
  - build: 'ppc64le'
 
206
  run: |
207
  sudo apt-get update
208
  sudo apt-get install -y --no-install-recommends \
209
+ python3 python3-pip python3-dev python3-wheel \
210
  libjpeg-dev build-essential libssl-dev \
211
  git-lfs
212
 
213
+ - name: Toolchain workaround (GCC 14)
214
+ if: ${{ contains(matrix.os, 'ubuntu-24.04') }}
215
+ run: |
216
+ sudo apt-get install -y gcc-14 g++-14
217
+ echo "CC=gcc-14" >> "$GITHUB_ENV"
218
+ echo "CXX=g++-14" >> "$GITHUB_ENV"
219
+
220
  - name: Python Dependencies
221
  id: python_depends
222
  run: |
223
+ export PIP_BREAK_SYSTEM_PACKAGES="1"
224
+ python3 -m pip install --upgrade pip setuptools
225
  pip3 install ./gguf-py
226
 
227
  - name: Swap Endianness
 
238
  cmake -B build \
239
  -DLLAMA_FATAL_WARNINGS=ON \
240
  -DGGML_RPC=ON
241
+ time cmake --build build --config Release -j $(nproc)
242
 
243
  - name: Test
244
  id: cmake_test
 
267
  wget https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K-be.gguf
268
  ./bin/llama-completion -m stories260K-be.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
269
 
270
+ android-arm64:
271
+ runs-on: ubuntu-latest
272
+
273
+ env:
274
+ NDK_VERSION: "29.0.14206865"
275
+
276
+ steps:
277
+ - name: Clone
278
+ id: checkout
279
+ uses: actions/checkout@v6
280
+
281
+ - name: ccache
282
+ uses: ggml-org/ccache-action@v1.2.21
283
+ with:
284
+ key: android-arm64
285
+ evict-old-files: 1d
286
+ save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
287
+
288
+ - name: Set up JDK
289
+ uses: actions/setup-java@v5
290
+ with:
291
+ java-version: 17
292
+ distribution: temurin
293
+
294
+ - name: Setup Android SDK
295
+ uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
296
+ with:
297
+ log-accepted-android-sdk-licenses: false
298
+
299
+ - name: Install NDK
300
+ run: |
301
+ sdkmanager "ndk;${{ env.NDK_VERSION }}"
302
+ echo "ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
303
+
304
+ - name: Build
305
+ id: cmake_build
306
+ run: |
307
+ cmake -B build \
308
+ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
309
+ -DANDROID_ABI=arm64-v8a \
310
+ -DANDROID_PLATFORM=android-28 \
311
+ -DLLAMA_FATAL_WARNINGS=ON \
312
+ -DGGML_BACKEND_DL=ON \
313
+ -DGGML_NATIVE=OFF \
314
+ -DGGML_CPU_ALL_VARIANTS=ON \
315
+ -DGGML_OPENMP=OFF \
316
+ -DLLAMA_BUILD_BORINGSSL=ON \
317
+ -DGGML_RPC=ON
318
+ time cmake --build build --config Release -j $(nproc)
319
+
320
  ubuntu-latest-rpc:
321
  runs-on: ubuntu-latest
322
 
 
331
  id: depends
332
  run: |
333
  sudo apt-get update
334
+ sudo apt-get install build-essential libssl-dev ninja-build
335
 
336
  - name: Build
337
  id: cmake_build
338
  run: |
339
  cmake -B build \
340
+ -G "Ninja" \
341
+ -DCMAKE_BUILD_TYPE=Release \
342
  -DGGML_RPC=ON
343
+ time cmake --build build --config Release -j $(nproc)
344
 
345
  - name: Test
346
  id: cmake_test
 
349
  ctest -L main --verbose
350
 
351
  ubuntu-24-vulkan:
352
+ strategy:
353
+ matrix:
354
+ include:
355
+ - build: 'x64'
356
+ os: ubuntu-24.04
357
+ - build: 'arm64'
358
+ os: ubuntu-24.04-arm
359
+
360
+ runs-on: ${{ matrix.os }}
361
 
362
  steps:
363
  - name: Clone
 
367
  - name: Dependencies
368
  id: depends
369
  run: |
370
+ sudo apt-get update
371
+ sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
372
+ echo "CC=gcc-14" >> "$GITHUB_ENV"
373
+ echo "CXX=g++-14" >> "$GITHUB_ENV"
374
 
375
  - name: Configure
376
  id: cmake_configure
377
  run: |
378
  cmake -B build \
379
+ -G "Ninja" \
380
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
381
  -DGGML_BACKEND_DL=ON \
382
  -DGGML_CPU_ALL_VARIANTS=ON \
 
385
  - name: Build
386
  id: cmake_build
387
  run: |
388
+ time cmake --build build -j $(nproc)
389
 
390
  ubuntu-24-webgpu:
391
  runs-on: ubuntu-24.04
 
407
  run: |
408
  sudo add-apt-repository -y ppa:kisak/kisak-mesa
409
  sudo apt-get update -y
410
+ sudo apt-get install -y build-essential mesa-vulkan-drivers \
411
+ libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libssl-dev
412
 
413
  - name: Get latest Vulkan SDK version
414
  id: vulkan_sdk_version
 
433
  id: dawn-depends
434
  run: |
435
  sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev libxi-dev
436
+ DAWN_VERSION="v20260317.182325"
437
+ DAWN_OWNER="google"
438
  DAWN_REPO="dawn"
439
+ DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-ubuntu-latest-Release"
440
+ echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
441
+ curl -L -o artifact.tar.gz \
442
+ "https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
443
  mkdir dawn
444
+ tar -xvf artifact.tar.gz -C dawn --strip-components=1
 
445
 
446
  - name: Build
447
  id: cmake_build
 
449
  export Dawn_DIR=dawn/lib64/cmake/Dawn
450
  cmake -B build \
451
  -DGGML_WEBGPU=ON
452
+ time cmake --build build --config Release -j $(nproc)
453
 
454
  - name: Test
455
  id: cmake_test
 
475
 
476
  - name: Fetch emdawnwebgpu
477
  run: |
478
+ DAWN_TAG="v20260317.182325"
479
  EMDAWN_PKG="emdawnwebgpu_pkg-${DAWN_TAG}.zip"
480
  echo "Downloading ${EMDAWN_PKG}"
481
  curl -L -o emdawn.zip \
 
486
  run: |
487
  source emsdk/emsdk_env.sh
488
  emcmake cmake -B build-wasm \
489
+ -G "Ninja" \
490
+ -DCMAKE_BUILD_TYPE=Release \
491
  -DGGML_WEBGPU=ON \
492
  -DLLAMA_OPENSSL=OFF \
493
  -DEMDAWNWEBGPU_DIR=emdawnwebgpu_pkg
494
 
495
+ time cmake --build build-wasm --config Release --target test-backend-ops -j $(nproc)
496
 
497
  ubuntu-22-hip:
498
  runs-on: ubuntu-22.04
 
522
  cmake -B build -S . \
523
  -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
524
  -DGGML_HIP_ROCWMMA_FATTN=ON \
525
+ -DGPU_TARGETS="gfx1030" \
526
  -DGGML_HIP=ON
527
  cmake --build build --config Release -j $(nproc)
528
 
 
553
  run: |
554
  cmake -B build -S . \
555
  -DGGML_MUSA=ON
556
+ time cmake --build build --config Release -j $(nproc)
557
 
558
  ubuntu-22-sycl:
559
  runs-on: ubuntu-22.04
 
602
  -DGGML_SYCL=ON \
603
  -DCMAKE_C_COMPILER=icx \
604
  -DCMAKE_CXX_COMPILER=icpx
605
+ time cmake --build build --config Release -j $(nproc)
606
 
607
  ubuntu-22-sycl-fp16:
608
  runs-on: ubuntu-22.04
 
625
  shell: bash
626
  run: |
627
  sudo apt update
628
+ sudo apt install intel-oneapi-compiler-dpcpp-cpp libssl-dev ninja-build
629
 
630
  - name: install oneAPI MKL library
631
  shell: bash
 
648
  run: |
649
  source /opt/intel/oneapi/setvars.sh
650
  cmake -B build \
651
+ -G "Ninja" \
652
+ -DCMAKE_BUILD_TYPE=Release \
653
  -DGGML_SYCL=ON \
654
  -DCMAKE_C_COMPILER=icx \
655
  -DCMAKE_CXX_COMPILER=icpx \
656
  -DGGML_SYCL_F16=ON
657
+ time cmake --build build --config Release -j $(nproc)
658
 
659
  ubuntu-24-openvino:
660
  name: ubuntu-24-openvino-${{ matrix.openvino_device }}
 
724
  cmake -B build/ReleaseOV -G Ninja \
725
  -DCMAKE_BUILD_TYPE=Release \
726
  -DGGML_OPENVINO=ON
727
+ time cmake --build build/ReleaseOV --config Release -j $(nproc)
728
 
729
  - name: Test
730
  id: cmake_test
 
992
  - name: Grab rocWMMA package
993
  id: grab_rocwmma
994
  run: |
995
+ curl -o rocwmma.deb "https://repo.radeon.com/rocm/apt/7.2.1/pool/main/r/rocwmma-dev/rocwmma-dev_2.2.0.70201-81~24.04_amd64.deb"
996
  7z x rocwmma.deb
997
  7z x data.tar
998
 
 
1035
  cmake -G "Unix Makefiles" -B build -S . `
1036
  -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
1037
  -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
1038
+ -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/opt/rocm-7.2.1/include/" `
1039
  -DCMAKE_BUILD_TYPE=Release `
1040
  -DLLAMA_BUILD_BORINGSSL=ON `
1041
  -DROCM_DIR="${env:HIP_PATH}" `
1042
  -DGGML_HIP=ON `
1043
  -DGGML_HIP_ROCWMMA_FATTN=ON `
1044
+ -DGPU_TARGETS="gfx1100" `
1045
  -DGGML_RPC=ON
1046
  cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
1047
 
1048
  ubuntu-cpu-riscv64-native:
1049
+ runs-on: ubuntu-24.04-riscv
1050
 
1051
  steps:
1052
  - name: Install dependencies
1053
  run: |
 
 
1054
  # Install necessary packages
1055
+ sudo apt-get update
1056
+ sudo apt-get install -y libssl-dev
1057
 
1058
  # Set gcc-14 and g++-14 as the default compilers
1059
  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
1060
  sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
 
 
 
 
 
 
1061
 
1062
  git lfs install
1063
 
 
 
 
 
1064
  - name: Check environment
1065
  run: |
1066
  uname -a
 
1070
  cmake --version
1071
  rustc --version
1072
 
1073
+ - name: Clone
1074
+ id: checkout
1075
+ uses: actions/checkout@v6
 
 
 
 
 
 
 
 
 
 
 
 
1076
 
1077
+ - name: ccache
1078
+ uses: ggml-org/ccache-action@afde29e5b5422e5da23cb1f639e8baecadeadfc3 # https://github.com/ggml-org/ccache-action/pull/1
1079
+ with:
1080
+ key: ubuntu-cpu-riscv64-native
1081
+ evict-old-files: 1d
1082
+ save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
1083
 
1084
  - name: Build
1085
  id: cmake_build
 
1096
  -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
1097
  -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14
1098
 
1099
+ time cmake --build build --config Release -j $(nproc)
1100
 
1101
  - name: Test
1102
  id: cmake_test
.github/workflows/close-issue.yml CHANGED
@@ -17,7 +17,7 @@ jobs:
17
  steps:
18
  - uses: actions/stale@v10
19
  with:
20
- exempt-issue-labels: "refactoring,help wanted,good first issue,research 🔬,bug,roadmap"
21
  days-before-issue-stale: 30
22
  days-before-issue-close: 14
23
  stale-issue-label: "stale"
 
17
  steps:
18
  - uses: actions/stale@v10
19
  with:
20
+ exempt-issue-labels: "refactoring,help wanted,good first issue,research 🔬,bug,roadmap,security"
21
  days-before-issue-stale: 30
22
  days-before-issue-close: 14
23
  stale-issue-label: "stale"
.github/workflows/copilot-setup-steps.yml CHANGED
@@ -54,4 +54,3 @@ jobs:
54
  python3 -m venv .venv
55
  source .venv/bin/activate
56
  pip install -r requirements/requirements-all.txt -r tools/server/tests/requirements.txt
57
- pip install flake8 pyright pre-commit
 
54
  python3 -m venv .venv
55
  source .venv/bin/activate
56
  pip install -r requirements/requirements-all.txt -r tools/server/tests/requirements.txt
 
.github/workflows/docker.yml CHANGED
@@ -25,64 +25,146 @@ permissions:
25
  packages: write
26
 
27
  jobs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  push_to_registry:
29
- name: Push Docker image to Docker Hub
 
30
 
31
  runs-on: ${{ matrix.config.runs_on }}
32
- env:
33
- COMMIT_SHA: ${{ github.sha }}
34
  strategy:
35
  fail-fast: false
36
  matrix:
37
- config:
38
- # Multi-stage build
39
- # Note: the arm64 images are failing, which prevents the amd64 images from being built
40
- # https://github.com/ggml-org/llama.cpp/issues/11888
41
- #- { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64,linux/arm64", full: true, light: true, server: true, free_disk_space: false }
42
- - { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false, runs_on: "ubuntu-22.04" }
43
- - { tag: "cuda cuda12", dockerfile: ".devops/cuda.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true, runs_on: "ubuntu-22.04", cuda_version: "12.4.0", ubuntu_version: "22.04" }
44
- - { tag: "cuda13", dockerfile: ".devops/cuda-new.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true, runs_on: "ubuntu-22.04", cuda_version: "13.1.0", ubuntu_version: "24.04" }
45
- - { tag: "musa", dockerfile: ".devops/musa.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true, runs_on: "ubuntu-22.04" }
46
- - { tag: "intel", dockerfile: ".devops/intel.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true, runs_on: "ubuntu-22.04" }
47
- - { tag: "vulkan", dockerfile: ".devops/vulkan.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false, runs_on: "ubuntu-22.04" }
48
- - { tag: "s390x", dockerfile: ".devops/s390x.Dockerfile", platforms: "linux/s390x", full: true, light: true, server: true, free_disk_space: false, runs_on: "ubuntu-22.04-s390x" }
49
- - { tag: "rocm", dockerfile: ".devops/rocm.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true, runs_on: "ubuntu-22.04" }
50
- - { tag: "openvino", dockerfile: ".devops/openvino.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false, runs_on: "ubuntu-22.04" }
51
  steps:
52
  - name: Check out the repo
53
  uses: actions/checkout@v6
54
  with:
55
- fetch-depth: 0 # preserve git history, so we can determine the build number
 
56
 
57
  - name: Set up QEMU
58
- if: ${{ matrix.config.tag != 's390x' }}
59
- uses: docker/setup-qemu-action@v3
60
  with:
61
- image: tonistiigi/binfmt:qemu-v7.0.0-28
62
 
63
  - name: Set up Docker Buildx
64
- uses: docker/setup-buildx-action@v3
65
 
66
- - name: Log in to Docker Hub
67
- uses: docker/login-action@v3
68
  with:
69
  registry: ghcr.io
70
  username: ${{ github.repository_owner }}
71
  password: ${{ secrets.GITHUB_TOKEN }}
72
 
73
- - name: Determine source tag name
74
- id: srctag
75
- uses: ./.github/actions/get-tag-name
76
- env:
77
- BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
78
-
79
- - name: Determine image tag name
80
- id: tag
81
  shell: bash
82
  run: |
 
 
83
  REPO_OWNER="${GITHUB_REPOSITORY_OWNER@L}" # to lower case
84
  REPO_NAME="${{ github.event.repository.name }}"
85
- PREFIX="ghcr.io/${REPO_OWNER}/${REPO_NAME}:"
 
 
 
86
 
87
  # list all tags possible
88
  tags="${{ matrix.config.tag }}"
@@ -92,19 +174,16 @@ jobs:
92
  else
93
  TYPE="-$tag"
94
  fi
95
- CACHETAGS="${PREFIX}buildcache${TYPE}"
96
- FULLTAGS="${FULLTAGS:+$FULLTAGS,}${PREFIX}full${TYPE},${PREFIX}full${TYPE}-${{ steps.srctag.outputs.name }}"
97
- LIGHTTAGS="${LIGHTTAGS:+$LIGHTTAGS,}${PREFIX}light${TYPE},${PREFIX}light${TYPE}-${{ steps.srctag.outputs.name }}"
98
- SERVERTAGS="${SERVERTAGS:+$SERVERTAGS,}${PREFIX}server${TYPE},${PREFIX}server${TYPE}-${{ steps.srctag.outputs.name }}"
99
  done
100
- echo "cache_output_tags=$CACHETAGS" >> $GITHUB_OUTPUT
101
- echo "full_output_tags=$FULLTAGS" >> $GITHUB_OUTPUT
102
- echo "light_output_tags=$LIGHTTAGS" >> $GITHUB_OUTPUT
103
- echo "server_output_tags=$SERVERTAGS" >> $GITHUB_OUTPUT
104
- echo "cache_output_tags=$CACHETAGS" # print out for debugging
105
- echo "full_output_tags=$FULLTAGS" # print out for debugging
106
- echo "light_output_tags=$LIGHTTAGS" # print out for debugging
107
- echo "server_output_tags=$SERVERTAGS" # print out for debugging
108
  env:
109
  GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}'
110
 
@@ -125,15 +204,14 @@ jobs:
125
  docker-images: true
126
  swap-storage: true
127
 
128
- - name: Build and push Full Docker image (tagged + versioned)
 
129
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.full == true }}
130
- uses: docker/build-push-action@v6
131
  with:
132
  context: .
133
- push: true
134
  platforms: ${{ matrix.config.platforms }}
135
- # tag list is generated from step above
136
- tags: ${{ steps.tag.outputs.full_output_tags }}
137
  file: ${{ matrix.config.dockerfile }}
138
  target: full
139
  provenance: false
@@ -147,18 +225,17 @@ jobs:
147
  #cache-to: type=local,dest=/tmp/.buildx-cache
148
  #cache-from: type=local,src=/tmp/.buildx-cache
149
  # using registry cache (no storage limit)
150
- cache-from: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }}
151
- cache-to: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }},mode=max
152
 
153
- - name: Build and push Light Docker image (tagged + versioned)
 
154
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.light == true }}
155
- uses: docker/build-push-action@v6
156
  with:
157
  context: .
158
- push: true
159
  platforms: ${{ matrix.config.platforms }}
160
- # tag list is generated from step above
161
- tags: ${{ steps.tag.outputs.light_output_tags }}
162
  file: ${{ matrix.config.dockerfile }}
163
  target: light
164
  provenance: false
@@ -172,18 +249,17 @@ jobs:
172
  #cache-to: type=local,dest=/tmp/.buildx-cache
173
  #cache-from: type=local,src=/tmp/.buildx-cache
174
  # using registry cache (no storage limit)
175
- cache-from: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }}
176
- cache-to: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }},mode=max
177
 
178
- - name: Build and push Server Docker image (tagged + versioned)
 
179
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.server == true }}
180
- uses: docker/build-push-action@v6
181
  with:
182
  context: .
183
- push: true
184
  platforms: ${{ matrix.config.platforms }}
185
- # tag list is generated from step above
186
- tags: ${{ steps.tag.outputs.server_output_tags }}
187
  file: ${{ matrix.config.dockerfile }}
188
  target: server
189
  provenance: false
@@ -197,31 +273,170 @@ jobs:
197
  #cache-to: type=local,dest=/tmp/.buildx-cache
198
  #cache-from: type=local,src=/tmp/.buildx-cache
199
  # using registry cache (no storage limit)
200
- cache-from: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }}
201
- cache-to: type=registry,ref=${{ steps.tag.outputs.cache_output_tags }},mode=max
202
 
203
- create_tag:
204
- name: Create and push git tag
205
- runs-on: ubuntu-22.04
206
- permissions:
207
- contents: write
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
  steps:
210
- - name: Clone
211
- id: checkout
212
  uses: actions/checkout@v6
213
  with:
214
  fetch-depth: 0
215
 
216
- - name: Determine source tag name
217
- id: srctag
218
- uses: ./.github/actions/get-tag-name
219
- env:
220
- BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
 
221
 
222
- - name: Create and push git tag
223
- env:
224
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
 
 
 
 
 
 
 
 
225
  run: |
226
- git tag ${{ steps.srctag.outputs.name }} || exit 0
227
- git push origin ${{ steps.srctag.outputs.name }} || exit 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  packages: write
26
 
27
  jobs:
28
+ create_tag:
29
+ name: Create and push git tag
30
+ runs-on: ubuntu-slim
31
+ permissions:
32
+ contents: write
33
+ outputs:
34
+ source_tag: ${{ steps.srctag.outputs.name }}
35
+
36
+ steps:
37
+ - name: Clone
38
+ id: checkout
39
+ uses: actions/checkout@v6
40
+ with:
41
+ fetch-depth: 0
42
+
43
+ - name: Determine source tag name
44
+ id: srctag
45
+ uses: ./.github/actions/get-tag-name
46
+ env:
47
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
48
+
49
+ - name: Create and push git tag
50
+ env:
51
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52
+ run: |
53
+ git tag ${{ steps.srctag.outputs.name }} || exit 0
54
+ git push origin ${{ steps.srctag.outputs.name }} || exit 0
55
+
56
+ prepare_matrices:
57
+ name: Prepare Docker matrices
58
+ runs-on: ubuntu-24.04
59
+ outputs:
60
+ build_matrix: ${{ steps.matrices.outputs.build_matrix }}
61
+ merge_matrix: ${{ steps.matrices.outputs.merge_matrix }}
62
+
63
+ steps:
64
+ - name: Generate build and merge matrices
65
+ id: matrices
66
+ shell: bash
67
+ run: |
68
+ set -euo pipefail
69
+
70
+ # Keep all build targets in one place and derive merge targets from it.
71
+ cat > build-matrix.json <<'JSON'
72
+ [
73
+ { "tag": "cpu", "dockerfile": ".devops/cpu.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04" },
74
+ { "tag": "cpu", "dockerfile": ".devops/cpu.Dockerfile", "platforms": "linux/arm64", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04-arm" },
75
+ { "tag": "cpu", "dockerfile": ".devops/s390x.Dockerfile", "platforms": "linux/s390x", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04-s390x" },
76
+ { "tag": "cuda cuda12", "dockerfile": ".devops/cuda.Dockerfile", "cuda_version": "12.8.1", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04" },
77
+ { "tag": "cuda cuda12", "dockerfile": ".devops/cuda.Dockerfile", "cuda_version": "12.8.1", "platforms": "linux/arm64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04-arm" },
78
+ { "tag": "cuda13", "dockerfile": ".devops/cuda.Dockerfile", "cuda_version": "13.1.1", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04" },
79
+ { "tag": "cuda13", "dockerfile": ".devops/cuda.Dockerfile", "cuda_version": "13.1.1", "platforms": "linux/arm64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04-arm" },
80
+ { "tag": "musa", "dockerfile": ".devops/musa.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04" },
81
+ { "tag": "intel", "dockerfile": ".devops/intel.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04" },
82
+ { "tag": "vulkan", "dockerfile": ".devops/vulkan.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04" },
83
+ { "tag": "vulkan", "dockerfile": ".devops/vulkan.Dockerfile", "platforms": "linux/arm64", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04-arm" },
84
+ { "tag": "rocm", "dockerfile": ".devops/rocm.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": true, "runs_on": "ubuntu-24.04" },
85
+ { "tag": "openvino", "dockerfile": ".devops/openvino.Dockerfile", "platforms": "linux/amd64", "full": true, "light": true, "server": true, "free_disk_space": false, "runs_on": "ubuntu-24.04" }
86
+ ]
87
+ JSON
88
+
89
+ BUILD_MATRIX="$(jq -c . build-matrix.json)"
90
+ MERGE_MATRIX="$(jq -c '
91
+ reduce .[] as $entry ({}; .[$entry.tag] |= (
92
+ . // {
93
+ tag: $entry.tag,
94
+ arches: [],
95
+ full: false,
96
+ light: false,
97
+ server: false
98
+ }
99
+ | .full = (.full or ($entry.full // false))
100
+ | .light = (.light or ($entry.light // false))
101
+ | .server = (.server or ($entry.server // false))
102
+ | .arches += [($entry.platforms | sub("^linux/"; ""))]
103
+ ))
104
+ # Backward compatibility: s390x tags are aliases of cpu for the linux/s390x platform.
105
+ | if (has("cpu") and (((.cpu.arches // []) | index("s390x")) != null)) then
106
+ . + {
107
+ s390x: {
108
+ tag: "s390x",
109
+ arches: ["s390x"],
110
+ full: .cpu.full,
111
+ light: .cpu.light,
112
+ server: .cpu.server
113
+ }
114
+ }
115
+ else
116
+ .
117
+ end
118
+ | [.[] | .arches = (.arches | unique | sort | join(" "))]
119
+ ' build-matrix.json)"
120
+
121
+ echo "build_matrix=$BUILD_MATRIX" >> "$GITHUB_OUTPUT"
122
+ echo "merge_matrix=$MERGE_MATRIX" >> "$GITHUB_OUTPUT"
123
+
124
  push_to_registry:
125
+ name: Push Docker image to Docker Registry
126
+ needs: [prepare_matrices, create_tag]
127
 
128
  runs-on: ${{ matrix.config.runs_on }}
 
 
129
  strategy:
130
  fail-fast: false
131
  matrix:
132
+ config: ${{ fromJSON(needs.prepare_matrices.outputs.build_matrix) }}
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  steps:
134
  - name: Check out the repo
135
  uses: actions/checkout@v6
136
  with:
137
+ fetch-depth: 0
138
+ ref: ${{ needs.create_tag.outputs.source_tag }}
139
 
140
  - name: Set up QEMU
141
+ if: ${{ contains(matrix.config.platforms, 'linux/amd64') }}
142
+ uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
143
  with:
144
+ image: tonistiigi/binfmt:qemu-v10.2.1
145
 
146
  - name: Set up Docker Buildx
147
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
148
 
149
+ - name: Log in to Docker Registry
150
+ uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
151
  with:
152
  registry: ghcr.io
153
  username: ${{ github.repository_owner }}
154
  password: ${{ secrets.GITHUB_TOKEN }}
155
 
156
+ - name: Determine image metadata
157
+ id: meta
 
 
 
 
 
 
158
  shell: bash
159
  run: |
160
+ set -euo pipefail
161
+
162
  REPO_OWNER="${GITHUB_REPOSITORY_OWNER@L}" # to lower case
163
  REPO_NAME="${{ github.event.repository.name }}"
164
+ IMAGE_REPO="ghcr.io/${REPO_OWNER}/${REPO_NAME}"
165
+ PREFIX="${IMAGE_REPO}:"
166
+ PLATFORM="${{ matrix.config.platforms }}"
167
+ ARCH_SUFFIX="${PLATFORM#linux/}"
168
 
169
  # list all tags possible
170
  tags="${{ matrix.config.tag }}"
 
174
  else
175
  TYPE="-$tag"
176
  fi
177
+ CACHETAG="${PREFIX}buildcache${TYPE}-${ARCH_SUFFIX}"
 
 
 
178
  done
179
+
180
+ SAFE_TAGS="$(echo "$tags" | tr ' ' '_')"
181
+
182
+ echo "image_repo=$IMAGE_REPO" >> $GITHUB_OUTPUT
183
+ echo "arch_suffix=$ARCH_SUFFIX" >> $GITHUB_OUTPUT
184
+ echo "cache_output_tag=$CACHETAG" >> $GITHUB_OUTPUT
185
+ echo "digest_artifact_suffix=${SAFE_TAGS}-${ARCH_SUFFIX}" >> $GITHUB_OUTPUT
186
+ echo "cache_output_tag=$CACHETAG" # print out for debugging
187
  env:
188
  GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}'
189
 
 
204
  docker-images: true
205
  swap-storage: true
206
 
207
+ - name: Build and push Full Docker image by digest
208
+ id: build_full
209
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.full == true }}
210
+ uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
211
  with:
212
  context: .
 
213
  platforms: ${{ matrix.config.platforms }}
214
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
 
215
  file: ${{ matrix.config.dockerfile }}
216
  target: full
217
  provenance: false
 
225
  #cache-to: type=local,dest=/tmp/.buildx-cache
226
  #cache-from: type=local,src=/tmp/.buildx-cache
227
  # using registry cache (no storage limit)
228
+ cache-from: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }}
229
+ cache-to: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }},mode=max
230
 
231
+ - name: Build and push Light Docker image by digest
232
+ id: build_light
233
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.light == true }}
234
+ uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
235
  with:
236
  context: .
 
237
  platforms: ${{ matrix.config.platforms }}
238
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
 
239
  file: ${{ matrix.config.dockerfile }}
240
  target: light
241
  provenance: false
 
249
  #cache-to: type=local,dest=/tmp/.buildx-cache
250
  #cache-from: type=local,src=/tmp/.buildx-cache
251
  # using registry cache (no storage limit)
252
+ cache-from: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }}
253
+ cache-to: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }},mode=max
254
 
255
+ - name: Build and push Server Docker image by digest
256
+ id: build_server
257
  if: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && matrix.config.server == true }}
258
+ uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
259
  with:
260
  context: .
 
261
  platforms: ${{ matrix.config.platforms }}
262
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
 
263
  file: ${{ matrix.config.dockerfile }}
264
  target: server
265
  provenance: false
 
273
  #cache-to: type=local,dest=/tmp/.buildx-cache
274
  #cache-from: type=local,src=/tmp/.buildx-cache
275
  # using registry cache (no storage limit)
276
+ cache-from: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }}
277
+ cache-to: type=registry,ref=${{ steps.meta.outputs.cache_output_tag }},mode=max
278
 
279
+ - name: Export digest metadata
280
+ shell: bash
281
+ run: |
282
+ set -euo pipefail
283
+
284
+ TAGS="${{ matrix.config.tag }}"
285
+ ARCH_SUFFIX="${{ steps.meta.outputs.arch_suffix }}"
286
+ DIGEST_FILE="/tmp/digests/${{ steps.meta.outputs.digest_artifact_suffix }}.tsv"
287
+ mkdir -p /tmp/digests
288
+
289
+ add_digest_rows() {
290
+ local image_type="$1"
291
+ local digest="$2"
292
+
293
+ if [[ -z "$digest" ]]; then
294
+ echo "Missing digest for image_type=${image_type}" >&2
295
+ exit 1
296
+ fi
297
+
298
+ for tag in $TAGS; do
299
+ printf '%s\t%s\t%s\t%s\n' "$tag" "$ARCH_SUFFIX" "$image_type" "$digest" >> "$DIGEST_FILE"
300
+ done
301
+ }
302
+
303
+ if [[ "${{ matrix.config.full }}" == "true" ]]; then
304
+ add_digest_rows "full" "${{ steps.build_full.outputs.digest }}"
305
+ fi
306
+
307
+ if [[ "${{ matrix.config.light }}" == "true" ]]; then
308
+ add_digest_rows "light" "${{ steps.build_light.outputs.digest }}"
309
+ fi
310
+
311
+ if [[ "${{ matrix.config.server }}" == "true" ]]; then
312
+ add_digest_rows "server" "${{ steps.build_server.outputs.digest }}"
313
+ fi
314
+
315
+ - name: Upload digest metadata
316
+ uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
317
+ with:
318
+ name: digests-${{ steps.meta.outputs.digest_artifact_suffix }}
319
+ path: /tmp/digests/${{ steps.meta.outputs.digest_artifact_suffix }}.tsv
320
+ if-no-files-found: error
321
+
322
+ merge_arch_tags:
323
+ name: Create shared tags from digests
324
+ needs: [prepare_matrices, push_to_registry, create_tag]
325
+ runs-on: ubuntu-24.04
326
+ strategy:
327
+ fail-fast: false
328
+ matrix:
329
+ config: ${{ fromJSON(needs.prepare_matrices.outputs.merge_matrix) }}
330
 
331
  steps:
332
+ - name: Check out the repo
 
333
  uses: actions/checkout@v6
334
  with:
335
  fetch-depth: 0
336
 
337
+ - name: Download digest metadata
338
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
339
+ with:
340
+ pattern: digests-*
341
+ path: /tmp/digests
342
+ merge-multiple: true
343
 
344
+ - name: Set up Docker Buildx
345
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
346
+
347
+ - name: Log in to Docker Registry
348
+ uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
349
+ with:
350
+ registry: ghcr.io
351
+ username: ${{ github.repository_owner }}
352
+ password: ${{ secrets.GITHUB_TOKEN }}
353
+
354
+ - name: Create tags from digests
355
+ shell: bash
356
  run: |
357
+ set -euo pipefail
358
+
359
+ REPO_OWNER="${GITHUB_REPOSITORY_OWNER@L}" # to lower case
360
+ REPO_NAME="${{ github.event.repository.name }}"
361
+ IMAGE_REPO="ghcr.io/${REPO_OWNER}/${REPO_NAME}"
362
+ PREFIX="${IMAGE_REPO}:"
363
+ SRC_TAG="${{ needs.create_tag.outputs.source_tag }}"
364
+ TAGS="${{ matrix.config.tag }}"
365
+ ARCHES="${{ matrix.config.arches }}"
366
+ DIGEST_GLOB="/tmp/digests/*.tsv"
367
+
368
+ if ! ls ${DIGEST_GLOB} >/dev/null 2>&1; then
369
+ echo "No digest metadata found in /tmp/digests" >&2
370
+ exit 1
371
+ fi
372
+
373
+ if [[ -z "$SRC_TAG" ]]; then
374
+ echo "Missing source tag from create_tag" >&2
375
+ exit 1
376
+ fi
377
+
378
+ find_digest() {
379
+ local tag_name="$1"
380
+ local arch="$2"
381
+ local image_type="$3"
382
+ local digest
383
+
384
+ digest="$(awk -F '\t' -v t="$tag_name" -v a="$arch" -v i="$image_type" '$1 == t && $2 == a && $3 == i { print $4; exit }' ${DIGEST_GLOB})"
385
+
386
+ # Backward compatibility: s390x tags are aliases of cpu for the linux/s390x platform.
387
+ if [[ -z "$digest" && "$tag_name" == "s390x" && "$arch" == "s390x" ]]; then
388
+ digest="$(awk -F '\t' -v t="cpu" -v a="$arch" -v i="$image_type" '$1 == t && $2 == a && $3 == i { print $4; exit }' ${DIGEST_GLOB})"
389
+ fi
390
+
391
+ if [[ -z "$digest" ]]; then
392
+ echo "Missing digest for tag=${tag_name} arch=${arch} image_type=${image_type}" >&2
393
+ exit 1
394
+ fi
395
+
396
+ echo "$digest"
397
+ }
398
+
399
+ create_manifest_tags() {
400
+ local image_type="$1"
401
+ local tag_name="$2"
402
+ local suffix="$3"
403
+
404
+ local merged_tag="${PREFIX}${image_type}${suffix}"
405
+ local merged_versioned_tag="${merged_tag}-${SRC_TAG}"
406
+
407
+ local refs=()
408
+
409
+ for arch in $ARCHES; do
410
+ local digest
411
+ digest="$(find_digest "$tag_name" "$arch" "$image_type")"
412
+ refs+=("${IMAGE_REPO}@${digest}")
413
+ done
414
+
415
+ echo "Creating ${merged_tag} from ${refs[*]}"
416
+ docker buildx imagetools create --tag "${merged_tag}" "${refs[@]}"
417
+
418
+ echo "Creating ${merged_versioned_tag} from ${refs[*]}"
419
+ docker buildx imagetools create --tag "${merged_versioned_tag}" "${refs[@]}"
420
+ }
421
+
422
+ for tag in $TAGS; do
423
+ if [[ "$tag" == "cpu" ]]; then
424
+ TYPE=""
425
+ else
426
+ TYPE="-$tag"
427
+ fi
428
+
429
+ if [[ "${{ matrix.config.full }}" == "true" ]]; then
430
+ create_manifest_tags "full" "$tag" "$TYPE"
431
+ fi
432
+
433
+ if [[ "${{ matrix.config.light }}" == "true" ]]; then
434
+ create_manifest_tags "light" "$tag" "$TYPE"
435
+ fi
436
+
437
+ if [[ "${{ matrix.config.server }}" == "true" ]]; then
438
+ create_manifest_tags "server" "$tag" "$TYPE"
439
+ fi
440
+ done
441
+ env:
442
+ GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}'
.github/workflows/editorconfig.yml CHANGED
@@ -23,7 +23,7 @@ jobs:
23
  runs-on: ubuntu-slim
24
  steps:
25
  - uses: actions/checkout@v6
26
- - uses: editorconfig-checker/action-editorconfig-checker@v2
27
  with:
28
  version: v3.0.3
29
  - run: editorconfig-checker
 
23
  runs-on: ubuntu-slim
24
  steps:
25
  - uses: actions/checkout@v6
26
+ - uses: editorconfig-checker/action-editorconfig-checker@840e866d93b8e032123c23bac69dece044d4d84c # v2.2.0
27
  with:
28
  version: v3.0.3
29
  - run: editorconfig-checker
.github/workflows/gguf-publish.yml CHANGED
@@ -28,17 +28,17 @@ jobs:
28
  - name: Set up Python
29
  uses: actions/setup-python@v6
30
  with:
31
- python-version: '3.9.x'
32
  - name: Install dependencies
33
  run: |
34
  cd gguf-py
35
- python -m pip install poetry
36
  poetry install
37
 
38
  - name: Build package
39
  run: cd gguf-py && poetry build
40
  - name: Publish package
41
- uses: pypa/gh-action-pypi-publish@release/v1
42
  with:
43
  password: ${{ secrets.PYPI_API_TOKEN }}
44
  packages-dir: gguf-py/dist
 
28
  - name: Set up Python
29
  uses: actions/setup-python@v6
30
  with:
31
+ python-version: '3.11'
32
  - name: Install dependencies
33
  run: |
34
  cd gguf-py
35
+ python -m pip install poetry==2.3.2
36
  poetry install
37
 
38
  - name: Build package
39
  run: cd gguf-py && poetry build
40
  - name: Publish package
41
+ uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
42
  with:
43
  password: ${{ secrets.PYPI_API_TOKEN }}
44
  packages-dir: gguf-py/dist
.github/workflows/hip-quality-check.yml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: HIP quality check
2
+
3
+ on:
4
+ workflow_dispatch: # allows manual triggering
5
+ push:
6
+ branches:
7
+ - master
8
+ paths: [
9
+ '.github/workflows/hip-quality-check.yml',
10
+ '**/*.cu',
11
+ '**/*.cuh',
12
+ 'scripts/hip/gcn-cdna-vgpr-check.py'
13
+ ]
14
+
15
+ pull_request:
16
+ types: [opened, synchronize, reopened]
17
+ paths: [
18
+ '.github/workflows/hip-quality-check.yml',
19
+ '**/*.cu',
20
+ '**/*.cuh',
21
+ 'scripts/hip/gcn-cdna-vgpr-check.py'
22
+ ]
23
+
24
+ concurrency:
25
+ group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
26
+ cancel-in-progress: true
27
+
28
+ env:
29
+ GGML_NLOOP: 3
30
+ GGML_N_THREADS: 1
31
+ LLAMA_LOG_COLORS: 1
32
+ LLAMA_LOG_PREFIX: 1
33
+ LLAMA_LOG_TIMESTAMPS: 1
34
+
35
+ jobs:
36
+ ubuntu-22-hip-quality-check:
37
+ runs-on: ubuntu-22.04
38
+ container: rocm/dev-ubuntu-22.04:7.2.1
39
+ steps:
40
+ - name: Clone
41
+ id: checkout
42
+ uses: actions/checkout@v6
43
+
44
+ - name: Dependencies
45
+ id: depends
46
+ run: |
47
+ sudo apt-get update
48
+ sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev libssl-dev python3
49
+
50
+ - name: ccache
51
+ uses: ggml-org/ccache-action@v1.2.21
52
+ with:
53
+ key: ubuntu-22-hip-quality-check
54
+ evict-old-files: 1d
55
+ save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
56
+
57
+ - name: Build with Werror
58
+ id: cmake_build
59
+ run: |
60
+ cmake -B build -S . \
61
+ -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
62
+ -DGPU_TARGETS=gfx942 \
63
+ -DGGML_HIP=ON \
64
+ -DGGML_HIP_EXPORT_METRICS=Off \
65
+ -DCMAKE_HIP_FLAGS="-Werror -Wno-tautological-compare" \
66
+ -DCMAKE_BUILD_TYPE=Release
67
+ cd build
68
+ make -j $(nproc)
69
+
70
+ - name: Check for major VGPR spills
71
+ id: vgpr_check
72
+ run: |
73
+ cmake -B build -S . \
74
+ -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
75
+ -DGPU_TARGETS=gfx908 \
76
+ -DGGML_HIP=ON \
77
+ -DGGML_HIP_EXPORT_METRICS=On \
78
+ -DCMAKE_HIP_FLAGS="" \
79
+ -DCMAKE_BUILD_TYPE=Release
80
+ cd build
81
+ make -j $(nproc) 2>&1 | tee metrics.log | grep -v 'Rpass-analysis=kernel-resource-usage\|remark:\|^$'
82
+ python3 ../scripts/hip/gcn-cdna-vgpr-check.py metrics.log
.github/workflows/python-lint.yml CHANGED
@@ -31,6 +31,6 @@ jobs:
31
  with:
32
  python-version: "3.11"
33
  - name: flake8 Lint
34
- uses: py-actions/flake8@v2
35
  with:
36
  plugins: "flake8-no-print"
 
31
  with:
32
  python-version: "3.11"
33
  - name: flake8 Lint
34
+ uses: py-actions/flake8@84ec6726560b6d5bd68f2a5bed83d62b52bb50ba # v2
35
  with:
36
  plugins: "flake8-no-print"
.github/workflows/python-type-check.yml CHANGED
@@ -4,15 +4,17 @@ on:
4
  push:
5
  paths:
6
  - '.github/workflows/python-type-check.yml'
7
- - 'pyrightconfig.json'
8
  - '**.py'
9
  - '**/requirements*.txt'
 
10
  pull_request:
11
  paths:
12
  - '.github/workflows/python-type-check.yml'
13
- - 'pyrightconfig.json'
14
  - '**.py'
15
  - '**/requirements*.txt'
 
16
 
17
  concurrency:
18
  group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
@@ -20,8 +22,8 @@ concurrency:
20
 
21
  jobs:
22
  python-type-check:
23
- runs-on: ubuntu-latest
24
- name: pyright type-check
25
  steps:
26
  - name: Check out source repository
27
  uses: actions/checkout@v6
@@ -29,10 +31,13 @@ jobs:
29
  uses: actions/setup-python@v6
30
  with:
31
  python-version: "3.11"
32
- pip-install: -r requirements/requirements-all.txt
33
- - name: Type-check with Pyright
34
- uses: jakebailey/pyright-action@v2
35
- with:
36
- version: 1.1.382
37
- level: warning
38
- warnings: true
 
 
 
 
4
  push:
5
  paths:
6
  - '.github/workflows/python-type-check.yml'
7
+ - 'ty.toml'
8
  - '**.py'
9
  - '**/requirements*.txt'
10
+ # - 'pyrightconfig.json'
11
  pull_request:
12
  paths:
13
  - '.github/workflows/python-type-check.yml'
14
+ - 'ty.toml'
15
  - '**.py'
16
  - '**/requirements*.txt'
17
+ # - 'pyrightconfig.json'
18
 
19
  concurrency:
20
  group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
 
22
 
23
  jobs:
24
  python-type-check:
25
+ runs-on: ubuntu-slim
26
+ name: python type-check
27
  steps:
28
  - name: Check out source repository
29
  uses: actions/checkout@v6
 
31
  uses: actions/setup-python@v6
32
  with:
33
  python-version: "3.11"
34
+ pip-install: -r requirements/requirements-all.txt ty==0.0.26
35
+ # - name: Type-check with Pyright
36
+ # uses: jakebailey/pyright-action@v2
37
+ # with:
38
+ # version: 1.1.382
39
+ # level: warning
40
+ # warnings: true
41
+ - name: Type-check with ty
42
+ run: |
43
+ ty check --output-format=github
.github/workflows/release.yml CHANGED
@@ -36,8 +36,26 @@ env:
36
  CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
37
 
38
  jobs:
39
- macOS-arm64:
40
- runs-on: macos-14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  steps:
43
  - name: Clone
@@ -49,7 +67,7 @@ jobs:
49
  - name: ccache
50
  uses: ggml-org/ccache-action@v1.2.21
51
  with:
52
- key: macOS-latest-arm64
53
  evict-old-files: 1d
54
 
55
  - name: Build
@@ -57,13 +75,11 @@ jobs:
57
  run: |
58
  sysctl -a
59
  cmake -B build \
 
60
  -DCMAKE_INSTALL_RPATH='@loader_path' \
61
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
62
  -DLLAMA_FATAL_WARNINGS=ON \
63
  -DLLAMA_BUILD_BORINGSSL=ON \
64
- -DGGML_METAL_USE_BF16=ON \
65
- -DGGML_METAL_EMBED_LIBRARY=ON \
66
- -DGGML_RPC=ON \
67
  ${{ env.CMAKE_ARGS }}
68
  cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
69
 
@@ -75,16 +91,26 @@ jobs:
75
  id: pack_artifacts
76
  run: |
77
  cp LICENSE ./build/bin/
78
- tar -czvf llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz -s ",./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
79
 
80
  - name: Upload artifacts
81
  uses: actions/upload-artifact@v6
82
  with:
83
- path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz
84
- name: llama-bin-macos-arm64.tar.gz
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- macOS-x64:
87
- runs-on: macos-15-intel
88
 
89
  steps:
90
  - name: Clone
@@ -94,26 +120,37 @@ jobs:
94
  fetch-depth: 0
95
 
96
  - name: ccache
 
97
  uses: ggml-org/ccache-action@v1.2.21
98
  with:
99
- key: macOS-latest-x64
100
  evict-old-files: 1d
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  - name: Build
103
  id: cmake_build
104
  run: |
105
- sysctl -a
106
- # Metal is disabled due to intermittent failures with Github runners not having a GPU:
107
- # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
108
  cmake -B build \
109
- -DCMAKE_INSTALL_RPATH='@loader_path' \
110
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
 
 
 
111
  -DLLAMA_FATAL_WARNINGS=ON \
112
- -DLLAMA_BUILD_BORINGSSL=ON \
113
- -DGGML_METAL=OFF \
114
- -DGGML_RPC=ON \
115
- -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
116
- cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
117
 
118
  - name: Determine tag name
119
  id: tag
@@ -123,25 +160,22 @@ jobs:
123
  id: pack_artifacts
124
  run: |
125
  cp LICENSE ./build/bin/
126
- tar -czvf llama-${{ steps.tag.outputs.name }}-bin-macos-x64.tar.gz -s ",./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
127
 
128
  - name: Upload artifacts
129
  uses: actions/upload-artifact@v6
130
  with:
131
- path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.tar.gz
132
- name: llama-bin-macos-x64.tar.gz
133
 
134
- ubuntu-22-cpu:
135
  strategy:
136
  matrix:
137
  include:
138
  - build: 'x64'
139
  os: ubuntu-22.04
140
- - build: 's390x'
141
- os: ubuntu-24.04-s390x
142
- # GGML_BACKEND_DL and GGML_CPU_ALL_VARIANTS are not currently supported on arm
143
- # - build: 'arm64'
144
- # os: ubuntu-22.04-arm
145
 
146
  runs-on: ${{ matrix.os }}
147
 
@@ -153,17 +187,25 @@ jobs:
153
  fetch-depth: 0
154
 
155
  - name: ccache
156
- if: ${{ matrix.build != 's390x' }}
157
  uses: ggml-org/ccache-action@v1.2.21
158
  with:
159
- key: ubuntu-cpu-${{ matrix.build }}
160
  evict-old-files: 1d
161
 
162
  - name: Dependencies
163
  id: depends
164
  run: |
165
- sudo apt-get update
166
- sudo apt-get install build-essential libssl-dev
 
 
 
 
 
 
 
 
 
167
 
168
  - name: Build
169
  id: cmake_build
@@ -174,7 +216,7 @@ jobs:
174
  -DGGML_BACKEND_DL=ON \
175
  -DGGML_NATIVE=OFF \
176
  -DGGML_CPU_ALL_VARIANTS=ON \
177
- -DLLAMA_FATAL_WARNINGS=ON \
178
  ${{ env.CMAKE_ARGS }}
179
  cmake --build build --config Release -j $(nproc)
180
 
@@ -186,16 +228,19 @@ jobs:
186
  id: pack_artifacts
187
  run: |
188
  cp LICENSE ./build/bin/
189
- tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
190
 
191
  - name: Upload artifacts
192
  uses: actions/upload-artifact@v6
193
  with:
194
- path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz
195
- name: llama-bin-ubuntu-${{ matrix.build }}.tar.gz
196
 
197
- ubuntu-22-vulkan:
198
- runs-on: ubuntu-22.04
 
 
 
199
 
200
  steps:
201
  - name: Clone
@@ -207,27 +252,40 @@ jobs:
207
  - name: ccache
208
  uses: ggml-org/ccache-action@v1.2.21
209
  with:
210
- key: ubuntu-22-vulkan
211
  evict-old-files: 1d
212
 
213
- - name: Dependencies
214
- id: depends
 
 
 
 
 
 
 
 
 
 
215
  run: |
216
- wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
217
- sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
218
- sudo apt-get update -y
219
- sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libssl-dev
220
 
221
  - name: Build
222
  id: cmake_build
223
  run: |
224
  cmake -B build \
 
 
 
225
  -DCMAKE_INSTALL_RPATH='$ORIGIN' \
226
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
227
  -DGGML_BACKEND_DL=ON \
228
  -DGGML_NATIVE=OFF \
229
  -DGGML_CPU_ALL_VARIANTS=ON \
230
- -DGGML_VULKAN=ON \
 
 
231
  ${{ env.CMAKE_ARGS }}
232
  cmake --build build --config Release -j $(nproc)
233
 
@@ -239,13 +297,13 @@ jobs:
239
  id: pack_artifacts
240
  run: |
241
  cp LICENSE ./build/bin/
242
- tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
243
 
244
  - name: Upload artifacts
245
  uses: actions/upload-artifact@v6
246
  with:
247
- path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.tar.gz
248
- name: llama-bin-ubuntu-vulkan-x64.tar.gz
249
 
250
  ubuntu-24-openvino:
251
  runs-on: ubuntu-24.04
@@ -618,8 +676,8 @@ jobs:
618
  strategy:
619
  matrix:
620
  include:
621
- - ROCM_VERSION: "7.2"
622
- gpu_targets: "gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1151;gfx1150;gfx1200;gfx1201"
623
  build: 'x64'
624
 
625
  steps:
@@ -629,6 +687,11 @@ jobs:
629
  with:
630
  fetch-depth: 0
631
 
 
 
 
 
 
632
  - name: ccache
633
  uses: ggml-org/ccache-action@v1.2.21
634
  with:
@@ -641,7 +704,7 @@ jobs:
641
  sudo apt install -y build-essential git cmake wget
642
 
643
  - name: Setup Legacy ROCm
644
- if: matrix.ROCM_VERSION == '7.2'
645
  id: legacy_env
646
  run: |
647
  sudo mkdir --parents --mode=0755 /etc/apt/keyrings
@@ -662,7 +725,7 @@ jobs:
662
  sudo apt-get install -y libssl-dev rocm-hip-sdk
663
 
664
  - name: Setup TheRock
665
- if: matrix.ROCM_VERSION != '7.2'
666
  id: therock_env
667
  run: |
668
  wget https://repo.amd.com/rocm/tarball/therock-dist-linux-gfx1151-${{ matrix.ROCM_VERSION }}.tar.gz
@@ -678,7 +741,6 @@ jobs:
678
  run: |
679
  cmake -B build -S . \
680
  -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
681
- -DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \
682
  -DCMAKE_BUILD_TYPE=Release \
683
  -DGGML_BACKEND_DL=ON \
684
  -DGGML_NATIVE=OFF \
@@ -696,17 +758,20 @@ jobs:
696
  id: tag
697
  uses: ./.github/actions/get-tag-name
698
 
 
 
 
699
  - name: Pack artifacts
700
  id: pack_artifacts
701
  run: |
702
  cp LICENSE ./build/bin/
703
- tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
704
 
705
  - name: Upload artifacts
706
  uses: actions/upload-artifact@v6
707
  with:
708
- path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}.tar.gz
709
- name: llama-bin-ubuntu-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}.tar.gz
710
 
711
  windows-hip:
712
  runs-on: windows-2022
@@ -728,7 +793,7 @@ jobs:
728
  - name: Grab rocWMMA package
729
  id: grab_rocwmma
730
  run: |
731
- curl -o rocwmma.deb "https://repo.radeon.com/rocm/apt/7.2/pool/main/r/rocwmma-dev/rocwmma-dev_2.2.0.70200-43~24.04_amd64.deb"
732
  7z x rocwmma.deb
733
  7z x data.tar
734
 
@@ -785,7 +850,7 @@ jobs:
785
  cmake -G "Unix Makefiles" -B build -S . `
786
  -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
787
  -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
788
- -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/opt/rocm-7.2.0/include/ -Wno-ignored-attributes -Wno-nested-anon-types" `
789
  -DCMAKE_BUILD_TYPE=Release `
790
  -DGGML_BACKEND_DL=ON `
791
  -DGGML_NATIVE=OFF `
@@ -907,7 +972,7 @@ jobs:
907
  - name: Set container image
908
  id: cann-image
909
  run: |
910
- image="ascendai/cann:${{ matrix.chip_type == '910b' && '8.3.rc2-910b-openeuler24.03-py3.11' || '8.3.rc2-310p-openeuler24.03-py3.11' }}"
911
  echo "image=${image}" >> "${GITHUB_OUTPUT}"
912
 
913
  - name: Pull container image
@@ -977,11 +1042,11 @@ jobs:
977
  - windows-sycl
978
  - windows-hip
979
  - ubuntu-22-rocm
980
- - ubuntu-22-cpu
981
- - ubuntu-22-vulkan
982
  - ubuntu-24-openvino
983
- - macOS-arm64
984
- - macOS-x64
985
  - ios-xcode-build
986
  - openEuler-cann
987
 
@@ -1056,16 +1121,22 @@ jobs:
1056
 
1057
  **macOS/iOS:**
1058
  - [macOS Apple Silicon (arm64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz)
 
1059
  - [macOS Intel (x64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-x64.tar.gz)
1060
  - [iOS XCFramework](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-xcframework.zip)
1061
 
1062
  **Linux:**
1063
  - [Ubuntu x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.tar.gz)
 
 
1064
  - [Ubuntu x64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.tar.gz)
 
1065
  - [Ubuntu x64 (ROCm 7.2)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-7.2-x64.tar.gz)
1066
- - [Ubuntu s390x (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-s390x.tar.gz)
1067
  - [Ubuntu x64 (OpenVINO)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-openvino-${{ needs.ubuntu-24-openvino.outputs.openvino_version }}-x64.tar.gz)
1068
 
 
 
 
1069
  **Windows:**
1070
  - [Windows x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-x64.zip)
1071
  - [Windows arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-arm64.zip)
 
36
  CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
37
 
38
  jobs:
39
+ macOS-cpu:
40
+ strategy:
41
+ matrix:
42
+ include:
43
+ - build: 'arm64'
44
+ arch: 'arm64'
45
+ os: macos-14
46
+ defines: "-DGGML_METAL_USE_BF16=ON -DGGML_METAL_EMBED_LIBRARY=ON"
47
+ - build: 'arm64-kleidiai'
48
+ arch: 'arm64'
49
+ os: macos-14
50
+ defines: "-DGGML_METAL_USE_BF16=ON -DGGML_METAL_EMBED_LIBRARY=ON -DGGML_CPU_KLEIDIAI=ON"
51
+ - build: 'x64'
52
+ arch: 'x64'
53
+ os: macos-15-intel
54
+ # Metal is disabled on x64 due to intermittent failures with Github runners not having a GPU:
55
+ # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
56
+ defines: "-DGGML_METAL=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3"
57
+
58
+ runs-on: ${{ matrix.os }}
59
 
60
  steps:
61
  - name: Clone
 
67
  - name: ccache
68
  uses: ggml-org/ccache-action@v1.2.21
69
  with:
70
+ key: macOS-latest-${{ matrix.arch }}
71
  evict-old-files: 1d
72
 
73
  - name: Build
 
75
  run: |
76
  sysctl -a
77
  cmake -B build \
78
+ ${{ matrix.defines }} \
79
  -DCMAKE_INSTALL_RPATH='@loader_path' \
80
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
81
  -DLLAMA_FATAL_WARNINGS=ON \
82
  -DLLAMA_BUILD_BORINGSSL=ON \
 
 
 
83
  ${{ env.CMAKE_ARGS }}
84
  cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
85
 
 
91
  id: pack_artifacts
92
  run: |
93
  cp LICENSE ./build/bin/
94
+ tar -czvf llama-${{ steps.tag.outputs.name }}-bin-macos-${{ matrix.build }}.tar.gz -s ",./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
95
 
96
  - name: Upload artifacts
97
  uses: actions/upload-artifact@v6
98
  with:
99
+ path: llama-${{ steps.tag.outputs.name }}-bin-macos-${{ matrix.build }}.tar.gz
100
+ name: llama-bin-macos-${{ matrix.build }}.tar.gz
101
+
102
+ ubuntu-cpu:
103
+ strategy:
104
+ matrix:
105
+ include:
106
+ - build: 'x64'
107
+ os: ubuntu-22.04
108
+ - build: 'arm64'
109
+ os: ubuntu-24.04-arm
110
+ - build: 's390x'
111
+ os: ubuntu-24.04-s390x
112
 
113
+ runs-on: ${{ matrix.os }}
 
114
 
115
  steps:
116
  - name: Clone
 
120
  fetch-depth: 0
121
 
122
  - name: ccache
123
+ if: ${{ matrix.build != 's390x' }}
124
  uses: ggml-org/ccache-action@v1.2.21
125
  with:
126
+ key: ubuntu-cpu-${{ matrix.build }}
127
  evict-old-files: 1d
128
 
129
+ - name: Dependencies
130
+ id: depends
131
+ run: |
132
+ sudo apt-get update
133
+ sudo apt-get install build-essential libssl-dev
134
+
135
+ - name: Toolchain workaround (GCC 14)
136
+ if: ${{ contains(matrix.os, 'ubuntu-24.04') }}
137
+ run: |
138
+ sudo apt-get install -y gcc-14 g++-14
139
+ echo "CC=gcc-14" >> "$GITHUB_ENV"
140
+ echo "CXX=g++-14" >> "$GITHUB_ENV"
141
+
142
  - name: Build
143
  id: cmake_build
144
  run: |
 
 
 
145
  cmake -B build \
146
+ -DCMAKE_INSTALL_RPATH='$ORIGIN' \
147
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
148
+ -DGGML_BACKEND_DL=ON \
149
+ -DGGML_NATIVE=OFF \
150
+ -DGGML_CPU_ALL_VARIANTS=ON \
151
  -DLLAMA_FATAL_WARNINGS=ON \
152
+ ${{ env.CMAKE_ARGS }}
153
+ cmake --build build --config Release -j $(nproc)
 
 
 
154
 
155
  - name: Determine tag name
156
  id: tag
 
160
  id: pack_artifacts
161
  run: |
162
  cp LICENSE ./build/bin/
163
+ tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
164
 
165
  - name: Upload artifacts
166
  uses: actions/upload-artifact@v6
167
  with:
168
+ path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz
169
+ name: llama-bin-ubuntu-${{ matrix.build }}.tar.gz
170
 
171
+ ubuntu-vulkan:
172
  strategy:
173
  matrix:
174
  include:
175
  - build: 'x64'
176
  os: ubuntu-22.04
177
+ - build: 'arm64'
178
+ os: ubuntu-24.04-arm
 
 
 
179
 
180
  runs-on: ${{ matrix.os }}
181
 
 
187
  fetch-depth: 0
188
 
189
  - name: ccache
 
190
  uses: ggml-org/ccache-action@v1.2.21
191
  with:
192
+ key: ubuntu-vulkan-${{ matrix.build }}
193
  evict-old-files: 1d
194
 
195
  - name: Dependencies
196
  id: depends
197
  run: |
198
+ if [[ "${{ matrix.os }}" =~ "ubuntu-22.04" ]]; then
199
+ wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
200
+ sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
201
+ sudo apt-get update -y
202
+ sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libssl-dev
203
+ else
204
+ sudo apt-get update -y
205
+ sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
206
+ echo "CC=gcc-14" >> "$GITHUB_ENV"
207
+ echo "CXX=g++-14" >> "$GITHUB_ENV"
208
+ fi
209
 
210
  - name: Build
211
  id: cmake_build
 
216
  -DGGML_BACKEND_DL=ON \
217
  -DGGML_NATIVE=OFF \
218
  -DGGML_CPU_ALL_VARIANTS=ON \
219
+ -DGGML_VULKAN=ON \
220
  ${{ env.CMAKE_ARGS }}
221
  cmake --build build --config Release -j $(nproc)
222
 
 
228
  id: pack_artifacts
229
  run: |
230
  cp LICENSE ./build/bin/
231
+ tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
232
 
233
  - name: Upload artifacts
234
  uses: actions/upload-artifact@v6
235
  with:
236
+ path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
237
+ name: llama-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
238
 
239
+ android-arm64:
240
+ runs-on: ubuntu-latest
241
+
242
+ env:
243
+ NDK_VERSION: "29.0.14206865"
244
 
245
  steps:
246
  - name: Clone
 
252
  - name: ccache
253
  uses: ggml-org/ccache-action@v1.2.21
254
  with:
255
+ key: android-arm64
256
  evict-old-files: 1d
257
 
258
+ - name: Set up JDK
259
+ uses: actions/setup-java@v5
260
+ with:
261
+ java-version: 17
262
+ distribution: temurin
263
+
264
+ - name: Setup Android SDK
265
+ uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
266
+ with:
267
+ log-accepted-android-sdk-licenses: false
268
+
269
+ - name: Install NDK
270
  run: |
271
+ sdkmanager "ndk;${{ env.NDK_VERSION }}"
272
+ echo "ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
 
 
273
 
274
  - name: Build
275
  id: cmake_build
276
  run: |
277
  cmake -B build \
278
+ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
279
+ -DANDROID_ABI=arm64-v8a \
280
+ -DANDROID_PLATFORM=android-28 \
281
  -DCMAKE_INSTALL_RPATH='$ORIGIN' \
282
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
283
  -DGGML_BACKEND_DL=ON \
284
  -DGGML_NATIVE=OFF \
285
  -DGGML_CPU_ALL_VARIANTS=ON \
286
+ -DLLAMA_FATAL_WARNINGS=ON \
287
+ -DGGML_OPENMP=OFF \
288
+ -DLLAMA_BUILD_BORINGSSL=ON \
289
  ${{ env.CMAKE_ARGS }}
290
  cmake --build build --config Release -j $(nproc)
291
 
 
297
  id: pack_artifacts
298
  run: |
299
  cp LICENSE ./build/bin/
300
+ tar -czvf llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
301
 
302
  - name: Upload artifacts
303
  uses: actions/upload-artifact@v6
304
  with:
305
+ path: llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz
306
+ name: llama-bin-android-arm64.tar.gz
307
 
308
  ubuntu-24-openvino:
309
  runs-on: ubuntu-24.04
 
676
  strategy:
677
  matrix:
678
  include:
679
+ - ROCM_VERSION: "7.2.1"
680
+ gpu_targets: "gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201"
681
  build: 'x64'
682
 
683
  steps:
 
687
  with:
688
  fetch-depth: 0
689
 
690
+ - name: Free up disk space
691
+ uses: ggml-org/free-disk-space@v1.3.1
692
+ with:
693
+ tool-cache: true
694
+
695
  - name: ccache
696
  uses: ggml-org/ccache-action@v1.2.21
697
  with:
 
704
  sudo apt install -y build-essential git cmake wget
705
 
706
  - name: Setup Legacy ROCm
707
+ if: matrix.ROCM_VERSION == '7.2.1'
708
  id: legacy_env
709
  run: |
710
  sudo mkdir --parents --mode=0755 /etc/apt/keyrings
 
725
  sudo apt-get install -y libssl-dev rocm-hip-sdk
726
 
727
  - name: Setup TheRock
728
+ if: matrix.ROCM_VERSION != '7.2.1'
729
  id: therock_env
730
  run: |
731
  wget https://repo.amd.com/rocm/tarball/therock-dist-linux-gfx1151-${{ matrix.ROCM_VERSION }}.tar.gz
 
741
  run: |
742
  cmake -B build -S . \
743
  -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
 
744
  -DCMAKE_BUILD_TYPE=Release \
745
  -DGGML_BACKEND_DL=ON \
746
  -DGGML_NATIVE=OFF \
 
758
  id: tag
759
  uses: ./.github/actions/get-tag-name
760
 
761
+ - name: Get ROCm short version
762
+ run: echo "ROCM_VERSION_SHORT=$(echo '${{ matrix.ROCM_VERSION }}' | cut -d '.' -f 1,2)" >> $GITHUB_ENV
763
+
764
  - name: Pack artifacts
765
  id: pack_artifacts
766
  run: |
767
  cp LICENSE ./build/bin/
768
+ tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz --transform "s,./,llama-${{ steps.tag.outputs.name }}/," -C ./build/bin .
769
 
770
  - name: Upload artifacts
771
  uses: actions/upload-artifact@v6
772
  with:
773
+ path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz
774
+ name: llama-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz
775
 
776
  windows-hip:
777
  runs-on: windows-2022
 
793
  - name: Grab rocWMMA package
794
  id: grab_rocwmma
795
  run: |
796
+ curl -o rocwmma.deb "https://repo.radeon.com/rocm/apt/7.2.1/pool/main/r/rocwmma-dev/rocwmma-dev_2.2.0.70201-81~24.04_amd64.deb"
797
  7z x rocwmma.deb
798
  7z x data.tar
799
 
 
850
  cmake -G "Unix Makefiles" -B build -S . `
851
  -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
852
  -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
853
+ -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/opt/rocm-7.2.1/include/ -Wno-ignored-attributes -Wno-nested-anon-types" `
854
  -DCMAKE_BUILD_TYPE=Release `
855
  -DGGML_BACKEND_DL=ON `
856
  -DGGML_NATIVE=OFF `
 
972
  - name: Set container image
973
  id: cann-image
974
  run: |
975
+ image="ascendai/cann:${{ matrix.chip_type == '910b' && '8.5.0-910b-openeuler24.03-py3.11' || '8.5.0-310p-openeuler24.03-py3.11' }}"
976
  echo "image=${image}" >> "${GITHUB_OUTPUT}"
977
 
978
  - name: Pull container image
 
1042
  - windows-sycl
1043
  - windows-hip
1044
  - ubuntu-22-rocm
1045
+ - ubuntu-cpu
1046
+ - ubuntu-vulkan
1047
  - ubuntu-24-openvino
1048
+ - android-arm64
1049
+ - macOS-cpu
1050
  - ios-xcode-build
1051
  - openEuler-cann
1052
 
 
1121
 
1122
  **macOS/iOS:**
1123
  - [macOS Apple Silicon (arm64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz)
1124
+ - [macOS Apple Silicon (arm64, KleidiAI enabled)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-arm64-kleidiai.tar.gz)
1125
  - [macOS Intel (x64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-x64.tar.gz)
1126
  - [iOS XCFramework](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-xcframework.zip)
1127
 
1128
  **Linux:**
1129
  - [Ubuntu x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.tar.gz)
1130
+ - [Ubuntu arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-arm64.tar.gz)
1131
+ - [Ubuntu s390x (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-s390x.tar.gz)
1132
  - [Ubuntu x64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.tar.gz)
1133
+ - [Ubuntu arm64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-arm64.tar.gz)
1134
  - [Ubuntu x64 (ROCm 7.2)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-7.2-x64.tar.gz)
 
1135
  - [Ubuntu x64 (OpenVINO)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-openvino-${{ needs.ubuntu-24-openvino.outputs.openvino_version }}-x64.tar.gz)
1136
 
1137
+ **Android:**
1138
+ - [Android arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz)
1139
+
1140
  **Windows:**
1141
  - [Windows x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-x64.zip)
1142
  - [Windows arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-arm64.zip)
.github/workflows/server-self-hosted.yml CHANGED
@@ -84,41 +84,42 @@ jobs:
84
  export ${{ matrix.extra_args }}
85
  pytest -v -x -m "not slow"
86
 
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"
 
 
84
  export ${{ matrix.extra_args }}
85
  pytest -v -x -m "not slow"
86
 
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"
.gitignore CHANGED
@@ -1,5 +1,7 @@
1
  # Extensions
2
-
 
 
3
  *.a
4
  *.bat
5
  *.bin
@@ -95,6 +97,8 @@
95
  # Server Web UI temporary files
96
  /tools/server/webui/node_modules
97
  /tools/server/webui/dist
 
 
98
 
99
  # Python
100
 
 
1
  # Extensions
2
+ build/
3
+ build_64/
4
+ models/
5
  *.a
6
  *.bat
7
  *.bin
 
97
  # Server Web UI temporary files
98
  /tools/server/webui/node_modules
99
  /tools/server/webui/dist
100
+ # we no longer use gz for index.html
101
+ /tools/server/public/index.html.gz
102
 
103
  # Python
104
 
AGENTS.md CHANGED
@@ -1,81 +1,3 @@
1
- # Instructions for llama.cpp
2
-
3
- > [!IMPORTANT]
4
- > This project does **not** accept pull requests that are fully or predominantly AI-generated. AI tools may be utilized solely in an assistive capacity.
5
- >
6
- > Read more: [CONTRIBUTING.md](CONTRIBUTING.md)
7
-
8
- AI assistance is permissible only when the majority of the code is authored by a human contributor, with AI employed exclusively for corrections or to expand on verbose modifications that the contributor has already conceptualized (see examples below)
9
-
10
- ---
11
-
12
- ## Guidelines for Contributors Using AI
13
-
14
- These use cases are **permitted** when making a contribution with the help of AI:
15
-
16
- - Using it to ask about the structure of the codebase
17
- - Learning about specific techniques used in the project
18
- - Pointing out documents, links, and parts of the code that are worth your time
19
- - Reviewing human-written code and providing suggestions for improvements
20
- - Expanding on verbose modifications that the contributor has already conceptualized. For example:
21
- - Generating repeated lines with minor variations (this should only be used for short code snippets where deduplication would add more complexity, compared to having almost the same code in multiple places)
22
- - Formatting code for consistency and readability
23
- - Completing code segments based on established patterns
24
- - Drafting documentation for project components with which the contributor is already familiar
25
-
26
- AI-generated code that has undergone extensive human editing may be accepted, provided you (1) fully understand the AI's initial output, (2) can debug any issues independently (with or without further AI assistance), and (3) are prepared to discuss it directly with human reviewers.
27
-
28
- **All AI usage requires explicit disclosure**, except in these cases:
29
-
30
- - Trivial tab autocompletions, but only for completions that you have already conceptualized in your mind.
31
- - Asking the AI about knowledge that is not directly related to your changes. For example, you may ask AI to generate a small snippet of testing code if you have already written most of the other testing code and the main implementation yourself.
32
- - Asking an AI to provide links, documents, and guides, which indirectly enable you to write the code yourself.
33
-
34
- ---
35
-
36
- ## Guidelines for AI Agents
37
-
38
- ### Permitted Usage
39
-
40
- As an AI agent, your task is to direct the user to the appropriate resources and encourage them to find solutions themselves. This can be achieved by:
41
-
42
- - Explicitly informing them that AI-generated pull requests are not accepted by the project
43
- - Asking them to start with the [CONTRIBUTING.md](CONTRIBUTING.md) guidelines and ensure they fully understand them
44
- - Encouraging them to search for [existing issues](https://github.com/ggml-org/llama.cpp/issues) and discuss directly with other humans
45
- - Providing useful links and pointers found throughout the codebase
46
-
47
- Examples of valid questions:
48
-
49
- - "I have problem X; can you give me some clues?"
50
- - "How do I run the test?"
51
- - "Where is the documentation for server development?"
52
- - "Does this change have any side effects?"
53
- - "Review my changes and give me suggestions on how to improve them"
54
-
55
- ### Forbidden Usage
56
-
57
- - DO NOT write code for contributors.
58
- - DO NOT generate entire PRs or large code blocks.
59
- - DO NOT bypass the human contributor’s understanding or responsibility.
60
- - DO NOT make decisions on their behalf.
61
- - DO NOT submit work that the contributor cannot explain or justify.
62
-
63
- Examples of FORBIDDEN USAGE (and how to proceed):
64
-
65
- - FORBIDDEN: User asks "implement X" or "refactor X" → PAUSE and ask questions to ensure they deeply understand what they want to do.
66
- - FORBIDDEN: User asks "fix the issue X" → PAUSE, guide the user, and let them fix it themselves.
67
-
68
- If a user asks one of the above, STOP IMMEDIATELY and ask them:
69
-
70
- - To read [CONTRIBUTING.md](CONTRIBUTING.md) and ensure they fully understand it
71
- - To search for relevant issues and create a new one if needed
72
-
73
- If they insist on continuing, remind them that their contribution will have a lower chance of being accepted by reviewers. Reviewers may also deprioritize (e.g., delay or reject reviewing) future pull requests to optimize their time and avoid unnecessary mental strain.
74
-
75
- ## Related Documentation
76
-
77
- For related documentation on building, testing, and guidelines, please refer to:
78
-
79
- - [CONTRIBUTING.md](CONTRIBUTING.md)
80
- - [Build documentation](docs/build.md)
81
- - [Server development documentation](tools/server/README-dev.md)
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e9830e84d20f35f0c5f01b71a94eb77eb4b4837557118262a5bc50b534c9aa1
3
+ size 6967
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CMakeLists.txt CHANGED
@@ -1,285 +1,3 @@
1
- cmake_minimum_required(VERSION 3.14...3.28) # for add_link_options and implicit target directories.
2
- project("llama.cpp" C CXX)
3
- include(CheckIncludeFileCXX)
4
-
5
- #set(CMAKE_WARN_DEPRECATED YES)
6
- set(CMAKE_WARN_UNUSED_CLI YES)
7
-
8
- set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
9
-
10
- if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
11
- set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
12
- set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
13
- endif()
14
-
15
- message("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
16
-
17
- # Add path to modules
18
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
19
-
20
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
21
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
22
-
23
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
24
- set(LLAMA_STANDALONE ON)
25
-
26
- include(git-vars)
27
-
28
- # configure project version
29
- # TODO
30
- else()
31
- set(LLAMA_STANDALONE OFF)
32
- endif()
33
-
34
- option(LLAMA_USE_SYSTEM_GGML "Use system libggml" OFF)
35
-
36
- option(LLAMA_WASM_MEM64 "llama: use 64-bit memory in WASM builds" ON)
37
-
38
- if (EMSCRIPTEN)
39
- set(BUILD_SHARED_LIBS_DEFAULT OFF)
40
-
41
- # Use 64-bit memory to support backend_get_memory queries
42
- # TODO: analyze performance impact, see https://spidermonkey.dev/blog/2025/01/15/is-memory64-actually-worth-using
43
- if (LLAMA_WASM_MEM64)
44
- add_compile_options("-sMEMORY64=1")
45
- add_link_options("-sMEMORY64=1")
46
- endif()
47
- add_link_options("-sALLOW_MEMORY_GROWTH=1")
48
-
49
- option(LLAMA_WASM_SINGLE_FILE "llama: embed WASM inside the generated llama.js" OFF)
50
- option(LLAMA_BUILD_HTML "llama: build HTML file" ON)
51
- if (LLAMA_BUILD_HTML)
52
- set(CMAKE_EXECUTABLE_SUFFIX ".html")
53
- endif()
54
- else()
55
- if (MINGW)
56
- set(BUILD_SHARED_LIBS_DEFAULT OFF)
57
- else()
58
- set(BUILD_SHARED_LIBS_DEFAULT ON)
59
- endif()
60
- endif()
61
-
62
- option(BUILD_SHARED_LIBS "build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
63
-
64
- if (WIN32)
65
- add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
66
- endif()
67
-
68
- if (MSVC)
69
- add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>")
70
- add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>")
71
- add_compile_options("$<$<COMPILE_LANGUAGE:C>:/bigobj>")
72
- add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
73
- endif()
74
-
75
- if (LLAMA_STANDALONE)
76
- # enable parallel builds for msbuild
77
- list(APPEND CMAKE_VS_GLOBALS UseMultiToolTask=true)
78
- list(APPEND CMAKE_VS_GLOBALS EnforceProcessCountAcrossBuilds=true)
79
- endif()
80
-
81
- if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
82
- set(LLAMA_TOOLS_INSTALL_DEFAULT OFF)
83
- else()
84
- set(LLAMA_TOOLS_INSTALL_DEFAULT ${LLAMA_STANDALONE})
85
- endif()
86
-
87
- #
88
- # option list
89
- #
90
-
91
- # debug
92
- option(LLAMA_ALL_WARNINGS "llama: enable all compiler warnings" ON)
93
- option(LLAMA_ALL_WARNINGS_3RD_PARTY "llama: enable all compiler warnings in 3rd party libs" OFF)
94
-
95
- # build
96
- option(LLAMA_FATAL_WARNINGS "llama: enable -Werror flag" OFF)
97
-
98
- # sanitizers
99
- option(LLAMA_SANITIZE_THREAD "llama: enable thread sanitizer" OFF)
100
- option(LLAMA_SANITIZE_ADDRESS "llama: enable address sanitizer" OFF)
101
- option(LLAMA_SANITIZE_UNDEFINED "llama: enable undefined sanitizer" OFF)
102
-
103
- # utils
104
- option(LLAMA_BUILD_COMMON "llama: build common utils library" ${LLAMA_STANDALONE})
105
-
106
- # extra artifacts
107
- option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
108
- option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
109
- option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
110
- option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
111
- option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_DEFAULT})
112
- option(LLAMA_TESTS_INSTALL "llama: install tests" ON)
113
-
114
- # 3rd party libs
115
- option(LLAMA_OPENSSL "llama: use openssl to support HTTPS" ON)
116
- option(LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF)
117
-
118
-
119
- # Required for relocatable CMake package
120
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
121
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
122
-
123
- if (NOT DEFINED LLAMA_BUILD_NUMBER)
124
- set(LLAMA_BUILD_NUMBER ${BUILD_NUMBER})
125
- endif()
126
- if (NOT DEFINED LLAMA_BUILD_COMMIT)
127
- set(LLAMA_BUILD_COMMIT ${BUILD_COMMIT})
128
- endif()
129
- set(LLAMA_INSTALL_VERSION 0.0.${LLAMA_BUILD_NUMBER})
130
-
131
- # override ggml options
132
- set(GGML_ALL_WARNINGS ${LLAMA_ALL_WARNINGS})
133
- set(GGML_FATAL_WARNINGS ${LLAMA_FATAL_WARNINGS})
134
-
135
- # change the default for these ggml options
136
- if (NOT DEFINED GGML_LLAMAFILE)
137
- set(GGML_LLAMAFILE_DEFAULT ON)
138
- endif()
139
-
140
- if (NOT DEFINED GGML_CUDA_GRAPHS)
141
- set(GGML_CUDA_GRAPHS_DEFAULT ON)
142
- endif()
143
-
144
- # transition helpers
145
- function (llama_option_depr TYPE OLD)
146
- if (${OLD})
147
- set(NEW "${ARGV2}")
148
- if(NEW)
149
- message(${TYPE} "${OLD} is deprecated, use ${NEW} instead")
150
- set(${NEW} ON PARENT_SCOPE)
151
- else()
152
- message(${TYPE} "${OLD} is deprecated and will be ignored")
153
- endif()
154
- endif()
155
- endfunction()
156
-
157
- llama_option_depr(FATAL_ERROR LLAMA_CUBLAS GGML_CUDA)
158
- llama_option_depr(WARNING LLAMA_CUDA GGML_CUDA)
159
- llama_option_depr(WARNING LLAMA_METAL GGML_METAL)
160
- llama_option_depr(WARNING LLAMA_METAL_EMBED_LIBRARY GGML_METAL_EMBED_LIBRARY)
161
- llama_option_depr(WARNING LLAMA_NATIVE GGML_NATIVE)
162
- llama_option_depr(WARNING LLAMA_RPC GGML_RPC)
163
- llama_option_depr(WARNING LLAMA_SYCL GGML_SYCL)
164
- llama_option_depr(WARNING LLAMA_SYCL_F16 GGML_SYCL_F16)
165
- llama_option_depr(WARNING LLAMA_CANN GGML_CANN)
166
- llama_option_depr(WARNING LLAMA_CURL)
167
-
168
- include("cmake/license.cmake")
169
- license_add_file("llama.cpp" "LICENSE")
170
-
171
- #
172
- # 3rd-party
173
- #
174
-
175
- if (LLAMA_USE_SYSTEM_GGML)
176
- message(STATUS "Using system-provided libggml, skipping ggml build")
177
- find_package(ggml REQUIRED)
178
- add_library(ggml ALIAS ggml::ggml)
179
- endif()
180
-
181
- if (NOT TARGET ggml AND NOT LLAMA_USE_SYSTEM_GGML)
182
- set(GGML_BUILD_NUMBER ${LLAMA_BUILD_NUMBER})
183
- set(GGML_BUILD_COMMIT ${LLAMA_BUILD_COMMIT})
184
- add_subdirectory(ggml)
185
- # ... otherwise assume ggml is added by a parent CMakeLists.txt
186
- endif()
187
-
188
- #
189
- # build the library
190
- #
191
-
192
- add_subdirectory(src)
193
-
194
- #
195
- # utils, programs, examples and tests
196
- #
197
-
198
- if (LLAMA_BUILD_COMMON)
199
- add_subdirectory(common)
200
- add_subdirectory(vendor/cpp-httplib)
201
- endif()
202
-
203
- if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
204
- include(CTest)
205
- add_subdirectory(tests)
206
- endif()
207
-
208
- if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_EXAMPLES)
209
- add_subdirectory(examples)
210
- add_subdirectory(pocs)
211
- endif()
212
-
213
- if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_TOOLS)
214
- add_subdirectory(tools)
215
- endif()
216
-
217
- # Automatically add all files from the 'licenses' directory
218
- file(GLOB EXTRA_LICENSES "${CMAKE_SOURCE_DIR}/licenses/LICENSE-*")
219
-
220
- foreach(FILE_PATH ${EXTRA_LICENSES})
221
- get_filename_component(FILE_NAME "${FILE_PATH}" NAME)
222
- string(REGEX REPLACE "^LICENSE-" "" NAME "${FILE_NAME}")
223
- license_add_file("${NAME}" "${FILE_PATH}")
224
- endforeach()
225
-
226
- if (LLAMA_BUILD_COMMON)
227
- license_generate(common)
228
- endif()
229
-
230
- #
231
- # install
232
- #
233
-
234
- include(GNUInstallDirs)
235
- include(CMakePackageConfigHelpers)
236
-
237
- set(LLAMA_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of header files")
238
- set(LLAMA_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
239
- set(LLAMA_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
240
-
241
- set(LLAMA_PUBLIC_HEADERS
242
- ${CMAKE_CURRENT_SOURCE_DIR}/include/llama.h
243
- ${CMAKE_CURRENT_SOURCE_DIR}/include/llama-cpp.h)
244
-
245
- set_target_properties(llama
246
- PROPERTIES
247
- PUBLIC_HEADER "${LLAMA_PUBLIC_HEADERS}")
248
-
249
- install(TARGETS llama LIBRARY PUBLIC_HEADER)
250
-
251
- configure_package_config_file(
252
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake/llama-config.cmake.in
253
- ${CMAKE_CURRENT_BINARY_DIR}/llama-config.cmake
254
- INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llama
255
- PATH_VARS LLAMA_INCLUDE_INSTALL_DIR
256
- LLAMA_LIB_INSTALL_DIR
257
- LLAMA_BIN_INSTALL_DIR )
258
-
259
- write_basic_package_version_file(
260
- ${CMAKE_CURRENT_BINARY_DIR}/llama-version.cmake
261
- VERSION ${LLAMA_INSTALL_VERSION}
262
- COMPATIBILITY SameMajorVersion)
263
-
264
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/llama-config.cmake
265
- ${CMAKE_CURRENT_BINARY_DIR}/llama-version.cmake
266
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llama)
267
-
268
- install(
269
- FILES convert_hf_to_gguf.py
270
- PERMISSIONS
271
- OWNER_READ
272
- OWNER_WRITE
273
- OWNER_EXECUTE
274
- GROUP_READ
275
- GROUP_EXECUTE
276
- WORLD_READ
277
- WORLD_EXECUTE
278
- DESTINATION ${CMAKE_INSTALL_BINDIR})
279
-
280
- configure_file(cmake/llama.pc.in
281
- "${CMAKE_CURRENT_BINARY_DIR}/llama.pc"
282
- @ONLY)
283
-
284
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/llama.pc"
285
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b95c7f2913f9922bd66c710bef5ac38c6ab9ae691b931081f16af66bb95876a2
3
+ size 9319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CODEOWNERS CHANGED
@@ -1,5 +1,21 @@
1
  # collaborators can optionally add themselves here to indicate their availability for reviewing related PRs
2
- # multiplie collaborators per item can be specified
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  /.devops/*.Dockerfile @ngxson
5
  /.github/actions/ @ggml-org/ci
@@ -7,9 +23,11 @@
7
  /ci/ @ggerganov
8
  /cmake/ @ggerganov
9
  /common/ @ggml-org/llama-common
 
10
  /common/jinja/ @CISC
11
  /common/ngram-map.* @srogmann
12
  /convert_*.py @CISC
 
13
  /examples/batched.swift/ @ggerganov
14
  /examples/batched/ @ggerganov
15
  /examples/convert-llama2c-to-ggml/ @ggerganov
@@ -65,6 +83,7 @@
65
  /scripts/gen* @ggerganov
66
  /scripts/get* @ggerganov
67
  /scripts/sync* @ggerganov
 
68
  /src/ @ggerganov
69
  /src/llama-adapter.* @CISC
70
  /src/llama-arch.* @CISC
 
1
  # collaborators can optionally add themselves here to indicate their availability for reviewing related PRs
2
+ # multiple collaborators per item can be specified
3
+ #
4
+ # ggml-org/ci : CISC, danbev, ggerganov, netrunnereve, ngxson, taronaeo
5
+ # ggml-org/ggml-cann : hipudding
6
+ # ggml-org/ggml-cuda : JohannesGaessler, am17an, IMbackK, ORippler
7
+ # ggml-org/ggml-hexagon : lhez, max-krasnyansky
8
+ # ggml-org/ggml-metal : ggerganov
9
+ # ggml-org/ggml-opencl : lhez, max-krasnyansky
10
+ # ggml-org/ggml-rpc : rgerganov
11
+ # ggml-org/ggml-sycl : arthw
12
+ # ggml-org/ggml-vulkan : 0cc4m, jeffbolznv
13
+ # ggml-org/ggml-webgpu : reeselevine
14
+ # ggml-org/ggml-zdnn : taronaeo
15
+ # ggml-org/llama-common : ggerganov, aldehir, angt, danbev, ngxson, pwilkin
16
+ # ggml-org/llama-mtmd : ngxson
17
+ # ggml-org/llama-server : ggerganov, ngxson, allozaur, angt, ServeurpersoCom
18
+ # ggml-org/llama-webui : allozaur
19
 
20
  /.devops/*.Dockerfile @ngxson
21
  /.github/actions/ @ggml-org/ci
 
23
  /ci/ @ggerganov
24
  /cmake/ @ggerganov
25
  /common/ @ggml-org/llama-common
26
+ /common/fit.* @JohannesGaessler
27
  /common/jinja/ @CISC
28
  /common/ngram-map.* @srogmann
29
  /convert_*.py @CISC
30
+ /docs/backend/snapdragon/ @ggml-org/ggml-hexagon
31
  /examples/batched.swift/ @ggerganov
32
  /examples/batched/ @ggerganov
33
  /examples/convert-llama2c-to-ggml/ @ggerganov
 
83
  /scripts/gen* @ggerganov
84
  /scripts/get* @ggerganov
85
  /scripts/sync* @ggerganov
86
+ /scripts/snapdragon/ @ggml-org/ggml-hexagon
87
  /src/ @ggerganov
88
  /src/llama-adapter.* @CISC
89
  /src/llama-arch.* @CISC
CONTRIBUTING.md CHANGED
@@ -1,191 +1,3 @@
1
- # Contributors
2
-
3
- The project differentiates between 3 levels of contributors:
4
-
5
- - Contributors: people who have contributed before (no special privileges)
6
- - Collaborators (Triage): people with significant contributions, who may be responsible for some parts of the code, and are expected to maintain and review contributions for the code they own
7
- - Maintainers: responsible for reviewing and merging PRs, after approval from the code owners
8
-
9
- # AI Usage Policy
10
-
11
- > [!IMPORTANT]
12
- > This project does **not** accept pull requests that are fully or predominantly AI-generated. AI tools may be utilized solely in an assistive capacity.
13
- >
14
- > Detailed information regarding permissible and restricted uses of AI can be found in the [AGENTS.md](AGENTS.md) file.
15
-
16
- Code that is initially generated by AI and subsequently edited will still be considered AI-generated. AI assistance is permissible only when the majority of the code is authored by a human contributor, with AI employed exclusively for corrections or to expand on verbose modifications that the contributor has already conceptualized (e.g., generating repeated lines with minor variations).
17
-
18
- If AI is used to generate any portion of the code, contributors must adhere to the following requirements:
19
-
20
- 1. Explicitly disclose the manner in which AI was employed.
21
- 2. Perform a comprehensive manual review prior to submitting the pull request.
22
- 3. Be prepared to explain every line of code they submitted when asked about it by a maintainer.
23
- 4. It is strictly prohibited to use AI to write your posts for you (bug reports, feature requests, pull request descriptions, Github discussions, responding to humans, ...).
24
-
25
- For more info, please refer to the [AGENTS.md](AGENTS.md) file.
26
-
27
- # Pull requests (for contributors & collaborators)
28
-
29
- Before submitting your PR:
30
- - Search for existing PRs to prevent duplicating efforts
31
- - llama.cpp uses the ggml tensor library for model evaluation. If you are unfamiliar with ggml, consider taking a look at the [examples in the ggml repository](https://github.com/ggml-org/ggml/tree/master/examples/). [simple](https://github.com/ggml-org/ggml/tree/master/examples/simple) shows the bare minimum for using ggml. [gpt-2](https://github.com/ggml-org/ggml/tree/master/examples/gpt-2) has minimal implementations for language model inference using GPT-2. [mnist](https://github.com/ggml-org/ggml/tree/master/examples/mnist) demonstrates how to train and evaluate a simple image classifier
32
- - Test your changes:
33
- - Execute [the full CI locally on your machine](ci/README.md) before publishing
34
- - Verify that the perplexity and the performance are not affected negatively by your changes (use `llama-perplexity` and `llama-bench`)
35
- - If you modified the `ggml` source, run the `test-backend-ops` tool to check whether different backend implementations of the `ggml` operators produce consistent results (this requires access to at least two different `ggml` backends)
36
- - If you modified a `ggml` operator or added a new one, add the corresponding test cases to `test-backend-ops`
37
- - Create separate PRs for each feature or fix:
38
- - Avoid combining unrelated changes in a single PR
39
- - For intricate features, consider opening a feature request first to discuss and align expectations
40
- - When adding support for a new model or feature, focus on **CPU support only** in the initial PR unless you have a good reason not to. Add support for other backends like CUDA in follow-up PRs
41
- - In particular, adding new data types (extension of the `ggml_type` enum) carries with it a disproportionate maintenance burden. As such, to add a new quantization type you will need to meet the following *additional* criteria *at minimum*:
42
- - convert a small model to GGUF using the new type and upload it to HuggingFace
43
- - provide [perplexity](https://github.com/ggml-org/llama.cpp/tree/master/tools/perplexity) comparisons to FP16/BF16 (whichever is the native precision) as well as to types of similar size
44
- - provide KL divergence data calculated vs. the FP16/BF16 (whichever is the native precision) version for both the new type as well as types of similar size
45
- - provide [performance data](https://github.com/ggml-org/llama.cpp/tree/master/tools/llama-bench) for the new type in comparison to types of similar size on pure CPU
46
- - Consider allowing write access to your branch for faster reviews, as reviewers can push commits directly
47
- - If you are a new contributor, limit your open PRs to 1.
48
-
49
- After submitting your PR:
50
- - Expect requests for modifications to ensure the code meets llama.cpp's standards for quality and long-term maintainability
51
- - Maintainers will rely on your insights and approval when making a final decision to approve and merge a PR
52
- - If your PR becomes stale, rebase it on top of latest `master` to get maintainers attention
53
- - Consider adding yourself to [CODEOWNERS](CODEOWNERS) to indicate your availability for fixing related issues and reviewing related PRs
54
-
55
- # Pull requests (for maintainers)
56
-
57
- - Squash-merge PRs
58
- - Use the following format for the squashed commit title: `<module> : <commit title> (#<issue_number>)`. For example: `utils : fix typo in utils.py (#1234)`
59
- - Optionally pick a `<module>` from here: https://github.com/ggml-org/llama.cpp/wiki/Modules
60
- - Let other maintainers merge their own PRs
61
- - When merging a PR, make sure you have a good understanding of the changes
62
- - Be mindful of maintenance: most of the work going into a feature happens after the PR is merged. If the PR author is not committed to contribute long-term, someone else needs to take responsibility (you)
63
-
64
- Maintainers reserve the right to decline review or close pull requests for any reason, particularly under any of the following conditions:
65
- - The proposed change is already mentioned in the roadmap or an existing issue, and it has been assigned to someone.
66
- - The pull request duplicates an existing one.
67
- - The contributor fails to adhere to this contributing guide.
68
-
69
- # Coding guidelines
70
-
71
- - Avoid adding third-party dependencies, extra files, extra headers, etc.
72
- - Always consider cross-compatibility with other operating systems and architectures
73
- - Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple
74
- - Vertical alignment makes things more readable and easier to batch edit
75
- - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a`
76
- - Use sized integer types such as `int32_t` in the public API, e.g. `size_t` may also be appropriate for allocation sizes or byte offsets
77
- - Declare structs with `struct foo {}` instead of `typedef struct foo {} foo`
78
- - In C++ code omit optional `struct` and `enum` keyword whenever they are not necessary
79
- ```cpp
80
- // OK
81
- llama_context * ctx;
82
- const llama_rope_type rope_type;
83
-
84
- // not OK
85
- struct llama_context * ctx;
86
- const enum llama_rope_type rope_type;
87
- ```
88
-
89
- _(NOTE: this guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline.)_
90
-
91
- - Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` (from clang-tools v15+) to format the added code
92
- - For anything not covered in the current guidelines, refer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
93
- - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices
94
- - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggml-org/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$
95
-
96
- ![matmul](media/matmul.png)
97
-
98
- # Naming guidelines
99
-
100
- - Use `snake_case` for function, variable and type names
101
- - Naming usually optimizes for longest common prefix (see https://github.com/ggml-org/ggml/pull/302#discussion_r1243240963)
102
-
103
- ```cpp
104
- // not OK
105
- int small_number;
106
- int big_number;
107
-
108
- // OK
109
- int number_small;
110
- int number_big;
111
- ```
112
-
113
- - Enum values are always in upper case and prefixed with the enum name
114
-
115
- ```cpp
116
- enum llama_vocab_type {
117
- LLAMA_VOCAB_TYPE_NONE = 0,
118
- LLAMA_VOCAB_TYPE_SPM = 1,
119
- LLAMA_VOCAB_TYPE_BPE = 2,
120
- LLAMA_VOCAB_TYPE_WPM = 3,
121
- LLAMA_VOCAB_TYPE_UGM = 4,
122
- LLAMA_VOCAB_TYPE_RWKV = 5,
123
- };
124
- ```
125
-
126
- - The general naming pattern is `<class>_<method>`, with `<method>` being `<action>_<noun>`
127
-
128
- ```cpp
129
- llama_model_init(); // class: "llama_model", method: "init"
130
- llama_sampler_chain_remove(); // class: "llama_sampler_chain", method: "remove"
131
- llama_sampler_get_seed(); // class: "llama_sampler", method: "get_seed"
132
- llama_set_embeddings(); // class: "llama_context", method: "set_embeddings"
133
- llama_n_threads(); // class: "llama_context", method: "n_threads"
134
- llama_adapter_lora_free(); // class: "llama_adapter_lora", method: "free"
135
- ```
136
-
137
- - The `get` `<action>` can be omitted
138
- - The `<noun>` can be omitted if not necessary
139
- - The `_context` suffix of the `<class>` is optional. Use it to disambiguate symbols when needed
140
- - Use `init`/`free` for constructor/destructor `<action>`
141
-
142
- - Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else
143
-
144
- ```cpp
145
- typedef struct llama_context * llama_context_t;
146
-
147
- enum llama_pooling_type llama_pooling_type(const llama_context_t ctx);
148
- ```
149
-
150
- _(NOTE: this guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline)_
151
-
152
- - C/C++ filenames are all lowercase with dashes. Headers use the `.h` extension. Source files use the `.c` or `.cpp` extension
153
- - Python filenames are all lowercase with underscores
154
-
155
- - _(TODO: abbreviations usage)_
156
-
157
- # Preprocessor directives
158
-
159
- - _(TODO: add guidelines with examples and apply them to the codebase)_
160
-
161
- ```cpp
162
- #ifdef FOO
163
- #endif // FOO
164
- ```
165
-
166
- # Code maintenance
167
-
168
- - Existing code should have designated collaborators and/or maintainers specified in the [CODEOWNERS](CODEOWNERS) file responsible for:
169
- - Reviewing and merging related PRs
170
- - Fixing related bugs
171
- - Providing developer guidance/support
172
-
173
- - When adding or modifying a large piece of code:
174
- - If you are a collaborator, make sure to add yourself to [CODEOWNERS](CODEOWNERS) to indicate your availability for reviewing related PRs
175
- - If you are a contributor, find an existing collaborator who is willing to review and maintain your code long-term
176
- - Provide the necessary CI workflow (and hardware) to test your changes (see [ci/README.md](https://github.com/ggml-org/llama.cpp/tree/master/ci))
177
-
178
- - New code should follow the guidelines (coding, naming, etc.) outlined in this document. Exceptions are allowed in isolated, backend-specific parts of the code that do not interface directly with the `ggml` interfaces.
179
- _(NOTE: for legacy reasons, existing code is not required to follow this guideline)_
180
-
181
- # Documentation
182
-
183
- - Documentation is a community effort
184
- - When you need to look into the source code to figure out how to use an API consider adding a short summary to the header file for future reference
185
- - When you notice incorrect or outdated documentation, please update it
186
-
187
- # Resources
188
-
189
- The Github issues, PRs and discussions contain a lot of information that can be useful to get familiar with the codebase. For convenience, some of the more important information is referenced from Github projects:
190
-
191
- https://github.com/ggml-org/llama.cpp/projects
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c17c06838de4d7ce61679cc76d7ca112c55996b8a85eee001d9ea1b7e2a73d7a
3
+ size 12093
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,595 +1,3 @@
1
- # llama.cpp
2
-
3
- ![llama](https://user-images.githubusercontent.com/1991296/230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524.png)
4
-
5
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
- [![Release](https://img.shields.io/github/v/release/ggml-org/llama.cpp)](https://github.com/ggml-org/llama.cpp/releases)
7
- [![Server](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml/badge.svg)](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml)
8
-
9
- [Manifesto](https://github.com/ggml-org/llama.cpp/discussions/205) / [ggml](https://github.com/ggml-org/ggml) / [ops](https://github.com/ggml-org/llama.cpp/blob/master/docs/ops.md)
10
-
11
- LLM inference in C/C++
12
-
13
- ## Recent API changes
14
-
15
- - [Changelog for `libllama` API](https://github.com/ggml-org/llama.cpp/issues/9289)
16
- - [Changelog for `llama-server` REST API](https://github.com/ggml-org/llama.cpp/issues/9291)
17
-
18
- ## Hot topics
19
-
20
- - **[guide : using the new WebUI of llama.cpp](https://github.com/ggml-org/llama.cpp/discussions/16938)**
21
- - [guide : running gpt-oss with llama.cpp](https://github.com/ggml-org/llama.cpp/discussions/15396)
22
- - [[FEEDBACK] Better packaging for llama.cpp to support downstream consumers 🤗](https://github.com/ggml-org/llama.cpp/discussions/15313)
23
- - Support for the `gpt-oss` model with native MXFP4 format has been added | [PR](https://github.com/ggml-org/llama.cpp/pull/15091) | [Collaboration with NVIDIA](https://blogs.nvidia.com/blog/rtx-ai-garage-openai-oss) | [Comment](https://github.com/ggml-org/llama.cpp/discussions/15095)
24
- - Multimodal support arrived in `llama-server`: [#12898](https://github.com/ggml-org/llama.cpp/pull/12898) | [documentation](./docs/multimodal.md)
25
- - VS Code extension for FIM completions: https://github.com/ggml-org/llama.vscode
26
- - Vim/Neovim plugin for FIM completions: https://github.com/ggml-org/llama.vim
27
- - Hugging Face Inference Endpoints now support GGUF out of the box! https://github.com/ggml-org/llama.cpp/discussions/9669
28
- - Hugging Face GGUF editor: [discussion](https://github.com/ggml-org/llama.cpp/discussions/9268) | [tool](https://huggingface.co/spaces/CISCai/gguf-editor)
29
-
30
- ----
31
-
32
- ## Quick start
33
-
34
- Getting started with llama.cpp is straightforward. Here are several ways to install it on your machine:
35
-
36
- - Install `llama.cpp` using [brew, nix or winget](docs/install.md)
37
- - Run with Docker - see our [Docker documentation](docs/docker.md)
38
- - Download pre-built binaries from the [releases page](https://github.com/ggml-org/llama.cpp/releases)
39
- - Build from source by cloning this repository - check out [our build guide](docs/build.md)
40
-
41
- Once installed, you'll need a model to work with. Head to the [Obtaining and quantizing models](#obtaining-and-quantizing-models) section to learn more.
42
-
43
- Example command:
44
-
45
- ```sh
46
- # Use a local model file
47
- llama-cli -m my_model.gguf
48
-
49
- # Or download and run a model directly from Hugging Face
50
- llama-cli -hf ggml-org/gemma-3-1b-it-GGUF
51
-
52
- # Launch OpenAI-compatible API server
53
- llama-server -hf ggml-org/gemma-3-1b-it-GGUF
54
- ```
55
-
56
- ## Description
57
-
58
- The main goal of `llama.cpp` is to enable LLM inference with minimal setup and state-of-the-art performance on a wide
59
- range of hardware - locally and in the cloud.
60
-
61
- - Plain C/C++ implementation without any dependencies
62
- - Apple silicon is a first-class citizen - optimized via ARM NEON, Accelerate and Metal frameworks
63
- - AVX, AVX2, AVX512 and AMX support for x86 architectures
64
- - RVV, ZVFH, ZFH, ZICBOP and ZIHINTPAUSE support for RISC-V architectures
65
- - 1.5-bit, 2-bit, 3-bit, 4-bit, 5-bit, 6-bit, and 8-bit integer quantization for faster inference and reduced memory use
66
- - Custom CUDA kernels for running LLMs on NVIDIA GPUs (support for AMD GPUs via HIP and Moore Threads GPUs via MUSA)
67
- - Vulkan and SYCL backend support
68
- - CPU+GPU hybrid inference to partially accelerate models larger than the total VRAM capacity
69
-
70
- The `llama.cpp` project is the main playground for developing new features for the [ggml](https://github.com/ggml-org/ggml) library.
71
-
72
- <details>
73
- <summary>Models</summary>
74
-
75
- Typically finetunes of the base models below are supported as well.
76
-
77
- Instructions for adding support for new models: [HOWTO-add-model.md](docs/development/HOWTO-add-model.md)
78
-
79
- #### Text-only
80
-
81
- - [X] LLaMA 🦙
82
- - [x] LLaMA 2 🦙🦙
83
- - [x] LLaMA 3 🦙🦙🦙
84
- - [X] [Mistral 7B](https://huggingface.co/mistralai/Mistral-7B-v0.1)
85
- - [x] [Mixtral MoE](https://huggingface.co/models?search=mistral-ai/Mixtral)
86
- - [x] [DBRX](https://huggingface.co/databricks/dbrx-instruct)
87
- - [x] [Jamba](https://huggingface.co/ai21labs)
88
- - [X] [Falcon](https://huggingface.co/models?search=tiiuae/falcon)
89
- - [X] [Chinese LLaMA / Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca) and [Chinese LLaMA-2 / Alpaca-2](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2)
90
- - [X] [Vigogne (French)](https://github.com/bofenghuang/vigogne)
91
- - [X] [BERT](https://github.com/ggml-org/llama.cpp/pull/5423)
92
- - [X] [Koala](https://bair.berkeley.edu/blog/2023/04/03/koala/)
93
- - [X] [Baichuan 1 & 2](https://huggingface.co/models?search=baichuan-inc/Baichuan) + [derivations](https://huggingface.co/hiyouga/baichuan-7b-sft)
94
- - [X] [Aquila 1 & 2](https://huggingface.co/models?search=BAAI/Aquila)
95
- - [X] [Starcoder models](https://github.com/ggml-org/llama.cpp/pull/3187)
96
- - [X] [Refact](https://huggingface.co/smallcloudai/Refact-1_6B-fim)
97
- - [X] [MPT](https://github.com/ggml-org/llama.cpp/pull/3417)
98
- - [X] [Bloom](https://github.com/ggml-org/llama.cpp/pull/3553)
99
- - [x] [Yi models](https://huggingface.co/models?search=01-ai/Yi)
100
- - [X] [StableLM models](https://huggingface.co/stabilityai)
101
- - [x] [Deepseek models](https://huggingface.co/models?search=deepseek-ai/deepseek)
102
- - [x] [Qwen models](https://huggingface.co/models?search=Qwen/Qwen)
103
- - [x] [PLaMo-13B](https://github.com/ggml-org/llama.cpp/pull/3557)
104
- - [x] [Phi models](https://huggingface.co/models?search=microsoft/phi)
105
- - [x] [PhiMoE](https://github.com/ggml-org/llama.cpp/pull/11003)
106
- - [x] [GPT-2](https://huggingface.co/gpt2)
107
- - [x] [Orion 14B](https://github.com/ggml-org/llama.cpp/pull/5118)
108
- - [x] [InternLM2](https://huggingface.co/models?search=internlm2)
109
- - [x] [CodeShell](https://github.com/WisdomShell/codeshell)
110
- - [x] [Gemma](https://ai.google.dev/gemma)
111
- - [x] [Mamba](https://github.com/state-spaces/mamba)
112
- - [x] [Grok-1](https://huggingface.co/keyfan/grok-1-hf)
113
- - [x] [Xverse](https://huggingface.co/models?search=xverse)
114
- - [x] [Command-R models](https://huggingface.co/models?search=CohereForAI/c4ai-command-r)
115
- - [x] [SEA-LION](https://huggingface.co/models?search=sea-lion)
116
- - [x] [GritLM-7B](https://huggingface.co/GritLM/GritLM-7B) + [GritLM-8x7B](https://huggingface.co/GritLM/GritLM-8x7B)
117
- - [x] [OLMo](https://allenai.org/olmo)
118
- - [x] [OLMo 2](https://allenai.org/olmo)
119
- - [x] [OLMoE](https://huggingface.co/allenai/OLMoE-1B-7B-0924)
120
- - [x] [Granite models](https://huggingface.co/collections/ibm-granite/granite-code-models-6624c5cec322e4c148c8b330)
121
- - [x] [GPT-NeoX](https://github.com/EleutherAI/gpt-neox) + [Pythia](https://github.com/EleutherAI/pythia)
122
- - [x] [Snowflake-Arctic MoE](https://huggingface.co/collections/Snowflake/arctic-66290090abe542894a5ac520)
123
- - [x] [Smaug](https://huggingface.co/models?search=Smaug)
124
- - [x] [Poro 34B](https://huggingface.co/LumiOpen/Poro-34B)
125
- - [x] [Bitnet b1.58 models](https://huggingface.co/1bitLLM)
126
- - [x] [Flan T5](https://huggingface.co/models?search=flan-t5)
127
- - [x] [Open Elm models](https://huggingface.co/collections/apple/openelm-instruct-models-6619ad295d7ae9f868b759ca)
128
- - [x] [ChatGLM3-6b](https://huggingface.co/THUDM/chatglm3-6b) + [ChatGLM4-9b](https://huggingface.co/THUDM/glm-4-9b) + [GLMEdge-1.5b](https://huggingface.co/THUDM/glm-edge-1.5b-chat) + [GLMEdge-4b](https://huggingface.co/THUDM/glm-edge-4b-chat)
129
- - [x] [GLM-4-0414](https://huggingface.co/collections/THUDM/glm-4-0414-67f3cbcb34dd9d252707cb2e)
130
- - [x] [SmolLM](https://huggingface.co/collections/HuggingFaceTB/smollm-6695016cad7167254ce15966)
131
- - [x] [EXAONE-3.0-7.8B-Instruct](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct)
132
- - [x] [FalconMamba Models](https://huggingface.co/collections/tiiuae/falconmamba-7b-66b9a580324dd1598b0f6d4a)
133
- - [x] [Jais](https://huggingface.co/inceptionai/jais-13b-chat)
134
- - [x] [Bielik-11B-v2.3](https://huggingface.co/collections/speakleash/bielik-11b-v23-66ee813238d9b526a072408a)
135
- - [x] [RWKV-7](https://huggingface.co/collections/shoumenchougou/rwkv7-gxx-gguf)
136
- - [x] [RWKV-6](https://github.com/BlinkDL/RWKV-LM)
137
- - [x] [QRWKV-6](https://huggingface.co/recursal/QRWKV6-32B-Instruct-Preview-v0.1)
138
- - [x] [GigaChat-20B-A3B](https://huggingface.co/ai-sage/GigaChat-20B-A3B-instruct)
139
- - [X] [Trillion-7B-preview](https://huggingface.co/trillionlabs/Trillion-7B-preview)
140
- - [x] [Ling models](https://huggingface.co/collections/inclusionAI/ling-67c51c85b34a7ea0aba94c32)
141
- - [x] [LFM2 models](https://huggingface.co/collections/LiquidAI/lfm2-686d721927015b2ad73eaa38)
142
- - [x] [Hunyuan models](https://huggingface.co/collections/tencent/hunyuan-dense-model-6890632cda26b19119c9c5e7)
143
- - [x] [BailingMoeV2 (Ring/Ling 2.0) models](https://huggingface.co/collections/inclusionAI/ling-v2-68bf1dd2fc34c306c1fa6f86)
144
-
145
- #### Multimodal
146
-
147
- - [x] [LLaVA 1.5 models](https://huggingface.co/collections/liuhaotian/llava-15-653aac15d994e992e2677a7e), [LLaVA 1.6 models](https://huggingface.co/collections/liuhaotian/llava-16-65b9e40155f60fd046a5ccf2)
148
- - [x] [BakLLaVA](https://huggingface.co/models?search=SkunkworksAI/Bakllava)
149
- - [x] [Obsidian](https://huggingface.co/NousResearch/Obsidian-3B-V0.5)
150
- - [x] [ShareGPT4V](https://huggingface.co/models?search=Lin-Chen/ShareGPT4V)
151
- - [x] [MobileVLM 1.7B/3B models](https://huggingface.co/models?search=mobileVLM)
152
- - [x] [Yi-VL](https://huggingface.co/models?search=Yi-VL)
153
- - [x] [Mini CPM](https://huggingface.co/models?search=MiniCPM)
154
- - [x] [Moondream](https://huggingface.co/vikhyatk/moondream2)
155
- - [x] [Bunny](https://github.com/BAAI-DCAI/Bunny)
156
- - [x] [GLM-EDGE](https://huggingface.co/models?search=glm-edge)
157
- - [x] [Qwen2-VL](https://huggingface.co/collections/Qwen/qwen2-vl-66cee7455501d7126940800d)
158
- - [x] [LFM2-VL](https://huggingface.co/collections/LiquidAI/lfm2-vl-68963bbc84a610f7638d5ffa)
159
-
160
- </details>
161
-
162
- <details>
163
- <summary>Bindings</summary>
164
-
165
- - Python: [ddh0/easy-llama](https://github.com/ddh0/easy-llama)
166
- - Python: [abetlen/llama-cpp-python](https://github.com/abetlen/llama-cpp-python)
167
- - Go: [go-skynet/go-llama.cpp](https://github.com/go-skynet/go-llama.cpp)
168
- - Node.js: [withcatai/node-llama-cpp](https://github.com/withcatai/node-llama-cpp)
169
- - JS/TS (llama.cpp server client): [lgrammel/modelfusion](https://modelfusion.dev/integration/model-provider/llamacpp)
170
- - JS/TS (Programmable Prompt Engine CLI): [offline-ai/cli](https://github.com/offline-ai/cli)
171
- - JavaScript/Wasm (works in browser): [tangledgroup/llama-cpp-wasm](https://github.com/tangledgroup/llama-cpp-wasm)
172
- - Typescript/Wasm (nicer API, available on npm): [ngxson/wllama](https://github.com/ngxson/wllama)
173
- - Ruby: [yoshoku/llama_cpp.rb](https://github.com/yoshoku/llama_cpp.rb)
174
- - Rust (more features): [edgenai/llama_cpp-rs](https://github.com/edgenai/llama_cpp-rs)
175
- - Rust (nicer API): [mdrokz/rust-llama.cpp](https://github.com/mdrokz/rust-llama.cpp)
176
- - Rust (more direct bindings): [utilityai/llama-cpp-rs](https://github.com/utilityai/llama-cpp-rs)
177
- - Rust (automated build from crates.io): [ShelbyJenkins/llm_client](https://github.com/ShelbyJenkins/llm_client)
178
- - C#/.NET: [SciSharp/LLamaSharp](https://github.com/SciSharp/LLamaSharp)
179
- - C#/VB.NET (more features - community license): [LM-Kit.NET](https://docs.lm-kit.com/lm-kit-net/index.html)
180
- - Scala 3: [donderom/llm4s](https://github.com/donderom/llm4s)
181
- - Clojure: [phronmophobic/llama.clj](https://github.com/phronmophobic/llama.clj)
182
- - React Native: [mybigday/llama.rn](https://github.com/mybigday/llama.rn)
183
- - Java: [kherud/java-llama.cpp](https://github.com/kherud/java-llama.cpp)
184
- - Java: [QuasarByte/llama-cpp-jna](https://github.com/QuasarByte/llama-cpp-jna)
185
- - Zig: [deins/llama.cpp.zig](https://github.com/Deins/llama.cpp.zig)
186
- - Flutter/Dart: [netdur/llama_cpp_dart](https://github.com/netdur/llama_cpp_dart)
187
- - Flutter: [xuegao-tzx/Fllama](https://github.com/xuegao-tzx/Fllama)
188
- - PHP (API bindings and features built on top of llama.cpp): [distantmagic/resonance](https://github.com/distantmagic/resonance) [(more info)](https://github.com/ggml-org/llama.cpp/pull/6326)
189
- - Guile Scheme: [guile_llama_cpp](https://savannah.nongnu.org/projects/guile-llama-cpp)
190
- - Swift [srgtuszy/llama-cpp-swift](https://github.com/srgtuszy/llama-cpp-swift)
191
- - Swift [ShenghaiWang/SwiftLlama](https://github.com/ShenghaiWang/SwiftLlama)
192
- - Delphi [Embarcadero/llama-cpp-delphi](https://github.com/Embarcadero/llama-cpp-delphi)
193
- - Go (no CGo needed): [hybridgroup/yzma](https://github.com/hybridgroup/yzma)
194
- - Android: [llama.android](/examples/llama.android)
195
-
196
- </details>
197
-
198
- <details>
199
- <summary>UIs</summary>
200
-
201
- *(to have a project listed here, it should clearly state that it depends on `llama.cpp`)*
202
-
203
- - [AI Sublime Text plugin](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) (MIT)
204
- - [BonzAI App](https://apps.apple.com/us/app/bonzai-your-local-ai-agent/id6752847988) (proprietary)
205
- - [cztomsik/ava](https://github.com/cztomsik/ava) (MIT)
206
- - [Dot](https://github.com/alexpinel/Dot) (GPL)
207
- - [eva](https://github.com/ylsdamxssjxxdd/eva) (MIT)
208
- - [iohub/collama](https://github.com/iohub/coLLaMA) (Apache-2.0)
209
- - [janhq/jan](https://github.com/janhq/jan) (AGPL)
210
- - [johnbean393/Sidekick](https://github.com/johnbean393/Sidekick) (MIT)
211
- - [KanTV](https://github.com/zhouwg/kantv?tab=readme-ov-file) (Apache-2.0)
212
- - [KodiBot](https://github.com/firatkiral/kodibot) (GPL)
213
- - [llama.vim](https://github.com/ggml-org/llama.vim) (MIT)
214
- - [LARS](https://github.com/abgulati/LARS) (AGPL)
215
- - [Llama Assistant](https://github.com/vietanhdev/llama-assistant) (GPL)
216
- - [LlamaLib](https://github.com/undreamai/LlamaLib) (Apache-2.0)
217
- - [LLMFarm](https://github.com/guinmoon/LLMFarm?tab=readme-ov-file) (MIT)
218
- - [LLMUnity](https://github.com/undreamai/LLMUnity) (MIT)
219
- - [LMStudio](https://lmstudio.ai/) (proprietary)
220
- - [LocalAI](https://github.com/mudler/LocalAI) (MIT)
221
- - [LostRuins/koboldcpp](https://github.com/LostRuins/koboldcpp) (AGPL)
222
- - [MindMac](https://mindmac.app) (proprietary)
223
- - [MindWorkAI/AI-Studio](https://github.com/MindWorkAI/AI-Studio) (FSL-1.1-MIT)
224
- - [Mobile-Artificial-Intelligence/maid](https://github.com/Mobile-Artificial-Intelligence/maid) (MIT)
225
- - [Mozilla-Ocho/llamafile](https://github.com/Mozilla-Ocho/llamafile) (Apache-2.0)
226
- - [nat/openplayground](https://github.com/nat/openplayground) (MIT)
227
- - [nomic-ai/gpt4all](https://github.com/nomic-ai/gpt4all) (MIT)
228
- - [ollama/ollama](https://github.com/ollama/ollama) (MIT)
229
- - [oobabooga/text-generation-webui](https://github.com/oobabooga/text-generation-webui) (AGPL)
230
- - [PocketPal AI](https://github.com/a-ghorbani/pocketpal-ai) (MIT)
231
- - [psugihara/FreeChat](https://github.com/psugihara/FreeChat) (MIT)
232
- - [ptsochantaris/emeltal](https://github.com/ptsochantaris/emeltal) (MIT)
233
- - [pythops/tenere](https://github.com/pythops/tenere) (AGPL)
234
- - [ramalama](https://github.com/containers/ramalama) (MIT)
235
- - [semperai/amica](https://github.com/semperai/amica) (MIT)
236
- - [withcatai/catai](https://github.com/withcatai/catai) (MIT)
237
- - [Autopen](https://github.com/blackhole89/autopen) (GPL)
238
-
239
- </details>
240
-
241
- <details>
242
- <summary>Tools</summary>
243
-
244
- - [akx/ggify](https://github.com/akx/ggify) – download PyTorch models from HuggingFace Hub and convert them to GGML
245
- - [akx/ollama-dl](https://github.com/akx/ollama-dl) – download models from the Ollama library to be used directly with llama.cpp
246
- - [crashr/gppm](https://github.com/crashr/gppm) – launch llama.cpp instances utilizing NVIDIA Tesla P40 or P100 GPUs with reduced idle power consumption
247
- - [gpustack/gguf-parser](https://github.com/gpustack/gguf-parser-go/tree/main/cmd/gguf-parser) - review/check the GGUF file and estimate the memory usage
248
- - [Styled Lines](https://marketplace.unity.com/packages/tools/generative-ai/styled-lines-llama-cpp-model-292902) (proprietary licensed, async wrapper of inference part for game development in Unity3d with pre-built Mobile and Web platform wrappers and a model example)
249
- - [unslothai/unsloth](https://github.com/unslothai/unsloth) – 🦥 exports/saves fine-tuned and trained models to GGUF (Apache-2.0)
250
-
251
- </details>
252
-
253
- <details>
254
- <summary>Infrastructure</summary>
255
-
256
- - [Paddler](https://github.com/intentee/paddler) - Open-source LLMOps platform for hosting and scaling AI in your own infrastructure
257
- - [GPUStack](https://github.com/gpustack/gpustack) - Manage GPU clusters for running LLMs
258
- - [llama_cpp_canister](https://github.com/onicai/llama_cpp_canister) - llama.cpp as a smart contract on the Internet Computer, using WebAssembly
259
- - [llama-swap](https://github.com/mostlygeek/llama-swap) - transparent proxy that adds automatic model switching with llama-server
260
- - [Kalavai](https://github.com/kalavai-net/kalavai-client) - Crowdsource end to end LLM deployment at any scale
261
- - [llmaz](https://github.com/InftyAI/llmaz) - ☸️ Easy, advanced inference platform for large language models on Kubernetes.
262
- - [LLMKube](https://github.com/defilantech/llmkube) - Kubernetes operator for llama.cpp with multi-GPU and Apple Silicon Metal
263
- support"
264
- </details>
265
-
266
- <details>
267
- <summary>Games</summary>
268
-
269
- - [Lucy's Labyrinth](https://github.com/MorganRO8/Lucys_Labyrinth) - A simple maze game where agents controlled by an AI model will try to trick you.
270
-
271
- </details>
272
-
273
-
274
- ## Supported backends
275
-
276
- | Backend | Target devices |
277
- | --- | --- |
278
- | [Metal](docs/build.md#metal-build) | Apple Silicon |
279
- | [BLAS](docs/build.md#blas-build) | All |
280
- | [BLIS](docs/backend/BLIS.md) | All |
281
- | [SYCL](docs/backend/SYCL.md) | Intel and Nvidia GPU |
282
- | [OpenVINO [In Progress]](docs/backend/OPENVINO.md) | Intel CPUs, GPUs, and NPUs |
283
- | [MUSA](docs/build.md#musa) | Moore Threads GPU |
284
- | [CUDA](docs/build.md#cuda) | Nvidia GPU |
285
- | [HIP](docs/build.md#hip) | AMD GPU |
286
- | [ZenDNN](docs/build.md#zendnn) | AMD CPU |
287
- | [Vulkan](docs/build.md#vulkan) | GPU |
288
- | [CANN](docs/build.md#cann) | Ascend NPU |
289
- | [OpenCL](docs/backend/OPENCL.md) | Adreno GPU |
290
- | [IBM zDNN](docs/backend/zDNN.md) | IBM Z & LinuxONE |
291
- | [WebGPU [In Progress]](docs/build.md#webgpu) | All |
292
- | [RPC](https://github.com/ggml-org/llama.cpp/tree/master/tools/rpc) | All |
293
- | [Hexagon [In Progress]](docs/backend/snapdragon/README.md) | Snapdragon |
294
- | [VirtGPU](docs/backend/VirtGPU.md) | VirtGPU APIR |
295
-
296
- ## Obtaining and quantizing models
297
-
298
- The [Hugging Face](https://huggingface.co) platform hosts a [number of LLMs](https://huggingface.co/models?library=gguf&sort=trending) compatible with `llama.cpp`:
299
-
300
- - [Trending](https://huggingface.co/models?library=gguf&sort=trending)
301
- - [LLaMA](https://huggingface.co/models?sort=trending&search=llama+gguf)
302
-
303
- You can either manually download the GGUF file or directly use any `llama.cpp`-compatible models from [Hugging Face](https://huggingface.co/) or other model hosting sites, such as [ModelScope](https://modelscope.cn/), by using this CLI argument: `-hf <user>/<model>[:quant]`. For example:
304
-
305
- ```sh
306
- llama-cli -hf ggml-org/gemma-3-1b-it-GGUF
307
- ```
308
-
309
- By default, the CLI would download from Hugging Face, you can switch to other options with the environment variable `MODEL_ENDPOINT`. For example, you may opt to downloading model checkpoints from ModelScope or other model sharing communities by setting the environment variable, e.g. `MODEL_ENDPOINT=https://www.modelscope.cn/`.
310
-
311
- After downloading a model, use the CLI tools to run it locally - see below.
312
-
313
- `llama.cpp` requires the model to be stored in the [GGUF](https://github.com/ggml-org/ggml/blob/master/docs/gguf.md) file format. Models in other data formats can be converted to GGUF using the `convert_*.py` Python scripts in this repo.
314
-
315
- The Hugging Face platform provides a variety of online tools for converting, quantizing and hosting models with `llama.cpp`:
316
-
317
- - Use the [GGUF-my-repo space](https://huggingface.co/spaces/ggml-org/gguf-my-repo) to convert to GGUF format and quantize model weights to smaller sizes
318
- - Use the [GGUF-my-LoRA space](https://huggingface.co/spaces/ggml-org/gguf-my-lora) to convert LoRA adapters to GGUF format (more info: https://github.com/ggml-org/llama.cpp/discussions/10123)
319
- - Use the [GGUF-editor space](https://huggingface.co/spaces/CISCai/gguf-editor) to edit GGUF meta data in the browser (more info: https://github.com/ggml-org/llama.cpp/discussions/9268)
320
- - Use the [Inference Endpoints](https://ui.endpoints.huggingface.co/) to directly host `llama.cpp` in the cloud (more info: https://github.com/ggml-org/llama.cpp/discussions/9669)
321
-
322
- To learn more about model quantization, [read this documentation](tools/quantize/README.md)
323
-
324
- ## [`llama-cli`](tools/cli)
325
-
326
- #### A CLI tool for accessing and experimenting with most of `llama.cpp`'s functionality.
327
-
328
- - <details open>
329
- <summary>Run in conversation mode</summary>
330
-
331
- Models with a built-in chat template will automatically activate conversation mode. If this doesn't occur, you can manually enable it by adding `-cnv` and specifying a suitable chat template with `--chat-template NAME`
332
-
333
- ```bash
334
- llama-cli -m model.gguf
335
-
336
- # > hi, who are you?
337
- # Hi there! I'm your helpful assistant! I'm an AI-powered chatbot designed to assist and provide information to users like you. I'm here to help answer your questions, provide guidance, and offer support on a wide range of topics. I'm a friendly and knowledgeable AI, and I'm always happy to help with anything you need. What's on your mind, and how can I assist you today?
338
- #
339
- # > what is 1+1?
340
- # Easy peasy! The answer to 1+1 is... 2!
341
- ```
342
-
343
- </details>
344
-
345
- - <details>
346
- <summary>Run in conversation mode with custom chat template</summary>
347
-
348
- ```bash
349
- # use the "chatml" template (use -h to see the list of supported templates)
350
- llama-cli -m model.gguf -cnv --chat-template chatml
351
-
352
- # use a custom template
353
- llama-cli -m model.gguf -cnv --in-prefix 'User: ' --reverse-prompt 'User:'
354
- ```
355
-
356
- </details>
357
-
358
- - <details>
359
- <summary>Constrain the output with a custom grammar</summary>
360
-
361
- ```bash
362
- llama-cli -m model.gguf -n 256 --grammar-file grammars/json.gbnf -p 'Request: schedule a call at 8pm; Command:'
363
-
364
- # {"appointmentTime": "8pm", "appointmentDetails": "schedule a a call"}
365
- ```
366
-
367
- The [grammars/](grammars/) folder contains a handful of sample grammars. To write your own, check out the [GBNF Guide](grammars/README.md).
368
-
369
- For authoring more complex JSON grammars, check out https://grammar.intrinsiclabs.ai/
370
-
371
- </details>
372
-
373
-
374
- ## [`llama-server`](tools/server)
375
-
376
- #### A lightweight, [OpenAI API](https://github.com/openai/openai-openapi) compatible, HTTP server for serving LLMs.
377
-
378
- - <details open>
379
- <summary>Start a local HTTP server with default configuration on port 8080</summary>
380
-
381
- ```bash
382
- llama-server -m model.gguf --port 8080
383
-
384
- # Basic web UI can be accessed via browser: http://localhost:8080
385
- # Chat completion endpoint: http://localhost:8080/v1/chat/completions
386
- ```
387
-
388
- </details>
389
-
390
- - <details>
391
- <summary>Support multiple-users and parallel decoding</summary>
392
-
393
- ```bash
394
- # up to 4 concurrent requests, each with 4096 max context
395
- llama-server -m model.gguf -c 16384 -np 4
396
- ```
397
-
398
- </details>
399
-
400
- - <details>
401
- <summary>Enable speculative decoding</summary>
402
-
403
- ```bash
404
- # the draft.gguf model should be a small variant of the target model.gguf
405
- llama-server -m model.gguf -md draft.gguf
406
- ```
407
-
408
- </details>
409
-
410
- - <details>
411
- <summary>Serve an embedding model</summary>
412
-
413
- ```bash
414
- # use the /embedding endpoint
415
- llama-server -m model.gguf --embedding --pooling cls -ub 8192
416
- ```
417
-
418
- </details>
419
-
420
- - <details>
421
- <summary>Serve a reranking model</summary>
422
-
423
- ```bash
424
- # use the /reranking endpoint
425
- llama-server -m model.gguf --reranking
426
- ```
427
-
428
- </details>
429
-
430
- - <details>
431
- <summary>Constrain all outputs with a grammar</summary>
432
-
433
- ```bash
434
- # custom grammar
435
- llama-server -m model.gguf --grammar-file grammar.gbnf
436
-
437
- # JSON
438
- llama-server -m model.gguf --grammar-file grammars/json.gbnf
439
- ```
440
-
441
- </details>
442
-
443
-
444
- ## [`llama-perplexity`](tools/perplexity)
445
-
446
- #### A tool for measuring the [perplexity](tools/perplexity/README.md) [^1] (and other quality metrics) of a model over a given text.
447
-
448
- - <details open>
449
- <summary>Measure the perplexity over a text file</summary>
450
-
451
- ```bash
452
- llama-perplexity -m model.gguf -f file.txt
453
-
454
- # [1]15.2701,[2]5.4007,[3]5.3073,[4]6.2965,[5]5.8940,[6]5.6096,[7]5.7942,[8]4.9297, ...
455
- # Final estimate: PPL = 5.4007 +/- 0.67339
456
- ```
457
-
458
- </details>
459
-
460
- - <details>
461
- <summary>Measure KL divergence</summary>
462
-
463
- ```bash
464
- # TODO
465
- ```
466
-
467
- </details>
468
-
469
- [^1]: [https://huggingface.co/docs/transformers/perplexity](https://huggingface.co/docs/transformers/perplexity)
470
-
471
- ## [`llama-bench`](tools/llama-bench)
472
-
473
- #### Benchmark the performance of the inference for various parameters.
474
-
475
- - <details open>
476
- <summary>Run default benchmark</summary>
477
-
478
- ```bash
479
- llama-bench -m model.gguf
480
-
481
- # Output:
482
- # | model | size | params | backend | threads | test | t/s |
483
- # | ------------------- | ---------: | ---------: | ---------- | ------: | ------------: | -------------------: |
484
- # | qwen2 1.5B Q4_0 | 885.97 MiB | 1.54 B | Metal,BLAS | 16 | pp512 | 5765.41 ± 20.55 |
485
- # | qwen2 1.5B Q4_0 | 885.97 MiB | 1.54 B | Metal,BLAS | 16 | tg128 | 197.71 ± 0.81 |
486
- #
487
- # build: 3e0ba0e60 (4229)
488
- ```
489
-
490
- </details>
491
-
492
- ## [`llama-simple`](examples/simple)
493
-
494
- #### A minimal example for implementing apps with `llama.cpp`. Useful for developers.
495
-
496
- - <details>
497
- <summary>Basic text completion</summary>
498
-
499
- ```bash
500
- llama-simple -m model.gguf
501
-
502
- # Hello my name is Kaitlyn and I am a 16 year old girl. I am a junior in high school and I am currently taking a class called "The Art of
503
- ```
504
-
505
- </details>
506
-
507
-
508
- ## Contributing
509
-
510
- - Contributors can open PRs
511
- - Collaborators will be invited based on contributions
512
- - Maintainers can push to branches in the `llama.cpp` repo and merge PRs into the `master` branch
513
- - Any help with managing issues, PRs and projects is very appreciated!
514
- - See [good first issues](https://github.com/ggml-org/llama.cpp/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) for tasks suitable for first contributions
515
- - Read the [CONTRIBUTING.md](CONTRIBUTING.md) for more information
516
- - Make sure to read this: [Inference at the edge](https://github.com/ggml-org/llama.cpp/discussions/205)
517
- - A bit of backstory for those who are interested: [Changelog podcast](https://changelog.com/podcast/532)
518
-
519
- ## Other documentation
520
-
521
- - [cli](tools/cli/README.md)
522
- - [completion](tools/completion/README.md)
523
- - [server](tools/server/README.md)
524
- - [GBNF grammars](grammars/README.md)
525
-
526
- #### Development documentation
527
-
528
- - [How to build](docs/build.md)
529
- - [Running on Docker](docs/docker.md)
530
- - [Build on Android](docs/android.md)
531
- - [Performance troubleshooting](docs/development/token_generation_performance_tips.md)
532
- - [GGML tips & tricks](https://github.com/ggml-org/llama.cpp/wiki/GGML-Tips-&-Tricks)
533
-
534
- #### Seminal papers and background on the models
535
-
536
- If your issue is with model generation quality, then please at least scan the following links and papers to understand the limitations of LLaMA models. This is especially important when choosing an appropriate model size and appreciating both the significant and subtle differences between LLaMA models and ChatGPT:
537
- - LLaMA:
538
- - [Introducing LLaMA: A foundational, 65-billion-parameter large language model](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/)
539
- - [LLaMA: Open and Efficient Foundation Language Models](https://arxiv.org/abs/2302.13971)
540
- - GPT-3
541
- - [Language Models are Few-Shot Learners](https://arxiv.org/abs/2005.14165)
542
- - GPT-3.5 / InstructGPT / ChatGPT:
543
- - [Aligning language models to follow instructions](https://openai.com/research/instruction-following)
544
- - [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155)
545
-
546
- ## XCFramework
547
- The XCFramework is a precompiled version of the library for iOS, visionOS, tvOS,
548
- and macOS. It can be used in Swift projects without the need to compile the
549
- library from source. For example:
550
- ```swift
551
- // swift-tools-version: 5.10
552
- // The swift-tools-version declares the minimum version of Swift required to build this package.
553
-
554
- import PackageDescription
555
-
556
- let package = Package(
557
- name: "MyLlamaPackage",
558
- targets: [
559
- .executableTarget(
560
- name: "MyLlamaPackage",
561
- dependencies: [
562
- "LlamaFramework"
563
- ]),
564
- .binaryTarget(
565
- name: "LlamaFramework",
566
- url: "https://github.com/ggml-org/llama.cpp/releases/download/b5046/llama-b5046-xcframework.zip",
567
- checksum: "c19be78b5f00d8d29a25da41042cb7afa094cbf6280a225abe614b03b20029ab"
568
- )
569
- ]
570
- )
571
- ```
572
- The above example is using an intermediate build `b5046` of the library. This can be modified
573
- to use a different version by changing the URL and checksum.
574
-
575
- ## Completions
576
- Command-line completion is available for some environments.
577
-
578
- #### Bash Completion
579
- ```bash
580
- $ build/bin/llama-cli --completion-bash > ~/.llama-completion.bash
581
- $ source ~/.llama-completion.bash
582
- ```
583
- Optionally this can be added to your `.bashrc` or `.bash_profile` to load it
584
- automatically. For example:
585
- ```console
586
- $ echo "source ~/.llama-completion.bash" >> ~/.bashrc
587
- ```
588
-
589
- ## Dependencies
590
-
591
- - [yhirose/cpp-httplib](https://github.com/yhirose/cpp-httplib) - Single-header HTTP server, used by `llama-server` - MIT license
592
- - [stb-image](https://github.com/nothings/stb) - Single-header image format decoder, used by multimodal subsystem - Public domain
593
- - [nlohmann/json](https://github.com/nlohmann/json) - Single-header JSON library, used by various tools/examples - MIT License
594
- - [miniaudio.h](https://github.com/mackron/miniaudio) - Single-header audio format decoder, used by multimodal subsystem - Public domain
595
- - [subprocess.h](https://github.com/sheredom/subprocess.h) - Single-header process launching solution for C and C++ - Public domain
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc44b7ba25614df70e6b65e3341cae0310163bd32fd31a6b928a542df433faf
3
+ size 30786
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ci/run.sh CHANGED
@@ -57,6 +57,13 @@ SRC=`pwd`
57
  CMAKE_EXTRA="-DLLAMA_FATAL_WARNINGS=${LLAMA_FATAL_WARNINGS:-ON} -DLLAMA_OPENSSL=OFF -DGGML_SCHED_NO_REALLOC=ON"
58
  CTEST_EXTRA=""
59
 
 
 
 
 
 
 
 
60
  if [ ! -z ${GG_BUILD_METAL} ]; then
61
  CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=ON"
62
  fi
@@ -112,6 +119,11 @@ if [ ! -z ${GG_BUILD_VULKAN} ]; then
112
  CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=OFF -DGGML_BLAS=OFF"
113
  fi
114
 
 
 
 
 
 
115
  fi
116
 
117
  if [ ! -z ${GG_BUILD_WEBGPU} ]; then
@@ -144,35 +156,7 @@ fi
144
 
145
  if [ -n "${GG_BUILD_KLEIDIAI}" ]; then
146
  echo ">>===== Enabling KleidiAI support"
147
-
148
- CANDIDATES=(
149
- "armv9-a+dotprod+i8mm+sve2"
150
- "armv9-a+dotprod+i8mm"
151
- "armv8.6-a+dotprod+i8mm"
152
- "armv8.2-a+dotprod"
153
- )
154
- CPU=""
155
-
156
- for cpu in "${CANDIDATES[@]}"; do
157
- if echo 'int main(){}' | ${CXX:-c++} -march="$cpu" -x c++ - -c -o /dev/null >/dev/null 2>&1; then
158
- CPU="$cpu"
159
- break
160
- fi
161
- done
162
-
163
- if [ -z "$CPU" ]; then
164
- echo "ERROR: None of the required ARM baselines (armv9/armv8.6/armv8.2 + dotprod) are supported by this compiler."
165
- exit 1
166
- fi
167
-
168
- echo ">>===== Using ARM baseline: ${CPU}"
169
-
170
- CMAKE_EXTRA="${CMAKE_EXTRA:+$CMAKE_EXTRA } \
171
- -DGGML_NATIVE=OFF \
172
- -DGGML_CPU_KLEIDIAI=ON \
173
- -DGGML_CPU_AARCH64=ON \
174
- -DGGML_CPU_ARM_ARCH=${CPU} \
175
- -DBUILD_SHARED_LIBS=OFF"
176
  fi
177
 
178
  if [ ! -z ${GG_BUILD_BLAS} ]; then
@@ -242,13 +226,13 @@ function gg_run_ctest_debug {
242
 
243
  set -e
244
 
245
- # Check cmake, make and ctest are installed
246
  gg_check_build_requirements
247
 
248
- (time cmake -DCMAKE_BUILD_TYPE=Debug ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
249
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
250
 
251
- (time ctest --output-on-failure -L main -E "test-opt|test-backend-ops" ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
252
 
253
  set +e
254
  }
@@ -273,16 +257,16 @@ function gg_run_ctest_release {
273
 
274
  set -e
275
 
276
- # Check cmake, make and ctest are installed
277
  gg_check_build_requirements
278
 
279
- (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
280
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
281
 
282
  if [ -z ${GG_BUILD_LOW_PERF} ]; then
283
- (time ctest --output-on-failure -L 'main|python' ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
284
  else
285
- (time ctest --output-on-failure -L main -E test-opt ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
286
  fi
287
 
288
  set +e
@@ -340,7 +324,7 @@ function gg_run_ctest_with_model_debug {
340
  cd build-ci-debug
341
  set -e
342
 
343
- (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
344
 
345
  set +e
346
  cd ..
@@ -353,7 +337,7 @@ function gg_run_ctest_with_model_release {
353
  cd build-ci-release
354
  set -e
355
 
356
- (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
357
 
358
  # test memory leaks
359
  #if [[ ! -z ${GG_BUILD_METAL} ]]; then
@@ -407,8 +391,8 @@ function gg_run_qwen3_0_6b {
407
 
408
  set -e
409
 
410
- (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
411
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
412
 
413
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf --outtype f16
414
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-bf16.gguf --outtype bf16
@@ -556,8 +540,8 @@ function gg_run_embd_bge_small {
556
 
557
  set -e
558
 
559
- (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
560
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
561
 
562
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
563
 
@@ -601,8 +585,8 @@ function gg_run_rerank_tiny {
601
 
602
  set -e
603
 
604
- (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
605
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
606
 
607
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
608
 
@@ -648,12 +632,36 @@ function gg_sum_rerank_tiny {
648
  }
649
 
650
  function gg_check_build_requirements {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
  if ! command -v cmake &> /dev/null; then
652
  gg_printf 'cmake not found, please install'
653
  fi
654
 
655
- if ! command -v make &> /dev/null; then
656
- gg_printf 'make not found, please install'
657
  fi
658
 
659
  if ! command -v ctest &> /dev/null; then
 
57
  CMAKE_EXTRA="-DLLAMA_FATAL_WARNINGS=${LLAMA_FATAL_WARNINGS:-ON} -DLLAMA_OPENSSL=OFF -DGGML_SCHED_NO_REALLOC=ON"
58
  CTEST_EXTRA=""
59
 
60
+ # Default to use make unless specified for compatibility
61
+ CMAKE_GENERATOR="Unix Makefiles"
62
+
63
+ if [ ! -z "${GG_BUILD_NINJA}" ]; then
64
+ CMAKE_GENERATOR="Ninja"
65
+ fi
66
+
67
  if [ ! -z ${GG_BUILD_METAL} ]; then
68
  CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=ON"
69
  fi
 
119
  CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=OFF -DGGML_BLAS=OFF"
120
  fi
121
 
122
+ # Build shared libs on Windows
123
+ # to reduce binary size and avoid errors in library loading unit tests
124
+ if uname -s | grep -qi nt; then
125
+ CMAKE_EXTRA="${CMAKE_EXTRA} -DBUILD_SHARED_LIBS=ON"
126
+ fi
127
  fi
128
 
129
  if [ ! -z ${GG_BUILD_WEBGPU} ]; then
 
156
 
157
  if [ -n "${GG_BUILD_KLEIDIAI}" ]; then
158
  echo ">>===== Enabling KleidiAI support"
159
+ CMAKE_EXTRA="${CMAKE_EXTRA:+$CMAKE_EXTRA } -DGGML_CPU_KLEIDIAI=ON"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  fi
161
 
162
  if [ ! -z ${GG_BUILD_BLAS} ]; then
 
226
 
227
  set -e
228
 
229
+ # Check required binaries are installed
230
  gg_check_build_requirements
231
 
232
+ (cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Debug ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
233
+ (time cmake --build . --config Debug -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
234
 
235
+ (time ctest -C Debug --output-on-failure -L main -E "test-opt|test-backend-ops" ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
236
 
237
  set +e
238
  }
 
257
 
258
  set -e
259
 
260
+ # Check required binaries are installed
261
  gg_check_build_requirements
262
 
263
+ (cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
264
+ (time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
265
 
266
  if [ -z ${GG_BUILD_LOW_PERF} ]; then
267
+ (time ctest -C Release --output-on-failure -L 'main|python' ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
268
  else
269
+ (time ctest -C Release --output-on-failure -L main -E test-opt ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
270
  fi
271
 
272
  set +e
 
324
  cd build-ci-debug
325
  set -e
326
 
327
+ (LLAMACPP_TEST_MODELFILE="$model" time ctest -C Debug --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
328
 
329
  set +e
330
  cd ..
 
337
  cd build-ci-release
338
  set -e
339
 
340
+ (LLAMACPP_TEST_MODELFILE="$model" time ctest -C Release --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
341
 
342
  # test memory leaks
343
  #if [[ ! -z ${GG_BUILD_METAL} ]]; then
 
391
 
392
  set -e
393
 
394
+ (cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
395
+ (time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
396
 
397
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf --outtype f16
398
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-bf16.gguf --outtype bf16
 
540
 
541
  set -e
542
 
543
+ (cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
544
+ (time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
545
 
546
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
547
 
 
585
 
586
  set -e
587
 
588
+ (cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
589
+ (time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
590
 
591
  python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
592
 
 
632
  }
633
 
634
  function gg_check_build_requirements {
635
+ if ! command -v git &> /dev/null; then
636
+ gg_printf 'git not found, please install'
637
+ fi
638
+
639
+ if ! command -v git-lfs &> /dev/null; then
640
+ gg_printf 'git-lfs not found, please install'
641
+ fi
642
+
643
+ if ! command -v wget &> /dev/null; then
644
+ gg_printf 'wget not found, please install'
645
+ fi
646
+
647
+ if ! command -v python3 &> /dev/null; then
648
+ gg_printf 'python3 not found, please install'
649
+ fi
650
+
651
+ if ! command -v pip3 &> /dev/null; then
652
+ gg_printf 'pip3 not found, please install'
653
+ fi
654
+
655
+ if ! python3 -m ensurepip --help &> /dev/null; then
656
+ gg_printf 'ensurepip not found, please install python3-venv package'
657
+ fi
658
+
659
  if ! command -v cmake &> /dev/null; then
660
  gg_printf 'cmake not found, please install'
661
  fi
662
 
663
+ if ! command -v ccache &> /dev/null; then
664
+ gg_printf 'ccache not found, please consider installing for faster builds'
665
  fi
666
 
667
  if ! command -v ctest &> /dev/null; then
cmake/arm64-linux-clang.cmake ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set( CMAKE_SYSTEM_NAME Linux )
2
+ set( CMAKE_SYSTEM_PROCESSOR arm64 )
3
+
4
+ set( target aarch64-linux-gnu )
5
+
6
+ set( CMAKE_C_COMPILER clang )
7
+ set( CMAKE_CXX_COMPILER clang++ )
8
+
9
+ set( CMAKE_C_COMPILER_TARGET ${target} )
10
+ set( CMAKE_CXX_COMPILER_TARGET ${target} )
11
+
12
+ set( arch_c_flags "-march=armv8.7-a -fvectorize -ffp-model=fast -fno-finite-math-only" )
13
+ set( warn_c_flags "-Wno-format -Wno-unused-variable -Wno-unused-function -Wno-gnu-zero-variadic-macro-arguments" )
14
+
15
+ set( CMAKE_C_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )
16
+ set( CMAKE_CXX_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )
17
+
common/CMakeLists.txt CHANGED
@@ -1,151 +1,3 @@
1
- # common
2
-
3
- find_package(Threads REQUIRED)
4
-
5
- llama_add_compile_flags()
6
-
7
- # Build info header
8
-
9
- if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
10
- set(GIT_DIR "${PROJECT_SOURCE_DIR}/.git")
11
-
12
- # Is git submodule
13
- if(NOT IS_DIRECTORY "${GIT_DIR}")
14
- file(READ ${GIT_DIR} REAL_GIT_DIR_LINK)
15
- string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK})
16
- string(FIND "${REAL_GIT_DIR}" "/" SLASH_POS)
17
- if (SLASH_POS EQUAL 0)
18
- set(GIT_DIR "${REAL_GIT_DIR}")
19
- else()
20
- set(GIT_DIR "${PROJECT_SOURCE_DIR}/${REAL_GIT_DIR}")
21
- endif()
22
- endif()
23
-
24
- if(EXISTS "${GIT_DIR}/index")
25
- # For build-info.cpp below
26
- set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${GIT_DIR}/index")
27
- else()
28
- message(WARNING "Git index not found in git repository.")
29
- endif()
30
- else()
31
- message(WARNING "Git repository not found; to enable automatic generation of build info, make sure Git is installed and the project is a Git repository.")
32
- endif()
33
-
34
- set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/build-info.cpp.in")
35
- set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/build-info.cpp")
36
- configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
37
-
38
- set(TARGET build_info)
39
- add_library(${TARGET} OBJECT ${OUTPUT_FILE})
40
- if (BUILD_SHARED_LIBS)
41
- set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
42
- endif()
43
-
44
- set(TARGET common)
45
-
46
- add_library(${TARGET} STATIC
47
- arg.cpp
48
- arg.h
49
- base64.hpp
50
- chat-auto-parser-generator.cpp
51
- chat-auto-parser-helpers.cpp
52
- chat-auto-parser.h
53
- chat-diff-analyzer.cpp
54
- chat-peg-parser.cpp
55
- chat-peg-parser.h
56
- chat.cpp
57
- chat.h
58
- common.cpp
59
- common.h
60
- console.cpp
61
- console.h
62
- debug.cpp
63
- debug.h
64
- download.cpp
65
- download.h
66
- http.h
67
- json-partial.cpp
68
- json-partial.h
69
- json-schema-to-grammar.cpp
70
- llguidance.cpp
71
- log.cpp
72
- log.h
73
- ngram-cache.cpp
74
- ngram-cache.h
75
- ngram-map.cpp
76
- ngram-map.h
77
- ngram-mod.cpp
78
- ngram-mod.h
79
- peg-parser.cpp
80
- peg-parser.h
81
- preset.cpp
82
- preset.h
83
- regex-partial.cpp
84
- reasoning-budget.cpp
85
- reasoning-budget.h
86
- regex-partial.h
87
- sampling.cpp
88
- sampling.h
89
- speculative.cpp
90
- speculative.h
91
- unicode.cpp
92
- unicode.h
93
- jinja/lexer.cpp
94
- jinja/lexer.h
95
- jinja/parser.cpp
96
- jinja/parser.h
97
- jinja/runtime.cpp
98
- jinja/runtime.h
99
- jinja/value.cpp
100
- jinja/value.h
101
- jinja/string.cpp
102
- jinja/string.h
103
- jinja/caps.cpp
104
- jinja/caps.h
105
- )
106
-
107
- target_include_directories(${TARGET} PUBLIC . ../vendor)
108
- target_compile_features (${TARGET} PUBLIC cxx_std_17)
109
-
110
- if (BUILD_SHARED_LIBS)
111
- set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
112
- endif()
113
-
114
- target_link_libraries(${TARGET} PRIVATE
115
- build_info
116
- cpp-httplib
117
- )
118
-
119
- if (LLAMA_LLGUIDANCE)
120
- include(ExternalProject)
121
- set(LLGUIDANCE_SRC ${CMAKE_BINARY_DIR}/llguidance/source)
122
- set(LLGUIDANCE_PATH ${LLGUIDANCE_SRC}/target/release)
123
- set(LLGUIDANCE_LIB_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}llguidance${CMAKE_STATIC_LIBRARY_SUFFIX}")
124
-
125
- ExternalProject_Add(llguidance_ext
126
- GIT_REPOSITORY https://github.com/guidance-ai/llguidance
127
- # v1.0.1:
128
- GIT_TAG d795912fedc7d393de740177ea9ea761e7905774
129
- PREFIX ${CMAKE_BINARY_DIR}/llguidance
130
- SOURCE_DIR ${LLGUIDANCE_SRC}
131
- BUILD_IN_SOURCE TRUE
132
- CONFIGURE_COMMAND ""
133
- BUILD_COMMAND cargo build --release --package llguidance
134
- INSTALL_COMMAND ""
135
- BUILD_BYPRODUCTS ${LLGUIDANCE_PATH}/${LLGUIDANCE_LIB_NAME} ${LLGUIDANCE_PATH}/llguidance.h
136
- UPDATE_COMMAND ""
137
- )
138
- target_compile_definitions(${TARGET} PUBLIC LLAMA_USE_LLGUIDANCE)
139
-
140
- add_library(llguidance STATIC IMPORTED)
141
- set_target_properties(llguidance PROPERTIES IMPORTED_LOCATION ${LLGUIDANCE_PATH}/${LLGUIDANCE_LIB_NAME})
142
- add_dependencies(llguidance llguidance_ext)
143
-
144
- target_include_directories(${TARGET} PRIVATE ${LLGUIDANCE_PATH})
145
- target_link_libraries(${TARGET} PRIVATE llguidance)
146
- if (WIN32)
147
- target_link_libraries(${TARGET} PRIVATE ws2_32 userenv ntdll bcrypt)
148
- endif()
149
- endif()
150
-
151
- target_link_libraries(${TARGET} PUBLIC llama Threads::Threads)
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4fe95e36bff8944120f212aaeef45c24c483038ddc30bffc5694102fdff30f0
3
+ size 4864
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/arg.cpp CHANGED
@@ -1,8 +1,10 @@
1
  #include "arg.h"
2
 
 
3
  #include "chat.h"
4
  #include "common.h"
5
  #include "download.h"
 
6
  #include "json-schema-to-grammar.h"
7
  #include "log.h"
8
  #include "sampling.h"
@@ -290,14 +292,16 @@ static bool common_params_handle_remote_preset(common_params & params, llama_exa
290
  hf_tag = "default";
291
  }
292
 
293
- const bool offline = params.offline;
294
- std::string model_endpoint = get_model_endpoint();
295
  auto preset_url = model_endpoint + hf_repo + "/resolve/main/preset.ini";
296
 
297
  // prepare local path for caching
298
  auto preset_fname = clean_file_name(hf_repo + "_preset.ini");
299
  auto preset_path = fs_get_cache_file(preset_fname);
300
- const int status = common_download_file_single(preset_url, preset_path, params.hf_token, offline);
 
 
 
301
  const bool has_preset = status >= 200 && status < 400;
302
 
303
  // remote preset is optional, so we don't error out if not found
@@ -326,60 +330,49 @@ struct handle_model_result {
326
  common_params_model mmproj;
327
  };
328
 
329
- static handle_model_result common_params_handle_model(
330
- struct common_params_model & model,
331
- const std::string & bearer_token,
332
- bool offline) {
333
  handle_model_result result;
334
- // handle pre-fill default model path and url based on hf_repo and hf_file
335
- {
336
- if (!model.docker_repo.empty()) { // Handle Docker URLs by resolving them to local paths
337
- model.path = common_docker_resolve_model(model.docker_repo);
338
- model.name = model.docker_repo; // set name for consistency
339
- } else if (!model.hf_repo.empty()) {
340
- // short-hand to avoid specifying --hf-file -> default it to --model
341
- if (model.hf_file.empty()) {
342
- if (model.path.empty()) {
343
- auto auto_detected = common_get_hf_file(model.hf_repo, bearer_token, offline);
344
- if (auto_detected.repo.empty() || auto_detected.ggufFile.empty()) {
345
- exit(1); // error message already printed
346
- }
347
- model.name = model.hf_repo; // repo name with tag
348
- model.hf_repo = auto_detected.repo; // repo name without tag
349
- model.hf_file = auto_detected.ggufFile;
350
- if (!auto_detected.mmprojFile.empty()) {
351
- result.found_mmproj = true;
352
- result.mmproj.hf_repo = model.hf_repo;
353
- result.mmproj.hf_file = auto_detected.mmprojFile;
354
- }
355
- } else {
356
- model.hf_file = model.path;
357
- }
358
- }
359
 
360
- std::string model_endpoint = get_model_endpoint();
361
- model.url = model_endpoint + model.hf_repo + "/resolve/main/" + model.hf_file;
362
- // make sure model path is present (for caching purposes)
363
- if (model.path.empty()) {
364
- // this is to avoid different repo having same file name, or same file name in different subdirs
365
- std::string filename = clean_file_name(model.hf_repo + "_" + model.hf_file);
366
- model.path = fs_get_cache_file(filename);
367
- }
 
 
 
 
 
 
 
 
 
 
368
 
369
- } else if (!model.url.empty()) {
370
- if (model.path.empty()) {
371
- auto f = string_split<std::string>(model.url, '#').front();
372
- f = string_split<std::string>(f, '?').front();
373
- model.path = fs_get_cache_file(string_split<std::string>(f, '/').back());
374
- }
375
 
 
 
 
 
 
 
 
 
 
376
  }
377
- }
378
 
379
- // then, download it if needed
380
- if (!model.url.empty()) {
381
- bool ok = common_download_model(model, bearer_token, offline);
382
- if (!ok) {
 
383
  LOG_ERR("error: failed to download model from %s\n", model.url.c_str());
384
  exit(1);
385
  }
@@ -434,6 +427,9 @@ static bool parse_bool_value(const std::string & value) {
434
  static bool common_params_parse_ex(int argc, char ** argv, common_params_context & ctx_arg) {
435
  common_params & params = ctx_arg.params;
436
 
 
 
 
437
  std::unordered_map<std::string, std::pair<common_arg *, bool>> arg_to_options;
438
  for (auto & opt : ctx_arg.options) {
439
  for (const auto & arg : opt.args) {
@@ -539,8 +535,17 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
539
  // parse the first time to get -hf option (used for remote preset)
540
  parse_cli_args();
541
 
 
 
 
 
 
 
 
 
 
542
  // maybe handle remote preset
543
- if (!params.model.hf_repo.empty()) {
544
  std::string cli_hf_repo = params.model.hf_repo;
545
  bool has_preset = common_params_handle_remote_preset(params, ctx_arg.ex);
546
 
@@ -571,7 +576,7 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
571
  }
572
 
573
  // handle model and download
574
- {
575
  auto res = common_params_handle_model(params.model, params.hf_token, params.offline);
576
  if (params.no_mmproj) {
577
  params.mmproj = {};
@@ -592,7 +597,7 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
592
 
593
  // model is required (except for server)
594
  // TODO @ngxson : maybe show a list of available models in CLI in this case
595
- if (params.model.path.empty() && ctx_arg.ex != LLAMA_EXAMPLE_SERVER && !params.usage && !params.completion) {
596
  throw std::invalid_argument("error: --model is required\n");
597
  }
598
 
@@ -635,8 +640,6 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
635
  ));
636
  }
637
 
638
- common_log_set_verbosity_thold(params.verbosity);
639
-
640
  return true;
641
  }
642
 
@@ -1042,8 +1045,8 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1042
  {"--version"},
1043
  "show version and build info",
1044
  [](common_params &) {
1045
- fprintf(stderr, "version: %d (%s)\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
1046
- fprintf(stderr, "built with %s for %s\n", LLAMA_COMPILER, LLAMA_BUILD_TARGET);
1047
  exit(0);
1048
  }
1049
  ));
@@ -1061,12 +1064,10 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1061
  {"-cl", "--cache-list"},
1062
  "show list of models in cache",
1063
  [](common_params &) {
1064
- printf("model cache directory: %s\n", fs_get_cache_directory().c_str());
1065
  auto models = common_list_cached_models();
1066
  printf("number of models in cache: %zu\n", models.size());
1067
  for (size_t i = 0; i < models.size(); i++) {
1068
- auto & model = models[i];
1069
- printf("%4d. %s\n", (int) i + 1, model.to_string().c_str());
1070
  }
1071
  exit(0);
1072
  }
@@ -1084,7 +1085,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1084
  [](common_params & params) {
1085
  params.verbose_prompt = true;
1086
  }
1087
- ));
1088
  add_opt(common_arg(
1089
  {"--display-prompt"},
1090
  {"--no-display-prompt"},
@@ -1314,6 +1315,14 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1314
  params.kv_unified = value;
1315
  }
1316
  ).set_env("LLAMA_ARG_KV_UNIFIED").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_PERPLEXITY, LLAMA_EXAMPLE_BATCHED, LLAMA_EXAMPLE_BENCH, LLAMA_EXAMPLE_PARALLEL}));
 
 
 
 
 
 
 
 
1317
  add_opt(common_arg(
1318
  {"--context-shift"},
1319
  {"--no-context-shift"},
@@ -1830,23 +1839,23 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1830
  ).set_sparam());
1831
  add_opt(common_arg(
1832
  {"--grammar"}, "GRAMMAR",
1833
- string_format("BNF-like grammar to constrain generations (see samples in grammars/ dir) (default: '%s')", params.sampling.grammar.c_str()),
1834
  [](common_params & params, const std::string & value) {
1835
- params.sampling.grammar = value;
1836
  }
1837
  ).set_sparam());
1838
  add_opt(common_arg(
1839
  {"--grammar-file"}, "FNAME",
1840
  "file to read grammar from",
1841
  [](common_params & params, const std::string & value) {
1842
- params.sampling.grammar = read_file(value);
1843
  }
1844
  ).set_sparam());
1845
  add_opt(common_arg(
1846
  {"-j", "--json-schema"}, "SCHEMA",
1847
  "JSON schema to constrain generations (https://json-schema.org/), e.g. `{}` for any JSON object\nFor schemas w/ external $refs, use --grammar + example/json_schema_to_grammar.py instead",
1848
  [](common_params & params, const std::string & value) {
1849
- params.sampling.grammar = json_schema_to_grammar(json::parse(value));
1850
  }
1851
  ).set_sparam());
1852
  add_opt(common_arg(
@@ -1863,7 +1872,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
1863
  std::istreambuf_iterator<char>(),
1864
  std::back_inserter(schema)
1865
  );
1866
- params.sampling.grammar = json_schema_to_grammar(json::parse(schema));
1867
  }
1868
  ).set_sparam());
1869
  add_opt(common_arg(
@@ -2343,19 +2352,21 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
2343
  }
2344
  ).set_env("LLAMA_ARG_N_GPU_LAYERS"));
2345
  add_opt(common_arg(
2346
- {"-sm", "--split-mode"}, "{none,layer,row}",
2347
  "how to split the model across multiple GPUs, one of:\n"
2348
  "- none: use one GPU only\n"
2349
- "- layer (default): split layers and KV across GPUs\n"
2350
- "- row: split rows across GPUs",
 
2351
  [](common_params & params, const std::string & value) {
2352
- std::string arg_next = value;
2353
- if (arg_next == "none") {
2354
  params.split_mode = LLAMA_SPLIT_MODE_NONE;
2355
- } else if (arg_next == "layer") {
2356
  params.split_mode = LLAMA_SPLIT_MODE_LAYER;
2357
- } else if (arg_next == "row") {
2358
  params.split_mode = LLAMA_SPLIT_MODE_ROW;
 
 
2359
  } else {
2360
  throw std::invalid_argument("invalid value");
2361
  }
@@ -2415,6 +2426,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
2415
  }
2416
  }
2417
  ).set_env("LLAMA_ARG_FIT"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2418
  add_opt(common_arg(
2419
  { "-fitt", "--fit-target" }, "MiB0,MiB1,MiB2,...",
2420
  string_format("target margin per device for --fit, comma-separated list of values, "
@@ -2583,7 +2608,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
2583
  {"-hf", "-hfr", "--hf-repo"}, "<user>/<model>[:quant]",
2584
  "Hugging Face model repository; quant is optional, case-insensitive, default to Q4_K_M, or falls back to the first file in the repo if Q4_K_M doesn't exist.\n"
2585
  "mmproj is also downloaded automatically if available. to disable, add --no-mmproj\n"
2586
- "example: unsloth/phi-4-GGUF:q4_k_m\n"
2587
  "(default: unused)",
2588
  [](common_params & params, const std::string & value) {
2589
  params.model.hf_repo = value;
@@ -2812,6 +2837,13 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
2812
  params.port = value;
2813
  }
2814
  ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_PORT"));
 
 
 
 
 
 
 
2815
  add_opt(common_arg(
2816
  {"--path"}, "PATH",
2817
  string_format("path to serve static files from (default: %s)", params.public_path.c_str()),
@@ -2848,6 +2880,15 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
2848
  params.webui_mcp_proxy = value;
2849
  }
2850
  ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_WEBUI_MCP_PROXY"));
 
 
 
 
 
 
 
 
 
2851
  add_opt(common_arg(
2852
  {"--webui"},
2853
  {"--no-webui"},
@@ -3250,6 +3291,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
3250
  "Set verbosity level to infinity (i.e. log all messages, useful for debugging)",
3251
  [](common_params & params) {
3252
  params.verbosity = INT_MAX;
 
3253
  }
3254
  ));
3255
  add_opt(common_arg(
@@ -3270,6 +3312,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
3270
  "(default: %d)\n", params.verbosity),
3271
  [](common_params & params, int value) {
3272
  params.verbosity = value;
 
3273
  }
3274
  ).set_env("LLAMA_LOG_VERBOSITY"));
3275
  add_opt(common_arg(
@@ -3494,7 +3537,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
3494
  throw std::invalid_argument("unknown speculative decoding type without draft model");
3495
  }
3496
  }
3497
- ).set_examples({LLAMA_EXAMPLE_SERVER}));
3498
  add_opt(common_arg(
3499
  {"--spec-ngram-size-n"}, "N",
3500
  string_format("ngram size N for ngram-simple/ngram-map speculative decoding, length of lookup n-gram (default: %d)", params.speculative.ngram_size_n),
 
1
  #include "arg.h"
2
 
3
+ #include "build-info.h"
4
  #include "chat.h"
5
  #include "common.h"
6
  #include "download.h"
7
+ #include "hf-cache.h"
8
  #include "json-schema-to-grammar.h"
9
  #include "log.h"
10
  #include "sampling.h"
 
292
  hf_tag = "default";
293
  }
294
 
295
+ std::string model_endpoint = common_get_model_endpoint();
 
296
  auto preset_url = model_endpoint + hf_repo + "/resolve/main/preset.ini";
297
 
298
  // prepare local path for caching
299
  auto preset_fname = clean_file_name(hf_repo + "_preset.ini");
300
  auto preset_path = fs_get_cache_file(preset_fname);
301
+ common_download_opts opts;
302
+ opts.bearer_token = params.hf_token;
303
+ opts.offline = params.offline;
304
+ const int status = common_download_file_single(preset_url, preset_path, opts);
305
  const bool has_preset = status >= 200 && status < 400;
306
 
307
  // remote preset is optional, so we don't error out if not found
 
330
  common_params_model mmproj;
331
  };
332
 
333
+ static handle_model_result common_params_handle_model(struct common_params_model & model,
334
+ const std::string & bearer_token,
335
+ bool offline) {
 
336
  handle_model_result result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
 
338
+ if (!model.docker_repo.empty()) {
339
+ model.path = common_docker_resolve_model(model.docker_repo);
340
+ model.name = model.docker_repo;
341
+ } else if (!model.hf_repo.empty()) {
342
+ // If -m was used with -hf, treat the model "path" as the hf_file to download
343
+ if (model.hf_file.empty() && !model.path.empty()) {
344
+ model.hf_file = model.path;
345
+ model.path = "";
346
+ }
347
+ common_download_opts opts;
348
+ opts.bearer_token = bearer_token;
349
+ opts.offline = offline;
350
+ auto download_result = common_download_model(model, opts, true);
351
+
352
+ if (download_result.model_path.empty()) {
353
+ LOG_ERR("error: failed to download model from Hugging Face\n");
354
+ exit(1);
355
+ }
356
 
357
+ model.name = model.hf_repo;
358
+ model.path = download_result.model_path;
 
 
 
 
359
 
360
+ if (!download_result.mmproj_path.empty()) {
361
+ result.found_mmproj = true;
362
+ result.mmproj.path = download_result.mmproj_path;
363
+ }
364
+ } else if (!model.url.empty()) {
365
+ if (model.path.empty()) {
366
+ auto f = string_split<std::string>(model.url, '#').front();
367
+ f = string_split<std::string>(f, '?').front();
368
+ model.path = fs_get_cache_file(string_split<std::string>(f, '/').back());
369
  }
 
370
 
371
+ common_download_opts opts;
372
+ opts.bearer_token = bearer_token;
373
+ opts.offline = offline;
374
+ auto download_result = common_download_model(model, opts);
375
+ if (download_result.model_path.empty()) {
376
  LOG_ERR("error: failed to download model from %s\n", model.url.c_str());
377
  exit(1);
378
  }
 
427
  static bool common_params_parse_ex(int argc, char ** argv, common_params_context & ctx_arg) {
428
  common_params & params = ctx_arg.params;
429
 
430
+ // setup log directly from params.verbosity: see tools/cli/cli.cpp
431
+ common_log_set_verbosity_thold(params.verbosity);
432
+
433
  std::unordered_map<std::string, std::pair<common_arg *, bool>> arg_to_options;
434
  for (auto & opt : ctx_arg.options) {
435
  for (const auto & arg : opt.args) {
 
535
  // parse the first time to get -hf option (used for remote preset)
536
  parse_cli_args();
537
 
538
+ // TODO: Remove later
539
+ try {
540
+ hf_cache::migrate_old_cache_to_hf_cache(params.hf_token, params.offline);
541
+ } catch (const std::exception & e) {
542
+ LOG_WRN("HF cache migration failed: %s\n", e.what());
543
+ }
544
+ // export_graph_ops loads only metadata
545
+ const bool skip_model_download = ctx_arg.ex == LLAMA_EXAMPLE_EXPORT_GRAPH_OPS;
546
+
547
  // maybe handle remote preset
548
+ if (!params.model.hf_repo.empty() && !skip_model_download) {
549
  std::string cli_hf_repo = params.model.hf_repo;
550
  bool has_preset = common_params_handle_remote_preset(params, ctx_arg.ex);
551
 
 
576
  }
577
 
578
  // handle model and download
579
+ if (!skip_model_download) {
580
  auto res = common_params_handle_model(params.model, params.hf_token, params.offline);
581
  if (params.no_mmproj) {
582
  params.mmproj = {};
 
597
 
598
  // model is required (except for server)
599
  // TODO @ngxson : maybe show a list of available models in CLI in this case
600
+ if (params.model.path.empty() && ctx_arg.ex != LLAMA_EXAMPLE_SERVER && !skip_model_download && !params.usage && !params.completion) {
601
  throw std::invalid_argument("error: --model is required\n");
602
  }
603
 
 
640
  ));
641
  }
642
 
 
 
643
  return true;
644
  }
645
 
 
1045
  {"--version"},
1046
  "show version and build info",
1047
  [](common_params &) {
1048
+ fprintf(stderr, "version: %d (%s)\n", llama_build_number(), llama_commit());
1049
+ fprintf(stderr, "built with %s for %s\n", llama_compiler(), llama_build_target());
1050
  exit(0);
1051
  }
1052
  ));
 
1064
  {"-cl", "--cache-list"},
1065
  "show list of models in cache",
1066
  [](common_params &) {
 
1067
  auto models = common_list_cached_models();
1068
  printf("number of models in cache: %zu\n", models.size());
1069
  for (size_t i = 0; i < models.size(); i++) {
1070
+ printf("%4zu. %s\n", i + 1, models[i].to_string().c_str());
 
1071
  }
1072
  exit(0);
1073
  }
 
1085
  [](common_params & params) {
1086
  params.verbose_prompt = true;
1087
  }
1088
+ ).set_examples({LLAMA_EXAMPLE_COMPLETION, LLAMA_EXAMPLE_CLI, LLAMA_EXAMPLE_EMBEDDING, LLAMA_EXAMPLE_RETRIEVAL}));
1089
  add_opt(common_arg(
1090
  {"--display-prompt"},
1091
  {"--no-display-prompt"},
 
1315
  params.kv_unified = value;
1316
  }
1317
  ).set_env("LLAMA_ARG_KV_UNIFIED").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_PERPLEXITY, LLAMA_EXAMPLE_BATCHED, LLAMA_EXAMPLE_BENCH, LLAMA_EXAMPLE_PARALLEL}));
1318
+ add_opt(common_arg(
1319
+ {"--cache-idle-slots"},
1320
+ {"--no-cache-idle-slots"},
1321
+ "save and clear idle slots on new task (default: enabled, requires unified KV and cache-ram)",
1322
+ [](common_params & params, bool value) {
1323
+ params.cache_idle_slots = value;
1324
+ }
1325
+ ).set_env("LLAMA_ARG_CACHE_IDLE_SLOTS").set_examples({LLAMA_EXAMPLE_SERVER}));
1326
  add_opt(common_arg(
1327
  {"--context-shift"},
1328
  {"--no-context-shift"},
 
1839
  ).set_sparam());
1840
  add_opt(common_arg(
1841
  {"--grammar"}, "GRAMMAR",
1842
+ "BNF-like grammar to constrain generations (see samples in grammars/ dir)",
1843
  [](common_params & params, const std::string & value) {
1844
+ params.sampling.grammar = {COMMON_GRAMMAR_TYPE_USER, value};
1845
  }
1846
  ).set_sparam());
1847
  add_opt(common_arg(
1848
  {"--grammar-file"}, "FNAME",
1849
  "file to read grammar from",
1850
  [](common_params & params, const std::string & value) {
1851
+ params.sampling.grammar = {COMMON_GRAMMAR_TYPE_USER, read_file(value)};
1852
  }
1853
  ).set_sparam());
1854
  add_opt(common_arg(
1855
  {"-j", "--json-schema"}, "SCHEMA",
1856
  "JSON schema to constrain generations (https://json-schema.org/), e.g. `{}` for any JSON object\nFor schemas w/ external $refs, use --grammar + example/json_schema_to_grammar.py instead",
1857
  [](common_params & params, const std::string & value) {
1858
+ params.sampling.grammar = {COMMON_GRAMMAR_TYPE_OUTPUT_FORMAT, json_schema_to_grammar(json::parse(value))};
1859
  }
1860
  ).set_sparam());
1861
  add_opt(common_arg(
 
1872
  std::istreambuf_iterator<char>(),
1873
  std::back_inserter(schema)
1874
  );
1875
+ params.sampling.grammar = {COMMON_GRAMMAR_TYPE_OUTPUT_FORMAT, json_schema_to_grammar(json::parse(schema))};
1876
  }
1877
  ).set_sparam());
1878
  add_opt(common_arg(
 
2352
  }
2353
  ).set_env("LLAMA_ARG_N_GPU_LAYERS"));
2354
  add_opt(common_arg(
2355
+ {"-sm", "--split-mode"}, "{none,layer,row,tensor}",
2356
  "how to split the model across multiple GPUs, one of:\n"
2357
  "- none: use one GPU only\n"
2358
+ "- layer (default): split layers and KV across GPUs (pipelined)\n"
2359
+ "- row: split weight across GPUs by rows (parallelized)\n"
2360
+ "- tensor: split weights and KV across GPUs (parallelized, EXPERIMENTAL)",
2361
  [](common_params & params, const std::string & value) {
2362
+ if (value == "none") {
 
2363
  params.split_mode = LLAMA_SPLIT_MODE_NONE;
2364
+ } else if (value == "layer") {
2365
  params.split_mode = LLAMA_SPLIT_MODE_LAYER;
2366
+ } else if (value == "row") {
2367
  params.split_mode = LLAMA_SPLIT_MODE_ROW;
2368
+ } else if (value == "tensor") {
2369
+ params.split_mode = LLAMA_SPLIT_MODE_TENSOR;
2370
  } else {
2371
  throw std::invalid_argument("invalid value");
2372
  }
 
2426
  }
2427
  }
2428
  ).set_env("LLAMA_ARG_FIT"));
2429
+ add_opt(common_arg(
2430
+ { "-fitp", "--fit-print" }, "[on|off]",
2431
+ string_format("print the estimated required memory ('on' or 'off', default: '%s')", params.fit_params_print ? "on" : "off"),
2432
+ [](common_params & params, const std::string & value) {
2433
+ if (is_truthy(value)) {
2434
+ params.fit_params_print = true;
2435
+ } else if (is_falsey(value)) {
2436
+ params.fit_params_print = false;
2437
+ } else {
2438
+ throw std::runtime_error(
2439
+ string_format("error: unknown value for --fit-print: '%s'\n", value.c_str()));
2440
+ }
2441
+ }
2442
+ ).set_examples({LLAMA_EXAMPLE_FIT_PARAMS}).set_env("LLAMA_ARG_FIT_ESTIMATE"));
2443
  add_opt(common_arg(
2444
  { "-fitt", "--fit-target" }, "MiB0,MiB1,MiB2,...",
2445
  string_format("target margin per device for --fit, comma-separated list of values, "
 
2608
  {"-hf", "-hfr", "--hf-repo"}, "<user>/<model>[:quant]",
2609
  "Hugging Face model repository; quant is optional, case-insensitive, default to Q4_K_M, or falls back to the first file in the repo if Q4_K_M doesn't exist.\n"
2610
  "mmproj is also downloaded automatically if available. to disable, add --no-mmproj\n"
2611
+ "example: ggml-org/GLM-4.7-Flash-GGUF:Q4_K_M\n"
2612
  "(default: unused)",
2613
  [](common_params & params, const std::string & value) {
2614
  params.model.hf_repo = value;
 
2837
  params.port = value;
2838
  }
2839
  ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_PORT"));
2840
+ add_opt(common_arg(
2841
+ {"--reuse-port"},
2842
+ string_format("allow multiple sockets to bind to the same port (default: %s)", params.reuse_port ? "enabled" : "disabled"),
2843
+ [](common_params & params) {
2844
+ params.reuse_port = true;
2845
+ }
2846
+ ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_REUSE_PORT"));
2847
  add_opt(common_arg(
2848
  {"--path"}, "PATH",
2849
  string_format("path to serve static files from (default: %s)", params.public_path.c_str()),
 
2880
  params.webui_mcp_proxy = value;
2881
  }
2882
  ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_WEBUI_MCP_PROXY"));
2883
+ add_opt(common_arg(
2884
+ {"--tools"}, "TOOL1,TOOL2,...",
2885
+ "experimental: whether to enable built-in tools for AI agents - do not enable in untrusted environments (default: no tools)\n"
2886
+ "specify \"all\" to enable all tools\n"
2887
+ "available tools: read_file, file_glob_search, grep_search, exec_shell_command, write_file, edit_file, apply_diff",
2888
+ [](common_params & params, const std::string & value) {
2889
+ params.server_tools = parse_csv_row(value);
2890
+ }
2891
+ ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_TOOLS"));
2892
  add_opt(common_arg(
2893
  {"--webui"},
2894
  {"--no-webui"},
 
3291
  "Set verbosity level to infinity (i.e. log all messages, useful for debugging)",
3292
  [](common_params & params) {
3293
  params.verbosity = INT_MAX;
3294
+ common_log_set_verbosity_thold(INT_MAX);
3295
  }
3296
  ));
3297
  add_opt(common_arg(
 
3312
  "(default: %d)\n", params.verbosity),
3313
  [](common_params & params, int value) {
3314
  params.verbosity = value;
3315
+ common_log_set_verbosity_thold(value);
3316
  }
3317
  ).set_env("LLAMA_LOG_VERBOSITY"));
3318
  add_opt(common_arg(
 
3537
  throw std::invalid_argument("unknown speculative decoding type without draft model");
3538
  }
3539
  }
3540
+ ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_SPEC_TYPE"));
3541
  add_opt(common_arg(
3542
  {"--spec-ngram-size-n"}, "N",
3543
  string_format("ngram size N for ngram-simple/ngram-map speculative decoding, length of lookup n-gram (default: %d)", params.speculative.ngram_size_n),
common/build-info.cpp.in CHANGED
@@ -1,4 +1,35 @@
 
 
 
 
 
1
  int LLAMA_BUILD_NUMBER = @LLAMA_BUILD_NUMBER@;
2
- char const *LLAMA_COMMIT = "@LLAMA_BUILD_COMMIT@";
3
- char const *LLAMA_COMPILER = "@BUILD_COMPILER@";
4
- char const *LLAMA_BUILD_TARGET = "@BUILD_TARGET@";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "build-info.h"
2
+
3
+ #include <cstdio>
4
+ #include <string>
5
+
6
  int LLAMA_BUILD_NUMBER = @LLAMA_BUILD_NUMBER@;
7
+ char const * LLAMA_COMMIT = "@LLAMA_BUILD_COMMIT@";
8
+ char const * LLAMA_COMPILER = "@BUILD_COMPILER@";
9
+ char const * LLAMA_BUILD_TARGET = "@BUILD_TARGET@";
10
+
11
+ int llama_build_number(void) {
12
+ return LLAMA_BUILD_NUMBER;
13
+ }
14
+
15
+ const char * llama_commit(void) {
16
+ return LLAMA_COMMIT;
17
+ }
18
+
19
+ const char * llama_compiler(void) {
20
+ return LLAMA_COMPILER;
21
+ }
22
+
23
+ const char * llama_build_target(void) {
24
+ return LLAMA_BUILD_TARGET;
25
+ }
26
+
27
+ const char * llama_build_info(void) {
28
+ static std::string s = "b" + std::to_string(LLAMA_BUILD_NUMBER) + "-" + LLAMA_COMMIT;
29
+ return s.c_str();
30
+ }
31
+
32
+ void llama_print_build_info(void) {
33
+ fprintf(stderr, "%s: build = %d (%s)\n", __func__, llama_build_number(), llama_commit());
34
+ fprintf(stderr, "%s: built with %s for %s\n", __func__, llama_compiler(), llama_build_target());
35
+ }
common/build-info.h ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ int llama_build_number(void);
4
+
5
+ const char * llama_commit(void);
6
+ const char * llama_compiler(void);
7
+
8
+ const char * llama_build_target(void);
9
+ const char * llama_build_info(void);
10
+
11
+ void llama_print_build_info(void);
common/chat-auto-parser-generator.cpp CHANGED
@@ -1,3 +1,4 @@
 
1
  #include "chat-auto-parser.h"
2
  #include "chat-peg-parser.h"
3
  #include "chat.h"
@@ -5,6 +6,7 @@
5
  #include "json-schema-to-grammar.h"
6
  #include "log.h"
7
  #include "nlohmann/json.hpp"
 
8
 
9
  #include <stdexcept>
10
  #include <string>
@@ -23,13 +25,13 @@ static void foreach_function(const json & tools, const std::function<void(const
23
 
24
  namespace autoparser {
25
 
26
- parser_build_context::parser_build_context(common_chat_peg_builder & p, const templates_params & inputs) :
27
  p(p),
28
  inputs(inputs),
29
  reasoning_parser(p.eps()) {}
30
 
31
  common_chat_params peg_generator::generate_parser(const common_chat_template & tmpl,
32
- const struct templates_params & inputs) {
33
  // Run differential analysis to extract template structure
34
  struct autoparser autoparser;
35
  autoparser.analyze_template(tmpl);
@@ -37,17 +39,16 @@ common_chat_params peg_generator::generate_parser(const common_chat_template &
37
  }
38
 
39
  common_chat_params peg_generator::generate_parser(const common_chat_template & tmpl,
40
- const struct templates_params & inputs,
41
  const autoparser & autoparser) {
42
- // Build the parser using the analysis results
43
- auto parser = autoparser.build_parser(inputs);
44
-
45
  // Create the result structure
46
  common_chat_params data;
47
  data.prompt = common_chat_template_direct_apply(tmpl, inputs);
48
  data.format = COMMON_CHAT_FORMAT_PEG_NATIVE;
49
  data.preserved_tokens = autoparser.preserved_tokens;
50
- data.parser = parser.save();
 
 
51
 
52
  // Build grammar if tools are present
53
  bool has_tools =
@@ -65,9 +66,13 @@ common_chat_params peg_generator::generate_parser(const common_chat_template &
65
  data.grammar = build_grammar([&](const common_grammar_builder & builder) {
66
  foreach_function(inputs.tools, [&](const json & tool) {
67
  const auto & function = tool.at("function");
68
- auto schema = function.at("parameters");
69
  builder.resolve_refs(schema);
70
  });
 
 
 
 
71
  parser.build_grammar(builder, data.grammar_lazy);
72
  });
73
 
@@ -82,44 +87,41 @@ common_chat_params peg_generator::generate_parser(const common_chat_template &
82
  return data;
83
  }
84
 
85
- common_peg_arena autoparser::build_parser(const templates_params & inputs) const {
86
  if (!analysis_complete) {
87
  throw std::invalid_argument("Cannot call build_parser on autoparser without performing analysis first, call analyze_template(...)");
88
  }
89
  return build_chat_peg_parser([&](common_chat_peg_builder & p) {
90
- // If the template uses Python dict format (single-quoted strings in JSON structures),
91
- // pre-register a json-string rule that accepts both quote styles. This must happen
92
- // before any call to p.json() so that all JSON parsing inherits the flexible rule.
93
- if (tools.format.uses_python_dicts) {
94
- p.rule("json-string", p.quoted_string());
95
- }
96
-
97
  parser_build_context ctx(p, inputs);
98
  bool extract_reasoning = inputs.reasoning_format != COMMON_REASONING_FORMAT_NONE;
99
- bool enable_thinking = inputs.enable_thinking;
100
 
101
- ctx.extracting_reasoning = extract_reasoning && enable_thinking && reasoning.mode != reasoning_mode::NONE;
102
  ctx.content = &content;
 
103
 
104
  // Build reasoning parser
105
  ctx.reasoning_parser = reasoning.build_parser(ctx);
106
 
 
 
107
  bool has_tools = inputs.tools.is_array() && !inputs.tools.empty();
108
  bool has_response_format = inputs.json_schema.is_object() && !inputs.json_schema.empty();
 
109
 
110
  if (has_response_format) {
111
  auto response_format = p.rule("response-format", p.content(p.schema(p.json(), "response-format-schema", inputs.json_schema)));
112
- return ctx.reasoning_parser + p.space() + p.choice({
113
  p.literal("```json") + p.space() + response_format + p.space() + p.literal("```"),
114
  response_format
115
  }) + p.end();
 
 
 
 
 
 
116
  }
117
-
118
- if (has_tools && inputs.tool_choice != COMMON_CHAT_TOOL_CHOICE_NONE && jinja_caps.supports_tool_calls) {
119
- return tools.build_parser(ctx);
120
- }
121
-
122
- return content.build_parser(ctx);
123
  });
124
  }
125
 
@@ -130,24 +132,15 @@ common_peg_parser analyze_reasoning::build_parser(parser_build_context & ctx) co
130
  return p.eps();
131
  }
132
 
133
- bool thinking_forced_open = (mode == reasoning_mode::FORCED_OPEN);
134
- bool thinking_forced_closed = (mode == reasoning_mode::FORCED_CLOSED);
135
-
136
- if (thinking_forced_open || thinking_forced_closed) {
137
- // Thinking is forced open OR forced closed with enable_thinking=true
138
- // In both cases, expect only the closing tag (opening was in template)
139
- // However, since we might have incorrectly detected the open/close pattern,
140
- // we admit an optional starting marker
141
- return p.optional(p.literal(start)) + p.reasoning(p.until(end)) + end;
142
- }
143
  if (mode == reasoning_mode::TAG_BASED || mode == reasoning_mode::TOOLS_ONLY) {
144
- // Standard tag-based reasoning OR tools-only mode (reasoning appears with tools)
145
- // Both use the same tag-based pattern if markers are available
146
- if (!start.empty() && !end.empty()) {
147
- return p.optional(start + p.reasoning(p.until(end)) + end);
 
 
 
148
  }
149
- } else if (mode == reasoning_mode::DELIMITER) {
150
- return p.optional(p.reasoning(p.until(end)) + end);
151
  }
152
 
153
  return p.eps();
@@ -205,10 +198,19 @@ common_peg_parser analyze_tools::build_tool_parser_json_native(parser_build_cont
205
  args_field = format.function_field + "." + args_field;
206
  }
207
 
208
- auto tools_parser = p.standard_json_tools(
209
- format.section_start, format.section_end, inputs.tools, inputs.parallel_tool_calls,
210
- inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED, name_field, args_field, format.tools_array_wrapped,
211
- format.fun_name_is_key, format.id_field, format.gen_id_field, format.parameter_order);
 
 
 
 
 
 
 
 
 
212
 
213
  // Handle content wrappers if present
214
  if (ctx.content && ctx.content->is_always_wrapped()) {
@@ -227,6 +229,44 @@ common_peg_parser analyze_tools::build_tool_parser_json_native(parser_build_cont
227
  p.end();
228
  }
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  common_peg_parser analyze_tools::build_tool_parser_tag_json(parser_build_context & ctx) const {
231
  auto & p = ctx.p;
232
  const auto & inputs = ctx.inputs;
@@ -237,20 +277,30 @@ common_peg_parser analyze_tools::build_tool_parser_tag_json(parser_build_context
237
  foreach_function(inputs.tools, [&](const json & tool) {
238
  const auto & func = tool.at("function");
239
  std::string name = func.at("name");
240
- const auto & schema = func.at("parameters");
241
 
242
  // Build call_id parser based on position (if supported)
 
243
  common_peg_parser call_id_section = p.eps();
244
  if (call_id.pos == call_id_position::BETWEEN_FUNC_AND_ARGS && !call_id.prefix.empty() &&
245
- !call_id.suffix.empty()) {
246
- call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(call_id.suffix))) + call_id.suffix;
 
 
 
 
 
247
  }
248
-
249
- auto func_parser = p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix) +
250
- call_id_section + p.tool_args(p.schema(p.json(), "tool-" + name + "-schema", schema));
251
- if (!function.close.empty()) {
252
- func_parser = func_parser + function.close;
 
253
  }
 
 
 
254
  tool_choice |= p.rule("tool-" + name, func_parser);
255
  });
256
 
@@ -295,49 +345,42 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
295
  const auto & inputs = ctx.inputs;
296
  bool force_tools = inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED;
297
 
 
 
298
  common_peg_parser tool_choice = p.choice();
299
 
300
  foreach_function(inputs.tools, [&](const json & tool) {
301
- const auto & func = tool.at("function");
302
- std::string name = func.at("name");
303
- const auto & params = func.at("parameters");
304
-
305
- if (!params.contains("properties") || !params.at("properties").is_object()) {
306
- return;
307
- }
308
 
309
- const auto & properties = params.at("properties");
310
  std::set<std::string> required;
311
- if (params.contains("required") && params.at("required").is_array()) {
312
  params.at("required").get_to(required);
313
  }
314
 
 
 
 
315
  // Build parser for each argument, separating required and optional
316
  std::vector<common_peg_parser> required_parsers;
317
  std::vector<common_peg_parser> optional_parsers;
318
  for (const auto & [param_name, param_schema] : properties.items()) {
319
- bool is_required = required.find(param_name) != required.end();
320
- std::string type = "object";
321
- auto type_obj = param_schema.contains("type") ? param_schema.at("type") : json::object();
322
- if (type_obj.is_string()) {
323
- type_obj.get_to(type);
324
- } else if (type_obj.is_object()) {
325
- if (type_obj.contains("type") && type_obj.at("type").is_string()) {
326
- type_obj.at("type").get_to(type);
327
- }
328
- }
329
-
330
- auto arg = p.tool_arg(
331
- p.tool_arg_open(arguments.name_prefix + p.tool_arg_name(p.literal(param_name)) +
332
- arguments.name_suffix) +
333
- arguments.value_prefix +
334
- (type == "string" ? p.tool_arg_string_value(p.schema(p.until(arguments.value_suffix),
335
- "tool-" + name + "-arg-" + param_name + "-schema",
336
- param_schema, true)) :
337
- p.tool_arg_json_value(p.schema(
338
- p.json(), "tool-" + name + "-arg-" + param_name + "-schema", param_schema, format.uses_python_dicts)) +
339
- p.space()) +
340
- p.tool_arg_close(p.literal(arguments.value_suffix)));
341
 
342
  auto named_arg = p.rule("tool-" + name + "-arg-" + param_name, arg);
343
  if (is_required) {
@@ -362,53 +405,34 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
362
  for (const auto & opt : optional_parsers) {
363
  any_opt |= opt;
364
  }
365
- args_seq = args_seq + p.repeat(p.space() + any_opt, 0, (int) optional_parsers.size());
 
 
 
 
 
 
 
366
  }
367
 
368
  // Build call_id parser based on position (if supported)
369
  common_peg_parser call_id_section = p.eps();
370
  bool have_call_id = false;
371
  if (call_id.pos == call_id_position::BETWEEN_FUNC_AND_ARGS && !call_id.prefix.empty() &&
372
- !call_id.suffix.empty()) {
373
  have_call_id = true;
374
- call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(call_id.suffix)) + call_id.suffix);
375
- }
376
-
377
- bool matched_atomic = false;
378
- common_peg_parser func_parser = p.eps();
379
- if (!function.name_suffix.empty()) {
380
- func_parser = p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix) +
381
- call_id_section + p.space() + args_seq;
382
- matched_atomic = true;
383
- } else if (have_call_id) {
384
- func_parser = p.atomic(p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix) +
385
- call_id_section) + p.space() + args_seq;
386
- matched_atomic = true;
387
- } else if (!arguments.name_prefix.empty() && properties.size() > 0) {
388
- func_parser = p.atomic(p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix) +
389
- call_id_section + p.space() + p.peek(p.literal(arguments.name_prefix))) + args_seq;
390
- matched_atomic = true;
391
- } else {
392
- func_parser = p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix) +
393
- call_id_section + p.space() + args_seq;
394
- }
395
-
396
- if (!function.close.empty()) {
397
- func_parser = func_parser + p.space() + p.tool_close(p.literal(function.close));
398
- } else if (!format.per_call_end.empty()) {
399
- // When there's no func_close but there is a per_call_end marker, use peek() to ensure
400
- // we only emit tool_close when we can actually see the closing marker. This prevents
401
- // premature closing during partial parsing when we've seen e.g. "</" which could be
402
- // either "</tool_call>" (end) or "<arg_key>" prefix that failed to match.
403
- func_parser = func_parser + p.tool_close(p.peek(p.literal(format.per_call_end)));
404
- } else {
405
- func_parser =
406
- func_parser + p.tool_close(p.space()); // force this to process tool closing callbacks in mapper
407
- }
408
- if (!matched_atomic) {
409
- func_parser = p.atomic(func_parser);
410
  }
411
 
 
 
 
 
 
412
  tool_choice |= p.rule("tool-" + name, func_parser);
413
  });
414
 
@@ -419,14 +443,14 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
419
  if (!format.per_call_start.empty()) {
420
  auto wrapped_call = format.per_call_start + p.space() + tool_choice + p.space() + format.per_call_end;
421
  if (inputs.parallel_tool_calls) {
422
- tool_calls = p.trigger_rule("tool-call", wrapped_call + p.zero_or_more(p.space() + wrapped_call));
423
  } else {
424
- tool_calls = p.trigger_rule("tool-call", wrapped_call);
425
  }
426
  if (!format.section_start.empty()) {
427
  tool_calls = p.trigger_rule("tool-calls",
428
  p.literal(format.section_start) + p.space() + tool_calls + p.space() +
429
- (format.section_end.empty() ? p.end() : p.literal(format.section_end)));
430
  }
431
  } else {
432
  std::string separator = ", "; // Default
 
1
+ #include "chat-auto-parser-helpers.h"
2
  #include "chat-auto-parser.h"
3
  #include "chat-peg-parser.h"
4
  #include "chat.h"
 
6
  #include "json-schema-to-grammar.h"
7
  #include "log.h"
8
  #include "nlohmann/json.hpp"
9
+ #include "peg-parser.h"
10
 
11
  #include <stdexcept>
12
  #include <string>
 
25
 
26
  namespace autoparser {
27
 
28
+ parser_build_context::parser_build_context(common_chat_peg_builder & p, const generation_params & inputs) :
29
  p(p),
30
  inputs(inputs),
31
  reasoning_parser(p.eps()) {}
32
 
33
  common_chat_params peg_generator::generate_parser(const common_chat_template & tmpl,
34
+ const struct generation_params & inputs) {
35
  // Run differential analysis to extract template structure
36
  struct autoparser autoparser;
37
  autoparser.analyze_template(tmpl);
 
39
  }
40
 
41
  common_chat_params peg_generator::generate_parser(const common_chat_template & tmpl,
42
+ const struct generation_params & inputs,
43
  const autoparser & autoparser) {
 
 
 
44
  // Create the result structure
45
  common_chat_params data;
46
  data.prompt = common_chat_template_direct_apply(tmpl, inputs);
47
  data.format = COMMON_CHAT_FORMAT_PEG_NATIVE;
48
  data.preserved_tokens = autoparser.preserved_tokens;
49
+
50
+ auto parser = autoparser.build_parser(inputs);
51
+ data.parser = parser.save();
52
 
53
  // Build grammar if tools are present
54
  bool has_tools =
 
66
  data.grammar = build_grammar([&](const common_grammar_builder & builder) {
67
  foreach_function(inputs.tools, [&](const json & tool) {
68
  const auto & function = tool.at("function");
69
+ auto schema = function.contains("parameters") ? function.at("parameters") : json::object();
70
  builder.resolve_refs(schema);
71
  });
72
+ if (has_response_format) {
73
+ auto schema = inputs.json_schema;
74
+ builder.resolve_refs(schema);
75
+ }
76
  parser.build_grammar(builder, data.grammar_lazy);
77
  });
78
 
 
87
  return data;
88
  }
89
 
90
+ common_peg_arena autoparser::build_parser(const generation_params & inputs) const {
91
  if (!analysis_complete) {
92
  throw std::invalid_argument("Cannot call build_parser on autoparser without performing analysis first, call analyze_template(...)");
93
  }
94
  return build_chat_peg_parser([&](common_chat_peg_builder & p) {
 
 
 
 
 
 
 
95
  parser_build_context ctx(p, inputs);
96
  bool extract_reasoning = inputs.reasoning_format != COMMON_REASONING_FORMAT_NONE;
 
97
 
98
+ ctx.extracting_reasoning = extract_reasoning && reasoning.mode != reasoning_mode::NONE;
99
  ctx.content = &content;
100
+ ctx.reasoning = &reasoning;
101
 
102
  // Build reasoning parser
103
  ctx.reasoning_parser = reasoning.build_parser(ctx);
104
 
105
+ auto parser = p.eps();
106
+
107
  bool has_tools = inputs.tools.is_array() && !inputs.tools.empty();
108
  bool has_response_format = inputs.json_schema.is_object() && !inputs.json_schema.empty();
109
+ bool pure_content = reasoning.mode == reasoning_mode::NONE;
110
 
111
  if (has_response_format) {
112
  auto response_format = p.rule("response-format", p.content(p.schema(p.json(), "response-format-schema", inputs.json_schema)));
113
+ parser = ctx.reasoning_parser + p.space() + p.choice({
114
  p.literal("```json") + p.space() + response_format + p.space() + p.literal("```"),
115
  response_format
116
  }) + p.end();
117
+ pure_content = false;
118
+ } else if (has_tools && inputs.tool_choice != COMMON_CHAT_TOOL_CHOICE_NONE && jinja_caps.supports_tool_calls) {
119
+ parser = tools.build_parser(ctx);
120
+ pure_content = false;
121
+ } else {
122
+ parser = content.build_parser(ctx);
123
  }
124
+ return pure_content ? p.prefix(inputs.generation_prompt, reasoning.start) + parser : p.prefix(inputs.generation_prompt, reasoning.start) << parser;
 
 
 
 
 
125
  });
126
  }
127
 
 
132
  return p.eps();
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
135
  if (mode == reasoning_mode::TAG_BASED || mode == reasoning_mode::TOOLS_ONLY) {
136
+ if (!end.empty()) {
137
+ if (!start.empty()) {
138
+ // Standard tag-based: optional(<think>reasoning</think>)
139
+ return p.optional(start + p.reasoning(p.until(end)) + end + p.space());
140
+ }
141
+ // Delimiter-style (empty start)
142
+ return p.optional(p.reasoning(p.until(end)) + end + p.space());
143
  }
 
 
144
  }
145
 
146
  return p.eps();
 
198
  args_field = format.function_field + "." + args_field;
199
  }
200
 
201
+ auto tools_parser = p.eps();
202
+ if (format.section_start.empty() && !format.per_call_start.empty()) {
203
+ auto single_tool_parser = p.standard_json_tools(
204
+ format.per_call_start, format.per_call_end, inputs.tools, inputs.parallel_tool_calls,
205
+ inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED, name_field, args_field, format.tools_array_wrapped,
206
+ format.fun_name_is_key, format.id_field, format.gen_id_field, format.parameter_order);
207
+ tools_parser = p.trigger_rule("tool-calls", p.one_or_more(single_tool_parser + p.space()));
208
+ } else {
209
+ tools_parser = p.standard_json_tools(
210
+ format.section_start, format.section_end, inputs.tools, inputs.parallel_tool_calls,
211
+ inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED, name_field, args_field, format.tools_array_wrapped,
212
+ format.fun_name_is_key, format.id_field, format.gen_id_field, format.parameter_order);
213
+ }
214
 
215
  // Handle content wrappers if present
216
  if (ctx.content && ctx.content->is_always_wrapped()) {
 
229
  p.end();
230
  }
231
 
232
+ common_peg_parser analyze_tools::build_func_parser(common_chat_peg_builder & p, const std::string & name,
233
+ const common_peg_parser & call_id_section, bool have_call_id,
234
+ const common_peg_parser & args,
235
+ std::optional<common_peg_parser> atomic_peek) const {
236
+ auto open = p.tool_open(function.name_prefix + p.tool_name(p.literal(name)) + function.name_suffix);
237
+ bool matched_atomic = false;
238
+ common_peg_parser func_parser = p.eps();
239
+
240
+ if (!function.name_suffix.empty()) {
241
+ func_parser = open + call_id_section + p.space() + args;
242
+ matched_atomic = true;
243
+ } else if (have_call_id) {
244
+ func_parser = p.atomic(open + call_id_section) + p.space() + args;
245
+ matched_atomic = true;
246
+ } else if (atomic_peek.has_value()) {
247
+ func_parser = p.atomic(open + call_id_section + p.space() + *atomic_peek) + args;
248
+ matched_atomic = true;
249
+ } else {
250
+ func_parser = open + call_id_section + p.space() + args;
251
+ }
252
+
253
+ if (!function.close.empty()) {
254
+ func_parser = func_parser + p.space() + p.tool_close(p.literal(function.close));
255
+ } else if (!format.per_call_end.empty()) {
256
+ // When there's no func_close but there is a per_call_end marker, use peek() to ensure
257
+ // we only emit tool_close when we can actually see the closing marker. This prevents
258
+ // premature closing during partial parsing when we've seen e.g. "</" which could be
259
+ // either "</tool_call>" (end) or "<arg_key>" prefix that failed to match.
260
+ func_parser = func_parser + p.tool_close(p.peek(p.literal(format.per_call_end)));
261
+ } else {
262
+ func_parser = func_parser + p.tool_close(p.space()); // force this to process tool closing callbacks in mapper
263
+ }
264
+ if (!matched_atomic) {
265
+ func_parser = p.atomic(func_parser);
266
+ }
267
+ return func_parser;
268
+ }
269
+
270
  common_peg_parser analyze_tools::build_tool_parser_tag_json(parser_build_context & ctx) const {
271
  auto & p = ctx.p;
272
  const auto & inputs = ctx.inputs;
 
277
  foreach_function(inputs.tools, [&](const json & tool) {
278
  const auto & func = tool.at("function");
279
  std::string name = func.at("name");
280
+ const auto & schema = func.contains("parameters") ? func.at("parameters") : json::object();
281
 
282
  // Build call_id parser based on position (if supported)
283
+ bool have_call_id = false;
284
  common_peg_parser call_id_section = p.eps();
285
  if (call_id.pos == call_id_position::BETWEEN_FUNC_AND_ARGS && !call_id.prefix.empty() &&
286
+ (!call_id.suffix.empty() || !arguments.start.empty())) {
287
+ if (!call_id.suffix.empty()) {
288
+ call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(call_id.suffix))) + call_id.suffix;
289
+ } else {
290
+ call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(arguments.start)));
291
+ }
292
+ have_call_id = true;
293
  }
294
+ auto args_parser = p.tool_args(p.schema(p.json(), "tool-" + name + "-schema", schema));
295
+ if (!arguments.start.empty()) {
296
+ args_parser = p.literal(arguments.start) + args_parser;
297
+ }
298
+ if (!arguments.end.empty()) {
299
+ args_parser = args_parser + p.literal(arguments.end);
300
  }
301
+
302
+ auto atomic_peek = !arguments.start.empty() ? std::optional(p.peek(p.literal(arguments.start))) : std::nullopt;
303
+ auto func_parser = build_func_parser(p, name, call_id_section, have_call_id, args_parser, atomic_peek);
304
  tool_choice |= p.rule("tool-" + name, func_parser);
305
  });
306
 
 
345
  const auto & inputs = ctx.inputs;
346
  bool force_tools = inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED;
347
 
348
+ auto until_suffix = p.rule("until-suffix", p.until(arguments.value_suffix));
349
+
350
  common_peg_parser tool_choice = p.choice();
351
 
352
  foreach_function(inputs.tools, [&](const json & tool) {
353
+ const auto & func = tool.at("function");
354
+ std::string name = func.at("name");
355
+ auto params = func.contains("parameters") ? func.at("parameters") : json::object();
356
+ const auto & properties = params.contains("properties") ? params.at("properties") : json::object();
 
 
 
357
 
 
358
  std::set<std::string> required;
359
+ if (params.contains("required")) {
360
  params.at("required").get_to(required);
361
  }
362
 
363
+ auto schema_info = common_schema_info();
364
+ schema_info.resolve_refs(params);
365
+
366
  // Build parser for each argument, separating required and optional
367
  std::vector<common_peg_parser> required_parsers;
368
  std::vector<common_peg_parser> optional_parsers;
369
  for (const auto & [param_name, param_schema] : properties.items()) {
370
+ bool is_required = required.find(param_name) != required.end();
371
+
372
+ auto arg =
373
+ p.tool_arg(p.tool_arg_open(arguments.name_prefix + p.tool_arg_name(p.literal(param_name)) +
374
+ arguments.name_suffix) +
375
+ arguments.value_prefix +
376
+ (schema_info.resolves_to_string(param_schema) ?
377
+ p.tool_arg_string_value(p.schema(until_suffix,
378
+ "tool-" + name + "-arg-" + param_name + "-schema",
379
+ param_schema, true)) :
380
+ p.tool_arg_json_value(p.schema(
381
+ p.json(), "tool-" + name + "-arg-" + param_name + "-schema", param_schema, false)) +
382
+ p.space()) +
383
+ p.tool_arg_close(p.literal(arguments.value_suffix)));
 
 
 
 
 
 
 
 
384
 
385
  auto named_arg = p.rule("tool-" + name + "-arg-" + param_name, arg);
386
  if (is_required) {
 
405
  for (const auto & opt : optional_parsers) {
406
  any_opt |= opt;
407
  }
408
+ args_seq = args_seq + p.repeat(p.space() + any_opt, 0, -1);
409
+ }
410
+
411
+ if (!arguments.start.empty()) {
412
+ args_seq = p.literal(arguments.start) + args_seq;
413
+ }
414
+ if (!arguments.end.empty()) {
415
+ args_seq = args_seq + p.literal(arguments.end);
416
  }
417
 
418
  // Build call_id parser based on position (if supported)
419
  common_peg_parser call_id_section = p.eps();
420
  bool have_call_id = false;
421
  if (call_id.pos == call_id_position::BETWEEN_FUNC_AND_ARGS && !call_id.prefix.empty() &&
422
+ (!call_id.suffix.empty() || !arguments.start.empty())) {
423
  have_call_id = true;
424
+ if (!call_id.suffix.empty()) {
425
+ call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(call_id.suffix)) + call_id.suffix);
426
+ } else {
427
+ call_id_section = p.optional(call_id.prefix + p.tool_id(p.until(arguments.start)));
428
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  }
430
 
431
+ // Only peek for an arg tag when there are required args that must follow.
432
+ // When all args are optional, the model may emit no arg tags at all (#20650).
433
+ auto atomic_peek = (!arguments.name_prefix.empty() && !required_parsers.empty()) ?
434
+ std::optional(p.peek(p.literal(arguments.name_prefix))) : std::nullopt;
435
+ auto func_parser = build_func_parser(p, name, call_id_section, have_call_id, args_seq, atomic_peek);
436
  tool_choice |= p.rule("tool-" + name, func_parser);
437
  });
438
 
 
443
  if (!format.per_call_start.empty()) {
444
  auto wrapped_call = format.per_call_start + p.space() + tool_choice + p.space() + format.per_call_end;
445
  if (inputs.parallel_tool_calls) {
446
+ tool_calls = p.trigger_rule("tool-call", wrapped_call + p.zero_or_more(p.space() + wrapped_call) + p.space());
447
  } else {
448
+ tool_calls = p.trigger_rule("tool-call", wrapped_call + p.space());
449
  }
450
  if (!format.section_start.empty()) {
451
  tool_calls = p.trigger_rule("tool-calls",
452
  p.literal(format.section_start) + p.space() + tool_calls + p.space() +
453
+ (format.section_end.empty() ? p.end() : p.literal(format.section_end) + p.space()));
454
  }
455
  } else {
456
  std::string separator = ", "; // Default
common/chat-auto-parser-helpers.cpp CHANGED
@@ -1,9 +1,11 @@
1
  #include "chat-auto-parser-helpers.h"
2
 
3
  #include "chat-auto-parser.h"
 
4
  #include "chat.h"
5
  #include "log.h"
6
  #include "nlohmann/json.hpp"
 
7
 
8
  #include <cctype>
9
  #include <numeric>
@@ -186,6 +188,21 @@ diff_split calculate_diff_split(const std::string & left, const std::string & ri
186
  result.suffix = "";
187
  // pick prefix = all as representation
188
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  return result;
190
  }
191
 
@@ -294,7 +311,7 @@ std::vector<segment> prune_whitespace_segments(const std::vector<segment> & segm
294
  namespace autoparser {
295
 
296
  std::string apply_template(const common_chat_template & tmpl, const template_params & params) {
297
- templates_params tmpl_params;
298
  tmpl_params.messages = params.messages;
299
  tmpl_params.tools = params.tools;
300
  tmpl_params.add_generation_prompt = params.add_generation_prompt;
 
1
  #include "chat-auto-parser-helpers.h"
2
 
3
  #include "chat-auto-parser.h"
4
+ #include "chat-peg-parser.h"
5
  #include "chat.h"
6
  #include "log.h"
7
  #include "nlohmann/json.hpp"
8
+ #include "peg-parser.h"
9
 
10
  #include <cctype>
11
  #include <numeric>
 
188
  result.suffix = "";
189
  // pick prefix = all as representation
190
  }
191
+
192
+ // When left has no unique content (result.left is empty), left is entirely
193
+ // shared with right. The simultaneous prefix/suffix segment matching can
194
+ // incorrectly consume trailing segments of left as suffix when those same
195
+ // segments also appear at the end of right (e.g. "\n" at the end of both
196
+ // the shared content and the generation prompt). This rotates the diff.
197
+ // Fix: if left is a prefix of right, enforce that directly.
198
+ if (result.left.empty() && !result.right.empty() &&
199
+ left.size() <= right.size() &&
200
+ right.substr(0, left.size()) == left) {
201
+ result.prefix = left;
202
+ result.suffix = "";
203
+ result.right = right.substr(left.size());
204
+ }
205
+
206
  return result;
207
  }
208
 
 
311
  namespace autoparser {
312
 
313
  std::string apply_template(const common_chat_template & tmpl, const template_params & params) {
314
+ generation_params tmpl_params;
315
  tmpl_params.messages = params.messages;
316
  tmpl_params.tools = params.tools;
317
  tmpl_params.add_generation_prompt = params.add_generation_prompt;