Repository navigation
Description
#74 established, with a control rather than an inference, that a CTA touching
tcgen05.alloc is charged the SM's entire tensor memory — 1 block per SM at
32 columns exactly as at 512, against 32/32/16/8 for the byte-identical kernel
with the allocator deleted. device-tests' tmem occupancy ladder is the
measurement and it is in tree.
That closed #74. What it opens is bigger than the kernel it was found in.
The consequence, which is a library-wide fact and not a flash detail
For any tcgen05 kernel, occupancy is warps per CTA. Nothing else is a
lever. At 1 block/SM the CTA's own width is the SM's occupancy, so the three
things this repo has reached for so far do not apply:
- Shrinking the shared plan does nothing (flash_forward asks for 147536 B of shared memory and the driver admits 0 blocks per SM #70 measured that on flash: 1 block/SM
at 147536 B and at 0). - Shrinking the TMEM allocation does nothing (flash_forward is pinned at 1 CTA/SM with no shared memory and no register pressure to explain it #74, above).
- Register pressure does not bind first (
flash_forwardis 123 registers with
no spills; 4 blocks' worth of headroom that it cannot use).
flash_forward runs 4 warps against its own max_threads_per_block of 512,
and against the 32 the control probe holds. The GEMM is the other tcgen05
entry and the occupancy query cannot describe it — a #[cluster_launch] kernel
takes a different path — so whether the GEMM is in the same position is not
currently known, and finding out is part of this.
Why this is not a tuning constant
QUERIES / 32 is where flash's 4 warps come from: one warp per 32 accumulator
rows. Raising the warp count means a different decomposition, not a bigger
number — a producer/consumer split with warps dedicated to TMA issue and to MMA
issue, which is the shape a tcgen05 kernel is supposed to have and the shape
ThunderKittens' own attention kernels use. That is a design to price, not an
edit to make.
Scope
- Establish whether the GEMM is also at 1 CTA/SM. The occupancy query will not
answer for a#[cluster_launch]kernel, so this needs another route — a
non-cluster probe with the same TMEM shape, or reading it off a timed run.
Do this first: if the GEMM is unaffected the rest is narrower than it
looks, and if it is affected then every tcgen05 kernel in this repo has an
occupancy ceiling nobody has priced. - Price the warp count on the control ladder before touching a real kernel.
The probe indevice-testsalready sweeps block width; extend it to hold
TMEM and vary warps, so the shape of the curve is known independently of any
kernel's decomposition. - Only then propose a decomposition for
flash_forward. It has no launcher
and no CPU reference, so a rewrite cannot currently be checked — see layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67,
where the harness had to come first and the fix turned on a rung the ladder
did not predict. Adding the launcher and reference is plausibly its own issue
and plausibly the prerequisite for this one.
Acceptance
A number for what warps per CTA buys on a tcgen05 kernel, measured on the
control rather than argued from the ISA. No claim about flash_forward being
faster without a CPU reference in front of it and a positive control behind it
(#67's discipline: an error class built as a real kernel, with predicted and
observed wrong-cell counts).
Related: #74 (the finding and the control), #70 (the shared plan is not the
lever), #47 and #67 (what an occupancy ceiling costs when nothing is in flight),
#63 (allocated is not cost).
Activity
feitreim commentedon Jul 28, 2026
Step 1 has an answer already, from #51, and it goes against this issue's premise. The GEMM is not at 1 CTA/SM.
#51 ported
gemm.rstopipeline::runand swept the grid cap on a B200. Min ms over 30 timed launches at 8192³:Capping the grid at one cluster per SM costs 2.07×. That is only possible if more than one cluster is actually resident per SM. If the hardware could hold just one, the uncapped grid's surplus clusters would queue behind the resident ones and the total work would take the same time — the cap would be free. It is not free; it is a factor of two.
So extrapolating #77 to the GEMM is false by at least 2×, and this issue's framing — "for any
tcgen05kernel, warps per CTA is the only occupancy lever" — is wrong as stated. I wrote it; the correction is mine, not #51's.What #77 actually established, restated precisely
#77's control is sound and nothing here contradicts it. What it measured is that
cuOccupancyMaxActiveBlocksPerMultiprocessorreturns 1 for any kernel containing atcgen05.alloc, at every column count and every block width, against 32/32/16/8 for the byte-identical kernel without one. That is a fact about the query.Whether the query's 1 describes hardware residency is a separate claim, and #51's timing is the first evidence either way. It says no — at least for a
#[cluster_launch]kernel usingalloc_cluster.Two candidate reasons, neither tested:
gemmwas never meaningful — but note the query was never asked aboutgemm; The 1 CTA/SM is tcgen05 itself, and a smaller TMEM allocation buys nothing (#74) #77 measuredflash_forwardand a synthetic probe, both plain#[kernel]s.alloc_cluster(cta_group::2) charges TMEM differently fromalloc_block, so a pair splits the SM's tensor memory rather than each rank claiming all of it. This would make the two kernels genuinely different, and The 1 CTA/SM is tcgen05 itself, and a smaller TMEM allocation buys nothing (#74) #77's control usedalloc_block.If (2) holds,
flash_forwardmay be at 1 CTA/SM for real while the GEMM is not, and the two need separate answers rather than one rule.Revised scope
Establish whether the GEMM is at 1 CTA/SM.Answered: it is not. Keep the table above as the evidence.flash_forward's 1 is real residency or only the query's answer. This is now the load-bearing question and it did not exist before. The query cannot be trusted as residency for at least one kernel here, so a timed probe is needed — the same shape as pipeline::run cannot schedule a cluster: work items are blockIdx.x-strided #51's grid-cap sweep, on a kernel where capping the grid is possible.tmem occupancy ladderto pricealloc_clusterbesidealloc_block. If the pair splits the allocation, that is the whole explanation and it belongs insrc/tmem.rs's docs.The warps-per-CTA question is still worth answering —
flash_forwardruns 4 warps against its ownmax_threads_per_blockof 512 — but it is no longer established that it is the only lever, and it should not be pursued on the strength of a query result that has now been shown not to predict residency once.Related: #77 (the query finding, which stands), #51 (the timing that limits its reach), #74, #70.
[-]For a tcgen05 kernel, warps per CTA is the only occupancy lever left — and nobody has priced it[/-][+]flash_forward's 1 CTA/SM may be the query rather than the hardware — the GEMM's is not real[/+]A work item belongs to a cluster, and the GEMM that proved it got slo…
gemm runs on the scaffold, at the cap a clock had to find (#51)
gemm runs on the scaffold, at the cap a clock had to find (#51) (#83)
feitreim commentedon Jul 28, 2026
Step 1 now has a number, not just a refutation: the GEMM's residency is 3 CTAs/SM, measured by bisecting the grid cap on a clock (#83).
Min ms at 8192³, B200, 148 SMs, 30 timed launches:
The curve stops at 222. So residency is three, and #77's figure extrapolated to this kernel would have said one — wrong by 3×, and wrong in the direction that costs 2× if you build a grid on it.
This also supersedes the provisional conclusion in #80 and its closing comment here. #80 measured caps 74 and 148 only, found the persistent GEMM 2.07× slower, and named cap 222 as the unmeasured point that would decide it. The Modal spend limit is what stopped it being taken. It came back a dead heat — 1076 vs 1077 TFLOP/s — so the GEMM now runs on
pipeline::run, and the entire effect was the grid cap rather than anything about persistence.The method is the transferable part. For a
#[cluster_launch]kernel the occupancy query is not merely unreliable, it is inapplicable — it takes a block shape and no cluster, which is whymain.rsprintsclusterin that row. A grid-cap sweep on a clock is currently the only residency probe available for such a kernel, and it works by bisection: cap the grid at k CTAs per SM and find where the time stops improving.What remains open here is unchanged and is the interesting half:
flash_forwardis a plain#[kernel], so the query does apply to it, and whether its 1 is real residency or only the query's answer is still unknown. The GEMM result does not settle it, because the two kernels allocate TMEM differently —alloc_clusterversusalloc_block— which is the leading hypothesis for why they differ and is exactly what the in-flight work on this issue is pricing.Say which query cannot answer a cluster launch, and which one can (#78)
Count the CTAs instead of asking, and flash_forward's 1 is real for t…