Skip to content

Commit 292c1ca

Browse files
committed
fix(llama-cpp,turboquant): only CPU_ALL_VARIANTS for pure-CPU builds, GPU uses fallback
The previous gate sent every non-hipblas build through llama-cpp-cpu-all, so the GPU image builds (cublas, sycl_f16/f32, vulkan, nvidia l4t) compiled the whole CPU microarch variant matrix on top of their already-huge GPU backend - blowing the build time (the sycl job was only 59% done after 2h11m) - and the arm64 l4t build failed at `apt-get install gcc-14` (exit 100) on the Jetson base. Gate on an empty BUILD_TYPE instead: only the pure CPU image (build-type: '' in .github/backend-matrix.yml) builds the CPU_ALL_VARIANTS set; every GPU build gets a single fallback CPU grpc-server, since the accelerator does the compute. This also confines the arm64 gcc-14 step (needed for the armv9.2 SME variants) to the CPU build, away from the GPU base images. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-4-8 [Claude Code]
1 parent 4e9bb4f commit 292c1ca

2 files changed

Lines changed: 23 additions & 17 deletions

File tree

.docker/llama-cpp-compile.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ if [[ -n "${CUDA_DOCKER_ARCH:-}" ]]; then
1818
fi
1919

2020
cd /LocalAI/backend/cpp/llama-cpp
21-
if [ "${BUILD_TYPE}" = "hipblas" ]; then
22-
# ROCm: the GPU does the compute, so a single fallback CPU build is enough.
23-
make llama-cpp-fallback
24-
else
25-
# arm64: ggml's CPU_ALL_VARIANTS table includes armv9.2 SME variants whose
26-
# -march=...+sme is rejected by the Ubuntu 24.04 default gcc-13. gcc-14 accepts it, so
27-
# build the arm64 variants with gcc-14 (the host never *selects* SME unless it has it,
28-
# but every variant must still compile).
21+
if [ -z "${BUILD_TYPE:-}" ]; then
22+
# Pure CPU image (BUILD_TYPE empty): one build with ggml CPU_ALL_VARIANTS replaces the
23+
# per-microarch binaries (x86: avx/avx2/avx512/fallback; arm64: armv8.x/armv9.x). ggml
24+
# dlopens the best libggml-cpu-*.so at runtime by probing host CPU features.
25+
#
26+
# arm64: the CPU_ALL_VARIANTS table includes armv9.2 SME variants whose -march=...+sme is
27+
# rejected by the Ubuntu 24.04 default gcc-13. gcc-14 accepts it, so build the arm64
28+
# variants with it (the host never *selects* SME unless it has it, but every variant must
29+
# still compile).
2930
if [ "${TARGETARCH}" = "arm64" ]; then
3031
apt-get update -qq && apt-get install -y -qq gcc-14 g++-14
3132
export CC=gcc-14 CXX=g++-14
3233
fi
33-
# x86 and arm64: one build with ggml CPU_ALL_VARIANTS replaces the per-microarch
34-
# binaries (x86: avx/avx2/avx512/fallback; arm64: armv8.x/armv9.x). ggml dlopens the
35-
# best libggml-cpu-*.so at runtime by probing host CPU features.
3634
make llama-cpp-cpu-all
35+
else
36+
# GPU build (cublas/hipblas/sycl/vulkan/...): the accelerator does the compute, so a
37+
# single fallback CPU build is enough - no per-microarch CPU variants needed. (This also
38+
# keeps the heavy GPU backend compile from also building the whole CPU variant matrix,
39+
# and avoids the gcc-14 apt step on GPU base images such as nvidia l4t.)
40+
make llama-cpp-fallback
3741
fi
3842
make llama-cpp-grpc
3943
make llama-cpp-rpc-server

.docker/turboquant-compile.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ fi
1919

2020
cd /LocalAI/backend/cpp/turboquant
2121

22-
if [ "${BUILD_TYPE}" = "hipblas" ]; then
23-
# ROCm: single fallback CPU build (GPU does the compute).
24-
make turboquant-fallback
25-
else
26-
# arm64: the CPU_ALL_VARIANTS armv9.2 SME variants need gcc-14 (gcc-13 rejects +sme).
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).
2725
if [ "${TARGETARCH}" = "arm64" ]; then
2826
apt-get update -qq && apt-get install -y -qq gcc-14 g++-14
2927
export CC=gcc-14 CXX=g++-14
3028
fi
31-
# x86 and arm64: one ggml CPU_ALL_VARIANTS build replaces the per-microarch binaries.
3229
make turboquant-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 turboquant-fallback
3335
fi
3436
make turboquant-grpc
3537
make turboquant-rpc-server

0 commit comments

Comments
 (0)