Repository navigation
Description
Found while tightening the GEMM's reference (#48), by auditing the other running example's generator against the same question: which coordinate errors can this check not see?
The hole
softmax.rs seeds its input with a permutation whose row term is 37 * 128 * row. Since 37 * 128 = 0 (mod 128), the permutation has period 128 in row — exactly one CTA band. Any row error that is a whole multiple of 128 rows produces bit-identical expected values, so the exact check passes it.
This is the same class as #48 (a coordinate the generator does not actually depend on) but narrower, and the narrowness is why it was left alone rather than folded into #55:
- The load and the store share the same
ROWS * blockIdx.x, so a band error moves both and lands back on itself. - The destination buffer is zeroed, so an entirely unwritten band fails on the zeros rather than on the values.
It bites only if those two coordinates diverge — a kernel that computes its load row and its store row separately, which is exactly what a split-row or persistent-CTA variant would do. That is a plausible next edit to this file, not a hypothetical.
What is NOT wrong
The plane axis is strong and needs no change; I checked before assuming symmetry with #48. 53 is odd, hence a bijection mod 128, and since 11^-1 = 35 (mod 128) a one-plane step is a 63-column rotation. Minimum relative error over every cell is 0.9985 against a 2^-8 tolerance — a 255x margin. So this issue is one axis of one example, not "softmax's check is weak".
Acceptance
- The row term depends on
rowin a way that survives mod 128 — i.e. picking a row multiplier that is not a multiple of 128, the way gemm: make the reference B vary along K, so the exact check covers the K walk #55 picked moduli sharing a factor rather than coprime ones. - A positive control, as in gemm: make the reference B vary along K, so the exact check covers the K walk #55: pin the kernel's row coordinate so it reads one band repeatedly, show the current seed passes it and the new seed fails it. A tightened check with no demonstration that it catches the bug it was written for is a claim, not evidence.
- Keep exactness/tolerance headroom stated numerically, and note any residual degenerate sizes explicitly rather than implying there are none — gemm: make the reference B vary along K, so the exact check covers the K walk #55's doc is the model.
- Re-run
modal run modal_app.py::examplesand::bench(softmax appears in both).
Not in scope
The GEMM's axes — #55 handled those and documented its own residual (at K = 0 mod 21 the column period collapses 21 to 7; no K this project runs is a multiple of 21).
Activity
Audit the library whole: three doc claims were wrong, and the surface…