Skip to content

ferro-kittens #197-#210 surveyed: the warpgroup split is measured here and rejected, and the instrument that rejected it ships - #119

Merged
feitreim merged 4 commits into
mainfrom
gemm-warpgroup-split
Aug 6, 2026
Merged

feitreim merged 4 commits into
mainfrom
gemm-warpgroup-split

Conversation

@feitreim

@feitreim feitreim commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Reverse of yesterday's review. ferro-kittens merged fourteen PRs since the
f64a27b this tree pins its kittens at (#195, which is in), and this went
through all of them, ported the one that looked portable, measured it, and
took it back out.

Net diff: an instrument and a note. The kernel is byte-identical to main.

What ships

  • bin/profile reports the three tcgen05 GEMMs' registers, spill and
    CTAs/SM beside the RMSNorm table. gpu/gemm's budget gate compiles those
    kernels in its own compilation and the training step compiles them in
    another; the gate being green is not evidence about the one that launches. A
    zero in CTAs/SM is a kernel the driver will refuse, and nothing in tree
    could see it before. On main it reads 132 / 168 / 146 registers, no spill,
    1 CTA/SM — agreeing with the gate exactly, which is the point of having both.
  • optimized.rs' module doc carries why this kernel does not take ferro #197.

The port that was measured and rejected: ferro #197, the warpgroup split

ferro's epilogue splits the accumulator's columns across two warpgroups —
the one axis open, since warp w reaches tensor-memory lanes 32 * w and no
others. Eight [32, 64] staging tiles are the 32 768 B four [32, 128] ones
cost, so the shared plan does not move and the block goes 192 → 320.

ferro had measured that split losing 1.4–1.8%, then found the losing table
was taken through a .local depot #166 has since removed and re-ran it: the
sign reversed to +0.8% at 4096³, +2.1% at 8192³, drain 35% cheaper. This
tree pins kittens past #166, so the depot was never here either, and the
transfer looked free.

Re-derived onto this kernel's three Drain impls (commits 1–2 of this branch —
Packed, Wide and Reduce each lift WARP_N columns instead of BLOCK_N,
with band_origin the single place a warp's corner is derived and
Tile::origin adding the same pair to the destination), it:

  • passed parity at unchanged tolerances, all four gpu/gemm checks;

  • dropped every register count — bf16 132 → 86, fp32 store 168 → 96, reduce
    146 → 140, zero spill and zero frame throughout;

  • and bought nothing. train_ab vs main, 30 steps, two rounds
    alternating in one container:

    arm mean tok/s spread runs
    baseline main 96 490.4 0.20% 96 391.5, 96 589.3
    candidate 96 290.1 0.29% 96 148.4, 96 431.9

    candidate/baseline = 0.9979, lower in both rounds. The GEMM spans agree
    in direction (7 spans, +1.5% across containers).

Which is what this kernel's own design already says: the deferred epilogue
releases the accumulator at the last tcgen05.ld and the ping-pong hands it to
an item two ahead, so the drain is not on the critical path and making it
cheaper is making already-hidden work cheaper. gemm_sol has no accumulator
ping-pong. That is where ferro's two points live.

And it costs a launch

At 192 threads a thread may have the architecture's 255. At 320 an SM will not
place one CTA past 168. Three builds of the identical split commit gave
gemm_tcgen05_f32_accumulate 140 registers with no frame twice — and 182
with a 2176 B frame
once, which is max_active_blocks_per_multiprocessor of
0 and DriverError(701, "too many resources requested for launch") at the
first weight-gradient launch of the backward pass. The same 182 launches fine
at 192 threads.

ptxas' allocation for these three kernels is not reproducible across builds in
this tree. The split is what turns that variance into a kernel that will not
run, by spending the whole register margin that one CTA an SM bought. That is
also what motivated the instrument above: the 701 was unreadable until
CTAs/SM was printed.

The rest of the survey

Window: ferro-kittens after f64a27b (#195, this tree's pin) through ac79127
(#210). Everything at or before the pin — #190 multicast accounting, #191/#184
masked-write unroll, #193 TMEM warpgroup lanes, #195 MN-major B — is already in.

ferro verdict why
#197 warpgroup-split epilogue rejected, measured above
#209 host picks the pair tile from the shape rejected Unreachable. ferro brackets the crossover at 36 < T ≤ 64 output tiles; this tree's smallest shape is bwd o_proj dW at 144 tiles, and the per-expert shapes are 1536–6144 items in one launch since #112. There is also no narrow rung to fall back to — #80 deleted it after it lost 5–28 points on thirteen rows.
#210 epilogue::Drain::staged rejected Refactor, no measurement, and ferro excludes exactly this drain's shape: "gemm_sol's drain does not migrate: it walks sub-bands narrower than its staging tile through tile_x8_batched and converges twice a pass." Packed is that drain. Behind the rev bump besides.
#199 col_map loop order rejected Zero call sites. This tree has two ColVecs (ops' NormColumns, flash's Cols) and neither goes through col_map.
#206 ldmatrix.x4 load side rejected ferro measured it a wash where the store side's was not. No claim to port.
#200 Job::finish rejected This GEMM left pipeline::run/Job at #80 and walks Walk itself. No call site.
#198, #207 fence contracts rejected, verified Contract text, no instruction removed. #207's one real fix — store_tile → MMA owing fence.proxy.async.shared::cta — this tree already has, at all three sites in flash-attn/src/tcgen05.rs (1121, 1661, 2077). Nothing to do; worth A8 knowing we were already right.
#201 store_row_vec / load_row_vec, SharedVec::slice handoff → A8 New enabling API, no measurement. The consumer that exists is flash's hand-rolled ROW_MAX / ROW_RESCALE / ROW_LSE static shared arrays. Flash territory, and behind the rev bump.
#208 SFU exp2_hw handoff → A8, as a negative ferro's finding is that it is 3.9% slower on flash_forward (and 2.7× on softmax, a shape we do not run). exp2_hw already exists at the pinned rev, so there is nothing to bump — the deliverable is the negative result. Our own .exp() sites are scalar f32::exp in cross-entropy and the router, not RegTile ops, so the swap would be a numerics change on the loss with no measurement behind it.
#203 typed TMEM columns / MMA shape deferred, own PR Would catch nothing here (ACCUM_COLS = 512 is a legal power of two, M256_N256 matches TmemTile<128, 256> at cg2). It is what makes a kittens rev bump breaking — alloc_cluster/dealloc_cluster gain a const parameter and mma_walk_cg2 gains two — and the breakage lands in gpu/flash-attn, which is A8's tree this week. Not to be bundled.
#202, #204, #205 n/a ferro repo organization and device-test probe fixes.

Follow-ups this leaves

  1. The register nondeterminism is its own bug. Same commit, same toolchain,
    same image, two builds, 140/0 vs 182/2176 on gemm_tcgen05_f32_accumulate.
    At 192 threads it is invisible; it will not stay invisible.
  2. The kittens rev bump (f64a27b → ac79127) as a separate PR once
    flash-attn is quiet, for #203's typing plus #199/#201/#210. None of it is a
    throughput claim.

… that made the split lose is gone (ferro #197)

ferro-kittens measured this exact split on `gemm_sol` and shipped one
warpgroup: 1.4-1.8% slower at 4096 cubed, and the mechanism offered was
hardware -- warps 0 and 4 own the same 32 tensor-memory lanes, so a column
split puts two requesters on each of four sub-partitions rather than
spreading over eight.

ferro #197 re-ran the same table at `f64a27b` and the sign reversed. Every
row of the losing one had been taken through a `.local` depot the library no
longer emits: `store_tile_x4` homed each drained band to local memory until
#166's rolled walks were marked (landed in #180/#181/#184), and a band *is*
the frame -- a `RegTile<32, 64>` is 64 f32 is 256 B. The split pays that frame
twice per accumulator where one warpgroup pays it once, so the arm doing more
of the broken thing read as the arm that was worse. Re-run: +0.8/+0.9% at
4096 cubed, +2.1/+2.1% at 8192 cubed, with the drain alone going 4.72 to
3.05 us -- 35% cheaper, where it had been blamed for the loss.

This tree pins kittens at `f64a27b`, which is past #180, so the depot was
never here either and the measurement transfers. What does not transfer is
the code: this kernel gained the expert item axis (#112) and the packed
`store_shared_rows` (#110) after the extraction, and its epilogue is three
`Drain` impls rather than one, so the split is re-derived onto them.

`GROUPS` is the new axis. `BAND_WARPS` keeps the row ceiling that hardware
fixes -- warp `w` reaches tensor-memory lanes `32 * w` and no others, so four
warps tile `BLOCK_M` exactly -- and `DRAIN_WARPS` is that by `GROUPS`, which
takes the block to 320 threads. `band_origin` is the one place a warp's
corner of the accumulator is derived, and `Tile::origin` adds the same pair
to the destination so a band index cannot mean two things.

The shared plan does not move a byte, which is what makes this free: eight
`[32, 64]` staging tiles are the 32 768 B four `[32, 128]` ones were, so
`SHARED_BYTES` is the same 229 632 and the six-stage operand ring gives up
nothing. `STAGE_N` is 64 again for a third distinct reason -- not the 16 KiB
two CTAs an SM lacked, and not #84's `ISSUE_LIMIT` band, but `WARP_N / 2`.

All three drains shrink with the band they lift. `Packed` lifts `[32, 64]`
twice instead of `[32, 128]` twice; `Wide`'s `HalfRow` is `[16, WARP_N]`, half
the issues and half the registers; `Reduce` is four passes rather than eight,
so its three-band lookahead now leaves three quarters of the drain behind the
release instead of three eighths. Every warp still takes two waits -- what
changed is that each covers half as many values and twice as many warps take
them in parallel.
…ed further than they did

bf16 132 -> 86, fp32 store 168 -> 96, reduce 146 -> 140: a band is what a
drain holds and the split halves the band. The cap moved more — at 320
threads ptxas compiles the two 640-`maxntid` entry points against 96 rather
than 168 — and all three land under it with zero spill and zero frame.
…m, not the crate that gates them

`gpu/gemm`'s budget gate and the training step compile the same three
kernels in different compilations, and ptxas does not have to agree with
itself across them. The number that matters is `CTAs/SM`: a block a thread's
registers no longer divide into the register file is a `701` at launch, not
a slow kernel, so it belongs beside the norm report rather than in a one-off
run.
…t measured it stays

ferro-kittens #197 re-ran the epilogue's column split against the table that
had rejected it, found that table had been taken through a `.local` depot #166
removed, and shipped the split on the reversed sign: +0.8% at 4096 cubed,
+2.1% at 8192 cubed, drain 35% cheaper. This tree pins kittens past #166, so
the depot was never here and the transfer looked free.

Re-derived onto this kernel's three `Drain` impls (the previous two commits)
and measured, it is not.

**It buys nothing.** `train_ab` against main, 30 steps, two rounds alternating
in one container: candidate/baseline = 0.9979, lower in both rounds, against a
within-arm spread of 0.20-0.29%. Parity passed at unchanged tolerances and
every register count fell -- bf16 132 to 86, fp32 store 168 to 96, reduce 146
to 140, no spill anywhere. The drain got cheaper and the step did not care,
which is what the deferred epilogue and the accumulator ping-pong already
say: the drain is not on the critical path here. `gemm_sol` has no ping-pong,
and that is where ferro's two points live.

**And it costs the register margin that one CTA an SM bought.** At 192 threads
a thread may have the architecture's 255; at 320 an SM will not place one CTA
past 168. Three builds of the identical split commit gave
`gemm_tcgen05_f32_accumulate` 140 registers and no frame twice, and 182 with a
2176 B frame once -- `max_active_blocks_per_multiprocessor` of 0, and
`DriverError(701, "too many resources requested for launch")` at the first
weight-gradient launch of the backward pass. The same 182 launches at 192
threads. ptxas' allocation for these kernels is not reproducible across builds
in this tree, and the split is what turns that variance into a launch the
driver refuses.

So `optimized.rs` goes back, and the module doc carries the reading -- a rung
that loses is the evidence for the shape that ships, and the next person to
read ferro #197 should find this beside it.

What stays is `bin/profile`'s GEMM report, which is how the 701 was read at
all. `gpu/gemm`'s budget gate compiles these three kernels in its own
compilation and the training step compiles them in another, and the gate being
green is not evidence about the one that launches. `CTAs/SM` is the column
that matters there, and a zero in it is a kernel that will not run.
@feitreim
feitreim merged commit 38ef7e1 into main Aug 6, 2026
feitreim added a commit that referenced this pull request Aug 6, 2026
…driver

stops deriving it

`cargo oxide` emits PTX and the driver JITs it at `cuModuleLoad`. An entry
point carrying no `.maxntid` tells that JIT nothing about the block it will be
launched in, so it allocates against the architecture's 255 registers and then
*derives* the largest block the result can be launched in. Measured on the
warpgroup-split commit of #119: 640, 640 and 384 threads, from 86, 96 and 140
registers. A build that had chosen 182 would have derived 256 — below that
kernel's own 320 — which is `max_active_blocks_per_multiprocessor` of 0 and
`DriverError(701)` at the first launch, and is exactly what #119 saw once in
three. The same 182 is fine at 192, which is why this is invisible today.

`#[launch_bounds(192, 1)]` on the three shipped tcgen05 GEMMs makes the
geometry an input instead of an output: `.maxntid` now reads exactly 192 rather
than a number the allocation happened to imply, and one resident CTA is a
constraint ptxas must satisfy. An allocation that cannot reach it spills, which
the budget gate already fails on, instead of producing a kernel the driver
refuses.

Two ceilings move with it — bf16 132 -> 160 and the fp32 store 168 -> 172, the
reduce unchanged at 146 — with zero spill and zero frame throughout, and the
budgets are ratcheted to match. The direction is the point: a `.maxntid` of
exactly 192 is what lets the allocator spend the register file this kernel's
one CTA an SM already owns. Residency does not move, because at 192 threads
even 255 registers is still one CTA.

Stable across four rebuilds at 160/172/146, parity green at unchanged
tolerances.
feitreim added a commit that referenced this pull request Aug 6, 2026
…driver

stops deriving it

`cargo oxide` emits PTX and the driver JITs it at `cuModuleLoad`. An entry
point carrying no `.maxntid` tells that JIT nothing about the block it will be
launched in, so it allocates against the architecture's 255 registers and then
*derives* the largest block the result can be launched in. Measured on the
warpgroup-split commit of #119: 640, 640 and 384 threads, from 86, 96 and 140
registers. A build that had chosen 182 would have derived 256 — below that
kernel's own 320 — which is `max_active_blocks_per_multiprocessor` of 0 and
`DriverError(701)` at the first launch, and is exactly what #119 saw once in
three. The same 182 is fine at 192, which is why this is invisible today.

`#[launch_bounds(192, 1)]` on the three shipped tcgen05 GEMMs makes the
geometry an input instead of an output: `.maxntid` now reads exactly 192 rather
than a number the allocation happened to imply, and one resident CTA is a
constraint ptxas must satisfy. An allocation that cannot reach it spills, which
the budget gate already fails on, instead of producing a kernel the driver
refuses.

Two ceilings move with it — bf16 132 -> 160 and the fp32 store 168 -> 172, the
reduce unchanged at 146 — with zero spill and zero frame throughout, and the
budgets are ratcheted to match. The direction is the point: a `.maxntid` of
exactly 192 is what lets the allocator spend the register file this kernel's
one CTA an SM already owns. Residency does not move, because at 192 threads
even 255 registers is still one CTA.

Stable across four rebuilds at 160/172/146, parity green at unchanged
tolerances.
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