Repository navigation
Description
#533's remaining failure is an ordering defect, not a fusion-eligibility one: a dispatch that was emitted before
the fused kernel reads a value the fusion writes. Fixing it needs the scheduler to withdraw (or never emit) a
dispatch that a later fusion supersedes. Recording the evidence here so the systemic fix is not lost.
The dump (selected-snapshot GDN graph, 8 commands)
command 0..3 ggml_copy_f32 graph values -> transients 1, 3, 5, 7
command 4 ggml_copy_f32 reads transient value 10 (3,145,728 B, Read) -> writes graph value 29
command 5 fused GDN …_selected_snapshot_projection_rms_gate_q8 (14 bindings)
reads q/k/v = 1, alpha 3, beta 5, state 8, raw_gate 7, …
writes snapshot_cache = value 29 (Write), dst 35, q8_output 40
command 6, 7 mul_mat, copy consume 40 -> 38 -> 39
Value 29 is the snapshot cache. Command 4 copies transient 10 into it; command 5 writes it directly, so command 4
is redundant — and transient 10 (the pre-fusion GDN snapshot output) has no writer any more. The verifier rejects
the plan with
VERIFY-ERROR: command 4 … binding source value=10 origin=Transient access=Read range=[0, 3145728)
reads transient value 10 before write
Why a matcher-level guard cannot fix it
Tested: refusing the fusion when a consumer of the pre-fusion snapshot value has a node index lower than its
producer's. It never fires, because dispatch order is by programme root, not by node index: the copy's
programme is rooted at the GET_ROWS node (early), while the fused programme is rooted at the GDN node (later).
So the copy is emitted first even though its node sits after the GDN node. The plan keeps the fused kernel, and
the case fails as before.
What the scheduler would need
Either
- withdraw on fusion: when a programme covers nodes whose dispatches are already in the plan, drop those
dispatches (they are redundant by construction) and re-verify; or - dependency-ordered emission: emit by data dependency rather than root index, so a writer always precedes
its readers.
Option 1 is the smaller change and matches how the covered set already works: covered_nodes marks the nodes a
programme claims, so the plan should not keep dispatches that only exist to serve a covered node.
The three affected matchers (all the same class)
dispatch_registration/llm/dispatch-gated-delta-net.cpp—match_selected_gated_delta_net_dispatch
(this dump).dispatch_registration/qwen/dispatch-qwen-attention-postprocess.cpp—qwen_attention_postprocess_dispatch:
command 0, 12 bindings,query_input/key_input/value_inputread before write.dispatch_registration/qwen/dispatch-routed-ffn.cpp—qwen_routed_gate_up_dispatch:command 3,
4 bindings,inputvalue 16 read before write.
All three currently sit behind known_fail("#533") in hrx-backend-test.
Activity
bong-water-water-bong commentedon Oct 25, 2026
Fixed by fork 1bit-MONSTER/llama.cpp#150 (merged): a registry-level fusion-order guard refuses any match that reads a transient value before a dispatch writes it, so the three verifier rows (gdn_selected_rms_q8, qwen_attention_postprocess, qwen_routed_gate_up) pass; host suite 60/0/6 -> 63/0/3, device 11/11, KLD identical on the GDN models and the 27B with 0 refusals. Also fixes a real defect: routed-ffn gate_up_swiglu_f16_wmma is now used only when every GLU consumer is a Q4_K/Q6_K routed down projection (other down weights read an unwritten value; unit-tested only, no local model has them). Reaches the engine with the next llama.cpp pin bump.