Skip to content

Commit 4226d8b

Browse files
fix(cachyllama): use portable ARM build
Avoid the CPU_ALL_VARIANTS SME matrix on ARM, where the Linux and Darwin backend toolchains fail to compile CachyLLaMA. Keep the existing variant build for x86 and use the fully linked fallback build for ARM. Assisted-by: Codex:gpt-5 [systematic-debugging]
1 parent c4b5ed8 commit 4226d8b

2 files changed

Lines changed: 12 additions & 25 deletions

File tree

.docker/cachyllama-compile.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ fi
2020
cd /LocalAI/backend/cpp/cachyllama
2121

2222
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).
23+
# Keep arm64 on the portable, fully linked build. CachyLLaMA's ARM
24+
# CPU_ALL_VARIANTS build includes SME variants that do not build reliably
25+
# across the Linux and Darwin toolchains used by backend CI.
2526
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
27+
make cachyllama-fallback
28+
else
29+
# One ggml CPU_ALL_VARIANTS build replaces the per-microarch x86 binaries.
30+
make cachyllama-cpu-all
2831
fi
29-
make cachyllama-cpu-all
3032
else
3133
# GPU build (cublas/hipblas/sycl/vulkan/...): single fallback CPU build, the accelerator
3234
# does the compute. Keeps the GPU compile from also building the CPU variant matrix and

scripts/build/cachyllama-darwin.sh

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ IMAGE_NAME="${IMAGE_NAME:-localai/cachyllama-darwin}"
66

77
pushd backend/cpp/cachyllama
88

9-
# Single build via ggml CPU_ALL_VARIANTS: one binary plus the per-microarch Apple/arm
10-
# dylibs (apple_m1/m2_m3/m4, armv8.x) that ggml selects at runtime. GGML_METAL stays ON
11-
# and --target ggml also builds ggml-metal (via add_dependencies), so the Metal GPU
12-
# backend is still produced as a loadable libggml-metal.dylib.
13-
make cachyllama-cpu-all && \
9+
# CachyLLaMA's ARM CPU_ALL_VARIANTS build includes SME variants that do not build
10+
# reliably across the Darwin toolchains used by backend CI. The fallback build
11+
# remains Metal-enabled on Darwin and is fully linked.
12+
make cachyllama-fallback && \
1413
make cachyllama-grpc && \
1514
make cachyllama-rpc-server
1615

@@ -20,24 +19,10 @@ mkdir -p build/darwin
2019
mkdir -p backend-images
2120
mkdir -p build/darwin/lib
2221

23-
cp -rf backend/cpp/cachyllama/cachyllama-cpu-all build/darwin/
22+
cp -rf backend/cpp/cachyllama/cachyllama-fallback build/darwin/
2423
cp -rf backend/cpp/cachyllama/cachyllama-grpc build/darwin/
2524
cp -rf backend/cpp/cachyllama/cachyllama-rpc-server build/darwin/
2625

27-
# Distribute the shared ggml/llama libraries from the CPU_ALL_VARIANTS build. Unlike the
28-
# old fully-static fallback build, these have @rpath install names, so the otool loop below
29-
# (which only copies deps that exist on disk) will not pick them up. The split is by suffix:
30-
# - ggml emits its loadable backends (per-microarch CPU variants, metal, blas) with a .so
31-
# suffix EVEN ON DARWIN. These go in the package ROOT next to the binary, because darwin
32-
# run.sh execs the binary directly (no bundled ld.so) so ggml's executable-directory
33-
# scan looks there.
34-
# - the core libraries (libggml-base/libggml/libllama/libllama-common/libmtmd) use the
35-
# platform .dylib suffix and are NEEDED deps; they go in lib/, resolved at load time via
36-
# the DYLD_LIBRARY_PATH=lib that run.sh exports. -a preserves the version symlinks.
37-
SHLIBS=backend/cpp/cachyllama/ggml-shared-libs
38-
cp -a $SHLIBS/*.so build/darwin/
39-
cp -a $SHLIBS/*.dylib build/darwin/lib/
40-
4126
# Set default additional libs only for Darwin on M chips (arm64)
4227
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]; then
4328
ADDITIONAL_LIBS=${ADDITIONAL_LIBS:-$(ls /opt/homebrew/Cellar/protobuf/**/lib/libutf8_validity*.dylib 2>/dev/null)}

0 commit comments

Comments
 (0)