Repository navigation
Description
Found while fixing an unrelated HIP compile error in #293. Filing separately because it is much larger than that PR.
Summary
The ubuntu-22-hip-quality-check job has a "Check for major VGPR spills" step that, as far as I can tell, has never run on this fork. The HIP build failed earlier, at a nodiscard compile error in fattn-common.cuh, so the job died before reaching the check. With that compile error fixed in #293, the step runs for the first time and fails.
What it reports
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 1, false> Total VGPRs: 555 (255 + 300)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 1, true > Total VGPRs: 575 (256 + 319)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 43, false> Total VGPRs: 550 (255 + 295)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 43, true > Total VGPRs: 558 (255 + 303)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 44, false> Total VGPRs: 578 (255 + 323)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 44, true > Total VGPRs: 576 (255 + 321)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 47, false> Total VGPRs: 550 (255 + 295)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 47, true > Total VGPRs: 552 (255 + 297)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 8, false> Total VGPRs: 586 (256 + 330)
fattn-vec.cuh:44: flash_attn_ext_vec<256, 2, type 47, type 8, true > Total VGPRs: 585 (256 + 329)
mmq.cuh:955: mul_mat_q<type 10, 64, true> Total VGPRs: 317 (128 + 189)
Target is gfx908 (CDNA), configured via -DGPU_TARGETS=gfx908 -DGGML_HIP_EXPORT_METRICS=On.
Reading it
The type ids are the fork's own: 47 = TURBO4_0, 44 = TURBO3_0, 43 = TURBO2_0, plus 8 = Q8_0 and 1 = F16. The first template argument of flash_attn_ext_vec is the head size.
Two things stand out:
- Every flagged flash-attention instantiation is at head size 256, and every one has TURBO4_0 as the K type.
- The numbers are
architectural + spilled. These kernels spill 295 to 330 VGPRs, roughly doubling their register footprint.
Spilling on that scale pushes traffic to scratch memory and collapses occupancy. Whatever the turbo FA path costs on CDNA today, this is likely to be a large part of it.
The mul_mat_q<type 10, ...> entry (type 10 = Q2_K) at 189 spilled is a separate, milder case and may well be upstream's rather than the fork's; worth checking against a clean upstream build before attributing it here.
Why it matters beyond performance
The fork has no AMD hardware in the fleet, so HIP has had effectively no coverage. Two independent things now point at the same corner:
- This check, flagging turbo FA at hsk=256 on gfx908.
- turbo4 V-cache corrupted since 2cbfdc62→c26cbdffc: TURBO4_0 dropped from V_rows_per_thread==4 list in fattn-vec.cuh #252 / fattn-vec: restore turbo4 V-cache (re-add GGML_TYPE_TURBO4_0 to V_rows_per_thread==4) #253, where @jasstrong reports turbo4 V-cache corruption on gfx1100 at head dim 256.
Different architectures and spilling is not a correctness bug on its own, so I am not claiming this explains #253. But "turbo FA at hsk=256 is in serious trouble on AMD" has gone from hypothesis to measurement, and it is the same neighborhood #253 has been stuck in for two weeks.
It also raises the value of #279, still open, which adds the first hsk=256 turbo FA test coverage the suite has ever had. Until that lands, every turbo FA case in the suite runs at hsk=128 and this shape is untested everywhere.
Suggested next steps
- Decide whether the check should gate CI or warn. If the spilling is longstanding and understood, a threshold or an allowlist is reasonable. If not, it should stay red.
- Establish whether this is fork-specific by building upstream at the same target and diffing the metrics. The Q2_K
mul_mat_qentry in particular smells upstream. - Look at why
flash_attn_ext_vecneeds so many registers at 256. Head size 256 doubles the per-thread K/V register working set versus 128, so a tiling orV_rows_per_threadchoice tuned for 128 may simply not fit at 256.
I have no AMD hardware, so I can take this no further than the CI metrics. Happy to help anyone who does.
Activity
jasstrong commentedon Aug 12, 2026
Ran the same set on gfx1100 (current HEAD,
-DGPU_TARGETS=gfx1100 -DGGML_HIP_EXPORT_METRICS=On). Short version: RDNA3 spills these harder than gfx908, not less. Same K=TURBO4_0 instantiations you flagged:Occupancy 5, ~2.5 KB/lane scratch. So the wave32 register file doesn't rescue it — the pressure is roughly double. (These are the gate-crossing variants; each shape also has a lower-spill instantiation, same as gfx908 — your spill gate just prints the bad ones.)
One useful narrowing: it's turbo-as-K that blows up, not turbo generally. Swapping roles on the same two types:
K=TURBO4_0, V=Q8_0spills 651, butK=Q8_0, V=TURBO4_0spills only 36 (zero-spill variant at occ 7). So the target is the turbo K-cache path infattn-vec— and the common mixedq8_0-K / turbo4-V shape, which is what my head-dim-256 deployment actually runs, is largely unaffected.On correctness: #252 is separately fixed on current HEAD — the added
dkq256/q8_0-turbo4 fattn instances that didn't exist at the old pin. My deployed model is exactly that shape (Qwen3.6-35B-A3B, head-dim 256,q8_0-K / turbo4-V cache) and runs clean — coherent generation, no garbling. So the corruption is resolved, and it's a separate axis from this spill.Happy to keep poking at these on gfx1100 — hardware's here.
jasstrong commentedon Aug 13, 2026
Third AMD-arch datapoint, since I had the hardware: gfx1030 (RDNA2 — a Radeon PRO V620, 32 GB). Same fork, built for
gfx1030with zero source changes; the WMMA/RDNA3 paths are all properly arch-guarded, so it compiles clean on RDNA2. And it runs: my deployed model (Qwen3.6-35B-A3B, head-dim 256, native TQ4 weights) generates coherent output on the V620 at ~17 tok/s decode / ~24 tok/s prompt, all layers on-card. So the turbo path is now exercised on CDNA (gfx908), RDNA2 (gfx1030), and RDNA3 (gfx1100).test-backend-opssurfaced three things, in decreasing order of interest:ncolsMUL_MAT_IDcrashes on AMD without WMMA. On gfx1030 aMUL_MAT_IDwith an odd row count falls through tomul_mat_vec_f, which assertsncols % 2 == 0(mmvf.cu:421) — hard abort. The dispatch is byte-identical to upstream ggml, so this is a latent upstream bug on the AMD-non-WMMA path, not something turbo introduced; gfx1100 dodges it via its WMMA route. Real MoE models are safe (their expert/routing dims are even — mine are), but the syntheticm=24, k=16384MUL_MAT_IDtest trips it. Since the dispatch is identical to upstream, I wasn't sure whether you'd rather carry a guard in the fork or leave it to upstream ggml — what's your read?MUL_MAT tq3_1slands a hair over the precision gate on RDNA2: NMSE 0.000508 vs the 0.0005 threshold (~1.7% over). gfx1100 passes the same shape, so this reads as RDNA2 fp-reduction ordering rather than anything structural — benign for inference (the real model runs clean), but flagging it as an arch difference.SET_ROWS_TURBO4reports "not supported" on gfx1030 and falls back to CPU. I haven't yet confirmed whether gfx1100 reports the same (i.e. simply no HIP impl for that op, = expected) or whether it's an RDNA2-specific gap — will check.VGPR-spill numbers for gfx1030 to follow: the metrics build is running now, so I'll add an RDNA2 column to the gfx1100/gfx908 table above.
TheTom commentedon Aug 13, 2026
Noted on the pronouns, jasstrong, sorry about that. Names only from me going forward.
This is a lot of ground covered and three of the four points change something on our side.
The K-vs-V narrowing is the useful part
That reframes #294 entirely. It is not "turbo flash attention spills", it is the turbo K-cache path in
fattn-vec, and the mixedq8_0-K / turbo4-V shape that real deployments use is largely clear. I will retitle the issue to say K-cache rather than turbo generally, because as filed it overstates the blast radius.The RDNA3 numbers being roughly double gf908 with occupancy 5 and ~2.5 KB/lane scratch is worth having on the record too. My original filing only had the one architecture and I explicitly could not say whether it generalised.
#252 being fixed on HEAD
That is the most valuable thing here and I would not have found it: your deployed shape is exactly
q8_0-K / turbo4-V at head-dim 256, it runs clean, and the added instances at current HEAD are what closed it. I will close #252 and #253 on that basis, crediting your run, unless you would rather keep #252 open until the spill work lands. They are separate axes and I do not want to leave a fixed bug open just because a neighbouring one is not.That also settles the 2x2 grid from #253 that we never finished. I am going to close #279 as well — its whole purpose was to add hsk=256 turbo FA coverage so this corruption would be reproducible in the suite, and if the underlying bug is fixed on HEAD the coverage argument is weaker than the cost. Happy to be argued out of that if you think the shapes are worth having regardless.
The odd-
ncolsMUL_MAT_IDabort, and your questionMy read: both, but not equally.
Since the dispatch is byte-identical to upstream ggml, the fix belongs upstream and a fork-local divergence in the dispatch itself would be the wrong shape. Please do report it there if you have the appetite; you have the repro and the hardware, and it will land better from you than relayed through me.
But there is a fork-side piece that is ours regardless, and it is the same complaint as #280: an unsupported combination should report
not supported, not abort the process. A hardGGML_ASSERTinmul_mat_vec_fmeans one synthetic shape takes down the wholetest-backend-opsrun on RDNA2, so nobody on that hardware can get a complete sweep. That is exactly how the HIP gaps kept hiding. Asupports_oprejection for oddncolson the non-WMMA AMD path costs us nothing on real models, since as you say their dims are even, and it buys back a completable suite.So: upstream for the dispatch, and I would take a fork-side
supports_opguard purely for testability. If you would rather not carry that, say so and I will not push it.The other two
tq3_1s NMSE 0.000508 against a 0.0005 gate — agreed that reads as RDNA2 reduction ordering, 1.7% over is not a structural failure. Worth leaving visible rather than widening the threshold, since a gate that moves whenever something brushes it stops being a gate.
SET_ROWS_TURBO4not supported on gfx1030 — please do check gfx1100. If both report it, it is simply an unimplemented HIP op and expected. If only RDNA2 does, that is a real arch gap. I have no AMD hardware so I genuinely cannot answer this one.Thanks for putting three architectures behind this. The fork has had zero AMD coverage in the fleet, which is precisely why the spill gate had never run, and you have now moved CDNA, RDNA2 and RDNA3 from untested to measured in a day.
jasstrong commentedon Aug 13, 2026
gfx1030 (RDNA2) spill column, as promised — same
K=TURBO4_0gate-crossing shapes, built with-DGGML_HIP_EXPORT_METRICS=On, VGPRs allocated + spilled:So RDNA2 is not better than RDNA3 here — if anything a touch worse. Every turbo-K shape spills a little harder than gfx1100 (with
Q8_0-V worst, 720 vs 651), at occupancy 4 vs gfx1100's 5. The wave32 register file doesn't buy anything back; the pressure is ~2.3× gfx908 on both RDNA parts, scratch ~2.5–2.8 KB/lane.The turbo-as-K finding holds identically on RDNA2, and it's the reassuring part: swap the roles to my actual deployment shape (
K=Q8_0,V=TURBO4_0, hsk=256) and the spill vanishes —— which lines up with the model running clean at 17 tok/s on the V620. So the picture across all three AMD arches is consistent: it's specifically the turbo K-cache path at hsk=256 that's in trouble, the common
q8_0-K / turbo-V shape is fine everywhere, and RDNA2 patterns with RDNA3 rather than rescuing it.TheTom commentedon Aug 13, 2026
Three architectures, a role-swap narrowing, a fixed bug confirmed, and a latent upstream dispatch bug found. That is a genuinely excellent piece of work, jasstrong, and it moved this from one unexplained data point to something we actually understand.
The RDNA2 column completes the picture:
That role swap is the whole finding. It is not turbo flash attention, it is the turbo K-cache path at hsk=256, and it reproduces on all three AMD architectures with RDNA2 slightly worse than RDNA3 rather than better. The common
q8_0-K / turbo-V shape that real deployments run is clean everywhere, which is why your V620 does 17 tok/s without complaint.I have retitled this issue accordingly. As filed it said "turbo flash-attention kernels", which overstated the blast radius considerably, and anyone reading it would have concluded turbo FA was broadly unusable on AMD. It is not.
Actions taken
#283 merged. The evidence there is exactly what I would want for re-enabling something that was disabled on measured grounds: PPL 5.6999 vs 5.7037 with the delta about 30x under the error bar, coherent generation, +33% decode, gated to HIP so CUDA is untouched, and an env escape hatch. I verified on my side that it builds clean on CUDA sm_121 with fatal warnings and that the non-HIP branch is byte-identical to base, so there is no way for it to affect CUDA users.
#252 and #253 closed. You established that the corruption is fixed on current HEAD by the added
dkq256/q8_0-turbo4 instances, and that your deployed shape runs clean. #253's one-line change is superseded by that, and I would rather close it as fixed than leave your PR hanging against a bug that no longer exists.#279 closed. Its only purpose was adding hsk=256 turbo FA coverage so the corruption would be reproducible in the suite. With the underlying bug fixed the coverage argument no longer carries its cost.
Still open, and yours if you want them
The odd-
ncolsMUL_MAT_IDabort is worth reporting upstream, since the dispatch is byte-identical to ggml. I still think a fork-sidesupports_oprejection is worth carrying purely so the suite can complete on RDNA2, for the same reason as #280, but that is a testability convenience and not a correctness fix, so it is your call whether to bother.The
SET_ROWS_TURBO4gfx1100 check would be useful whenever you get to it.Thanks for putting real hardware behind this. The fork has had no AMD in the fleet at all, which is exactly why the spill gate had never once run, and you have taken CDNA, RDNA2 and RDNA3 from completely untested to measured inside a day.
[-]HIP: turbo flash-attention kernels spill 295-330 VGPRs at head size 256 (quality gate had never run)[/-][+]HIP: turbo K-cache flash-attention spills 295-720 VGPRs at head size 256 on CDNA/RDNA2/RDNA3 (quality gate had never run)[/+]seanrasch commentedon Aug 14, 2026
Ampere (SM 86) data: the fix removes the spill, but costs 12-31% turbo2 decode
First NVIDIA numbers on this issue, since the three columns so far are all AMD. Short version: on
Ampere the spill is much worse than any arch measured so far and PR #295 drives it to zero — but
on the shapes that decode actually launches there was no spill to remove, and the split costs
turbo2 up to 31%. I think the gate wants to be
ncols-based rather thanD-based.Setup
RTX 3080 Ti (SM 86, driver 580.173.02, nvcc 12.0),
-DGGML_CUDA_FA_ALL_QUANTS=ON,-DCMAKE_CUDA_ARCHITECTURES=86,-Xptxas=-v.fca3093c9unpatchedfca3093c9+a70a324facherry-pickedModel: Qwen3.5-9B Q4_K_M —
attention.key_length = attention.value_length = 256, GQA 16/4,full_attention_interval = 4. This is the shape the issue is about, and it is what I run inproduction with
--cache-type-k turbo2.Method note, because it nearly cost me the result: cross-session run-to-run drift on this box is
~7% (re-running A alone moved turbo2 81.01 → 86.84 t/s). Everything below is therefore
clock-locked at 1500 MHz and interleaved A,B,B,A inside a single session, 5 reps. Repeats agree
within 0.3 t/s.
Registers and spill, D=256, turbo-as-K
Two things stand out against the AMD columns:
jasstrong measured. The fix zeroes all of it. It does what it says.
turbo4-K spills at ncols=1.
Decode throughput, tg128, interleaved
Prefill is unaffected throughout. Correctness is fine — greedy, seed 42, A and B generations are
byte-identical. B is slower, not wrong.
Why: the LUT paths assume
nthreads_KQ == 1The shared-memory LUT fast paths for turbo3 (
fattn-vec.cuhL320) and turbo2 (L340) compute the fullD-length dot per lane with nonthreads_KQstriding, and neither callswarp_reduce_sum— onlythe
elseat L358 does. They structurally requirenthreads_KQ == 1.Raising
nthreads_KQto128/cpy_nbmakes thei_KQ_0loop run that many times with several lanesmasked onto the same
i_KQ, so each lane recomputes the whole dot redundantly. Every lane still endsup with the correct full sum, which is exactly why the output stays byte-identical while throughput
drops.
The PR message anticipated this branch and set it aside — "the shared-memory LUT branch that assumes
a single lane is gated on ncols==1, which no spilling shape uses." That is true on AMD. On Ampere the
ncols == 1shapes are precisely the ones that never spill, and they are what decode runs.Which kernels actually launch (nsys)
This is the part that explains the turbo3 row, which otherwise looks inconsistent:
flash_attn_ext_vec<256, 1, TURBO2_0, TURBO2_0>flash_attn_ext_f16<256, 256, 2, 4, …, TURBO3_0, TURBO3_0>+flash_attn_stream_k_fixupturbo3 decode never enters
fattn-vec.cuhon this shape — it goes down the MMA path. So turbo3being flat is expected rather than surprising, and its identical-looking LUT branch is simply not
executed here. B launches the same kernel and the same call count as A for turbo2, so the regression
is inside the kernel rather than a dispatch change.
I could not get any ncols=2 VEC instance to launch. Single-stream decode, and
llama-batched-benchat-npl 1,2,4, all launch ncols=1 only. So on this model the ~4,300-bytespill is on instances that do not appear to run in decode, while the cost lands on the one that does.
Caveat: I have not tested speculative decoding / MTP, which I would expect to be the other source
of
ncols > 1, and I have not tested other head dims or architectures.One more thing the
D > 128gate leaves behindAt ncols=2, turbo-as-K also spills at head_dim 128 — 548-680 bytes — and those numbers are
identical in A and B, because
D > 128excludes them:To be precise, since it would be easy to overstate: this is ncols=2 only — D=128 at ncols=1 is
clean at 0 bytes. But if the goal is "no turbo-K shape spills", the D=128 ncols=2 cases are still
spilling after the patch.
Suggestion
The discriminator that matches the measurements is whether the shape actually spills, which
tracks
ncolsand the K type, notD:That keeps the real win — every ncols=2 shape, at both head dims, plus turbo4-K at ncols=1, which is
the one ncols=1 shape that genuinely spills — while leaving the zero-spill turbo2/turbo3 ncols=1
decode path alone. On the AMD data this should be equivalent to the current patch, since the spilling
shapes there are the ncols=2 ones.
Happy to re-run any of this, or test a revised gate on SM 86.
apollo-mg commentedon Aug 14, 2026
I have gfx1201 (RX 9070 XT, RDNA4), so here is the target the CI has never built.
Build-only, same knob you used:
fca3093c9(currentfeature/turboquant-kv-cache),-DGPU_TARGETS=gfx1201 -DGGML_HIP_EXPORT_METRICS=On, ROCm 7.2.53211. No benchmark, noruntime, just the resource-usage remarks. 7034 kernels analysed, 346 of them
flash_attn_ext_vec, 98 spilling.RDNA4 reproduces it, and in three ways the gfx908 picture doesn't show.
1. It is not confined to head size 256
You wrote "Every flagged flash-attention instantiation is at head size 256." On gfx1201,
spilling FA kernels by head size:
hsk=128 is the shape the suite already tests, and the shape most models actually run. If
that also holds on gfx908 once #293 lands, the "untested shape" framing understates it —
the tested shape is affected too.
2. Not only TURBO4_0 as the K type
You wrote "every one has TURBO4_0 as the K type." K-type distribution across the 98
spillers here:
TURBO4_0 does lead. But all three turbo K types spill, and the single worst kernel in the
build has TURBO2_0 as K:
All ten worst are pinned at the 256-VGPR architectural cap with occupancy 5 waves/SIMD,
pushing 2.5-2.75 KB per lane to scratch. Worst spill is 735 against your 330, roughly
2.2x.
11 of the 98 involve no turbo type at all, so there is a residue here that isn't
attributable to this fork's types.
3. On the Q2_K
mul_mat_qentry — your instinct looks rightYou flagged
mul_mat_q<type 10, 64, true>at 189 spilled and said it "smells upstream."On gfx1201 it is both worse and clearly the dominant pattern:
Type 10 is Q2_K, a stock ggml type, and it occupies six of the top ten
mul_mat_qspillers. Plenty of other stock types spill mildly too (Q8_0, Q4_0, IQ2/IQ3/IQ4, MXFP4),
all in the 3-33 range. That is consistent with an upstream issue rather than a fork one,
though I have not built clean upstream at gfx1201 to confirm — happy to do that next if
it's useful, it's the same one-command build.
Limits
turbo4 V-cache corrupted since 2cbfdc62→c26cbdffc: TURBO4_0 dropped from V_rows_per_thread==4 list in fattn-vec.cuh #252/fattn-vec: restore turbo4 V-cache (re-add GGML_TYPE_TURBO4_0 to V_rows_per_thread==4) #253 V-cache corruption.
haven't measured one.
this is current-branch-at-gfx1201, not gfx908's exact build conditions.
can tell still has no data in this thread either.
One reproduction note that cost me an hour: the turbo type IDs move between commits. I
first read
ggml.hfrom an older checkout whereTURBO4_0=44, and mislabelled every type.At
fca3093c9it'sTURBO2_0=43, TURBO3_0=44, TQ3_1S=45, TQ4_1S=46, TURBO4_0=47. Yourmapping in the issue is correct — mine was briefly wrong. Worth stating explicitly if the
check ever becomes a gate, since a threshold allowlist keyed on type ID would silently rot.
Raw log available if you want it. Happy to rerun once #293 merges so it's like-for-like.
jasstrong commentedon Aug 15, 2026
Extending @apollo-mg's head-size sweep to RDNA2, RDNA3, and the RDNA3 APU (V620/gfx1030, 7900 XTX/gfx1100, and a Phoenix2 iGPU/gfx1103). Same base
fca3093c,-DGPU_TARGETS=<arch> -DGGML_HIP_EXPORT_METRICS=On, build-only, all 347flash_attn_ext_vecinstances.@apollo-mg is right, and it holds across the whole RDNA line — hsk=128 spills too:
My earlier "every flagged instantiation is at head size 256" was an artifact of only tabulating the gate-crossing hsk=256 turbo-K shapes. The broad sweep shows hsk=128 spills ~40 kernels on every RDNA generation (40/41/42/40) — the tested, common shape, not a corner the suite skips.
Still overwhelmingly the turbo K-cache path (RDNA2: 83 of 89 spillers are K=TURBO{2,3,4}_0; K=F16 spills 5), so the
q8_0-K / turbo-V deployment shape stays clean at every head size. Worth noting the Phoenix APU is the worst case — occ 4 (vs the discrete gfx1100's occ 5) and the highest peak spill of any arch tested (786 VGPRs at hsk=256), because the iGPU's register file is tighter.Design note: #295 gates its split on
D>128, so it wouldn't cover the ~40 hsk=128 spillers — consistent with @seanrasch's argument that the gate wants to bencols-based rather thanD-based.jasstrong commentedon Aug 15, 2026
@seanrasch your ncols-based-gate call looks right from where we're sitting — the sweep above shows a
D>128gate would both over-apply the split and skip the ~40 hsk=128 spillers per arch, so D can't be the whole story.Whatever gate @TheTom lands on, we're glad to run it through the House of Radeons™ — gfx1030 (V620, RDNA2), gfx1100 (7900 XTX, RDNA3), and gfx1103 (Phoenix2 APU, RDNA3). The metrics trees are already stood up, so we can turn both halves around quickly: the
-Rpassresource sweep (does the revised gate actually zero the spills at both 128 and 256?) and a real on-hardware decode benchmark (does it dodge the 12–31% turbo2 hit you measured on the launched shapes?). Just point us at a branch.fattn-vec: gate the turbo K split on the LUT, not on D
Merge pull request #295 from TheTom/fix/turbo-k-vgpr-spill
fattn-vec: split the turbo K dot at D>128 to stop the VGPR spill
TheTom commentedon Aug 17, 2026
Scope correction on my own
f050a2501write-up above, before any RDNA4 data lands and makes it look like a regression appeared.I wrote "All 15
<128,2,turbo-K,*>shapes went from 173-421 VGPR spill to zero." That was measured on gfx1030, gfx1100 and gfx1103, which is what @jasstrong had swept at the time, and I wrote it as though it held for the RDNA line generally. gfx1201 was never in that table and I should have said so instead of letting "zero" stand unqualified.@apollo-mg, you have the only gfx1201 in this thread, and you were the one who showed the original
D>128gate had the head sizes wrong in the first place. If you have re-run the resource sweep againstf6124e914, please post it here. Two things I want and cannot get from this desk:<128,1,K=TURBO2,V=TURBO3>at 36 VGPR. I said that if that pattern turned out to be common, the fix is teaching the LUT paths to stride and reduce so they work at anynthreads_KQ. That is a big change and I would rather not sign anyone up for it on the strength of one instance on one arch. Whether it appears on gfx1201 is what decides it.<128,2,turbo-K,*>actually reaches zero on gfx1201 or only gets close.ncols=2is a shape decode really launches, so a residual there sits on a live path, unlike the D=256 one which is a V-side accumulator spill on a shape nothing launches.Separately, for whoever gets to a runtime bench first: after @seanrasch's Ampere numbers I do not trust build-only resource metrics to tell us whether a small residual costs anything real. A turbo2/turbo3 decode run against
f6124e914on any RDNA part would settle whether a 20-60 VGPR residual is worth chasing or worth leaving alone. My guess is leave it alone, but guesses are how the first gate got written wrong.apollo-mg commentedon Aug 18, 2026
gfx1201 resource sweep against
f6124e914, plus the runtime run you asked for.Provenance first: the resource sweep was built at
f050a2501, not the merge. The only delta between them touching flash attention is infattn-common.cuh—(void)casts to silence[[nodiscard]]oncudaStreamSynchronize/cudaFreeinside a destructor. No functional change, no register-allocation impact (the other file,ggml-cuda.cu, is the host-side RDNA2 stream-capture fix). So the spill numbers below apply tof6124e914. The runtime bench buildsf6124e914directly.RX 9070 XT, ROCm 7.2.4,
-DGGML_HIP=ON -DGPU_TARGETS=gfx1201 -DGGML_HIP_EXPORT_METRICS=On, matched to my 2026-08-14 baseline run. Parser reproduces that baseline's published headline figures exactly, so the delta is like-for-like.Resource sweep
fca3093c9f6124e914flash_attn_ext_veckernelsBy head size: 256 → 55/33, 128 → 40/8, 64 → 3/0. 57 fixed, 0 newly spilling.
Your two questions
1. Residual #3 — the gfx1100-only
<128,1,K=TURBO2,V=TURBO3>at 36 VGPR.Zero instances on gfx1201. It does not occur here at all. On the evidence I have that reads as architecture-specific rather than a common pattern, which argues against signing anyone up for teaching the LUT paths to stride and reduce.
2. Does
<128,2,turbo-K,*>reach zero on gfx1201?No — it gets close and survives. Matches the scope correction you just posted:
<128,2,TURBO3,TURBO3><128,2,TURBO2,TURBO3><128,2,TURBO4,TURBO3><128,2,TURBO3,Q8_0>Two things you may not have
Bucket #1 is not "identical under both gates" here. Present, 18 kernels, but they fell 698 → 57, 681 → 57, 661 → 36. On gfx1030/1100/1103 they were already ≤22/62/23 before the fix; on gfx1201 they started at 625–735 and the gate cut them ~90%.
A fourth bucket. 19 of the 41 survivors are
Q8_0-K pairs at D=256, ncols=2:Q8_0/TURBO2 (61, 60),Q8_0/F16 (40, 40),Q8_0/BF16 (32),Q8_0/TURBO4 (28, 25), plusBF16/BF16(13) andF16/F16(1). All byte-unchanged before→after. Same structural story as your Q4_0 residual — a non-turbo K path the gate doesn't reach — at a different type.Bucket #2 confirmed as pre-existing: 4 kernels, byte-unchanged (357→357, 336→336, 226→226, 206→206).
Scale context, since gfx1201 wasn't in the original sweep:
Largest absolute win of the four, from a starting point ~2.5× worse, and still carrying 4–20× the residual count of the others.
Runtime
llama-bench, pure decode (-p 0 -n 128),-fa 1,TURBO_AUTO_ASYMMETRIC=0. Llama-3.2-3B-BF16 (D=128, GQA 3:1) so the<128,2>shapes are live and the auto-asymmetric gate can't fire. Two independent passes:Null result at ±1 %. The two passes disagree in sign on turbo2 and turbo3, and this box shows intermittent 1–2 % (occasionally 6 %) variance between identical runs — some cells came back at ±1.7 even at 12 reps. I'm not claiming an improvement; I'm claiming there's no cost I can detect.
So: the 23–57 VGPR residual doesn't buy back measurable decode throughput on RDNA4. Your instinct to leave it alone holds up.
On the 12–31 % turbo2
ncols=1regression — it does not reproduce here. turbo2 was +0.4 % / −0.3 %. That one I'd treat as a real absence rather than a resolution limit, since 12–31 % is an order of magnitude above this machine's noise floor.Caveats
Decode only — no prefill, no long context, no batch >1. Throughput only, no fidelity gate. One card. And
ncols=2arises through GQA packing rather than being pinned by a flag, so a shape-pinned microbenchmark would be stronger evidence than this.D=256 was also measured; I'm not quoting deltas there because the 12-rep pass moved all four cells positive including the f16 control the fix doesn't touch, which reads as a machine-state offset between the two builds' runs rather than an effect of the commit.
Happy to re-run anything, pin specific shapes, or test other configs — it's the only gfx1201 here and it's free.
TheTom commentedon Aug 18, 2026
@apollo-mg this is the most careful piece of measurement anyone has put on this issue, thank you. Two things in particular: running the f16 control that the fix does not touch, and then refusing to quote the D=256 deltas once that control moved. That is the part most people skip, and it is the only reason I believe the rest of the table.
Residual #3 is closed. Zero instances on gfx1201 settles it. It is a gfx1100 artifact, not a property of the LUT path, so nobody is teaching the LUT paths to stride and reduce. That was the expensive branch of this issue and it is now off the table on evidence rather than on my guess.
I got bucket #1 wrong, and in the opposite direction this time. I called it "identical under both gates, a V-side accumulator spill, a different mechanism." That was true on gfx1030/1100/1103 where it sat at 22/62/23 before and after. On gfx1201 it starts at 625-735 and the gate cuts it about 90 percent, to 36-57. So it is not a different mechanism, or at least not only that. My characterisation was arch-scoped twice over and I stated it as general twice. I will stop generalising from three RDNA parts.
The fourth bucket is a real finding and it lines up with something CI just told us. Your 19
Q8_0-K pairs at D=256 ncols=2 are the same structural story as the Q4_0 residual, a non-turbo K path the gate cannot reach. Independently, theubuntu-22-hip-quality-checkjob on gfx942 flagsflash_attn_ext_vec<128,2,TURBO3,Q8_0>at 259 VGPR, which is 255 plus a 4 VGPR spill. Same shape class you measured at 424 to 23 on gfx1201. So that class is small-but-nonzero on both CDNA and RDNA4, and it is the surviving turbo shape on both.On the runtime null. Agreed, and it matches what I expected but had no right to assert. Your point that the 12-31 percent turbo2
ncols=1regression is a real absence rather than a resolution limit is the useful half, since 12-31 percent is well clear of your noise floor. That reads as SM 86 specific rather than general, which is worth @seanrasch knowing.Where this leaves the gate.
ubuntu-22-hip-quality-checkis still red, but as of #302 it is no longer red for thenodiscardreason, that is fixed and the count is 19 to 0. What it flags now isrwkv_wkv_f32at 387,mul_mat_qat 317, and the two<128,2,TURBO3,Q8_0>instances at 259. The first two are not turbo kernels at all.Given your runtime result, I do not think chasing a 4 VGPR spill that provably costs nothing is a good use of anyone's time. The check script already carries an ignore list,
rwkv_wkv7_f32andgated_linear_attn_f32are on it. I would rather add the surviving shapes with a comment pointing at your numbers, so the gate goes green and starts catching regressions again, than leave it permanently red where it catches nothing. Any objection before I do that? You have the only measurements that would justify the entry.jasstrong commentedon Aug 18, 2026
House of Radeons runtime cross-check — extending @apollo-mg's RDNA4 method to RDNA2, RDNA3, and the RDNA3 APU.
Same
llama-benchrecipe Mark used: pure decode-p 0 -n 128 -fa 1,TURBO_AUTO_ASYMMETRIC=0, KV sweep f16/turbo2/turbo3/turbo4. One difference in framing: rather than baseline-vs-fix, we compared the D-gate (a70a324f) directly against the LUT-gate (f050a2501) on the same card — so this pins the exact gate that produced seanrasch's over-split. f16 is the control the fix never touches; its delta is the per-box noise floor.D=128 — Llama-3.2-3B-BF16 (Mark's model), decode t/s, D-gate → LUT-gate
D=256 — qwen3.6-35B-A3B (seanrasch's exact ncols=1 launched shape), decode t/s
At D=256, the D-gate splits the ncols=1 launched shape and the LUT gate keeps it unsplit — the precise thing seanrasch measured at 12–31% on SM 86.
Verdict
No regression on any RDNA part, at either head size. Every turbo2 delta lands between −0.0% and +0.7%, an order of magnitude below the 12–31% seanrasch measured — which does not reproduce on RDNA2, RDNA3, or the RDNA3 APU, matching Mark's read that it's SM 86-specific. The D=256 run puts the ncols=1 launched shape directly under test and still finds nothing.
Where deltas do creep above the f16 control's noise floor they go the other way — toward the LUT gate: turbo4 at D=128 on both discrete parts (+1.4%), and turbo2/turbo3 on the V620 at D=256 (+0.7% / +1.3%). Small, and if anything a marginal recovery in the direction seanrasch's cost would live — never a penalty. Consistent with the LUT gate being strictly the better shape choice.
Supports adding the surviving turbo shapes to the ignore list — three more arches showing the residual spill buys back nothing at runtime.
Notes: the iGPU couldn't hold the 35B (17.6 GB > its 15.4 GB GTT pool), so D=256 is the two discrete cards; it's RDNA3, already covered by the 7900 XTX at D=256 and by itself at D=128. TQ4max wouldn't load in the metrics-tree
llama-bench(unsupported quant) so both cards used TQ3_1S/TQ4opt weights — the turbo-K decode kernel is identical regardless of weight quant.apollo-mg commentedon Aug 18, 2026
No objection to the ignore entry. @jasstrong's four-arch run is stronger evidence for it than mine, for two reasons I want to state plainly before adding anything.
First, their comparison axis is better for this question. They ran D-gate
a70a324f→ LUT-gatef050a2501, which isolates the gate. I ranfca3093c9→f6124e914, which bundles everything between the pre-fix baseline and the merge. For "did the gate cost anything", theirs is the cleaner instrument.Second, their noise floor is better. Their f16 controls move 0.0–0.5%; mine moved 1.1–1.2% and two of my D=256 cells came back at ~6%. Where we agree, weight theirs.
Two things I can add that their run wouldn't have surfaced.
Direct dispatch evidence for the ncols question, at D=128
You wrote that
ncols=2is a shape decode really launches, and that this is what makes a residual there matter. jasstrong's D=256 run establishesncols=1as the launched shape there. I can check D=128 — where the shapes in question actually live — from the dispatch side.No
rocprofon this box, butAMD_LOG_LEVEL=4prints every dispatch'sShaderNamewith template arguments intact. Buildf6124e914,-fa 1,TURBO_AUTO_ASYMMETRIC=0, types per the fork'sggml.h(8=Q8_0 43=TURBO2 44=TURBO3 47=TURBO4):flash_attn_ext_vec<128, 1, TURBO3, Q8_0>flash_attn_ext_vec<256, 1, TURBO3, Q8_0>flash_attn_ext_vec<256, 1, TURBO3, Q8_0>flash_attn_ext_vec<128, 1, TURBO3, Q8_0>flash_attn_ext_vec<128, 1, TURBO3, TURBO3>Every one is
ncols=1. Three GQA ratios, two head dims, and the packing factor never moves the VECncols. Depth changes the launch count (84 → 112) and not the shape, which is the control behaving.So
ncols=1is the launched shape at D=128 as well as D=256 — jasstrong's result from the gate side, mine from the dispatch side, covering both head sizes. On gfx1201, ordinary decode never reaches<128,2,…>.That supports the ignore entry rather than complicating it: the shapes being exempted are less live than the premise assumed. What I can't tell you is what does launch
ncols=2— speculation and multi-sequence batching are the obvious candidates andllama-benchproduces neither. Happy to run the census on any config you name.llama-benchcan't prefill with quantized KV on gfx1201Found while trying to add a prefill regime so the runtime evidence wasn't decode-only. Same build,
llama-benchvsllama-server:llama-bench-p 256 -n 0, any quantized KVggml-cuda.cu:109llama-serverturbo3/q8_0The threshold is exact and sits on your HIP VEC/TILE boundary in
ggml_cuda_get_best_fattn_kernel:-p 8-p 9-p 256 -ub 16-p 256 -ub 8 -b 8turbo3/q8_0,turbo3/turbo3,q8_0/q8_0,turbo4/q8_0,turbo2/q8_0all abort; onlyf16/f16prefills (1639 t/s). Pre-existing —fca3093c9does the same, so #295 neither caused nor fixed it.Scope, to be exact: benchmark path only. My first read was "prefill with quantized KV aborts on RDNA4" and that is wrong — serving is fine at every prompt length I tried.
-ub 8 -b 8works around it.Worth flagging because it's a second
llama-benchgap on this work, alongside jasstrong's note that TQ4max wouldn't load in the metrics-tree build. Between them, the standard measurement tool can't do prefill with quantized KV on RDNA4 and can't load some turbo weight quants — which may be part of why RDNA runtime evidence has been thin.On the entry itself
Two suggestions about keeping the gate useful, not about whether to add it.
A threshold rather than a blanket shape ignore. If
<128,2,TURBO3,Q8_0>is listed outright, a later change taking it from 4 VGPR to 200 keeps the gate green. Since the goal is to start catching regressions again, "flag above N" preserves that on the shape most likely to move, and still goes green today at 259.rwkv_wkv_f32at 387 andmul_mat_qat 317 aren't covered by any of this. They're larger than the turbo residuals and, as you say, not turbo kernels. Neither my data nor jasstrong's speaks to them. If "the surviving shapes" means all four, the gate goes green over two unexplained spills — I'd keep those separate.One scope note on gfx942: everything above is RDNA. The
ubuntu-22-hip-quality-checkflag is CDNA, and none of us has that hardware. You just said you'd stop generalising from three RDNA parts — with jasstrong's run it's now four, but they're still all RDNA.Standing offer
gfx1201 and a pair of P100s here, both idle most of the time — RDNA4 and pre-Turing CUDA. Any sweep, census, or config you want, say the word.
TheTom commentedon Sep 3, 2026
Data point from PR triage on 2026-09-03:
hip-quality-checkhas failed on every PR since 2026-08-23, and a manual dispatch onfeature/turboquant-kv-cacheat 80be9a7 fails the same way, so it is red on the base branch, not the PRs: https://github.com/TheTom/llama-cpp-turboquant/actions/runs/33712051649The
-Werrorbuild step passes. The failure is the VGPR step (scripts/hip/gcn-cdna-vgpr-check.py), currently flagging:fattn-vec.cuh:44flash_attn_ext_vec<128,2,turbo3,q8_0,*>at 259 VGPRs (255 + 4)mmq.cuh:955mul_mat_q<type 10, 64, true>at 317 (128 + 189)wkv.cu:5rwkv_wkv_f32<128>at 387 (64 + 323)Until this is fixed, the check is noise for every PR that touches a
.cu/.cuh. Real CUDA/HIP signal is the hostedcuda,hip,musabuild jobs.