Repository navigation
fix(install): the CUDA backend actually builds, ships, and is proven before the install is blessed - #3749
Merged
Conversation
…before the install is blessed
The 5090 host served no citizens for weeks. `llama-server --list-devices` reported
`Available devices: (none)` on a machine with an RTX 5090, so the serving receipt
correctly refused to place a lane. Three defects, stacked; each hid the next.
1. THE FORK'S CUDA BACKEND HAD NOT COMPILED SINCE 2026-08-04.
ggml-cuda/mmvq.cu:1118 — GGML_TYPE_Q2_0 called
mul_mat_vec_q_switch_ncols_dst without `expert_ptrs`, six lines below the
GGML_TYPE_Q1_0 case that HAD been updated. Both are fork-added types; the
upstream merge updated one and missed the other. 22 of 23 call sites correct.
Fixed in the submodule (CambrianTech/llama.cpp fb668a88b); pointer bumped here.
It stayed invisible because the failed target left the last good
ggml-cuda.dll in the build cache and the installer shipped it — Aug 4, while
every sibling DLL was Sep 4.
2. THE BACKENDS WERE BUILT UNLOADABLE. ggml/CMakeLists.txt:86 defaults
GGML_BACKEND_DL=OFF, and ggml-backend-impl.h:241 only defines the exported
`ggml_backend_init` under that flag, so the loader at ggml-backend-reg.cpp:237
dlopened each ggml-*.dll, found no symbol, and registered nothing. Measured: 0
occurrences of the symbol in ggml-cpu.dll and ggml-cuda.dll, 3 in ggml.dll.
Now BUILD_SHARED_LIBS=ON + GGML_BACKEND_DL=ON explicitly.
GGML_CPU_ALL_VARIANTS=ON rather than GGML_NATIVE=OFF (DL forbids NATIVE):
NATIVE=OFF would build ONE lowest-common-denominator CPU backend for the whole
fleet and silently slow the CPU-only tier — an Intel Mac serving its citizens
on Accelerate. ALL_VARIANTS keeps per-machine CPU speed.
3. THE CUDA RUNTIME WAS NEVER SHIPPED BESIDE THE BACKEND. ggml-cuda.dll links
cudart64_12/cublas64_12, which live in the toolkit, not the install dir.
Windows searches the loading module's directory, so it could not load at all.
Proven by the error changing category once they were copied:
before: load_backend: failed to load ...ggml-cuda.dll:
after: load_backend: failed to find ggml_backend_init in ...ggml-cuda.dll
AND THE ASYMMETRY THAT LET ALL THREE SHIP: the exe was copied atomically and
verified FATAL; the DLLs it cannot run without were copied
`2>/dev/null || true`. The loud failure was guarded and the silent one was not,
which is backwards — a missing exe fails immediately, a stale DLL produces a
server that starts and has no backend. On Windows that copy fails routinely
because a running llama-server holds the DLLs open. Now it fails loud.
POSTCONDITION, the durable half: after installing, ASK THE ENGINE WHAT IT CAN DO.
Everything else verifies that files exist; only running it verifies it works. If
the build selected a GPU backend and the engine reports no GPU device, the install
FATALs and refuses to stamp. A cpu-backend build reporting no GPU stays silent —
that is correct, and #3729's Intel Mac depends on it.
Mutation-proved rather than assumed, on this host:
ggml-cuda.dll hidden -> "(none)" -> detector FATALs
restored -> "CUDA0: NVIDIA GeForce RTX 5090" -> detector passes
a Metal host's line -> detector passes
RESULT on windows-msvc + CUDA 12 (RTX 5090):
403/403 build steps, 0 errors
CUDA0: NVIDIA GeForce RTX 5090 (32606 MiB, 30991 MiB free)
serving/status ready:true lanes:3 degraded_reason:null
nvidia-smi 31694 MiB / 32607 MiB (was 674 MiB at 2% on CPU)
citizens resident
KNOWN GAP, carded not fixed: the idempotency stamp is `$SUBMODULE_HEAD:$BACKEND`
and does not cover CMAKE_ARGS, so a build-flag change alone is a silent no-op
without --force. The stamp check runs before CMAKE_ARGS is declared, so covering
it needs a reorder this change deliberately does not attempt.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
… — MTL0 is not Metal0 M5's change request on #3749, with the receipt: this Mac prints its Metal device as MTL0: Apple M5 Pro (53084 MiB, 53083 MiB free) `MTL0`, not `Metal0`. The postcondition matched `(CUDA|Metal|Vulkan|ROCm|SYCL)[0-9]*:` — an enumeration of prefixes I happened to know, validated against a Metal line I WROTE MYSELF because I had no Mac to ask. Merged as written it would have FATAL'd every install on every Apple-silicon host and refused to stamp the engine hosting twelve citizens. Refusing a working machine is strictly worse than the bug the check exists to catch. **An allowlist of device prefixes is a promise to know every backend llama.cpp will ever name.** We do not, and the failure mode of being wrong is to break hosts that work. Inverted to a DENYLIST of CPU markers, which fails in the safe direction: allowlist of GPU prefixes -> unknown GPU REFUSED (breaks a working host) denylist of CPU markers -> unknown GPU ACCEPTED (fails safe) Match the SHAPE of a device row — indented `<id>: <text>` — and exclude the rows that are not a GPU. All three excluded forms are real output pasted by the fleet today, not invented: `(none)` (no-backend marker), `BLAS: Accelerate` (IntelMac's CPU-only build), `CPU: ...`. IntelMac's BLAS line is why the exclusions are load-bearing rather than tidy: a purely structural match ACCEPTS `BLAS: Accelerate` on a GPU-backend build, which is exactly the "GPU host serving on the CPU" failure this postcondition was written for. The first structural draft would have been a green light for the original bug. Verified against every real output the fleet has produced, plus a hypothetical future backend: M5 real Metal MTL0: Apple M5 Pro ... PASS (old allowlist: FATAL) my real CUDA CUDA0: RTX 5090 ... PASS IntelMac BLAS: Accelerate ... FATAL (structural-only: PASS) broken (none) FATAL CPU row CPU: 24 threads FATAL future WEBGPU0: ... PASS (allowlist: FATAL) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply
enabled auto-merge (squash)
September 5, 2026 10:54
joelteply
added a commit
that referenced
this pull request
Sep 5, 2026
…s enumerated a GPU the server could not use (#3757) #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
added a commit
that referenced
this pull request
Nov 7, 2026
The stamp file only records SUBMODULE_HEAD + backend — a correct claim about history that an out-of-band binary swap cannot invalidate. Before this patch the script would exit 0 on a matching stamp even if the installed binary was CPU-only on a GPU host (the #3749 split-brain). Add the same --list-devices + serving-path probe the postcondition uses, run it inside the idempotency branch. If verification fails we fall through to rebuild; only when the binary proves itself do we respect the stamp and exit. The stamp now describes what is on disk, not what the script once did. Card 3a783ea1.
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.
The 5090 host served no citizens for weeks.
llama-server --list-devicesreportedAvailable devices: (none)on a machine with an RTX 5090, so the serving receipt correctly refused to place a lane. Three defects, stacked — each hid the next.1. The fork's CUDA backend hadn't compiled since 2026-08-04
ggml-cuda/mmvq.cu:1118—GGML_TYPE_Q2_0called the template withoutexpert_ptrs, six lines below theGGML_TYPE_Q1_0case that had been updated:Both are fork-added types. Audited all 23 call sites; this was the only one. Fixed in the submodule (
CambrianTech/llama.cppfb668a88b), pointer bumped here.It stayed invisible because the failed target left the last good
ggml-cuda.dllin the build cache and the installer shipped it — Aug 4, while every sibling DLL was Sep 4.2. The backends were built unloadable
ggml/CMakeLists.txt:86defaultsGGML_BACKEND_DL=OFF, andggml-backend-impl.h:241only defines the exportedggml_backend_initunder that flag. So the loader atggml-backend-reg.cpp:237dlopened eachggml-*.dll, found no symbol, registered nothing. Measured: 0 occurrences of the symbol inggml-cpu.dllandggml-cuda.dll, 3 inggml.dll.GGML_CPU_ALL_VARIANTS=ONrather thanGGML_NATIVE=OFF(DL forbids NATIVE):NATIVE=OFFwould build one lowest-common-denominator CPU backend for the whole fleet and silently slow the CPU-only tier — an Intel Mac serving citizens on Accelerate. ALL_VARIANTS keeps per-machine CPU speed.3. The CUDA runtime was never shipped beside the backend
ggml-cuda.dlllinkscudart64_12/cublas64_12, which live in the toolkit. Windows searches the loading module's directory. Proven by the error changing category once copied:The asymmetry that let all three ship
The exe was copied atomically and verified FATAL. The DLLs it cannot run without were copied
2>/dev/null || true. The loud failure was guarded and the silent one was not — backwards, since a missing exe fails immediately while a stale DLL produces a server that starts and has no backend. On Windows that copy fails routinely, because a running llama-server holds them open.The postcondition (the durable half)
Everything else verifies files exist; only running the engine verifies it works. After install, ask it. If the build selected a GPU backend and the engine reports no GPU, FATAL and refuse to stamp. A cpu-backend build reporting no GPU stays silent — #3729's Intel Mac depends on that.
Mutation-proved, not assumed:
ggml-cuda.dllhidden →(none)CUDA0: NVIDIA GeForce RTX 5090Metal0:lineResult (windows-msvc + CUDA 12, RTX 5090)
Known gap, carded not fixed
The idempotency stamp is
$SUBMODULE_HEAD:$BACKENDand does not coverCMAKE_ARGS, so a build-flag change alone is a silent no-op without--force. The stamp check runs beforeCMAKE_ARGSis declared, so covering it needs a reorder this PR deliberately does not attempt.