Repository navigation
hrx: the multi-stream flash-attention matcher declines V head sizes its kernel refuses (fork #450 review) - #462
Conversation
…ts kernel refuses (fork #450 review) onebit.flash_attention_streams_f32_f16_wmma admitted a V head size up to 576, but ggml_flash_attention_f32_f16_wmma declares value_head_size in [64, 512]. A claimed Dv=576 node failed the whole graph at JIT time ("symbol @ggml.flash_attention.value_head_size value 576 violates constraint range", then "failed to prepare command") instead of falling back to the CPU. The cap is now 512. The matcher also requires every nb[3] to be a multiple of 16, the alignment the kernel declares for all five bindings (llama graphs always satisfy it: n_kv is a multiple of 256). tests/test-hrx-fa-streams: supports_op is now asked before the tensors are allocated, the way the scheduler asks. Afterwards HRX0 answers yes for any node whose output already sits in its memory, so the old claim check proved nothing. 12 new cases: Dv != D (192/128, 96/64), one KV head at head 256, H == Hkv, 8:1 GQA, 2100 tokens per stream (query chunks inside a stream), q stream planes with a gap, 576/512 with a separate V cache, plus optional cases that must be declined or correct: a 113-key mask, Dv=576, a broadcast mask, sinks. Measured on strixhalo (gfx1151), performance mode, fork 5abb405 + hrx-system 7f423692, no gpu-kernels add-on, 3 runs per arm: - before (fork 5abb405 lib, new test): 19/20 every run; the Dv=576 case FAILs (claimed, JIT refuses it). - after: 20/20 every run; Dv=576 declined; the other 16 claimed cases NMSE 1.06e-6 to 2.32e-5, max abs <= 1.15e-3, identical across runs. - test-backend-ops -o FLASH_ATTN_EXT -b HRX0 (after): 484/484 passed. - MES failure count 0 before and after both device tickets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
VERDICT: READY " That is the right kind of follow-up: the matcher and the kernel disagreeing about their contract, found by reading both rather than by watching one fail. A matcher that admits a size the kernel does not implement is the worst of the three possible states — it passes the dispatch decision, then fails (or corrupts) at launch, and it fails only on the shapes nobody tested. Today's fleet-wide serve breakage was the same class in a different costume ( Three asks:
On the shape: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6f4ed17: READY
The matcher change comes with a test edit in the same PR (tests/test-hrx-fa-streams.cpp), which is the thing I would have asked for otherwise — this is a dispatch-decision change, and the only durable evidence that a matcher declines the right shapes is an arm that runs it.
What the change is: the multi-stream flash-attention matcher declines (rather than accepts and failing later) for the shapes it cannot serve, which is the same direction every good change in this family has taken tonight — a matcher that says no lets the next registration answer, while one that says yes and produces garbage hides the problem one layer down.
I did not run the suite (it needs the device and the add-on), so my READY rests on: the matcher edit plus its test edit travelling together, and the change being a decline rather than a reroute. If any part of it widens an accept, that is where I would want the device run quoted.
|
VERDICT at Two things the change gets right and one question. Right: The question: the comment quotes four bounds — Q/K head size a multiple of 16 in [16, 576], V in [64, 512] as a multiple of 64, 1..64 heads, and at most 2048 query rows per launch — while the added code I can see enforces The fixture row with LFM3's real attention shape (head 128, 16 query heads over 4 KV heads) is the right kind of test data — a matcher's arms are only as good as the shapes they pin, and a real model's shape beats a synthetic one. |
Review follow-up to #450 (engine#2918), by an independent read of the matcher against the kernel.
onebit.flash_attention_streams_f32_f16_wmma(#450) admitted V head sizes up to 576, butggml_flash_attention_f32_f16_wmmadeclaresvalue_head_sizein [64, 512]. A claimed Dv=576 node failed the graph at JIT time ("value 576 violates constraint 'range'", then "failed to prepare command") instead of falling back to the CPU. The cap is now 512. The matcher also requires eachnb[3]to be a multiple of 16, the alignment the kernel declares for every binding (llama graphs always meet it).tests/test-hrx-fa-streamsnow askssupports_opbefore allocating, the way the scheduler does: after allocation HRX0 says yes for any node already in its memory, so the old check proved nothing. It adds 12 cases: Dv != D (192/128, 96/64), one KV head at head 256, H == Hkv, 8:1 GQA, 2100 tokens per stream, q planes with a gap, 576/512 with a separate V cache, and optional cases (113-key mask, Dv=576, broadcast mask, sinks) that must be declined or correct.Verified from source and unchanged: per-stream offsets for all five bindings, V addressing for D != Dv, sinks and broadcast masks declined, no scratch shared across streams, cache keys, and the matcher cannot take ne[3]==1 nodes from any other FA matcher (in-tree or add-on).
Measured on strixhalo (gfx1151, performance mode), 3 runs per arm: before 19/20 (Dv=576 fails), after 20/20; claimed cases NMSE 1.06e-6 to 2.32e-5, identical across runs;
test-backend-ops -o FLASH_ATTN_EXT -b HRX0484/484; MES failures 0. No performance claim: the fix only declines shapes llama never builds.Follow-ups, not in this PR: the single-stream matcher has the same Dv=576 over-admission (
dispatch-flash-attention.cpp:124-126); multi-stream MLA (V a view of K) is declined today and could be admitted the way the single-stream matcher does.🤖 Generated with Claude Code