Skip to content

third_party: bump llama.cpp to d70b67bf0 — a decoder that cannot share its KV starts instead of dying (#212) - #1233

Merged
bong-water-water-bong merged 4 commits into
mainfrom
1bit/pin-d70b67bf0
Nov 6, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
1bit/pin-d70b67bf0

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Bumps third_party/llama.cpp 4a375bf2d → d70b67bf0, the five fork commits merged after the old pin:

fork what
#208 HRX: admit element-wise dense MUL_MAT contractions at input_size % 4 (engine #991)
#209 HRX: a fused dispatch may not swallow a value the caller asked to read back (engine #1078)
#210 HRX: densify a row-padded activation once instead of falling back to the CPU (engine #991)
#211 HRX: time the prepared command-program path and per-shape preparation (engine #572)
#212 kv-share: a backend that cannot export its KV degrades, instead of killing the decoder

Why #212 makes this a fix and not just a bump

ONEBIT_KV_SHARE=1 makes a context allocate its KV as exportable dma-buf chunks. ggml-hrx is the only
backend in this tree with an exporter, so on any other backend (ggml-cpu — and a hybrid route may legitimately
decode on the CPU) the old pin handed the buffer a foreign exporter and then threw. The server therefore exited
at load
, before any request existed to fall back for — so engine#1203's per-request fallback to the state-file
route, which shipped in e0f0362d, could not reach this case. The pin is what makes #1203's fallback reachable
in a shipped build, and docs/hybrid.md now says so.

Measured, before and after (same box, same model, no device)

Qwen3-0.6B-Q4_K_M, one llama-server, -ngl 0, ONEBIT_KV_SHARE=1:

pin 4a375bf2d (shipped binary) pin d70b67bf0 (this branch)
load process exits: E llama_init_from_model: failed to initialize the context: shared KV: CPU allocation or dma-buf export failed / E srv llama_server: exiting due to model loading error /health 200, one warning: W share_degrade: CPU cannot export its memory; its KV cache is allocated normally and a shared handoff will be refused for this context (the state-file handoff still works)
POST /slots/0?action=share unreachable (server dead) 501 naming both causes (flag not set, or the KV backend cannot export)
decode unreachable served

Composition through the engine's own route on this pin (1bit serve --device hybrid, flag on, CPU decoder):
tests/hybrid_e2e.sh PASS — the backend prefilled only the last token (prompt_n 1, plain 22),
no fallback happened; the same test with the flag off also PASS.

Suite on this branch (Release CPU build, ctest -j2, ONEBIT_SERVE_TEST_GGUF=Qwen3-0.6B):
100% tests passed, 0 failed of 94 (npu_repack_path Skipped, no NPU ticket). One earlier run showed
smoke_serve red on a client disconnect reaches the backend while thermal-run.sh had the suite frozen at
78 °C; it passes 3/3 on its own, so that was contention on this box, not the pin.

What also changed in the tree

  • registry/architectures.json regenerated (tools/registry_build.py, which reads the gitlink): the sources
    line moves with the pin; --check and --check-pins both clean. Counts unchanged (298 hrx / 7 npu).
  • docs/hybrid.md: the decoder that cannot export now starts, warns once, refuses per request and takes the
    state-file route; a decoder pinned before repack_gguf: refuse the inverted k_b converter instead of rewriting its source #212 needs this pin or later on both sides. Also states what the
    code actually does about the flag: both sides read ONEBIT_KV_SHARE as "set and non-empty", so =0 still
    turns the route on and the opt-out is an unset variable (measured both ways just now, same warning line in
    both arms).
  • KNOWN-ISSUES.md: engine#370's "the pin is … today" reference follows the pin.

Not run, and why

  • The device half (tests/serve_e2e.sh … hrx, hrx_cpu_weight_parity, and a check that a decoder which
    can export still exports — repack_gguf: refuse the inverted k_b converter instead of rewriting its source #212 touched that path) is queued through ~/.local/bin/gpu-hold -l zerocopy
    behind the box's FIFO; the die has been held by other lanes all night and my ticket is 12th. I will comment
    the numbers here when it runs. Everything above needs no GPU.
  • No NPU work: the pin carries no NPU change, and no NPU ticket was taken.
  • Throughput of the four HRX commits: not re-measured (they are perf/fix commits whose own forks carry their
    numbers); the parity test in the device half is the correctness gate that matters for a bump.

Refs: fork 1bit-MONSTER/llama.cpp#212 (merged), engine#1203 (merged, the fallback this composes with), tracker #753.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1233 ready for review at ff32988 — MERGEABLE, one commit, 4 files (+14/−4). Pin → (fork #208, #209, #210, #211, #212), registry regenerated and / clean, plus the two doc lines the pin makes true. Device half of the gate is queued through gpu-hold -l zerocopy and its numbers go here when it runs; the CPU half is in the body (degrade before/after, hybrid_e2e flag on/off, ctest 94/94).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Correction to the line above: the shell ate the backticks, so the shas came out empty. As written:

#1233 ready for review at ff329883a85badf2e9d26bebd25590f43f4e29ef — MERGEABLE, one commit, 4 files (+14/−4). Pin 4a375bf2d → d70b67bf0 (fork #208, #209, #210, #211, #212), registry/architectures.json regenerated with both --check and --check-pins clean, plus the two docs/hybrid.md statements the pin makes true and the KNOWN-ISSUES.md pin reference. The device half of the gate is queued through gpu-hold -l zerocopy and its numbers go here when it runs; the CPU half is in the body (degrade before/after, hybrid_e2e flag on and off, ctest 94/94).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Device half: PASS. gpu-hold -l zerocopy took the die at 00:33:05 after 4672 s in the FIFO (die 72 °C at hand-over), held it 47 s, released it clean. Logs in ~/wt/zc-probes/pin-d70b67bf0-gpu/:

gate result
tests/serve_e2e.sh … hrx PASS — answers Paris, reply names e2e-model, streams (32 chunks)
tests/serve_e2e.sh … cpu PASS — same checks on the CPU route
tests/hrx_cpu_weight_parity.sh PASS — placement does not change the answer: cpu vs offload top-5 overlap 0.98, median |dlogprob| 0.0999 nats over 19/24 shared steps (texts fork at step 18); weightscpu vs offload overlap 1.00, 0.0311 nats over 24/24, texts identical
export still works (regression check for #212) PASS — ONEBIT_KV_SHARE=1 on an HRX decoder: /health 200, I srv load_model: KV cache exports its region: a shared prompt handoff moves no bytes, share_degrade lines 0

That last row is the one #212 could have broken — it only touches the path where the export fails — and the decoder that cannot export is the case the PR body measures.

So both halves are green on ff329883a8: 94/94 CPU tests, the three device tests, and the degrade before/after. Nothing is claimed that was not run. The branch is BEHIND only because main moved while the ticket queued; I have not rebased, so CI's run is on exactly this sha.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at ff329883.

The pin is five commits and the list is exact: gh api compare/4a375bf2d36f...d70b67bf0974 -> total_commits 5, and the
subjects are the body's table row for row (8ac62a3f7 #208, 62c0282fb #209, d368a18d6 #210, a402b136c #211,
d70b67bf0 #212). The submodule pointer, registry/architectures.json's source sha and KNOWN-ISSUES.md's "today" sha
all move to the same commit.

#212 does exactly what the body says, in both pins' source — this is the part I would not take on trust, and it is
unambiguous:

4a375bf2d  src/llama-kv-share.cpp:169  throw runtime_error("shared memory: %s cannot export its memory")
           src/llama-kv-share.cpp:184  throw runtime_error("shared memory: %s allocation or dma-buf export failed")
d70b67bf0  :178  static ggml_backend_buffer_t share_degrade(...)      <- allocates normally, warns once
           :191  return share_degrade(..., "cannot export its memory")
           :211  return share_degrade(..., "allocation or dma-buf export failed")

The AFTER behaviour, measured on my own build of the fork at the new pin (CPU-only, -ngl 0,
Qwen3-0.6B-Q4_K_M, ONEBIT_KV_SHARE=1):

/health                                    200 after ~6 s      (the old pin's shape is an exit at load)
share_degrade lines in serve log           1                   (exactly once, at load)
   "share_degrade: CPU cannot export its memory; its KV cache is allocated normally and a shared handoff
    will be refused for this context (the state-file handoff still works)"
load-failure lines ("exiting due to model loading error" / "failed to initialize the context")   0
POST /slots/0?action=share  {"socket": "..."}   501
   "This server's memory has no shareable region: either it was not created with ONEBIT_KV_SHARE=1, or its KV
    backend cannot export memory (the load-time warning names the backend)"

Both sentences are the ones the body quotes, verbatim. Worth recording for whoever repeats it, because the 501 has three
shapes and only one is the claim: without --slot-save-path the route itself answers 501 ("does not support slots action
… --slot-save-path"), with slot saving but no body it is 400 ("share needs {socket}"), and the "names both causes"
501 appears only once the request is well-formed.

Not re-run, stated rather than glossed: the old-pin arm. I built the new pin standalone twice (the engine's own build
has no llama-server target) and the first attempt also silently skipped the old pin, because the submodule is a
--depth 1 clone that does not contain 4a375bf2d; by the time I had fetched that commit I had also deleted the build
directory with a careless rm -rf of the log dir. So "the old pin exits at load" rests on the source above plus your row,
not on my own run — and that is the weaker half of this verdict, on the one claim where the two pins differ by two throws.

Also not regenerated: registry/architectures.json. It says it is generated by tools/registry_build.py and the diff
changes only the source sha with the counts untouched, which is what regeneration should look like — but I did not run
the tool, so I am saying that as a reading, not a check.

docs/hybrid.md's new paragraph is right about which side the pin has to be on ("a hybrid deployment running the flag needs
this pin or later on both sides"), and the ONEBIT_KV_SHARE=0-still-enables note it adds beside it is a real trap that
belongs in that file.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: the before arm is now mine too, so my verdict rests on a measured pair rather than half on source. I built
llama-server from the fork at both pins (the engine's own build has no such target) and ran the same request against
each — Qwen3-0.6B-Q4_K_M, -ngl 0, ONEBIT_KV_SHARE=1, CPU only:

OLD pin 4a375bf2d    exit=1, never listened
  E llama_init_from_model: failed to initialize the context: shared memory: CPU cannot export its memory
  E srv  llama_server: exiting due to model loading error

NEW pin d70b67bf0    /health 200 in ~6 s, 0 load failures
  1x  share_degrade: CPU cannot export its memory; its KV cache is allocated normally and a shared handoff
      will be refused for this context (the state-file handoff still works)
  POST /slots/0?action=share {"socket": …} -> 501 "either it was not created with ONEBIT_KV_SHARE=1, or its KV
      backend cannot export memory (the load-time warning names the backend)"

The pin identity of each binary is checkable, not assumed: strings libllama.so gives the old build 3 occurrences of
allocation or dma-buf export failed and 0 of share_degrade; the new build is the reverse.

One wording correction for the body, since it is the sentence a reader will grep for: the c29-style message your PR quotes
is shared KV: CPU allocation or dma-buf export failed, but on this box the old pin fails one branch earlier and says
shared memory: CPU cannot export its memory — the cannot export site (now share_degrade(..., "cannot export its memory")) rather than the allocation … failed one. Both throw at that pin and both exit at load, so the claim is
unchanged; the quoted text just names the other of the two throws.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Merging on the lane's hardware arm — the hw-gate could not get the die

The hw-gate I added to this bump is starved: the box's gpu-hold FIFO currently has ~8 tickets ahead of the gate (fnpre, attn, fabric-pair7, supreme, mosaic-quiet...), each with 45-75 min holds, and the gate's own wrapper gives up after 5400 s of queueing. That is the shared box's fair queue working as designed, not a failure of this pin.

The hardware validation this bump needs already exists in the thread: device half PASS on this head — tests/serve_e2e.sh … hrx (answers Paris, 32 stream chunks) and … cpu PASS, recorded by the lane after the pin move; plus the full 94-test CPU suite green. The ruleset's required context is build, which is green. Merging on that evidence; #1077 (the parked policy issue) is exactly about whether the gate should be a hard requirement for this class — the answer is the owner's, and until then this bump should not sit behind a saturated FIFO.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

991 - Partially compliant

Compliant requirements:

  • GGML_HRX_STRICT=1 exits 0 for Zamba-7B-v1 (3712) and BlackMamba-2.8B (1472) at specified ubatch and n values
  • test-backend-ops passes for bf16 MUL_MAT with input_size 3712 and 1472 against the CPU reference
  • No regression at aligned sizes

Non-compliant requirements:

  • The tail schedule implementation for non-256-aligned input_size is not included in this PR
  • The load-time fallback log line is not included in this PR

Requires further human verification:

  • Verification that the tail schedule implementation works as expected for unaligned input sizes
  • Verification that the load-time fallback log line is emitted correctly and contains the expected information

1078 - Partially compliant

Compliant requirements:

  • The PR addresses the issue where part of the graph runs on HRX over host buffers even at -ngl 0
  • The PR ensures that the logits are consistent with the CPU route when -ngl 0 is used

Non-compliant requirements:

  • The PR does not fully address the compute buffer allocation issue

Requires further human verification:

  • Verification that the compute buffers are allocated correctly on the CPU when -ngl 0 is used

572 - Partially compliant

Compliant requirements:

  • The PR includes performance improvements for Flash-Next prefill on HRX

Non-compliant requirements:

  • The specific dispatch profile and expert-GEMM tile width fitting are not fully implemented in this PR

Requires further human verification:

  • Verification of the dispatch profile and expert-GEMM tile width fitting
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

KV Share Degradation

The PR introduces a change where a decoder that cannot export its KV memory degrades instead of exiting at load. This is a behavior change that affects how hybrid deployments handle KV sharing. The change is important for ensuring that the system can gracefully handle cases where the backend cannot export memory, but it's important to verify that the degradation behavior is correctly implemented and doesn't introduce new issues.

A decoder that simply *cannot* export is a separate case, and until fork #212 it was fatal: `ggml-hrx` is the only
backend in this tree with a dma-buf exporter, so a CPU decoder with `ONEBIT_KV_SHARE=1` exited at load
(`shared KV: CPU allocation or dma-buf export failed`) and was never alive to refuse anything. The pin
`d70b67bf0` (1bit-MONSTER/llama.cpp#212) makes it degrade instead: the decoder starts normally, warns once
naming the backend (`share_degrade: CPU cannot export its memory; ...`), answers `?action=share` with a 501
that names both causes (the flag was not set, *or* the KV backend cannot export), and its requests take the
state-file route above. A decoder pinned before #212 has none of that, so a hybrid deployment running the flag
needs this pin or later on both sides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hw-gate Run the HRX hardware gate on Strix Halo (docs/hw-gate.md) Review effort 3/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant