Repository navigation
Open
Description
Blocked on #66. Evaluate and, where the measurement says yes, rewrite the gpu/ops and gpu/tensor-gpu kernels on ferro-kittens tiles. Unlike gemm/flash-attn these crates don't currently depend on kittens at all, so this is adoption, not migration — and the standing rule applies: port where tiles win on the clock, not for uniformity. Measure first.
Inventory, grouped by likely outcome
Ferro-kittens has a direct reference — port these first:
rms_norm_forward/_fast/ backward family → ferro'sexamples/src/layernorm.rs(SharedVec-staged γ/β vialdst::load_vec,block_reducefor the row statistic, TMA store).softmax_forward,cross_entropy_loss,softmax_cross_entropy_backward,fused_classifier_*→ ferro'sexamples/src/softmax.rs(row_max/row_sum,online_rescale,Exp2*). Note ferro Flash HD=128 follow-ups: persistent stream-B regression + M64 operand-K mispairing (M128 waste) #47's finding for this family: softmax is shared-memory-capped, so register streaming that helps elsewhere cost 2.6× there — which resource is binding decides the shape.
Plausible but unproven — measure a tile version against the current one before committing:
swiglu_forward/_bf16/backward,rope_forward/rope_backward— bandwidth-bound elementwise; a tile pass buys vectorized 16-byte access (store_shared_rows-style) but the current flat kernels may already be at bandwidth. If the probe says no win, close that half with the numbers attached.
Probably not tile-shaped — justify inclusion, don't assume it:
embedding_forward/backward,moe_gather_*,router_backward_weight,split_group*— gather/scatter with no dense tile structure.- All of
tensor-gpu(adamw,muon_apply_bf16,ema_momentum, conversions, fills) — optimizer-state streaming; bandwidth-bound by construction. attention_probabilities/attention_output/attention_backward_*— the non-flash attention path;gpu/model/src/lib.rsno longer references it. Confirm it's dead and consider deleting instead of porting.
Process
- One PR per family above, branch off
main, never touchmain. - Every port PR carries a B200 before/after via
modal_app.py; a family where tiles lose gets its result recorded here and stays flat. - Any library gap the ports surface (e.g. shared-tile/shared-vector map+reduce instantiations — GAPS §3.1/§3.2, the tile half filed nowhere; fp32
TensorMapElementfor descriptors over f32 buffers — GAPS §1.5) gets an issue on feitreim/ferro-kittens, linked from the PR. The rms_norm and classifier ports are exactly the consumers those gaps have been waiting for. - A Modal check red in ~15s is the spend limit, not the code.
Metadata
Metadata
Assignees
Labels
No labels
Activity
feitreim commentedon Aug 3, 2026
Measured on a B200, at
gpu/model/src/bin/train.rs's shapes (N = 24576,D = 3072,FF = 4096,VOCAB = 50257,VP = 50432), three warmups and twenty timed iterations per row, shipped and tile kernel in the same container on the same clocks. Every number below is effective bytes per second over compulsory traffic — the reads and writes the kernel is obliged to move, no reuse assumed — because every family here is bandwidth-shaped and FLOP/s says nothing about any of them.The tiering in this issue is backwards. Both port-first families lose; the measure-first one wins. #73 ports SwiGLU. The rest of this comment is the record for the ones that stay flat.
The exploration is on
feat/issue-70-tile-probes— every kernel below, its correctness gate against the shipped one, and the bench rows, so these are reproducible and not just reported.1. RMSNorm — tiles lose, stays flat
rms_norm_forward_fastreaches 4167 GB/s andrms_norm_backward_x_fast5634 GB/s. The best tile shape found reaches 0.83x and 0.91x of those. Fifteen shapes, sweeping rows per warp, columns per chunk, and warps per block:Why. The row statistic is genuinely cheaper on tiles —
RegTile::row_sumis two shuffles against a 256-thread shared-memory tree and eight barriers — and it does not matter, because the reduction was never what these kernels were waiting on. What decides them is memory-level parallelism, and the shipped block-per-row kernel has 24576 CTAs of 256 threads = 6.3M threads where a warp-per-band kernel has 24576. A tile lane holds a chunk's worth of loads in flight; 128x fewer lanes cannot make that up, and the chunk width is the only knob that would — which runs into the second finding.The cliff past 32 columns is a
.localdepot, not registers. The natural suspect was the parameter vector: reading a[dim]weight through a stride-zeroload_rowscostsSLOTS * VALUESregisters to holdVALUESdistinct numbers. That is real, and I filed and fixed it (ferro-kittens#172 / #173,global::load_cols, the global twin ofldst::load_vec). It moved chunk 64 from 0.151x to 0.165x and no further. So what collapses there is something else, upstream of ptxas — the same shape ferro-kittens'regcountlocal-memory census (#167 there) was built to see. Worth its own issue there; it is not what decides this family either way.RMSNorm's own headroom is real and is not a tile question. Forward is at 4167 GB/s where backward, on the same card and the same buffers, reaches 5634. Backward does 24 elements per thread against forward's 12, so what forward is short of is work per thread, not bandwidth — a two-rows-per-block variant of the existing kernel is the shape that would collect it.
2. Softmax / cross-entropy / fused classifier — tiles lose, stays flat
fused_classifier_forward_bf16at 24576 x 50432 reaches 1676 GB/s. The tile version — one warp per 16 rows,row_max/row_suminstead of the two shared arrays and the branchy eight-round merge, running(max, sum_exp)carried across chunks in registers so it is still one pass — reaches 720 GB/s, 0.430x.Same mechanism as RMSNorm and worse: 24576 CTAs become 192. ferro-kittens#47's finding is the same result reached from the other side — softmax's binding resource is not the one register streaming buys.
Forward only, deliberately: both directions share one reduction and one row walk, and the backward only adds a write-back pass no tile shape changes. A forward at 0.43x settles the family.
3. SwiGLU — tiles win, ported in #73
swiglu_forwardswiglu_backward_gateswiglu_backward_upswiglu_forward_bf16This issue's guess about SwiGLU was that "the current flat kernels may already be at bandwidth". They are not: 2447 GB/s where the RMSNorm backward reaches 5634 on the same card. The flat kernel gives one output element to one thread — one 4-byte load from each input, one 4-byte store — and what a tile buys is the access width and the loads in flight, which is the entire difference. No reduction is involved anywhere in this family.
The bf16 arm losing is the same fact read backwards, and it is the useful half of the result: that kernel already stores a packed pair per thread, so it already had the access width, and at 3516 GB/s a tile has nothing left to sell it. Not ported.
Peak shape is 16 rows per warp and 32 columns per chunk. 64 columns falls to 0.39x — the same
.localcliff as §1, at the same width, on a kernel with no parameter vector in it at all, which is what identifies it as the codegen and not the operand.4. RoPE — not a memory kernel, no tile version written
rope_forwardat 24576 x 3072: 924 GB/s, against SwiGLU's 2447 on comparable traffic and the same card. It computes apowf, asinand acosper element. It is transcendental-bound, not bandwidth-bound, and a tile pass moves the same bytes with the same arithmetic still in it — the probe this issue asked for is answered by the ratio without writing one.The win here is a precomputed
[T, HD/2]cos/sin table, which isT * HD / 2 * 4 = 512 KBat the training shape and read from L2 — orthogonal to tiles and worth its own issue if anyone wants it.5.
attention_probabilities/attention_output/attention_backward_*— not dead, do not deleteThis issue's premise is half right:
gpu/modelno longer references any of the five. It stopped at0b79bdf(2026-07-17), which deleted thenaive_attention_probabilities: Option<...>oracle plumbing and madeflash_attention_forward_into/_backward_intounconditional. Butgpu/flash-attnis a live consumer — it#[path]-includes../../ops/src/lib.rsasmod naive(gpu/flash-attn/src/main.rs:19-20) and diffs the tcgen05 flash output against all five:attention_probabilitiesgpu/flash-attn/src/main.rs:127, 276, 449;src/bin/bench.rs:58attention_outputgpu/flash-attn/src/main.rs:137, 459;src/bin/bench.rs:68attention_backward_qgpu/flash-attn/src/main.rs:289, 469;src/bin/bench.rs:111attention_backward_kgpu/flash-attn/src/main.rs:302, 482;src/bin/bench.rs:124attention_backward_vgpu/flash-attn/src/main.rs:314, 494;src/bin/bench.rs:136Deleting them removes flash-attn's correctness gate and its bench baseline, which is exactly the role
SPEC.md:353-356assigns them ("the naive kernels are never deleted — they are the spec the fused ones are tested against"). They are oracle-only and never in the training loop; that is the intended state, not rot.One real cost, and it is not runtime:
gpu/modeltextually includes all ofgpu/ops/src/lib.rs, so those five compile into the training binary's device image and are paid for in PTX size and ptxas time by a binary that cannot launch them. If that is worth fixing, the fix is a#[cfg]on the oracle set, not a deletion.Library gaps filed
load_cols, the global twin ofldst::load_vecferro-kittens#172 — a per-column operand in global memory had no way into registers;ldst::load_vecreads aColVecout of aSharedVecandglobal::load_rowsreads aRegTileout of global memory, and there was no third call. Fixed in A per-column operand in global memory reaches registers without a tile's worth of them (#172) ferro-kittens#173 (global::load_cols), device caseglobal column map, 43/43 on a B200. Honest caveat carried on that PR: the RMSNorm port that motivated it did not ship, so it lands with a device case and no kernel consumer.TensorMapElement(§1.5) — were not needed, and the reason is worth recording. Neither port went through shared memory or a TMA descriptor at all.global::load_rows/store_rowsare generic overElement, so an fp32 register tile reaches global memory directly, with no descriptor to encode and no shared tile to stage; the fp32TensorMapElementonly binds if you want the engine, and at these shapes there is nothing to prefetch into. The tile path being 16-bit-only (ldst'sElement<Unpacked = [f32; 2]>bound on theldmatrix/stmatrixpaths) never came up for the same reason.Merge pull request #73 from feitreim/feat/issue-70-swiglu-tiles
feitreim commentedon Aug 4, 2026
Re-measured both families that this issue left flat, against the
c648c67pin (#76) that carries ferro-kittens#180's mover unroll. One of the three kernels turns over; #78 ports it.Same conditions as the comment above — B200,
bin/train.rsshapes, three warmups and twenty timed iterations, shipped and tile in one container on one set of clocks.rms_norm_forwardrms_norm_backward_xfused_classifier_forward_bf16§1, RMSNorm — the forward ports, the backward does not
This issue's cliff was right about where it was and right that it was not registers. It was the depot, and it moved rather than vanished:
64 columns went from 0.165x to 1.026x at 32 rows and to 1.246x at 16. The new edge is at 96, and it is a different failure: both tile kernels now come out of ptxas with no
.localdeclaration at all at 64, so what breaks at 96 is a[16, 96]fp32 band that no longer fits the register file — ferro-kittens#181's category, not #180's.This issue's diagnosis of why was correct and is why the forward wins. The reduction was never what these kernels were waiting on; what the tile buys is loads in flight, and at 64 columns per lane against the block-per-row kernel's 12 elements per thread it buys enough of them to beat the 64x cut in thread count that this issue counted (6.3M → 98k). And this issue named the target itself: "forward is at 4167 GB/s where backward, on the same card and the same buffers, reaches 5634 ... what forward is short of is work per thread, not bandwidth". That is exactly the gap the tile collects — 5179 GB/s — and it is why 16 rows beats 32, which spends the same register budget on rows instead of columns and reaches only 1.026x.
It is also why the backward cannot follow. It was already at the roof the forward just reached; 0.985–0.997x across four shapes is the same rate from the same side. The two-rows-per-block variant of the existing forward that this issue proposed would have been chasing the same 5600 GB/s ceiling — the tile got there first, so that follow-up is now closed rather than open.
§2, classifier — still not close, and the frame is not the reason
0.442x at 64 classes per chunk, 0.224x at 128, 0.206x at 256, 0.367x at 32 rows per warp. No shape helps.
It is the one kernel here that still carries a frame, and the frame is real: 400 bytes, from
RegTile::maskbehind the singleright_fillon the vocabulary's ragged last chunk.maskwalks slots by a runtime index, sosetunder a data-dependent condition keeps the slot array addressable and LLVM homes the whole 32-register tile — once per vocabulary chunk, all 786 of them, not just the masked one. ferro-kittens#180 did not reach it;src/reg.rshas no__unroll_configanywhere.Deleting that one call removes the depot entirely and moves the kernel to 0.563x. So the frame is 27% of its runtime and it is still not what decides the family — this issue's count is: 24576 CTAs become 384, and no tile shape reaches that.
Filed as feitreim/ferro-kittens#184 with the PTX. The patch is two lines and I did not push it: it drops
examples/flash_forward's frame 1824 → 1568 bytes and takes it from 165 to 255 registers, which is #181's band-that-does-not-fit surfacing honestly rather than a win, and no kernel here gets faster from it.What is left of this issue
§3 SwiGLU shipped in #73, §1's forward ships in #78. Still open and unchanged by any of this: §1's backward and §2 stay flat with the numbers above, §4 RoPE's precomputed cos/sin table, and §5's
#[cfg]on the five oracle kernels that compile into the training binary without being launchable from it.Merge pull request #78 from feitreim/feat/ops-tile-relook