Repository navigation
Description
The problem
Every register claim in this repo is measured at exactly 32 and 128 columns, and the guidance I have been handing agents is "measure both, trust neither in advance." That guidance exists because two points keep disagreeing:
- Generic map mechanism and the standard elementwise op set #5 found the 32-wide probes insensitive — they did not move under a change that cost 87 registers at 128.
- Reductions: column-wise, whole-tile, and a generic reduce #6 found 32 was the sensitive width for a different change.
- The map mechanism needs in-place variants: by-value costs 87 registers at 128 columns #31 measured six spellings that were identical at 32 (48 regs, no spill, every one) and spread across 87 registers at 128.
Two points is enough to know the curve is not flat and not enough to know its shape. Every one of those findings is really "there is a cliff somewhere between 32 and 128, and we do not know where."
Why it is only two, and why that is the wrong reason
Not cost. ptxas is a host compiler — modal run modal_app.py::regcount is CPU-only and the ptxas -v pass is milliseconds per PTX file. The actual constraint is structural, and regcount's own docstring states it:
Only kernels that are actually monomorphized appear — an op no kernel calls emits no PTX and measures nothing, so a codegen probe in
device-testsis how a bare library function gets onto this table at all.
So each width costs a hand-written probe kernel in device-tests/src/main.rs. Widths are two because writing probes is manual, which is a reason to generate them, not a reason to measure less.
What to build
A macro that emits a probe per (shape, spelling), so a ladder costs one line per rung:
- Columns: 16, 32, 48, 64, 96, 128, 192, 256. All multiples of 16 (
BaseLdtmneedsN % 16 == 0). - Rows: at least 16, 32, 64 — the row extent has never been swept at all, and
SLOTS = M/8scales the per-thread array just asVALUES = N/4does. - Deliberately cross the cliff. A thread holds
M*N/32fp32 values, so[32, 256]is 256 registers — one past the file. Shapes that spill are the informative ones; do not stop short of them, and expect some to fail to build (report, do not silently drop).
Cover the spellings #31 established as the axis that actually orders cost — how many whole bands get materialized between statements:
- fused single expression (
out.scale(k).add(b.scale(k))) - in-place
_assign - rebinding (
x = x.op(..)) - open-coded loop
Acceptance
- One table, one command, all rungs — and the cliff location printed, not left for a human to eyeball. "Where does spill first become non-zero" is the number every future issue actually wants.
- A determinism control, per The map mechanism needs in-place variants: by-value costs 87 registers at 128 columns #31: measure the same tree twice and assert an identical table before trusting any diff. That is what let The map mechanism needs in-place variants: by-value costs 87 registers at 128 columns #31 attribute an unexpected 71→32 swing to its own refactor rather than to noise.
- Report the harness's build time before and after. If generating 50+ probes makes
::regcountmaterially slower, say so and consider a--quicksubset for iteration with the full ladder on demand. - Update
GAPS.md/examples/README.mdwhere they quote the two-point numbers.
While you are in there
lane_probe's recorded table is stale in three cells — it claims 198/2816 and 72/256 where main measures 168/2816 and 56/384. Two separate agents have now noticed and correctly left it alone as #27's. If the sweep replaces those numbers wholesale, this goes away; if not, fix the three cells and say so.
Related: #27 (implicit lane), #31 (which produced the model this sweep would test).
Activity
Sweep the register ladder instead of measuring two widths (#60)
softmax: the band was never in registers, and that was the 362 GB/s (#47
Put a clock on the register ladder: a streamed band costs, and #47 sa…
Put a clock on the register ladder: a streamed band costs, and #47 sa…