Skip to content

Commit 9e4f5d6

Browse files
committed
feat(backend): add buun-llama-cpp fork (DFlash + TCQ KV-cache)
spiritbuun/buun-llama-cpp is a fork of TheTom/llama-cpp-turboquant that adds two independent features on top: DFlash block-diffusion speculative decoding (via a dedicated DFlashDraftModel GGUF arch) and two extra TCQ KV-cache variants (turbo2_tcq, turbo3_tcq) on top of TurboQuant's turbo2/turbo3/turbo4. Follows the turboquant thin-wrapper pattern — reuses backend/cpp/llama-cpp grpc-server sources verbatim, patches only the build copy to extend the KV allow-list and wire up buun-exclusive tree_budget / draft_topk options. DraftModel is already wired end-to-end (proto field 39 → params.speculative), so DFlash activation only needs the existing options passthrough (spec_type:dflash) plus the drafter path in draft_model. CacheTypeOptions now surfaces the five turbo* values so the React UI dropdown shows them — benefits turboquant too (previously users had to type them in YAML manually). Assisted-by: Claude:Opus-4.7 [Read] [Edit] [Bash] [WebFetch]
1 parent 5e062b4 commit 9e4f5d6

11 files changed

Lines changed: 797 additions & 3 deletions

File tree

Makefile

Lines changed: 21 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/outetts backends/piper backends/stablediffusion-ggml backends/whisper backends/faster-whisper backends/silero-vad backends/local-store backends/huggingface backends/rfdetr 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/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/tinygrad
2+
.NOTPARALLEL: backends/diffusers backends/llama-cpp backends/turboquant backends/buun-llama-cpp backends/outetts backends/piper backends/stablediffusion-ggml backends/whisper backends/faster-whisper backends/silero-vad backends/local-store backends/huggingface backends/rfdetr 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/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/tinygrad
33

44
GOCMD=go
55
GOTEST=$(GOCMD) test
@@ -545,6 +545,19 @@ test-extra-backend-turboquant: docker-build-turboquant
545545
BACKEND_TEST_CACHE_TYPE_V=turbo3 \
546546
$(MAKE) test-extra-backend
547547

548+
## buun-llama-cpp: exercises the fork-of-a-fork backend (spiritbuun/buun-llama-cpp)
549+
## with the *TurboQuant/TCQ-specific* KV-cache types (turbo3 for V). Same rationale
550+
## as turboquant above: picking a standard llama.cpp type would only re-test the
551+
## shared code path. buun inherits turboquant's turbo2/turbo3/turbo4 and adds
552+
## turbo2_tcq / turbo3_tcq on top. DFlash speculative decoding is not exercised
553+
## here because no small DFlash drafter model exists (the known public pair is
554+
## Qwen3.5-27B, ~54 GB).
555+
test-extra-backend-buun-llama-cpp: docker-build-buun-llama-cpp
556+
BACKEND_IMAGE=local-ai-backend:buun-llama-cpp \
557+
BACKEND_TEST_CACHE_TYPE_K=q8_0 \
558+
BACKEND_TEST_CACHE_TYPE_V=turbo3 \
559+
$(MAKE) test-extra-backend
560+
548561
## Audio transcription wrapper for the llama-cpp backend.
549562
## Drives the new AudioTranscription / AudioTranscriptionStream RPCs against
550563
## ggml-org/Qwen3-ASR-0.6B-GGUF (a small ASR model that requires its mmproj
@@ -911,6 +924,11 @@ BACKEND_IK_LLAMA_CPP = ik-llama-cpp|ik-llama-cpp|.|false|false
911924
# turboquant is a llama.cpp fork with TurboQuant KV-cache quantization.
912925
# Reuses backend/cpp/llama-cpp grpc-server sources via a thin wrapper Makefile.
913926
BACKEND_TURBOQUANT = turboquant|turboquant|.|false|false
927+
# buun-llama-cpp is a fork-of-a-fork (spiritbuun/buun-llama-cpp forks
928+
# TheTom/llama-cpp-turboquant) that adds DFlash block-diffusion speculative
929+
# decoding and extra TCQ KV-cache variants on top of TurboQuant. Same thin
930+
# wrapper pattern as turboquant — reuses backend/cpp/llama-cpp grpc-server.
931+
BACKEND_BUUN_LLAMA_CPP = buun-llama-cpp|buun-llama-cpp|.|false|false
914932

915933
# Golang backends
916934
BACKEND_PIPER = piper|golang|.|false|true
@@ -990,6 +1008,7 @@ endef
9901008
$(eval $(call generate-docker-build-target,$(BACKEND_LLAMA_CPP)))
9911009
$(eval $(call generate-docker-build-target,$(BACKEND_IK_LLAMA_CPP)))
9921010
$(eval $(call generate-docker-build-target,$(BACKEND_TURBOQUANT)))
1011+
$(eval $(call generate-docker-build-target,$(BACKEND_BUUN_LLAMA_CPP)))
9931012
$(eval $(call generate-docker-build-target,$(BACKEND_PIPER)))
9941013
$(eval $(call generate-docker-build-target,$(BACKEND_LOCAL_STORE)))
9951014
$(eval $(call generate-docker-build-target,$(BACKEND_HUGGINGFACE)))
@@ -1040,7 +1059,7 @@ $(eval $(call generate-docker-build-target,$(BACKEND_SAM3_CPP)))
10401059
docker-save-%: backend-images
10411060
docker save local-ai-backend:$* -o backend-images/$*.tar
10421061

1043-
docker-build-backends: docker-build-llama-cpp docker-build-ik-llama-cpp docker-build-turboquant docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-sglang docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-coqui docker-build-chatterbox docker-build-vibevoice 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-qwen3-tts-cpp docker-build-insightface docker-build-speaker-recognition
1062+
docker-build-backends: docker-build-llama-cpp docker-build-ik-llama-cpp docker-build-turboquant docker-build-buun-llama-cpp docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-sglang docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-coqui docker-build-chatterbox docker-build-vibevoice 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-qwen3-tts-cpp docker-build-insightface docker-build-speaker-recognition
10441063

10451064
########################################################
10461065
### Mock Backend for E2E Tests

backend/Dockerfile.buun-llama-cpp

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
ARG BASE_IMAGE=ubuntu:24.04
2+
ARG GRPC_BASE_IMAGE=${BASE_IMAGE}
3+
4+
5+
# The grpc target does one thing, it builds and installs GRPC. This is in it's own layer so that it can be effectively cached by CI.
6+
# You probably don't need to change anything here, and if you do, make sure that CI is adjusted so that the cache continues to work.
7+
FROM ${GRPC_BASE_IMAGE} AS grpc
8+
9+
# This is a bit of a hack, but it's required in order to be able to effectively cache this layer in CI
10+
ARG GRPC_MAKEFLAGS="-j4 -Otarget"
11+
ARG GRPC_VERSION=v1.65.0
12+
ARG CMAKE_FROM_SOURCE=false
13+
# CUDA Toolkit 13.x compatibility: CMake 3.31.9+ fixes toolchain detection/arch table issues
14+
ARG CMAKE_VERSION=3.31.10
15+
16+
ENV MAKEFLAGS=${GRPC_MAKEFLAGS}
17+
18+
WORKDIR /build
19+
20+
RUN apt-get update && \
21+
apt-get install -y --no-install-recommends \
22+
ca-certificates \
23+
build-essential curl libssl-dev \
24+
git wget && \
25+
apt-get clean && \
26+
rm -rf /var/lib/apt/lists/*
27+
28+
# Install CMake (the version in 22.04 is too old)
29+
RUN <<EOT bash
30+
if [ "${CMAKE_FROM_SOURCE}" = "true" ]; then
31+
curl -L -s https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz -o cmake.tar.gz && tar xvf cmake.tar.gz && cd cmake-${CMAKE_VERSION} && ./configure && make && make install
32+
else
33+
apt-get update && \
34+
apt-get install -y \
35+
cmake && \
36+
apt-get clean && \
37+
rm -rf /var/lib/apt/lists/*
38+
fi
39+
EOT
40+
41+
# We install GRPC to a different prefix here so that we can copy in only the build artifacts later
42+
# saves several hundred MB on the final docker image size vs copying in the entire GRPC source tree
43+
# and running make install in the target container
44+
RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
45+
mkdir -p /build/grpc/cmake/build && \
46+
cd /build/grpc/cmake/build && \
47+
sed -i "216i\ TESTONLY" "../../third_party/abseil-cpp/absl/container/CMakeLists.txt" && \
48+
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH=/opt/grpc ../.. && \
49+
make && \
50+
make install && \
51+
rm -rf /build
52+
53+
FROM ${BASE_IMAGE} AS builder
54+
ARG CMAKE_FROM_SOURCE=false
55+
ARG CMAKE_VERSION=3.31.10
56+
# We can target specific CUDA ARCHITECTURES like --build-arg CUDA_DOCKER_ARCH='75;86;89;120'
57+
ARG CUDA_DOCKER_ARCH
58+
ENV CUDA_DOCKER_ARCH=${CUDA_DOCKER_ARCH}
59+
ARG CMAKE_ARGS
60+
ENV CMAKE_ARGS=${CMAKE_ARGS}
61+
ARG BACKEND=rerankers
62+
ARG BUILD_TYPE
63+
ENV BUILD_TYPE=${BUILD_TYPE}
64+
ARG CUDA_MAJOR_VERSION
65+
ARG CUDA_MINOR_VERSION
66+
ARG SKIP_DRIVERS=false
67+
ENV CUDA_MAJOR_VERSION=${CUDA_MAJOR_VERSION}
68+
ENV CUDA_MINOR_VERSION=${CUDA_MINOR_VERSION}
69+
ENV DEBIAN_FRONTEND=noninteractive
70+
ARG TARGETARCH
71+
ARG TARGETVARIANT
72+
ARG GO_VERSION=1.25.4
73+
ARG UBUNTU_VERSION=2404
74+
75+
RUN apt-get update && \
76+
apt-get install -y --no-install-recommends \
77+
build-essential \
78+
ccache git \
79+
ca-certificates \
80+
make \
81+
pkg-config libcurl4-openssl-dev \
82+
curl unzip \
83+
libssl-dev wget && \
84+
apt-get clean && \
85+
rm -rf /var/lib/apt/lists/*
86+
87+
# Cuda
88+
ENV PATH=/usr/local/cuda/bin:${PATH}
89+
90+
# HipBLAS requirements
91+
ENV PATH=/opt/rocm/bin:${PATH}
92+
93+
94+
# Vulkan requirements
95+
RUN <<EOT bash
96+
if [ "${BUILD_TYPE}" = "vulkan" ] && [ "${SKIP_DRIVERS}" = "false" ]; then
97+
apt-get update && \
98+
apt-get install -y --no-install-recommends \
99+
software-properties-common pciutils wget gpg-agent && \
100+
apt-get install -y libglm-dev cmake libxcb-dri3-0 libxcb-present0 libpciaccess0 \
101+
libpng-dev libxcb-keysyms1-dev libxcb-dri3-dev libx11-dev g++ gcc \
102+
libwayland-dev libxrandr-dev libxcb-randr0-dev libxcb-ewmh-dev \
103+
git python-is-python3 bison libx11-xcb-dev liblz4-dev libzstd-dev \
104+
ocaml-core ninja-build pkg-config libxml2-dev wayland-protocols python3-jsonschema \
105+
clang-format qtbase5-dev qt6-base-dev libxcb-glx0-dev sudo xz-utils
106+
if [ "amd64" = "$TARGETARCH" ]; then
107+
wget "https://sdk.lunarg.com/sdk/download/1.4.335.0/linux/vulkansdk-linux-x86_64-1.4.335.0.tar.xz" && \
108+
tar -xf vulkansdk-linux-x86_64-1.4.335.0.tar.xz && \
109+
rm vulkansdk-linux-x86_64-1.4.335.0.tar.xz && \
110+
mkdir -p /opt/vulkan-sdk && \
111+
mv 1.4.335.0 /opt/vulkan-sdk/ && \
112+
cd /opt/vulkan-sdk/1.4.335.0 && \
113+
./vulkansdk --no-deps --maxjobs \
114+
vulkan-loader \
115+
vulkan-validationlayers \
116+
vulkan-extensionlayer \
117+
vulkan-tools \
118+
shaderc && \
119+
cp -rfv /opt/vulkan-sdk/1.4.335.0/x86_64/bin/* /usr/bin/ && \
120+
cp -rfv /opt/vulkan-sdk/1.4.335.0/x86_64/lib/* /usr/lib/x86_64-linux-gnu/ && \
121+
cp -rfv /opt/vulkan-sdk/1.4.335.0/x86_64/include/* /usr/include/ && \
122+
cp -rfv /opt/vulkan-sdk/1.4.335.0/x86_64/share/* /usr/share/ && \
123+
rm -rf /opt/vulkan-sdk
124+
fi
125+
if [ "arm64" = "$TARGETARCH" ]; then
126+
mkdir vulkan && cd vulkan && \
127+
curl -L -o vulkan-sdk.tar.xz https://github.com/mudler/vulkan-sdk-arm/releases/download/1.4.335.0/vulkansdk-ubuntu-24.04-arm-1.4.335.0.tar.xz && \
128+
tar -xvf vulkan-sdk.tar.xz && \
129+
rm vulkan-sdk.tar.xz && \
130+
cd 1.4.335.0 && \
131+
cp -rfv aarch64/bin/* /usr/bin/ && \
132+
cp -rfv aarch64/lib/* /usr/lib/aarch64-linux-gnu/ && \
133+
cp -rfv aarch64/include/* /usr/include/ && \
134+
cp -rfv aarch64/share/* /usr/share/ && \
135+
cd ../.. && \
136+
rm -rf vulkan
137+
fi
138+
ldconfig && \
139+
apt-get clean && \
140+
rm -rf /var/lib/apt/lists/*
141+
fi
142+
EOT
143+
144+
# CuBLAS requirements
145+
RUN <<EOT bash
146+
if ( [ "${BUILD_TYPE}" = "cublas" ] || [ "${BUILD_TYPE}" = "l4t" ] ) && [ "${SKIP_DRIVERS}" = "false" ]; then
147+
apt-get update && \
148+
apt-get install -y --no-install-recommends \
149+
software-properties-common pciutils
150+
if [ "amd64" = "$TARGETARCH" ]; then
151+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/cuda-keyring_1.1-1_all.deb
152+
fi
153+
if [ "arm64" = "$TARGETARCH" ]; then
154+
if [ "${CUDA_MAJOR_VERSION}" = "13" ]; then
155+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/sbsa/cuda-keyring_1.1-1_all.deb
156+
else
157+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/arm64/cuda-keyring_1.1-1_all.deb
158+
fi
159+
fi
160+
dpkg -i cuda-keyring_1.1-1_all.deb && \
161+
rm -f cuda-keyring_1.1-1_all.deb && \
162+
apt-get update && \
163+
apt-get install -y --no-install-recommends \
164+
cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
165+
libcufft-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
166+
libcurand-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
167+
libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
168+
libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
169+
libcusolver-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
170+
if [ "${CUDA_MAJOR_VERSION}" = "13" ] && [ "arm64" = "$TARGETARCH" ]; then
171+
apt-get install -y --no-install-recommends \
172+
libcufile-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcudnn9-cuda-${CUDA_MAJOR_VERSION} cuda-cupti-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libnvjitlink-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
173+
fi
174+
apt-get clean && \
175+
rm -rf /var/lib/apt/lists/*
176+
fi
177+
EOT
178+
179+
180+
# https://github.com/NVIDIA/Isaac-GR00T/issues/343
181+
RUN <<EOT bash
182+
if [ "${BUILD_TYPE}" = "cublas" ] && [ "${TARGETARCH}" = "arm64" ]; then
183+
wget https://developer.download.nvidia.com/compute/cudss/0.6.0/local_installers/cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0_0.6.0-1_arm64.deb && \
184+
dpkg -i cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0_0.6.0-1_arm64.deb && \
185+
cp /var/cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0/cudss-*-keyring.gpg /usr/share/keyrings/ && \
186+
apt-get update && apt-get -y install cudss cudss-cuda-${CUDA_MAJOR_VERSION} && \
187+
wget https://developer.download.nvidia.com/compute/nvpl/25.5/local_installers/nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5_1.0-1_arm64.deb && \
188+
dpkg -i nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5_1.0-1_arm64.deb && \
189+
cp /var/nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5/nvpl-*-keyring.gpg /usr/share/keyrings/ && \
190+
apt-get update && apt-get install -y nvpl
191+
fi
192+
EOT
193+
194+
# If we are building with clblas support, we need the libraries for the builds
195+
RUN if [ "${BUILD_TYPE}" = "clblas" ] && [ "${SKIP_DRIVERS}" = "false" ]; then \
196+
apt-get update && \
197+
apt-get install -y --no-install-recommends \
198+
libclblast-dev && \
199+
apt-get clean && \
200+
rm -rf /var/lib/apt/lists/* \
201+
; fi
202+
203+
RUN if [ "${BUILD_TYPE}" = "hipblas" ] && [ "${SKIP_DRIVERS}" = "false" ]; then \
204+
apt-get update && \
205+
apt-get install -y --no-install-recommends \
206+
hipblas-dev \
207+
rocblas-dev && \
208+
apt-get clean && \
209+
rm -rf /var/lib/apt/lists/* && \
210+
# I have no idea why, but the ROCM lib packages don't trigger ldconfig after they install, which results in local-ai and others not being able
211+
# to locate the libraries. We run ldconfig ourselves to work around this packaging deficiency
212+
ldconfig && \
213+
# Log which GPU architectures have rocBLAS kernel support
214+
echo "rocBLAS library data architectures:" && \
215+
(ls /opt/rocm*/lib/rocblas/library/Kernels* 2>/dev/null || ls /opt/rocm*/lib64/rocblas/library/Kernels* 2>/dev/null) | grep -oP 'gfx[0-9a-z+-]+' | sort -u || \
216+
echo "WARNING: No rocBLAS kernel data found" \
217+
; fi
218+
219+
RUN echo "TARGETARCH: $TARGETARCH"
220+
221+
# We need protoc installed, and the version in 22.04 is too old. We will create one as part installing the GRPC build below
222+
# but that will also being in a newer version of absl which stablediffusion cannot compile with. This version of protoc is only
223+
# here so that we can generate the grpc code for the stablediffusion build
224+
RUN <<EOT bash
225+
if [ "amd64" = "$TARGETARCH" ]; then
226+
curl -L -s https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-x86_64.zip -o protoc.zip && \
227+
unzip -j -d /usr/local/bin protoc.zip bin/protoc && \
228+
rm protoc.zip
229+
fi
230+
if [ "arm64" = "$TARGETARCH" ]; then
231+
curl -L -s https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-aarch_64.zip -o protoc.zip && \
232+
unzip -j -d /usr/local/bin protoc.zip bin/protoc && \
233+
rm protoc.zip
234+
fi
235+
EOT
236+
237+
# Install CMake (the version in 22.04 is too old)
238+
RUN <<EOT bash
239+
if [ "${CMAKE_FROM_SOURCE}" = "true" ]; then
240+
curl -L -s https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz -o cmake.tar.gz && tar xvf cmake.tar.gz && cd cmake-${CMAKE_VERSION} && ./configure && make && make install
241+
else
242+
apt-get update && \
243+
apt-get install -y \
244+
cmake && \
245+
apt-get clean && \
246+
rm -rf /var/lib/apt/lists/*
247+
fi
248+
EOT
249+
250+
COPY --from=grpc /opt/grpc /usr/local
251+
252+
253+
COPY . /LocalAI
254+
255+
RUN <<'EOT' bash
256+
set -euxo pipefail
257+
258+
if [[ -n "${CUDA_DOCKER_ARCH:-}" ]]; then
259+
CUDA_ARCH_ESC="${CUDA_DOCKER_ARCH//;/\\;}"
260+
export CMAKE_ARGS="${CMAKE_ARGS:-} -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCH_ESC}"
261+
echo "CMAKE_ARGS(env) = ${CMAKE_ARGS}"
262+
rm -rf /LocalAI/backend/cpp/buun-llama-cpp-*-build
263+
fi
264+
265+
cd /LocalAI/backend/cpp/buun-llama-cpp
266+
267+
if [ "${TARGETARCH}" = "arm64" ] || [ "${BUILD_TYPE}" = "hipblas" ]; then
268+
make buun-llama-cpp-fallback
269+
make buun-llama-cpp-grpc
270+
make buun-llama-cpp-rpc-server
271+
else
272+
make buun-llama-cpp-avx
273+
make buun-llama-cpp-avx2
274+
make buun-llama-cpp-avx512
275+
make buun-llama-cpp-fallback
276+
make buun-llama-cpp-grpc
277+
make buun-llama-cpp-rpc-server
278+
fi
279+
EOT
280+
281+
282+
# Copy libraries using a script to handle architecture differences
283+
RUN make -BC /LocalAI/backend/cpp/buun-llama-cpp package
284+
285+
286+
FROM scratch
287+
288+
289+
# Copy all available binaries (the build process only creates the appropriate ones for the target architecture)
290+
COPY --from=builder /LocalAI/backend/cpp/buun-llama-cpp/package/. ./

0 commit comments

Comments
 (0)