Repository navigation
fix(serving): link ggml backends statically — #3749's dynamic backends enumerated a GPU the server could not use - #3757
Merged
Conversation
…s enumerated a GPU the server could not use #3749 (mine) set BUILD_SHARED_LIBS + GGML_BACKEND_DL + GGML_CPU_ALL_VARIANTS to fix `Available devices: (none)`. It fixed device ENUMERATION and left the SERVER dark. Measured on BigMama, same binary, seconds apart, from a plain shell: llama-server --list-devices -> CUDA0: NVIDIA GeForce RTX 5090 llama-server -m MODEL --n-gpu-layers 999 -> warning: no usable GPU found The serving lane came up on CPU: 15.8 GB in host RAM, 500 MiB of a 32 GB card, 93 tok/s that looked healthy — while serving/status reported ready:true lanes:3. The core WAS asking for the GPU (`--n-gpu-layers 999` in the real command line); the engine declined and said so in a warning nothing was reading. In DL mode the server path asks llama_supports_gpu_offload() before the backends have been dlopened; --list-devices loads them first. Enumeration and serving disagree because they are two different orders. GGML_BACKEND_PATH does not help. Static linking removes the failure mode instead of timing around it: no dlopen, so no unexported symbol, no load order, no silently partial registry — a backend either compiled in or it did not. GGML_CPU_ALL_VARIANTS goes with it (runtime CPU-variant selection is a DL-mode concern) and GGML_NATIVE returns to its default ON, which is right: we compile per machine, so host tuning is free. Submodule fb668a88b (the expert_ptrs fix) is untouched. SECOND GATE, and it is the actual lesson. The existing postcondition asked --list-devices and PASSED on the binary that was serving on CPU. A postcondition that exercises a different code path than the product does is not a postcondition. The new gate probes the SERVING path with a deliberately nonexistent model — llama.cpp prints the offload verdict during argument handling, before it opens the file, so this costs no GGUF at install time. Verified on this box, not reasoned about: gate vs the BROKEN binary FATAL (mutation test on the real artifact) gate vs the static build pass installer "engine offloads on the serving path" live daemon after lane restart 23,342 MiB resident (was 500 MiB)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts the build-mode half of #3749. Keeps the submodule bump
fb668a88b.Authorised on airc by M5; IntelMac and M5 both held deploys on this.
What #3749 got wrong
#3749 (mine) fixed
Available devices: (none)by making backends dynamicallyloadable. It fixed device enumeration and left the server dark. Same
binary, plain interactive shell, seconds apart:
On canary
f7e201c93this box served its citizens on the CPU of a machine witha 5090: 15.8 GB in host RAM, 500 MiB of 32 GB used — while
serving/statusreported
ready:true lanes:3. The core was asking for the GPU (--n-gpu-layers 999in the realWin32_Processcommand line). The engine declined and said so ina warning nothing read.
In DL mode the server path asks
llama_supports_gpu_offload()before thebackends have been dlopened;
--list-devicesloads them first. Enumeration andserving disagree because they run in two different orders.
GGML_BACKEND_PATHdoes not help.
Eliminated by measurement before finding it, in case it saves someone the walk:
cwd,
PATH, CUDA-tree shadowing, compute-mode exclusivity, env, stale binary,startup race. None of them — it reproduces with four arguments.
The fix
-DBUILD_SHARED_LIBS=OFF. No dlopen, so no unexported symbol, no load order, nosilently-partial registry — a backend either compiled in or it did not.
GGML_CPU_ALL_VARIANTSgoes with it (runtime CPU-variant selection is a DL-modeconcern) and
GGML_NATIVEreturns to defaultON, which is what we want since wecompile per machine — that also restores host tuning for the CPU-only tier, which
ALL_VARIANTSwas there to protect.The second gate — the actual lesson
The existing postcondition asks
--list-devices. It passed on the binary thatwas serving on CPU. A postcondition that exercises a different code path than
the product does is not a postcondition; it is a second opinion from someone who
was not there.
The new gate probes the serving path with a deliberately nonexistent model —
llama.cpp prints the offload verdict during argument handling, before it opens the
file, so it costs no GGUF at install time.
Verification — run on this box, not reasoned about
→ engine reports: CUDA0: NVIDIA GeForce RTX 5090 (32606 MiB, 30991 MiB free)→ engine offloads on the serving path (no 'no usable GPU' warning)I built this and ran it before opening the PR, because #3749 shipped on a
postcondition I had validated against a code path that was not the failing one.
Still open, tracked separately
serving/statusreturnedready:true lanes:3with the GPU dark. Nothing in thereadiness path verifies the backend it promises, so the grid scheduler would have
placed CUDA work here. That is a real defect independent of this fix and it wants
a
ready_verified_at_ms-style observation rather than a cached claim.