Skip to content

Commit c4b5ed8

Browse files
feat(backends): add CachyLLaMA support
Add CachyLLaMA as a GGUF-compatible llama.cpp fork backend with CPU and Vulkan builds on Linux and Metal on Apple silicon. Expose it through model import, document persistent SSD cache options, and wire CI path filtering and dependency updates. Assisted-by: Codex:gpt-5
1 parent 9bfd713 commit c4b5ed8

21 files changed

Lines changed: 777 additions & 13 deletions

.docker/cachyllama-compile.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Shared compile logic for backend/Dockerfile.cachyllama.
3+
# Sourced (via bind mount) from both builder-fromsource and builder-prebuilt stages.
4+
5+
set -euxo pipefail
6+
7+
export CCACHE_DIR=/root/.ccache
8+
ccache --max-size=5G || true
9+
ccache -z || true
10+
11+
export CMAKE_ARGS="${CMAKE_ARGS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache"
12+
13+
if [[ -n "${CUDA_DOCKER_ARCH:-}" ]]; then
14+
CUDA_ARCH_ESC="${CUDA_DOCKER_ARCH//;/\\;}"
15+
export CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCH_ESC}"
16+
echo "CMAKE_ARGS(env) = ${CMAKE_ARGS}"
17+
rm -rf /LocalAI/backend/cpp/cachyllama-*-build
18+
fi
19+
20+
cd /LocalAI/backend/cpp/cachyllama
21+
22+
if [ -z "${BUILD_TYPE:-}" ]; then
23+
# Pure CPU image: one ggml CPU_ALL_VARIANTS build replaces the per-microarch binaries.
24+
# arm64: the armv9.2 SME variants need gcc-14 (gcc-13 rejects +sme).
25+
if [ "${TARGETARCH}" = "arm64" ]; then
26+
apt-get update -qq && apt-get install -y -qq gcc-14 g++-14
27+
export CC=gcc-14 CXX=g++-14
28+
fi
29+
make cachyllama-cpu-all
30+
else
31+
# GPU build (cublas/hipblas/sycl/vulkan/...): single fallback CPU build, the accelerator
32+
# does the compute. Keeps the GPU compile from also building the CPU variant matrix and
33+
# avoids the gcc-14 apt step on GPU base images such as nvidia l4t.
34+
make cachyllama-fallback
35+
fi
36+
make cachyllama-grpc
37+
make cachyllama-rpc-server
38+
39+
ccache -s || true

.github/backend-matrix.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6085,6 +6085,68 @@ include:
60856085
context: "./"
60866086
ubuntu-version: '2404'
60876087

6088+
# CachyLLaMA targets the lower-spec/APU use case with CPU and Vulkan builds.
6089+
- build-type: ''
6090+
cuda-major-version: ""
6091+
cuda-minor-version: ""
6092+
platforms: 'linux/amd64'
6093+
platform-tag: 'amd64'
6094+
tag-latest: 'auto'
6095+
tag-suffix: '-cpu-cachyllama'
6096+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-amd64'
6097+
runs-on: 'ubuntu-latest'
6098+
base-image: "ubuntu:24.04"
6099+
skip-drivers: 'false'
6100+
backend: "cachyllama"
6101+
dockerfile: "./backend/Dockerfile.cachyllama"
6102+
context: "./"
6103+
ubuntu-version: '2404'
6104+
- build-type: ''
6105+
cuda-major-version: ""
6106+
cuda-minor-version: ""
6107+
platforms: 'linux/arm64'
6108+
platform-tag: 'arm64'
6109+
tag-latest: 'auto'
6110+
tag-suffix: '-cpu-cachyllama'
6111+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-arm64'
6112+
runs-on: 'ubuntu-24.04-arm'
6113+
base-image: "ubuntu:24.04"
6114+
skip-drivers: 'false'
6115+
backend: "cachyllama"
6116+
dockerfile: "./backend/Dockerfile.cachyllama"
6117+
context: "./"
6118+
ubuntu-version: '2404'
6119+
- build-type: 'vulkan'
6120+
cuda-major-version: ""
6121+
cuda-minor-version: ""
6122+
platforms: 'linux/amd64'
6123+
platform-tag: 'amd64'
6124+
tag-latest: 'auto'
6125+
tag-suffix: '-gpu-vulkan-cachyllama'
6126+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-vulkan-amd64'
6127+
runs-on: 'ubuntu-latest'
6128+
base-image: "ubuntu:24.04"
6129+
skip-drivers: 'false'
6130+
backend: "cachyllama"
6131+
dockerfile: "./backend/Dockerfile.cachyllama"
6132+
context: "./"
6133+
ubuntu-version: '2404'
6134+
- build-type: 'vulkan'
6135+
cuda-major-version: ""
6136+
cuda-minor-version: ""
6137+
platforms: 'linux/arm64'
6138+
platform-tag: 'arm64'
6139+
tag-latest: 'auto'
6140+
tag-suffix: '-gpu-vulkan-cachyllama'
6141+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-vulkan-arm64'
6142+
runs-on: 'ubuntu-24.04-arm'
6143+
base-image: "ubuntu:24.04"
6144+
skip-drivers: 'false'
6145+
backend: "cachyllama"
6146+
dockerfile: "./backend/Dockerfile.cachyllama"
6147+
context: "./"
6148+
ubuntu-version: '2404'
6149+
60886150
# Darwin matrix (consumed by backend-jobs-darwin).
60896151
includeDarwin:
60906152
- backend: "diffusers"
@@ -6111,6 +6173,9 @@ includeDarwin:
61116173
- backend: "llama-cpp"
61126174
tag-suffix: "-metal-darwin-arm64-llama-cpp"
61136175
lang: "go"
6176+
- backend: "cachyllama"
6177+
tag-suffix: "-metal-darwin-arm64-cachyllama"
6178+
lang: "go"
61146179
- backend: "stablediffusion-ggml"
61156180
tag-suffix: "-metal-darwin-arm64-stablediffusion-ggml"
61166181
build-type: "metal"

.github/workflows/backend_build_darwin.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ jobs:
230230
make protogen-go
231231
make backends/llama-cpp-darwin
232232
233+
- name: Build CachyLLaMA backend (Darwin Metal)
234+
if: inputs.backend == 'cachyllama'
235+
run: |
236+
make protogen-go
237+
make backends/cachyllama-darwin
238+
233239
- name: Build ds4 backend (Darwin Metal)
234240
if: inputs.backend == 'ds4'
235241
run: |
@@ -245,7 +251,7 @@ jobs:
245251
make backends/privacy-filter-darwin
246252
247253
- name: Build ${{ inputs.backend }}-darwin
248-
if: inputs.backend != 'llama-cpp' && inputs.backend != 'ds4' && inputs.backend != 'privacy-filter'
254+
if: inputs.backend != 'llama-cpp' && inputs.backend != 'cachyllama' && inputs.backend != 'ds4' && inputs.backend != 'privacy-filter'
249255
run: |
250256
make protogen-go
251257
BACKEND=${{ inputs.backend }} BUILD_TYPE=${{ inputs.build-type }} USE_PIP=${{ inputs.use-pip }} make build-darwin-${{ inputs.lang }}-backend

.github/workflows/bump_deps.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
variable: "TURBOQUANT_VERSION"
2323
branch: "feature/turboquant-kv-cache"
2424
file: "backend/cpp/turboquant/Makefile"
25+
- repository: "fewtarius/CachyLLama"
26+
variable: "CACHYLLAMA_VERSION"
27+
branch: "master"
28+
file: "backend/cpp/cachyllama/Makefile"
2529
- repository: "PrismML-Eng/llama.cpp"
2630
variable: "BONSAI_VERSION"
2731
branch: "prism"

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Disable parallel execution for backend builds
2-
.NOTPARALLEL: backends/diffusers backends/llama-cpp backends/turboquant backends/bonsai backends/outetts backends/piper backends/stablediffusion-ggml backends/trellis2cpp backends/trellis2cpp-darwin backends/whisper backends/crispasr backends/parakeet-cpp backends/moss-transcribe-cpp backends/faster-whisper backends/silero-vad backends/local-store backends/valkey-store backends/cloud-proxy backends/huggingface backends/rfdetr backends/rfdetr-cpp backends/insightface backends/speaker-recognition backends/kitten-tts backends/kokoro backends/chatterbox backends/llama-cpp-darwin backends/neutts build-darwin-python-backend build-darwin-go-backend backends/mlx backends/diffuser-darwin backends/mlx-vlm backends/mlx-audio backends/mlx-distributed backends/stablediffusion-ggml-darwin backends/vllm backends/vllm-omni backends/longcat-video backends/sglang backends/moonshine backends/pocket-tts backends/qwen-tts backends/faster-qwen3-tts backends/qwen-asr backends/nemo backends/voxcpm backends/whisperx backends/ace-step backends/acestep-cpp backends/fish-speech backends/voxtral backends/opus backends/trl backends/llama-cpp-quantization backends/kokoros backends/sam3-cpp backends/qwen3-tts-cpp backends/moss-tts-cpp backends/magpie-tts-cpp backends/vllm-cpp backends/omnivoice-cpp backends/vibevoice-cpp backends/localvqe backends/tinygrad backends/sherpa-onnx backends/ds4 backends/ds4-darwin backends/liquid-audio backends/supertonic backends/depth-anything-cpp backends/privacy-filter backends/privacy-filter-darwin
2+
.NOTPARALLEL: backends/diffusers backends/llama-cpp backends/turboquant backends/cachyllama backends/cachyllama-darwin backends/bonsai backends/outetts backends/piper backends/stablediffusion-ggml backends/trellis2cpp backends/trellis2cpp-darwin backends/whisper backends/crispasr backends/parakeet-cpp backends/moss-transcribe-cpp backends/faster-whisper backends/silero-vad backends/local-store backends/valkey-store backends/cloud-proxy backends/huggingface backends/rfdetr backends/rfdetr-cpp backends/insightface backends/speaker-recognition backends/kitten-tts backends/kokoro backends/chatterbox backends/llama-cpp-darwin backends/neutts build-darwin-python-backend build-darwin-go-backend backends/mlx backends/diffuser-darwin backends/mlx-vlm backends/mlx-audio backends/mlx-distributed backends/stablediffusion-ggml-darwin backends/vllm backends/vllm-omni backends/longcat-video backends/sglang backends/moonshine backends/pocket-tts backends/qwen-tts backends/faster-qwen3-tts backends/qwen-asr backends/nemo backends/voxcpm backends/whisperx backends/ace-step backends/acestep-cpp backends/fish-speech backends/voxtral backends/opus backends/trl backends/llama-cpp-quantization backends/kokoros backends/sam3-cpp backends/qwen3-tts-cpp backends/moss-tts-cpp backends/magpie-tts-cpp backends/vllm-cpp backends/omnivoice-cpp backends/vibevoice-cpp backends/localvqe backends/tinygrad backends/sherpa-onnx backends/ds4 backends/ds4-darwin backends/liquid-audio backends/supertonic backends/depth-anything-cpp backends/privacy-filter backends/privacy-filter-darwin
33

44
GOCMD=go
55
GOTEST=$(GOCMD) test
@@ -1193,6 +1193,10 @@ backends/llama-cpp-darwin: build
11931193
bash ./scripts/build/llama-cpp-darwin.sh
11941194
./local-ai backends install "ocifile://$(abspath ./backend-images/llama-cpp.tar)"
11951195

1196+
backends/cachyllama-darwin: build
1197+
bash ./scripts/build/cachyllama-darwin.sh
1198+
./local-ai backends install "ocifile://$(abspath ./backend-images/cachyllama.tar)"
1199+
11961200
backends/ds4-darwin: build
11971201
bash ./scripts/build/ds4-darwin.sh
11981202
./local-ai backends install "ocifile://$(abspath ./backend-images/ds4.tar)"
@@ -1246,6 +1250,8 @@ BACKEND_IK_LLAMA_CPP = ik-llama-cpp|ik-llama-cpp|.|false|false
12461250
# turboquant is a llama.cpp fork with TurboQuant KV-cache quantization.
12471251
# Reuses backend/cpp/llama-cpp grpc-server sources via a thin wrapper Makefile.
12481252
BACKEND_TURBOQUANT = turboquant|turboquant|.|false|false
1253+
# CachyLLaMA is a llama.cpp fork with persistent SSD prompt caching and APU tuning.
1254+
BACKEND_CACHYLLAMA = cachyllama|cachyllama|.|false|false
12491255
# bonsai is a llama.cpp fork (PrismML) adding the Q1_0 (1-bit) and Q2_0 (ternary)
12501256
# weight-quant kernels the Bonsai / Ternary-Bonsai models ship in. Reuses
12511257
# backend/cpp/llama-cpp grpc-server sources via a thin wrapper Makefile.
@@ -1358,6 +1364,7 @@ endef
13581364
$(eval $(call generate-docker-build-target,$(BACKEND_LLAMA_CPP)))
13591365
$(eval $(call generate-docker-build-target,$(BACKEND_IK_LLAMA_CPP)))
13601366
$(eval $(call generate-docker-build-target,$(BACKEND_TURBOQUANT)))
1367+
$(eval $(call generate-docker-build-target,$(BACKEND_CACHYLLAMA)))
13611368
$(eval $(call generate-docker-build-target,$(BACKEND_BONSAI)))
13621369
$(eval $(call generate-docker-build-target,$(BACKEND_DS4)))
13631370
$(eval $(call generate-docker-build-target,$(BACKEND_PRIVACY_FILTER)))
@@ -1429,7 +1436,7 @@ $(eval $(call generate-docker-build-target,$(BACKEND_SUPERTONIC)))
14291436
docker-save-%: backend-images
14301437
docker save local-ai-backend:$* -o backend-images/$*.tar
14311438

1432-
docker-build-backends: docker-build-llama-cpp docker-build-ik-llama-cpp docker-build-turboquant docker-build-bonsai docker-build-ds4 docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-longcat-video docker-build-sglang docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-crispasr docker-build-coqui docker-build-chatterbox docker-build-vibevoice docker-build-liquid-audio docker-build-moonshine docker-build-pocket-tts docker-build-qwen-tts docker-build-fish-speech docker-build-faster-qwen3-tts docker-build-qwen-asr docker-build-nemo docker-build-voxcpm docker-build-whisperx docker-build-ace-step docker-build-acestep-cpp docker-build-voxtral docker-build-mlx-distributed docker-build-trl docker-build-llama-cpp-quantization docker-build-tinygrad docker-build-kokoros docker-build-sam3-cpp docker-build-rfdetr-cpp docker-build-qwen3-tts-cpp docker-build-moss-tts-cpp docker-build-magpie-tts-cpp docker-build-vllm-cpp docker-build-omnivoice-cpp docker-build-vibevoice-cpp docker-build-localvqe docker-build-insightface docker-build-speaker-recognition docker-build-sherpa-onnx docker-build-cloud-proxy docker-build-supertonic docker-build-depth-anything-cpp docker-build-moss-transcribe-cpp docker-build-privacy-filter docker-build-trellis2cpp docker-build-valkey-store
1439+
docker-build-backends: docker-build-llama-cpp docker-build-ik-llama-cpp docker-build-turboquant docker-build-cachyllama docker-build-bonsai docker-build-ds4 docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-longcat-video docker-build-sglang docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-crispasr docker-build-coqui docker-build-chatterbox docker-build-vibevoice docker-build-liquid-audio docker-build-moonshine docker-build-pocket-tts docker-build-qwen-tts docker-build-fish-speech docker-build-faster-qwen3-tts docker-build-qwen-asr docker-build-nemo docker-build-voxcpm docker-build-whisperx docker-build-ace-step docker-build-acestep-cpp docker-build-voxtral docker-build-mlx-distributed docker-build-trl docker-build-llama-cpp-quantization docker-build-tinygrad docker-build-kokoros docker-build-sam3-cpp docker-build-rfdetr-cpp docker-build-qwen3-tts-cpp docker-build-moss-tts-cpp docker-build-magpie-tts-cpp docker-build-vllm-cpp docker-build-omnivoice-cpp docker-build-vibevoice-cpp docker-build-localvqe docker-build-insightface docker-build-speaker-recognition docker-build-sherpa-onnx docker-build-cloud-proxy docker-build-supertonic docker-build-depth-anything-cpp docker-build-moss-transcribe-cpp docker-build-privacy-filter docker-build-trellis2cpp docker-build-valkey-store
14331440

14341441
########################################################
14351442
### Mock Backend for E2E Tests

0 commit comments

Comments
 (0)