Repository navigation
Description
Found by #67's agent while fixing layernorm_rows, deliberately not shipped
in #75, and correctly so — softmax.rs's header argues for CHUNK = 32 at
length, and a one-constant probe is not an argument against a written one.
Filing it so the probe is not lost.
The probe
softmax_rows at CHUNK = 16 against its shipped CHUNK = 32, nothing else
changed:
| regs | frame | GB/s | |
|---|---|---|---|
CHUNK = 32, as shipped |
66 | 256 B | 950 |
CHUNK = 16 |
50 | 128 B | 1185 |
Half the frame, a quarter more throughput, on a kernel whose arithmetic did not
change.
Why it is worth a ticket
softmax is now the slow kernel in the repository. After #67,
layernorm_rows runs 5539 GB/s where softmax_rows runs 950 — a factor of
5.8, at equal shared memory and the same 6 blocks per SM. Layernorm does
strictly more work per element (two statistics rather than one, plus a gamma
and beta apply), so the ordering is backwards and something is being left on
the floor.
The 16-rung probe is the obvious first suspect but it is not the whole gap: 950
→ 1185 is 1.25×, and the gap is 5.8×. Do not assume closing the rung closes
the difference. The rest is unexplained and is the more interesting half.
What #67 established that applies here
- The frame, not the register count, is what tracks time on this pair of
kernels.layernorm_rowsatCHUNK = 32is seven registers cheaper than
at 16 and 1.46× slower, at identical occupancy — the register column
ordered time backwards for the third time in this repo (softmax is latency-bound, not bandwidth-bound: 362 GB/s ceiling and a flat 51us floor #47, Is a streamed local-memory band actually slower? ptxas cannot say, and the ladder now makes the question concrete #63, layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67). - Occupancy is not the variable. Both rungs give 6 blocks an SM; shared memory
binds there either way. - The ladder in
examples/README.mdsays[32, 32]has a zero frame in all
five spellings, and both of these kernels get a non-zero frame at that shape.
The probe carries noColVecparameters and no cross-chunk statistics; a
real kernel's extra live state moves its cliff a rung down. The ladder
narrows the search; it does not answer.
Scope
- Re-run the
[32, N]column sweep againstsoftmax_rowsat every rung, the
way layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67 did rather than testing two points, and report registers, spill,
frame, blocks/SM and GB/s per rung.ptxas -vreports what was allocated,
never what it cost (Is a streamed local-memory band actually slower? ptxas cannot say, and the ladder now makes the question concrete #63) — the GB/s column is the one that decides. - If a rung wins, rewrite
softmax.rs's header argument for 32 rather than
silently changing the constant underneath it. The prose is the reason the
number is what it is, and a number that no longer matches its argument is
the GAPS.md §3.2 (Reductions) is stale from before #6 landed #65 failure mode in code. - Then account for the rest of the 5.8×, which is the actual point of this
issue.softmaxalready survived one round of this in softmax is latency-bound, not bandwidth-bound: 362 GB/s ceiling and a flat 51us floor #47 and came out
latency-bound with a flat floor; layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67 has since shown that floor is not a
fixed harness cost (layernormreaches 8.4 µs where softmax is latency-bound, not bandwidth-bound: 362 GB/s ceiling and a flat 51us floor #47 read softmax's 23 µs
as the launch itself). So the floor is back on the table as a defect rather
than a constant.
Acceptance
Same discipline as #67: no throughput claim without the exact check passing at
all six sizes first, and a positive control showing the check fails against a
deliberately broken kernel. softmax already has a reference and a bench row,
so unlike #67 this one starts from a harness that exists.
Related: #47 (softmax's last round, and the 23 µs floor this reopens), #67 (the
finding, and the rung discipline), #63 (allocated is not cost), #60 (the
ladder).
Activity
softmax: the rung was a quarter of it and the exp2 polynomial was the…
Audit the library whole: three doc claims were wrong, and the surface…
The pin moves to 20a5616, and two doc claims did not survive the audit
The pin moves to 20a5616, and two doc claims did not survive the audit