Skip to content

fix(serving): link ggml backends statically — #3749's dynamic backends enumerated a GPU the server could not use - #3757

Merged
joelteply merged 1 commit into
canaryfrom
fix/revert-ggml-backend-dl
Sep 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/revert-ggml-backend-dl

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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 dynamically
loadable. It fixed device enumeration and left the server dark. Same
binary, plain interactive shell, seconds apart:

llama-server --list-devices                 ->  CUDA0: NVIDIA GeForce RTX 5090 (32606 MiB)
llama-server -m MODEL --n-gpu-layers 999    ->  warning: no usable GPU found

On canary f7e201c93 this box served its citizens on the CPU of a machine with
a 5090
: 15.8 GB in host RAM, 500 MiB of 32 GB used — while serving/status
reported ready:true lanes:3. The core was asking for the GPU (--n-gpu-layers 999 in the real Win32_Process command line). The engine declined and said so in
a warning nothing read.

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 run in two different orders. GGML_BACKEND_PATH
does 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, 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 default ON, which is what we want since we
compile per machine — that also restores host tuning for the CPU-only tier, which
ALL_VARIANTS was there to protect.

The second gate — the actual lesson

The existing postcondition asks --list-devices. It 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; 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

check result
new gate vs the broken binary FATAL — mutation-tested on the real failing artifact, not a synthetic one
new gate vs the static build pass
installer output → engine reports: CUDA0: NVIDIA GeForce RTX 5090 (32606 MiB, 30991 MiB free)
→ engine offloads on the serving path (no 'no usable GPU' warning)
live daemon after lane restart 23,342 MiB resident (was 500 MiB)

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/status returned ready:true lanes:3 with the GPU dark. Nothing in the
readiness 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.

…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)
@joelteply
joelteply enabled auto-merge (squash) September 5, 2026 11:57
@joelteply
joelteply merged commit 3a0be91 into canary Sep 5, 2026
10 checks passed
@joelteply
joelteply deleted the fix/revert-ggml-backend-dl branch September 5, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant