Skip to content

ggml-hrx: let a gated delta net carry more than five rollback snapshots - #125

Merged
bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/gdn-snapshot-cap
Oct 22, 2026
Merged

bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/gdn-snapshot-cap

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

PR body — 1bit-MONSTER/llama.cpp, branch 1bit/gdn-snapshot-cap, sha 4dcf2cc

Title: ggml-hrx: let a gated delta net carry more than five rollback snapshots

Why

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 change

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 a 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 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):

planes recurrent state
one state plane per layer — 128×128×48×4 B = 3 MiB
one snapshot slot, all 48 layers 1 144 MiB
--spec-draft-n-max 3 4 576 MiB
--spec-draft-n-max 7 8 1.125 GiB

The 576 MiB difference is paid by the flag today, not by this commit: n_rs_seq follows --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 --mtp at --spec-draft-n-max 3, 5, 7, GGML_HRX_STRICT=1 + GGML_HRX_REPORT=2, fresh
    server 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 acceptance
    69/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.
  • device memory measured (GTT, loaded server, no requests sent): 20,981 MiB at n-max 3 against
    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_seq follows
    --spec-draft-n-max, not this matcher — so this commit adds no memory, it lets a graph write planes that
    were already reserved.
  • scripts/hw-gate.sh on this build, seven models, ops,kat,placement: ops 663/663 PASS, kat PASS on
    all 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 isolated
    HW_GATE_STORE has no recording at the pin ("base logits missing … record them at the release pin"). That is
    a 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-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, and not something this change
    removes. The model-level runs above plus the hw-gate rows are what cover it.

🤖 Generated with Claude Code

bong-water-water-bong and others added 2 commits October 21, 2026 22:38
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]>
@bong-water-water-bong
bong-water-water-bong merged commit 851fa6c into 1bit/hrx-vulkan-patched Oct 22, 2026
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/gdn-snapshot-cap branch November 12, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant