Repository navigation
V is read where its GEMM left it, because a descriptor transposes and an epilogue rounds (#107 A8) - #118
Merged
Conversation
… an epilogue rounds (#107 A8) `stage_qkv_heads_bf16` did three things to V's third of the projection panel: read it fp32, round it to bf16, and transpose token against head. Nothing rotated it, nothing scaled it, nothing accumulated it — the staging pass existed for V only to change its dtype and its layout. The GEMM's packed epilogue already rounds, and a TMA descriptor already transposes. So the qkv projection runs as two GEMMs over the one transposed weight operand, read through descriptors over its two row bands: Q and K into the fp32 panel the rotate-and-stage pass still needs, and V's group's packed bf16 straight into the saved panel flash reads. Flash addresses head `h` of that row-major panel as a column band — `row = batch * T + token`, `plane = head`, where a staged panel takes `row = token`, `plane = batch * H + head` — which is one strided `GlobalLayout` and no kernel work at all. Splitting the output's N leaves each output tile's K walk alone, so V's fp32 accumulator is the unsplit GEMM's to the bit and the epilogue's rounding lands exactly where `f32_to_bf16_rne` did. What disappears per block is V's whole fp32 round trip: the wide store, the staging read and the staging write. The flash harness gates it: the fused staging gate is now Q/K against `split_group2` + two rope passes + two staging launches, still exact, and every tcgen05 forward/backward parity shape now feeds V through the row-major descriptor rather than a staged panel — so the descriptor's relayout is checked against a head-major CPU reference at every shape.
feitreim
force-pushed
the
a8-elide-v-panel
branch
from
August 6, 2026 23:15
56c48b7 to
789eac4
Compare
Owner
Author
|
Rebased onto The model parity harness never reaches the staged path — its shapes are Normal descent, no NaN, no plateau — V arrives correct at the real shape, which |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #107's A8, the last unimplemented inventory item with real traffic.
What the inventory got wrong
A8 was priced at 6.75 GiB/step and marked HARD, on the reading that flash
would need a TMA descriptor over the fp32 row-major
[N, 3, D]qkv panel, whichit cannot have: tcgen05 takes bf16 operands and nothing widens on the way in.
That is right about the fp32 panel and wrong about the obstacle. The
descriptor was never the obstacle.
stage_qkv_heads_bf16did exactly three things to V's third of the panel: readit fp32, round it to bf16, and transpose token against head. Nothing rotated it
(RoPE is Q and K only), nothing scaled it, nothing accumulated it. The GEMM's
packed epilogue already rounds, and a TMA descriptor already transposes —
Tcgen05Gemm::storeandGlobalLayout::stridedboth shipped before the issuewas filed. So the question was never "can a descriptor address V inside an fp32
panel" but "can V's group have its own bf16 destination", and it can.
Not #88's declined half either: #88 rejected fusing RoPE into the epilogue (its
tile mapping is MN-major and a rotation crosses column pairs inside a tile).
Nothing is fused into the epilogue here — V's group gets its own GEMM and the
epilogue is the one already in the tree.
The change
The qkv projection runs as two GEMMs over the one transposed weight operand,
read through descriptors over its two row bands (
TransposedBands, mapping thesame bytes
transposed_tmamaps whole — two descriptors, no storage):[N, 2D]panelstage_qk_heads_bf16still needs,Flash addresses head
hof that row-major panel as a column band throughcreate_flash_row_major_tma_map: a rank-3 stridedGlobalLayoutover[HD, B*T, H]at element strides[1, H*HD, HD].(batch, token)collapsesinto the row coordinate because
batch * T + tokenis the panel's row index,so the kernels change by their coordinates alone —
row = batch * T + token,plane = head, where a staged panel takesrow = token,plane = batch * H + head. No new tile-library call, no relayout, no kernelwork, and the driver accepts the descriptor's non-monotonic strides (head stride
256 B inside a 6144 B row stride) — checked on device, not assumed.
Per block V's whole fp32 round trip goes: the wide store, the staging read and
the staging write, against one bf16 store added back.
8 · N · Dbytes a block— 9 GiB/step at B=16, 18 GiB/step at B=32. VRAM is unchanged (same
[N, D]packed panel, different writer). Launches +12.
Parity — exact, tolerances untouched
Splitting the output's
Nleaves each output tile's K walk alone, so V's fp32accumulator is the unsplit GEMM's to the bit and the packed epilogue's RNE lands
exactly where
f32_to_bf16_rnedid in the staging pass.--kernel flash-attn: the fused-staging exact gate is now Q/K againstsplit_group2+ two rope passes + two staging launches — still exact, everyword. And every tcgen05 forward/backward parity shape now feeds V through
the row-major descriptor while its CPU reference still indexes head-major, so
the descriptor's relayout is itself under an exact-layout check at each shape.
All green.
--kernel flash-attn flash: green, ptxas budget gate passes. Forward128 regs / 0 spill (pinned 128), backward q 128 / 0, backward kv
138 / 0 (under the pinned 142). Forward residency unchanged at
2 CTA/SM, 114836 B shared.
--kernel model: all 14 checks green.Measurement — small, and smaller than the bytes
compare_profile, same container, B=32. The attributable rows:forward.qkv_proj.gemmforward.qkv_proj.gemm_vforward.attention.stage_qkv→stage_qkforward.attention.flashbackward.attention.flash_q/flash_kvTwo things to read off this. Flash pays nothing for the strided descriptor —
all three flash rows are flat or better, which is the load-bearing result.
And the qkv GEMM is not store-bound at this shape: halving a third of its
output cost it nothing measurable and the split's extra wave gave 0.37 ms back,
so only the staging third of the 18 GiB converts. Directly attributable:
−0.70 ms of a 720 ms step. The remaining −4.6 ms of that full-step delta is
spread across untouched expert-GEMM rows and is container drift, not this change.
train_ab, 30 steps, arms alternating, two containers:+0.39%, candidate ahead in 5 of 6 paired rounds. That is at the edge of what
this harness resolves (spreads 0.24–0.98%), and it is the size the arithmetic
allows once the GEMM's share is known not to convert. #107's own caveat holds:
this is a many-small-wins area and A8 is one of the small ones now that A1/A2
have taken the large one. The value here is as much that the descriptor question
is settled — a strided view into a projection panel is a working flash operand —
as the 0.4%.