Repository navigation
ggml-hrx: let a gated delta net carry more than five rollback snapshots - #125
Merged
bong-water-water-bong merged 2 commits intoOct 22, 2026
Merged
Conversation
Qwen3.8-27B --mtp --spec-draft-n-max 5 and 7 refuse to load on HRX under GGML_HRX_STRICT=1, and the node they
name is the gated delta net itself (the L2_NORM in front of it was fixed in gpu-kernels#23):
unsupported HRX node 65: GATED_DELTA_NET output=77:f32[6144,1026,1,1] ... consumers=[66:VIEW, 69:VIEW]
ne[1] = 1026 = 2 tokens + 8 * 128 snapshot rows, i.e. eight rollback snapshots, and both gated-delta-net
matchers in dispatch-gated-delta-net.cpp carried `if (snapshot_count < 1 || snapshot_count > 5) return {};`.
n-max 3 needs four, which is exactly why n-max 3 loaded and 5 and 7 did not.
The bound is now kMaximumSnapshots (ubatch-token-limits.h, = kUbatchMaxTokens), used by both matchers. It
allocates nothing, and it cannot make the kernel write outside the cache:
- llama_memory_recurrent sizes (1 + n_rs_seq) state planes per layer, and
common_params_speculative::need_n_rs_seq() sets n_rs_seq to the draft n_max, so --spec-draft-n-max N already
commits N + 1 planes at context creation, whether or not any graph writes them;
- the matcher still requires the cache to hold exactly as many planes as the graph writes
(cache->ne[2] == written_snapshot_count), that nb[2] covers a whole state plane, that
byte_count >= state_plane_bytes + (written_snapshot_count - 1) * nb[2], and that the state and the cache are
different storages. A graph that asks for more planes than the cache has is declined, not written.
Memory, Qwen3.8-27B (48 gated-delta-net layers, width 128, 48 v-heads, one sequence): one state plane per layer
is 128*128*48*4 B = 3 MiB, so one snapshot slot across the model is 48 * 3 MiB = 144 MiB. n-max 3 commits 4
slots = 576 MiB, n-max 7 commits 8 slots = 1.125 GiB - a difference of 576 MiB that the flag already pays today
(n_rs_seq follows --spec-draft-n-max, not the matcher's cap), plus 12 MiB for the draft model's own layer.
Measured, device memory (GTT) of a loaded server with no requests sent: 20,981 MiB at n-max 3 against
21,579 MiB at n-max 7, i.e. +598 MiB, against the 588 MiB the arithmetic predicts. Resident set is identical
(1,688 MiB) in both, because these are device buffers. This commit therefore adds no memory: it lets a graph
write planes that n_rs_seq already reserved.
Checked: Qwen3.8-27B --mtp at --spec-draft-n-max 3, 5 and 7, GGML_HRX_STRICT=1 + GGML_HRX_REPORT=2, one fresh
server each: all three load with 0 nodes off HRX, answer a 96-token greedy request, and produce the same text
(sha256 ea66004076024aab...). Decode on that prompt: 30.54 / 25.12 / 24.44 tok/s at n-max 3 / 5 / 7, with draft
acceptance 69/76, 74/102 and 78/112 - so the fix removes the hard failure and the default n-max 3 stays the
fastest setting; a larger n-max is a flag for the user, not a new default.
test-backend-ops has no GATED_DELTA_NET cases in this fork (-o GATED_DELTA_NET reports "0/0 tests passed"), so
that op has no small-shape CPU comparison at all - pre-existing, not something this change removes. The
model-level runs above and the hw-gate rows (ops 663/663, kat and placement on all seven models) are what cover
this change; the kld phase cannot be compared right now because the shared base-logit store was rewritten by
concurrent gate runs today and an isolated store has no recording at the pin.
Co-Authored-By: Claude Opus 5 <[email protected]>
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.
PR body — 1bit-MONSTER/llama.cpp, branch
1bit/gdn-snapshot-cap, sha 4dcf2ccTitle: ggml-hrx: let a gated delta net carry more than five rollback snapshots
Why
Qwen3.8-27B --mtp --spec-draft-n-max 5and7refuse to load on HRX underGGML_HRX_STRICT=1, and the nodethey name is the gated delta net itself (the L2_NORM in front of it was fixed in gpu-kernels#23):
ne[1] = 1026 = 2 tokens + 8 × 128snapshot rows, i.e. eight rollback snapshots, and both gated-delta-netmatchers in
dispatch-gated-delta-net.cppcarriedif (snapshot_count < 1 || snapshot_count > 5) return {};.n-max 3 needs four — which is exactly why n-max 3 loaded and 5 and 7 did not.
The change
The bound is now
kMaximumSnapshots(ubatch-token-limits.h, =kUbatchMaxTokens), used by both matchers. Itallocates nothing, and it cannot make the kernel write outside the cache:
llama_memory_recurrentsizes(1 + n_rs_seq)state planes per layer, andcommon_params_speculative::need_n_rs_seq()setsn_rs_seqto the draftn_max, so--spec-draft-n-max Nalready commits
N + 1planes at context creation whether or not a graph writes them;(
cache->ne[2] == written_snapshot_count), thatnb[2]covers a whole state plane, thatbyte_count >= state_plane_bytes + (written_snapshot_count - 1) * nb[2], and that the state and the cache aredifferent storages. A graph asking for more planes than the cache has is declined, not written.
Memory, Qwen3.8-27B (48 gated-delta-net layers, width 128, 48 v-heads, one sequence):
--spec-draft-n-max 3--spec-draft-n-max 7The 576 MiB difference is paid by the flag today, not by this commit:
n_rs_seqfollows--spec-draft-n-max,so the planes exist whether or not the matcher lets a graph write them. Measured resident size of a loaded
server, no requests sent, is in the checks below.
Checks
Qwen3.8-27B --mtpat--spec-draft-n-max3, 5, 7,GGML_HRX_STRICT=1+GGML_HRX_REPORT=2, freshserver each: all three load, 0 nodes off HRX, answer a 96-token greedy request, and produce the same
text (
ea66004076024aab…). Decode on that prompt: 30.54 / 25.12 / 24.44 tok/s, draft acceptance69/76, 74/102, 78/112 — so the fix removes the hard failure and the default n-max 3 stays the fastest
setting; larger n-max is a flag for the user, not a new default.
21,579 MiB at n-max 7 = +598 MiB, against the 588 MiB the arithmetic predicts; resident set identical
(1,688 MiB), because these are device buffers. The flag pays it today —
n_rs_seqfollows--spec-draft-n-max, not this matcher — so this commit adds no memory, it lets a graph write planes thatwere already reserved.
scripts/hw-gate.shon this build, seven models,ops,kat,placement: ops 663/663 PASS, kat PASS onall seven except zaya1-8b (the known pin drift: a no-patch build at the same gpu-kernels pin drifts
identically, and its golden predates gpu-kernels hrx-ops-test: every expectation names a kernel dispatch can select; the stale table is gone (engine#2774) #490/moe-stream: prefetch on a worker thread, N layers ahead; ONEBIT_MOE_STATS #20), placement PASS on all seven (152 graphs for
the 27B, 170 for zaya). The kld rows could not be compared: the shared base-logit store
(
~/.cache/hw-gate/kld) was rewritten by three other agents' gate runs at 19:15-19:19 today, and an isolatedHW_GATE_STOREhas no recording at the pin ("base logits missing … record them at the release pin"). That isa store problem, not a numerics result, and the kld phase needs a recording run at the pin before it can be
quoted again.
test-backend-opshas no GATED_DELTA_NET cases in this fork (-o GATED_DELTA_NETreports "0/0 testspassed"), so that op has no small-shape CPU comparison at all — pre-existing, and not something this change
removes. The model-level runs above plus the hw-gate rows are what cover it.
🤖 Generated with Claude Code