Skip to content

Commit 955fed3

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 b13c429 commit 955fed3

21 files changed

Lines changed: 778 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
@@ -6176,6 +6176,68 @@ include:
61766176
context: "./"
61776177
ubuntu-version: '2404'
61786178

6179+
# CachyLLaMA targets the lower-spec/APU use case with CPU and Vulkan builds.
6180+
- build-type: ''
6181+
cuda-major-version: ""
6182+
cuda-minor-version: ""
6183+
platforms: 'linux/amd64'
6184+
platform-tag: 'amd64'
6185+
tag-latest: 'auto'
6186+
tag-suffix: '-cpu-cachyllama'
6187+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-amd64'
6188+
runs-on: 'ubuntu-latest'
6189+
base-image: "ubuntu:24.04"
6190+
skip-drivers: 'false'
6191+
backend: "cachyllama"
6192+
dockerfile: "./backend/Dockerfile.cachyllama"
6193+
context: "./"
6194+
ubuntu-version: '2404'
6195+
- build-type: ''
6196+
cuda-major-version: ""
6197+
cuda-minor-version: ""
6198+
platforms: 'linux/arm64'
6199+
platform-tag: 'arm64'
6200+
tag-latest: 'auto'
6201+
tag-suffix: '-cpu-cachyllama'
6202+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-arm64'
6203+
runs-on: 'ubuntu-24.04-arm'
6204+
base-image: "ubuntu:24.04"
6205+
skip-drivers: 'false'
6206+
backend: "cachyllama"
6207+
dockerfile: "./backend/Dockerfile.cachyllama"
6208+
context: "./"
6209+
ubuntu-version: '2404'
6210+
- build-type: 'vulkan'
6211+
cuda-major-version: ""
6212+
cuda-minor-version: ""
6213+
platforms: 'linux/amd64'
6214+
platform-tag: 'amd64'
6215+
tag-latest: 'auto'
6216+
tag-suffix: '-gpu-vulkan-cachyllama'
6217+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-vulkan-amd64'
6218+
runs-on: 'ubuntu-latest'
6219+
base-image: "ubuntu:24.04"
6220+
skip-drivers: 'false'
6221+
backend: "cachyllama"
6222+
dockerfile: "./backend/Dockerfile.cachyllama"
6223+
context: "./"
6224+
ubuntu-version: '2404'
6225+
- build-type: 'vulkan'
6226+
cuda-major-version: ""
6227+
cuda-minor-version: ""
6228+
platforms: 'linux/arm64'
6229+
platform-tag: 'arm64'
6230+
tag-latest: 'auto'
6231+
tag-suffix: '-gpu-vulkan-cachyllama'
6232+
builder-base-image: 'quay.io/go-skynet/ci-cache:base-grpc-vulkan-arm64'
6233+
runs-on: 'ubuntu-24.04-arm'
6234+
base-image: "ubuntu:24.04"
6235+
skip-drivers: 'false'
6236+
backend: "cachyllama"
6237+
dockerfile: "./backend/Dockerfile.cachyllama"
6238+
context: "./"
6239+
ubuntu-version: '2404'
6240+
61796241
# Darwin matrix (consumed by backend-jobs-darwin).
61806242
includeDarwin:
61816243
- backend: "diffusers"
@@ -6202,6 +6264,9 @@ includeDarwin:
62026264
- backend: "llama-cpp"
62036265
tag-suffix: "-metal-darwin-arm64-llama-cpp"
62046266
lang: "go"
6267+
- backend: "cachyllama"
6268+
tag-suffix: "-metal-darwin-arm64-cachyllama"
6269+
lang: "go"
62056270
- backend: "stablediffusion-ggml"
62066271
tag-suffix: "-metal-darwin-arm64-stablediffusion-ggml"
62076272
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: |
@@ -256,7 +262,7 @@ jobs:
256262
make backends/audio-cpp-darwin
257263
258264
- name: Build ${{ inputs.backend }}-darwin
259-
if: inputs.backend != 'llama-cpp' && inputs.backend != 'ds4' && inputs.backend != 'privacy-filter' && inputs.backend != 'audio-cpp'
265+
if: inputs.backend != 'llama-cpp' && inputs.backend != 'cachyllama' && inputs.backend != 'ds4' && inputs.backend != 'privacy-filter' && inputs.backend != 'audio-cpp'
260266
run: |
261267
make protogen-go
262268
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 backends/audio-cpp backends/audio-cpp-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 backends/audio-cpp backends/audio-cpp-darwin
33

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

1213+
backends/cachyllama-darwin: build
1214+
bash ./scripts/build/cachyllama-darwin.sh
1215+
./local-ai backends install "ocifile://$(abspath ./backend-images/cachyllama.tar)"
1216+
12131217
backends/ds4-darwin: build
12141218
bash ./scripts/build/ds4-darwin.sh
12151219
./local-ai backends install "ocifile://$(abspath ./backend-images/ds4.tar)"
@@ -1267,6 +1271,8 @@ BACKEND_IK_LLAMA_CPP = ik-llama-cpp|ik-llama-cpp|.|false|false
12671271
# turboquant is a llama.cpp fork with TurboQuant KV-cache quantization.
12681272
# Reuses backend/cpp/llama-cpp grpc-server sources via a thin wrapper Makefile.
12691273
BACKEND_TURBOQUANT = turboquant|turboquant|.|false|false
1274+
# CachyLLaMA is a llama.cpp fork with persistent SSD prompt caching and APU tuning.
1275+
BACKEND_CACHYLLAMA = cachyllama|cachyllama|.|false|false
12701276
# bonsai is a llama.cpp fork (PrismML) adding the Q1_0 (1-bit) and Q2_0 (ternary)
12711277
# weight-quant kernels the Bonsai / Ternary-Bonsai models ship in. Reuses
12721278
# backend/cpp/llama-cpp grpc-server sources via a thin wrapper Makefile.
@@ -1384,6 +1390,7 @@ endef
13841390
$(eval $(call generate-docker-build-target,$(BACKEND_LLAMA_CPP)))
13851391
$(eval $(call generate-docker-build-target,$(BACKEND_IK_LLAMA_CPP)))
13861392
$(eval $(call generate-docker-build-target,$(BACKEND_TURBOQUANT)))
1393+
$(eval $(call generate-docker-build-target,$(BACKEND_CACHYLLAMA)))
13871394
$(eval $(call generate-docker-build-target,$(BACKEND_BONSAI)))
13881395
$(eval $(call generate-docker-build-target,$(BACKEND_DS4)))
13891396
$(eval $(call generate-docker-build-target,$(BACKEND_PRIVACY_FILTER)))
@@ -1456,7 +1463,7 @@ $(eval $(call generate-docker-build-target,$(BACKEND_SUPERTONIC)))
14561463
docker-save-%: backend-images
14571464
docker save local-ai-backend:$* -o backend-images/$*.tar
14581465

1459-
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 docker-build-audio-cpp
1466+
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 docker-build-audio-cpp
14601467

14611468
########################################################
14621469
### Mock Backend for E2E Tests

0 commit comments

Comments
 (0)