Repository navigation
ferro-kittens #197-#210 surveyed: the warpgroup split is measured here and rejected, and the instrument that rejected it ships - #119
Merged
Conversation
… 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
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.
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.
Reverse of yesterday's review. ferro-kittens merged fourteen PRs since the
f64a27bthis tree pins its kittens at (#195, which is in), and this wentthrough 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/profilereports the three tcgen05 GEMMs' registers, spill andCTAs/SM beside the RMSNorm table.
gpu/gemm's budget gate compiles thosekernels 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/SMis a kernel the driver will refuse, and nothing in treecould see it before. On
mainit 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
wreaches tensor-memory lanes32 * wand noothers. Eight
[32, 64]staging tiles are the 32 768 B four[32, 128]onescost, 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
.localdepot #166 has since removed and re-ran it: thesign 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
Drainimpls (commits 1–2 of this branch —Packed,WideandReduceeach liftWARP_Ncolumns instead ofBLOCK_N,with
band_originthe single place a warp's corner is derived andTile::originadding the same pair to the destination), it:passed parity at unchanged tolerances, all four
gpu/gemmchecks;dropped every register count — bf16 132 → 86, fp32 store 168 → 96, reduce
146 → 140, zero spill and zero frame throughout;
and bought nothing.
train_abvsmain, 30 steps, two roundsalternating in one container:
maincandidate/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.ldand the ping-pong hands it toan item two ahead, so the drain is not on the critical path and making it
cheaper is making already-hidden work cheaper.
gemm_solhas no accumulatorping-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_accumulate140 registers with no frame twice — and 182with a 2176 B frame once, which is
max_active_blocks_per_multiprocessorof0 and
DriverError(701, "too many resources requested for launch")at thefirst 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/SMwas printed.The rest of the survey
Window: ferro-kittens after
f64a27b(#195, this tree's pin) throughac79127(#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.
bwd o_proj dWat 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.epilogue::Drain::stagedgemm_sol's drain does not migrate: it walks sub-bands narrower than its staging tile throughtile_x8_batchedand converges twice a pass."Packedis that drain. Behind the rev bump besides.col_maploop orderColVecs (ops'NormColumns, flash'sCols) and neither goes throughcol_map.ldmatrix.x4load sideJob::finishpipeline::run/Jobat #80 and walksWalkitself. No call site.store_tile→ MMA owingfence.proxy.async.shared::cta— this tree already has, at all three sites inflash-attn/src/tcgen05.rs(1121, 1661, 2077). Nothing to do; worth A8 knowing we were already right.store_row_vec/load_row_vec,SharedVec::sliceROW_MAX/ROW_RESCALE/ROW_LSEstatic shared arrays. Flash territory, and behind the rev bump.exp2_hwflash_forward(and 2.7× onsoftmax, a shape we do not run).exp2_hwalready exists at the pinned rev, so there is nothing to bump — the deliverable is the negative result. Our own.exp()sites are scalarf32::expin cross-entropy and the router, notRegTileops, so the swap would be a numerics change on the loss with no measurement behind it.ACCUM_COLS = 512is a legal power of two,M256_N256matchesTmemTile<128, 256>at cg2). It is what makes a kittens rev bump breaking —alloc_cluster/dealloc_clustergain a const parameter andmma_walk_cg2gains two — and the breakage lands ingpu/flash-attn, which is A8's tree this week. Not to be bundled.Follow-ups this leaves
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.
f64a27b→ac79127) as a separate PR onceflash-attn is quiet, for #203's typing plus #199/#201/#210. None of it is a
throughput claim.