Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .agents/llama-cpp-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Every llama-cpp image ships `llama-cpp-cpu-all`: ggml built with `GGML_BACKEND_D
- The variants must come from the same llama.cpp commit as the GPU tree. The Makefile checks this through the `LLAMA_VERSION` file the stage writes.
- Keep the stage on the oldest glibc of any builder image. The script refuses a variant that needs a newer glibc or libstdc++ than Ubuntu 22.04 has.
- turboquant, bonsai and olala build a llama.cpp fork and use the same stage with their own pin (`CPU_VARIANTS_VERSION_VAR`, and `OLALA_CMAKE_ARGS` for olala's CPU flags) and their own patches. The variants of a fork come from that fork, never from upstream. ik-llama-cpp has its own ggml without the backend loader, so it keeps per-instruction-set binaries.
- `llama-cpp-grpc` and `llama-cpp-rpc-server` are separate static builds and still compile their own CPU backend.
- `llama-cpp-grpc` and `llama-cpp-rpc-server` come from the same tree as `llama-cpp-cpu-all` in the image builds (`CPU_ALL_RPC=ON`, set by the `.docker/*-compile.sh` scripts of llama-cpp, bonsai, turboquant and olala). That tree also builds `libggml-rpc.so` and `ggml-rpc-server`, and both binaries find the RPC backend through the backend registry. Do not go back to a separate static grpc tree: it compiles the GPU backend a second time for every CUDA or HIP arch, which was half of each GPU build and took the ROCm images to GitHub's 6h job limit. The Darwin and Windows builds still call the static `llama-cpp-grpc` target.
- `backend.yml` and `backend_pr.yml` end with a `build-timings` job (`scripts/ci/backend-build-timings.sh`). It writes the slowest image jobs to the run summary and fails when a llama.cpp-family job ran longer than 4h.

## NCCL (CUDA images)

Expand Down
8 changes: 5 additions & 3 deletions .docker/bonsai-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ cd /LocalAI/backend/cpp/bonsai
# run time, for CPU-only and GPU images alike. See .docker/llama-cpp-compile.sh.
CPU_VARIANTS_DIR=/LocalAI/backend/cpp/bonsai/cpu-variants
ls "$CPU_VARIANTS_DIR"/libggml-cpu-*.so > /dev/null
make bonsai-cpu-all CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR"
make bonsai-grpc
make bonsai-rpc-server
# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the same tree, so
# bonsai-grpc and bonsai-rpc-server come out of this one build. Building them in their own
# static tree compiled the whole GPU backend a second time, which was half the job time.
make bonsai-cpu-all CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR" CPU_ALL_RPC=ON
test -x bonsai-grpc && test -x bonsai-rpc-server

ccache -s || true
8 changes: 5 additions & 3 deletions .docker/llama-cpp-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ if [ "$BUILD_TARGET" = "llama-cpp-cpu-all" ]; then
else
set --
fi
make "$BUILD_TARGET" "$@"
make llama-cpp-grpc
make llama-cpp-rpc-server
# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the same tree, so
# llama-cpp-grpc and llama-cpp-rpc-server come out of this one build. Building them in their own
# static tree compiled the whole GPU backend a second time, which was half the job time.
make "$BUILD_TARGET" "$@" CPU_ALL_RPC=ON
test -x llama-cpp-grpc && test -x llama-cpp-rpc-server

ccache -s || true
8 changes: 5 additions & 3 deletions .docker/olala-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ cd /LocalAI/backend/cpp/olala
# run time, for CPU-only and GPU images alike. See .docker/llama-cpp-compile.sh.
CPU_VARIANTS_DIR=/LocalAI/backend/cpp/olala/cpu-variants
ls "$CPU_VARIANTS_DIR"/libggml-cpu-*.so > /dev/null
make olala-cpu-all CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR"
make olala-grpc
make olala-rpc-server
# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the same tree, so
# olala-grpc and olala-rpc-server come out of this one build. Building them in their own
# static tree compiled the whole GPU backend a second time, which was half the job time.
make olala-cpu-all CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR" CPU_ALL_RPC=ON
test -x olala-grpc && test -x olala-rpc-server

ccache -s || true
8 changes: 5 additions & 3 deletions .docker/turboquant-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ BUILD_TARGET=$(/LocalAI/.docker/turboquant-build-target.sh "${TARGETARCH}" "${BU
# run time. See .docker/llama-cpp-compile.sh.
CPU_VARIANTS_DIR=/LocalAI/backend/cpp/turboquant/cpu-variants
ls "$CPU_VARIANTS_DIR"/libggml-cpu-*.so > /dev/null
make "$BUILD_TARGET" CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR"
make turboquant-grpc
make turboquant-rpc-server
# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the same tree, so
# turboquant-grpc and turboquant-rpc-server come out of this one build. Building them in their own
# static tree compiled the whole GPU backend a second time, which was half the job time.
make "$BUILD_TARGET" CPU_VARIANTS_DIR="$CPU_VARIANTS_DIR" CPU_ALL_RPC=ON
test -x turboquant-grpc && test -x turboquant-rpc-server

ccache -s || true
18 changes: 18 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,21 @@ jobs:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-windows) }}

# Fails when a llama.cpp-family image build ran longer than 4h, well before
# GitHub kills the job at 6h, and writes the slowest jobs to the run summary.
build-timings:
needs: [backend-jobs-multiarch, backend-jobs-singlearch-1, backend-jobs-singlearch-2, backend-jobs-singlearch-3, backend-jobs-singlearch-4]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: scripts/ci
- name: Backend build timings
env:
GH_TOKEN: ${{ github.token }}
run: bash scripts/ci/backend-build-timings.sh "${{ github.run_id }}" "${{ github.run_attempt }}"
18 changes: 18 additions & 0 deletions .github/workflows/backend_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,21 @@ jobs:
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-windows) }}

# Fails when a llama.cpp-family image build ran longer than 4h, well before
# GitHub kills the job at 6h, and writes the slowest jobs to the run summary.
build-timings:
needs: [backend-jobs-multiarch, backend-jobs-singlearch-1, backend-jobs-singlearch-2, backend-jobs-singlearch-3, backend-jobs-singlearch-4]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: scripts/ci
- name: Backend build timings
env:
GH_TOKEN: ${{ github.token }}
run: bash scripts/ci/backend-build-timings.sh "${{ github.run_id }}" "${{ github.run_attempt }}"
1 change: 1 addition & 0 deletions .github/workflows/test-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ jobs:
run: |
make test-extra-backend-llama-cpp
make test-extra-backend-llama-cpp-embeddings
make test-extra-backend-llama-cpp-rpc
tests-llama-cpp-grpc-transcription:
needs: detect-changes
if: needs.detect-changes.outputs.llama-cpp == 'true' || needs.detect-changes.outputs.run-all == 'true'
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,11 @@ test-extra-backend-llama-cpp-embeddings: docker-build-llama-cpp
BACKEND_TEST_EMBEDDING_LAYOUT=per_token \
$(MAKE) test-extra-backend

## RPC mode: llama-cpp-grpc loads the model and offloads it to llama-cpp-rpc-server,
## both started from the image through run.sh, as a LocalAI worker does.
test-extra-backend-llama-cpp-rpc: docker-build-llama-cpp
bash scripts/ci/llama-cpp-rpc-smoke.sh local-ai-backend:llama-cpp

test-extra-backend-ik-llama-cpp: docker-build-ik-llama-cpp
BACKEND_IMAGE=local-ai-backend:ik-llama-cpp $(MAKE) test-extra-backend

Expand Down
18 changes: 16 additions & 2 deletions backend/cpp/bonsai/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ bonsai-fallback:
# Unset, the variants are built in tree.
CPU_VARIANTS_DIR?=

# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the cpu-all tree too and
# ships them as bonsai-grpc and bonsai-rpc-server, so the GPU backend is compiled once
# instead of a second time for the static bonsai-grpc tree. See CPU_ALL_RPC in
# backend/cpp/llama-cpp/Makefile.
CPU_ALL_RPC?=OFF
ifeq ($(CPU_ALL_RPC),ON)
CPU_ALL_RPC_CMAKE_ARGS:=-DGGML_RPC=ON
CPU_ALL_RPC_TARGET:=--target ggml-rpc-server
endif

bonsai-cpu-all:
rm -rf $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build
cp -rf $(LLAMA_CPP_DIR) $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build
Expand All @@ -93,15 +103,19 @@ bonsai-cpu-all:
bash $(CURRENT_MAKEFILE_DIR)/apply-patches.sh $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/llama.cpp $(PATCHES_DIR)
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
test "$$(cat $(CPU_VARIANTS_DIR)/LLAMA_VERSION)" = "$(BONSAI_VERSION)" || { echo "CPU variants in $(CPU_VARIANTS_DIR) were built for another commit than $(BONSAI_VERSION)" >&2; exit 1; }
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(BONSAI_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build grpc-server
else
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(BONSAI_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build grpc-server
endif
cp -rfv $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/grpc-server bonsai-cpu-all
ifeq ($(CPU_ALL_RPC),ON)
cp -fv $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/grpc-server bonsai-grpc
cp -fv $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/llama.cpp/build/bin/ggml-rpc-server bonsai-rpc-server
endif
rm -rf ggml-shared-libs && mkdir -p ggml-shared-libs
find $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/llama.cpp/build \( -name '*.so*' -o -name '*.dylib' \) -exec cp -av {} ggml-shared-libs/ \;
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
Expand Down
22 changes: 20 additions & 2 deletions backend/cpp/llama-cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ llama-cpp-fallback: llama.cpp
# builds the variants in the same tree (local builds, macOS).
CPU_VARIANTS_DIR?=

# CPU_ALL_RPC=ON also builds the RPC backend (libggml-rpc.so) and ggml-rpc-server in the
# cpu-all tree, and ships that tree's grpc-server as llama-cpp-grpc and its
# ggml-rpc-server as llama-cpp-rpc-server. Both find the RPC backend through the backend
# registry (add_rpc_devices and rpc-server.cpp call ggml_backend_reg_by_name("RPC")), so
# a GGML_BACKEND_DL tree serves them as it serves the CPU and GPU backends. The image
# build sets it: without it the llama-cpp-grpc target compiles the GPU backend a second
# time (statically, for every CUDA or HIP arch), which was half of each GPU build.
# Off by default for the Darwin and Windows builds, which call llama-cpp-grpc directly.
CPU_ALL_RPC?=OFF
ifeq ($(CPU_ALL_RPC),ON)
CPU_ALL_RPC_CMAKE_ARGS:=-DGGML_RPC=ON
CPU_ALL_RPC_TARGET:=--target ggml-rpc-server
endif

# Single-build CPU backend using ggml's CPU_ALL_VARIANTS. Produces ONE grpc-server
# plus a set of dlopen-able libggml-cpu-*.so (sandybridge/haswell/skylakex/...) that
# ggml's backend registry selects from at runtime by probing host CPU features.
Expand All @@ -158,11 +172,15 @@ llama-cpp-cpu-all: llama.cpp
$(info ${GREEN}I llama-cpp build info:cpu-all-variants${RESET})
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
test "$$(cat $(CPU_VARIANTS_DIR)/LLAMA_VERSION)" = "$(LLAMA_VERSION)" || { echo "CPU variants in $(CPU_VARIANTS_DIR) were built for another llama.cpp commit than $(LLAMA_VERSION)" >&2; exit 1; }
$(MAKE) SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF" TARGET="--target grpc-server --target ggml" VARIANT="llama-cpp-cpu-all-build" build-llama-cpp-grpc-server
$(MAKE) SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" VARIANT="llama-cpp-cpu-all-build" build-llama-cpp-grpc-server
else
$(MAKE) SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON" TARGET="--target grpc-server --target ggml" VARIANT="llama-cpp-cpu-all-build" build-llama-cpp-grpc-server
$(MAKE) SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" VARIANT="llama-cpp-cpu-all-build" build-llama-cpp-grpc-server
endif
cp -rfv $(CURRENT_MAKEFILE_DIR)/../llama-cpp-cpu-all-build/grpc-server llama-cpp-cpu-all
ifeq ($(CPU_ALL_RPC),ON)
cp -fv $(CURRENT_MAKEFILE_DIR)/../llama-cpp-cpu-all-build/grpc-server llama-cpp-grpc
cp -fv $(CURRENT_MAKEFILE_DIR)/../llama-cpp-cpu-all-build/llama.cpp/build/bin/ggml-rpc-server llama-cpp-rpc-server
endif
rm -rf ggml-shared-libs && mkdir -p ggml-shared-libs
find $(CURRENT_MAKEFILE_DIR)/../llama-cpp-cpu-all-build/llama.cpp/build \( -name '*.so*' -o -name '*.dylib' \) -exec cp -av {} ggml-shared-libs/ \;
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
Expand Down
18 changes: 16 additions & 2 deletions backend/cpp/olala/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ olala-fallback:
# so the flags that shape the CPU kernels stay defined in one place.
CPU_VARIANTS_DIR?=

# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the cpu-all tree too and
# ships them as olala-grpc and olala-rpc-server, so the GPU backend is compiled once
# instead of a second time for the static olala-grpc tree. See CPU_ALL_RPC in
# backend/cpp/llama-cpp/Makefile.
CPU_ALL_RPC?=OFF
ifeq ($(CPU_ALL_RPC),ON)
CPU_ALL_RPC_CMAKE_ARGS:=-DGGML_RPC=ON
CPU_ALL_RPC_TARGET:=--target ggml-rpc-server
endif

olala-cpu-all:
rm -rf $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build
cp -rf $(LLAMA_CPP_DIR) $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build
Expand All @@ -95,15 +105,19 @@ olala-cpu-all:
bash $(CURRENT_MAKEFILE_DIR)/apply-patches.sh $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build/llama.cpp $(PATCHES_DIR)
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
test "$$(cat $(CPU_VARIANTS_DIR)/LLAMA_VERSION)" = "$(OLALA_VERSION)" || { echo "CPU variants in $(CPU_VARIANTS_DIR) were built for another commit than $(OLALA_VERSION)" >&2; exit 1; }
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="$(OLALA_CMAKE_ARGS) -DGGML_BACKEND_DL=ON -DGGML_CPU=OFF" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="$(OLALA_CMAKE_ARGS) -DGGML_BACKEND_DL=ON -DGGML_CPU=OFF $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(OLALA_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build grpc-server
else
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="$(OLALA_CMAKE_ARGS) -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="$(OLALA_CMAKE_ARGS) -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(OLALA_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build grpc-server
endif
cp -rfv $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build/grpc-server olala-cpu-all
ifeq ($(CPU_ALL_RPC),ON)
cp -fv $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build/grpc-server olala-grpc
cp -fv $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build/llama.cpp/build/bin/ggml-rpc-server olala-rpc-server
endif
rm -rf ggml-shared-libs && mkdir -p ggml-shared-libs
find $(CURRENT_MAKEFILE_DIR)/../olala-cpu-all-build/llama.cpp/build \( -name '*.so*' -o -name '*.dylib' \) -exec cp -av {} ggml-shared-libs/ \;
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
Expand Down
18 changes: 16 additions & 2 deletions backend/cpp/turboquant/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ turboquant-fallback:
# Unset, the variants are built in tree.
CPU_VARIANTS_DIR?=

# CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the cpu-all tree too and
# ships them as turboquant-grpc and turboquant-rpc-server, so the GPU backend is compiled once
# instead of a second time for the static turboquant-grpc tree. See CPU_ALL_RPC in
# backend/cpp/llama-cpp/Makefile.
CPU_ALL_RPC?=OFF
ifeq ($(CPU_ALL_RPC),ON)
CPU_ALL_RPC_CMAKE_ARGS:=-DGGML_RPC=ON
CPU_ALL_RPC_TARGET:=--target ggml-rpc-server
endif

turboquant-cpu-all:
rm -rf $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build
cp -rf $(LLAMA_CPP_DIR) $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build
Expand All @@ -100,15 +110,19 @@ turboquant-cpu-all:
bash $(CURRENT_MAKEFILE_DIR)/apply-patches.sh $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build/llama.cpp $(PATCHES_DIR)
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
test "$$(cat $(CPU_VARIANTS_DIR)/LLAMA_VERSION)" = "$(TURBOQUANT_VERSION)" || { echo "CPU variants in $(CPU_VARIANTS_DIR) were built for another commit than $(TURBOQUANT_VERSION)" >&2; exit 1; }
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU=OFF $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(TURBOQUANT_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build grpc-server
else
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON" TARGET="--target grpc-server --target ggml" \
SHARED_LIBS=ON EXTRA_CMAKE_ARGS="-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON $(CPU_ALL_RPC_CMAKE_ARGS)" TARGET="--target grpc-server --target ggml $(CPU_ALL_RPC_TARGET)" \
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(TURBOQUANT_VERSION) \
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build grpc-server
endif
cp -rfv $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build/grpc-server turboquant-cpu-all
ifeq ($(CPU_ALL_RPC),ON)
cp -fv $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build/grpc-server turboquant-grpc
cp -fv $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build/llama.cpp/build/bin/ggml-rpc-server turboquant-rpc-server
endif
rm -rf ggml-shared-libs && mkdir -p ggml-shared-libs
find $(CURRENT_MAKEFILE_DIR)/../turboquant-cpu-all-build/llama.cpp/build \( -name '*.so*' -o -name '*.dylib' \) -exec cp -av {} ggml-shared-libs/ \;
ifneq ($(strip $(CPU_VARIANTS_DIR)),)
Expand Down
12 changes: 12 additions & 0 deletions scripts/build/llama-cpp-build-target_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ MAKEFILE="$CURDIR/../../backend/cpp/llama-cpp/Makefile"
grep -q -- '-DGGML_CPU=OFF' "$MAKEFILE" || { echo "FAIL: Makefile does not build the GPU tree with -DGGML_CPU=OFF"; exit 1; }
grep -q 'CPU_VARIANTS_DIR' "$CURDIR/../../.docker/llama-cpp-compile.sh" || { echo "FAIL: compile script does not pass CPU_VARIANTS_DIR"; exit 1; }

# The RPC binaries must come out of the cpu-all tree. A separate static grpc tree
# compiles the whole GPU backend (every CUDA or HIP arch) a second time, which
# doubled the GPU image builds and pushed the ROCm ones to the 6h job limit.
for fork in llama-cpp bonsai turboquant olala; do
script="$CURDIR/../../.docker/${fork}-compile.sh"
grep -q 'CPU_ALL_RPC=ON' "$script" || { echo "FAIL: $script does not build the RPC binaries in the cpu-all tree"; exit 1; }
if grep -Eq "^make ${fork}-(grpc|rpc-server)" "$script"; then
echo "FAIL: $script builds a second, static grpc tree"; exit 1
fi
grep -q 'CPU_ALL_RPC_TARGET' "$CURDIR/../../backend/cpp/${fork}/Makefile" || { echo "FAIL: backend/cpp/${fork}/Makefile has no CPU_ALL_RPC mode"; exit 1; }
done

echo "PASS: every llama.cpp image flavor selects the CPU variant build"
Loading
Loading