Skip to content

ci(llama-cpp): compile the GPU backend once per image - #13526

Merged
mudler merged 3 commits into
masterfrom
ci/llama-build-speed
Nov 26, 2026
Merged

mudler merged 3 commits into
masterfrom
ci/llama-build-speed

Conversation

@mudler-agent

Copy link
Copy Markdown
Collaborator

Each llama.cpp-family image (llama-cpp, bonsai, turboquant, olala) built two full trees: the cpu-all tree (GGML_BACKEND_DL, loader plus GPU backend) and a static tree for *-grpc and *-rpc-server. The static tree compiled the whole CUDA or HIP backend a second time for every arch. In the ROCm llama-cpp job of master run 45793596845, each tree took 2h26m of the 4h52m compile step. The ROCm bonsai and llama-cpp images ran 5h10m and 5h13m on master and hit the 6h limit on PRs.

Changes:

  • CPU_ALL_RPC=ON builds the RPC backend and ggml-rpc-server in the cpu-all tree. The *-grpc binary is that tree's grpc-server. The image compile scripts set it. Both binaries find the RPC backend through the backend registry (ggml_backend_reg_by_name("RPC"), and rpc-server.cpp calls ggml_backend_load_all()). This holds in upstream and in the three fork pins.
  • A build-timings job in backend.yml and backend_pr.yml writes the slowest image jobs to the run summary. It fails when a llama.cpp-family build ran longer than 4h.

What does not change: the file names in each image, the CUDA arch list, AMDGPU_TARGETS and the CPU variants. The Darwin and Windows builds keep the static grpc target.

What changes for users: *-grpc and *-rpc-server now link the bundled shared ggml libraries and use the best CPU variant for the host, as *-cpu-all already does. Before, they were static builds with AVX off.

This PR runs the changed builds so the before and after durations can be compared.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DjrQykNTTf8SGGXmfHpyDA

Each llama.cpp-family image built two full trees: the cpu-all tree
(GGML_BACKEND_DL, loader plus GPU backend) and a static tree for
llama-cpp-grpc and llama-cpp-rpc-server. The static tree compiled the
whole CUDA or HIP backend again for every arch. In the ROCm llama-cpp job
of master run 45793596845 each tree took 2h26m of the 4h52m compile
step, and ccache could not help: the two trees use different defines and
-fPIC, and HIP objects had no compiler launcher.

Build the RPC backend and ggml-rpc-server in the cpu-all tree instead
(CPU_ALL_RPC=ON) and copy that tree's grpc-server to llama-cpp-grpc.
grpc-server finds the RPC backend through ggml_backend_reg_by_name("RPC")
and rpc-server.cpp calls ggml_backend_load_all() first, in upstream and
in the bonsai, turboquant and olala pins, so a DL tree serves both.

The file names in the image stay the same. The two RPC binaries now link
the bundled shared ggml libraries and use the best CPU variant for the
host, as llama-cpp-cpu-all does, instead of a static build with AVX off.
The CUDA arch list, AMDGPU_TARGETS and the CPU variants do not change.
The Darwin and Windows builds do not set CPU_ALL_RPC and keep the static
llama-cpp-grpc target.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Hosted runners kill a job at 6h. The ROCm bonsai and llama-cpp images
took 5h10m and 5h13m on master and timed out on PRs, and nothing showed
the drift until a job died.

Add a build-timings job to backend.yml and backend_pr.yml. It reads the
jobs of the run, writes the 20 slowest image builds to the run summary,
and fails when a llama-cpp, ik-llama-cpp, turboquant, bonsai or olala
build ran longer than 4h.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
llama-cpp-grpc and llama-cpp-rpc-server now come from the
GGML_BACKEND_DL tree and load libggml-rpc.so and the CPU variants from
lib/ at run time. No test started either binary, so a packaging gap
would only show on a user's worker.

The new test-extra-backend-llama-cpp-rpc target starts the worker from
the image through run.sh (LLAMACPP_BINARY), runs the e2e backend suite
with LLAMACPP_GRPC_SERVERS pointing at it, and checks that the worker
accepted the connection. tests-llama-cpp-grpc runs it.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler
mudler merged commit 4ebf637 into master Nov 26, 2026
3 of 55 checks passed
@mudler
mudler deleted the ci/llama-build-speed branch November 26, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants