Skip to content

hrx: the fused GDN selected-snapshot programme keeps its gate producer before the kernel (engine #533) [verify pending] - #133

Closed
bong-water-water-bong wants to merge 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/533-gdn-rms-order
Closed

bong-water-water-bong wants to merge 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/533-gdn-rms-order

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

What

match_gated_delta_net_rmsnorm_q8 replaces the last dispatch of the matched programme with the fused
..._selected_snapshot_projection_rms_gate_q8 kernel, and then cleared the whole dispatch list before
pushing that one back:

selected.dispatches.clear();
selected.dispatches.push_back(std::move(dispatch));

A one-token graph's programme has two dispatches, so that dropped the first — the projections / gate
producer — even though its nodes stay in selected.covered_nodes. The fused kernel therefore reads
raw_gate from a command that is emitted after it, and the command-program verifier rejects the plan
(engine ggml-org#533):

VERIFY-ERROR: command 6 kind=Kernel kernel_id=16267978791500782568 bindings=5 deps=1
              binding raw_gate value=33 origin=Transient access=Read range=[0, 24576)
              reads transient value 33 before write by command 7

Replace only the dispatch the fused kernel supersedes (back()), so the producer stays ahead of its
consumer. The planner orders commands by append position and gives each a linear dependency on the
previous one (dispatch/command-program.cpp: "TODO: replace this linear ordinal dependency with real
graph/resource dependency analysis"), which is what makes the reversal fatal rather than merely untidy.

Before (at the pin, llama.cpp 7ca8ba5a + hrx-system 82804197)

[KNOWN-FAIL #533] gdn_selected_rms_q8_dispatch
       VERIFY-ERROR: command 6 ... binding raw_gate value=33 ... before write by command 7

Dumped programmes show the same case's passing shapes are 7 commands with gdn@4 reading raw_gate = value 7 written by command 3 — the normal order — while the failing shapes are exactly the ones that take
this branch.

After — pending, and why

The verifier re-run for this branch has not been made: the owner handed the GPU lane to the 27B
leaderboard ("no new gpu-hold claims until 'leaderboard done'") in the middle of this change, and I
cancelled my queued claim rather than sit on the lane. The command is ready to run:

~/wt/bw220/build-t533.sh hrx-backend-test && ~/wt/bw220/hold.sh ~/wt/bw220/hold32.sh fix2
# expect: [UNEXPECTED-PASS #533] gdn_selected_rms_q8_dispatch  (then retire the tag -> [PASS])

I am not claiming PR-READY for this one until that output exists.

Model check (unchanged either way)

Qwen3.8-27B UD-Q4_K_XL --mtp, family enabled vs
GGML_HRX_DISABLE_DISPATCH=llm.gated_delta_net.selected_snapshot, per-token top-5 logprobs:

prompt tokens greedy text logprobs max abs Δlogprob
code 128 identical identical 0.000e+00
prose 128 identical identical 0.000e+00
short 26 identical identical 0.000e+00

Cold-vs-warm identical. 90 W cap, PCM pad (23 Oct). So the fix is plan-order only; it cannot move
numbers, and the A/B above is the evidence for that.

Risk

One branch of one matcher, no kernel change, no binding-count change: the programme keeps one more
dispatch, which was already being covered by this match before it was dropped. If the verifier still
complains after the re-run, the remaining candidate is the planner's linear dependency model (the TODO
above), not this matcher.

bong-water-water-bong and others added 2 commits October 23, 2026 12:39
…-only value (engine ggml-org#533 verify)

The fused postops export declares its bias and residual bindings with read access whether or not
the kernel uses them, and the kernel only loads them when has_bias / has_residual is set. For an
absent slot the dispatcher bound the command's own output transient, which the command-program
verifier rejects:

  VERIFY-ERROR: command 2 kind=Kernel bindings=10 deps=1 binding bias value=5 origin=Transient
                access=Read range=[0, 16384) reads transient value 5 before write

Bind a value the programme already reads instead - the weight - for those placeholder slots. The
kernel never loads it (has_bias / has_residual guard the read), so nothing changes numerically.

  before: [KNOWN-FAIL ggml-org#533] common_mul_mat_id_postops_dispatch
              VERIFY-ERROR: command 2 ... binding bias value=5 ... reads transient value 5 before write
  after:  [PASS] common_mul_mat_id_postops_dispatch  (tag retired in tests/hrx-backend-test.cpp)

Model check (Qwen3-Coder-30B-A3B Q4_K_M, the postops+next_rmsnorm user): the family enabled vs
GGML_HRX_DISABLE_DISPATCH=common.mul_mat_id_postops.f32_f32_wmma gives identical greedy text and
identical per-token top-5 logprobs on three prompts (128/126/29 tokens, max |dlogprob| = 0), and an
identical second pass on the same server (cold vs warm). 90 W cap, PCM pad (23 Oct).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…r before the kernel (engine ggml-org#533)

match_gated_delta_net_rmsnorm_q8 replaces the last dispatch of the matched programme with the fused
selected_snapshot_projection_rms_gate_q8 kernel, then cleared the whole dispatch list and pushed that
one back. For a one-token graph the programme has two dispatches, so clearing dropped the first (the
projections / gate producer) even though its nodes stay in covered_nodes - the fused kernel then reads
raw_gate from a command that is emitted later, and the command-program verifier rejects the plan:

  VERIFY-ERROR: command 6 kind=Kernel bindings=5 deps=1 binding raw_gate value=33 origin=Transient
                access=Read range=[0, 24576) reads transient value 33 before write by command 7

Replace only the dispatch the fused kernel supersedes (back()) instead of clearing the list, so the
producer stays ahead of its consumer in the programme. The planner orders commands by append position
and gives each a linear dependency (dispatch/command-program.cpp), which is what makes the reversal
fatal rather than merely untidy.

Model check (Qwen3.8-27B UD-Q4_K_XL --mtp, the GDN selected-snapshot user): the family enabled vs
GGML_HRX_DISABLE_DISPATCH=llm.gated_delta_net.selected_snapshot gives identical greedy text and
identical per-token top-5 logprobs on three prompts (128/128/26 tokens, max |dlogprob| = 0), and an
identical second pass on the same server (cold vs warm). 90 W cap, PCM pad (23 Oct).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

Review (orchestrator): the GDN change is the right fix - replacing only the superseded dispatch keeps the gate producer ahead of the fused kernel instead of dropping it with the whole list; the postops hunk is #131 again (already on the base, merges as a no-op) and the test table drops the ggml-org#533 tag for the case #131 fixed. Merge waits for the device verify (hrx-backend-test run from the already-built ~/wt/t533 binary, ~1 min in a claim) once the leaderboard releases the lane; then I merge and the engine pin follows.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Reviewed and run at this tip (f7071dde, hrx-system 82804197bc, GGML_HRX=ON, host planner). Two commits, both
well-argued; here is what each buys and where the remaining ggml-org#533 failure sits.

d6d0f715 (absent bias/residual slots bind a read-only value) — works. common_mul_mat_id_postops_dispatch
no longer reports the verifier error and no longer needs its guard: at this tip the suite is
59 passed, 0 failed, 7 known-fail, 0 unexpected-pass, with that row passing and its marker retired by this
commit. The reasoning is right too: the ABI declares those slots read, so binding the output transient there
was always going to read a value nothing had written.

f7071dde (keep the gate producer) — the ordering diagnosis is right, but the plan still fails. Before it,
the one-token programme's first dispatch was dropped while its nodes stayed covered; selected.dispatches.back() = std::move(dispatch) keeps it. The plan now reads:

ggml_scale_f32, ggml_scale_f32, ggml_scale_f32, ggml_scale_f32,
ggml_copy_f32/b2, llm_gated_delta_net_f32_wmma_head128_selected_snapshot_projection_rms_gate_q8/b14,
ggml_mul_mat_f32_f32_wmma, ggml_scale_f32

and gdn_selected_rms_q8_dispatch now gets past its own assertions to the verifier, which rejects it for a
different reason:

VERIFY-ERROR: command 4 kind=Kernel kernel_id=11446535075934139114 bindings=2 deps=1 binding source
              value=10 origin=Transient access=Read range=[0, 3145728) reads transient value 10 before write

Command 4 is the snapshot ggml_copy_f32; its source transient belongs to the node the fused kernel now covers,
so nothing writes it. That is a fusion-eligibility question rather than an ordering one: the fused kernel should
not claim a programme when the gate/rmsnorm output still has a consumer outside it (here the copy that
materialises the selected-snapshot plane). selected.dispatches.size() == (token_count == 1 ? 2 : 1) is exactly
where that check belongs.

So: this PR closes one of ggml-org#533's two rows and corrects the ordering bug behind the other, but it does not close
the issue on its own. Suggested follow-up (small): in match_selected_gated_delta_net_dispatch, refuse the fused
programme when any consumer of the rmsnorm output falls outside selected + rms_match, in the same style as the
existing value_ready / only-consumer guards.

One test note for whoever takes that: run_gdn_selected_rms_q8_dispatch_checks forbids any ggml_copy_f32 in
the plan, which is now wrong — the snapshot copy is a legitimate part of the fused programme. It should assert
that the copy precedes the fused kernel and feeds one of its bindings (patch ready in
~/wt/issues-b/llama.cpp history, not pushed), and the #533 marker stays until the verifier passes.

bong-water-water-bong added a commit that referenced this pull request Oct 25, 2026
…(engine ggml-org#533, ggml-org#570) (#150)

Registry-level fusion-order guard (dispatch-fusion-order.{h,cpp}): a match whose non-write-only binding reads transient data that no earlier dispatch (in the plan or in the match) wrote is refused and falls through to the next registration; GGML_HRX_FUSION_ORDER_GUARD=0 disables, GGML_HRX_LOG_FUSION_ORDER=1 logs. Also: routed-ffn gate_up_swiglu_f16_wmma only when every GLU consumer is a Q4_K/Q6_K routed down projection (a real defect: other down weights read an unwritten f32 value). hrx-backend-test host 60/0/6 -> 63/0/3, device 11/11, test-backend-ops 314/314, KLD identical on Qwen3.5-4B / ZAYA1-8B / Qwen3.8-27B with 0 refusals, 27B draft-mtp completions identical, hw-gate PASS. Supersedes #133 and #146.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

Superseded by #150 (merged): a registry-level read-before-write guard closes engine ggml-org#533 / ggml-org#570 for all matchers; #133's kept copy read a value nothing writes in the fused programme (the 'value 10' error), and #146's consumers_covered_by is covered by the guard's checks 1 and 3.

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