Repository navigation
Description
#94 vectorized store_rows/load_rows and took gemm_cg2 from 40 registers
to 167, with zero spill and an unchanged frame. It is a clear net win —
8192³ went 1076 → 1223 TFLOP/s and occupancy did not move — but it spent almost
all of a budget nobody was tracking.
At 128 threads against a 64 K register file:
| registers | CTAs/SM |
|---|---|
| ≤ 128 | 4 |
| ≤ 170 | 3 |
| ≤ 256 | 2 |
gemm_cg2 is at 167. Three registers of headroom. The 171st register costs
a third of the kernel's occupancy.
Why this is a live risk rather than a curiosity
#84 measured the GEMM at 3 CTAs/SM, capped by its 73792 B shared plan. Registers
were nowhere near binding at 40, so nothing in the repo watches them. They are
now the joint binding constraint, and four in-flight or queued changes all add
live state to this kernel:
- lcsf and the rest of the prototype layer #15 (
lcsf) — a store stage, which is more state across the item boundary - Sweep the GEMM's pair tile and pipeline depth: [256,256] at three stages should dominate on paper #87 — a bigger pair tile, which is more accumulator drain
- Cluster Launch Control: hardware work-stealing exists in cuda-oxide and pipeline::run schedules statically #88 — Cluster Launch Control, which adds a response buffer and a harvest
- bench has no denominator: put cuBLASLt beside the GEMM at every size #92 — a cuBLASLt baseline (does not touch the kernel, but shares the file)
Any one of them can silently cross 170. The failure mode is not a build error or
a wrong number: it is a third of the occupancy, showing up as a throughput
regression that looks like the feature was a bad idea. That is expensive to
diagnose and easy to misattribute — and #47, #63, #67, #76 and now #94 are five
occasions where a register count did not mean what someone assumed it meant.
The cause of the jump is unestablished, and that is stated honestly
#94's agent hypothesized the inline asm's memory clobber, measured it, and was
wrong — deleting both clobbers gives byte-identical counts. So this issue is
not "undo the regression"; the registers may well be buying the speed. It is
"make the cliff visible".
Worth a look anyway: 4x the registers for a change that only alters how stores
are issued is surprising, and if the extra state is incidental rather than
load-bearing then there is headroom to reclaim for free.
Scope
- Make the cliff checked rather than remembered.
modal_app.py::regcount
already prints registers per entry function and runs CPU-only on every PR
through tier 2. A threshold that fails the run when a named kernel crosses
its occupancy step would catch this at the cheapest gate available, before a
B200 is ever booked. Prefer that to aconstassert, since the count is a
ptxasoutput and not something the type system can see. - Express the threshold as the occupancy step, not as a magic 170 — derive it
from threads and the register file so it stays right ifTHREADSchanges. - Do not gate on an exact count, which would fail on every incidental
codegen wobble. Gate on the step. - Then investigate whether the 40 → 167 jump is load-bearing. Report what
the extra live state is; if some is incidental, reclaiming it is free
headroom for lcsf and the rest of the prototype layer #15, Sweep the GEMM's pair tile and pipeline depth: [256,256] at three stages should dominate on paper #87 and Cluster Launch Control: hardware work-stealing exists in cuda-oxide and pipeline::run schedules statically #88.
Acceptance
A tier-2 gate that fails when a kernel's register count would cost it a CTA per
SM, with the step derived rather than hardcoded, and a positive control showing
it fires — deliberately inflate a kernel past its step and watch the gate go
red. Same discipline as #67 and #76: a check nobody has seen fail is not
a check.
Related: #94 (the jump and the win), #84 (the residency census and why shared
memory was the only cap anyone was watching), #63, #15, #87, #88.
Activity
regcount fails the run when a kernel crosses its occupancy step (#95) (…
The pin bump moved 44 of 270 register counts, and four of them are sp…
The pin bump moved 46 of 272 register counts, and the census is basel…