Skip to content

The occupancy pole of the walk idiom, measured: the high-occupancy form is expressible, and it loses (#222) - #224

Merged
feitreim merged 3 commits into
mainfrom
issue-222-walk-occupancy
Aug 7, 2026
Merged

feitreim merged 3 commits into
mainfrom
issue-222-walk-occupancy

Conversation

@feitreim

@feitreim feitreim commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Closes #222 — both dispositions, and the API half is answered by measurement rather than by API: the narrow-per-lane, high-occupancy walk needs no new surface, was built, and is the worst arm of five.

The verdict

experiments/src/norm_occupancy.rs, bench --case norm-occupancy. Five arms computing y = x · rsqrt(mean(x²) + ε) per row, every one reading the row twice and writing it once, so all five issue identical bytes. The reference is a block-per-row kernel with no register tile in it; the other four are the walk over global::load_rows at a [16, CHUNK] band a warp, differing only in CHUNK (fp32 live in a lane) and warps a CTA (threads a block). Separating those two levers is the point — #222's hypothesis is about their product.

B200, 148 SMs, 24576 × 3072 (oxide-train's own shape), median of 3 whole measurements an arm taken round-robin, each the min of 30 timed launches after 5 warm-up, every arm checked against an f64 reference over every element first:

arm threads live f32 blocks waves regs blocks/SM threads/SM min ms GB/s vs row
block-per-row 256 2 24576 166.05 23 8 2048 0.0716 6325.2 1.000
walk c64 w4 (the reverted shape) 128 32 384 2.59 48 10 1280 0.1495 3030.6 2.087
walk c64 w8 256 32 192 1.30 48 5 1280 0.1809 2504.1 2.526
walk c16 w4 128 8 384 2.59 32 16 2048 0.1947 2326.3 2.719
walk c16 w8 (the form #222 asks for) 256 8 192 1.30 32 8 2048 0.2237 2025.1 3.123

The occupancy lever was pulled and it made things worse. The narrow-chunk arms reach 2048 threads an SM — the reference's own number, driver-queried at each arm's own launch envelope — and are the slowest two rows. The other two shapes order the four walk arms identically (c64 w4 < c64 w8 < c16 w4 < c16 w8):

arm 24576 × 1024 GB/s / vs row 6144 × 8192 GB/s / vs row
block-per-row 4110.3 / 1.000 6411.1 / 1.000
walk c64 w4 3332.3 / 1.233 1217.9 / 5.264
walk c64 w8 2614.2 / 1.572 1124.9 / 5.699
walk c16 w4 2538.2 / 1.619 625.0 / 10.257
walk c16 w8 2171.5 / 1.893 582.2 / 11.012

So chunk width orders this table and occupancy orders it backwards. The mechanism is the fragment map, not residency: under BaseLdtm a warp's paired access names 8 rows × 16 bytes — eight half-used 32-byte sectors — where the reference's 32 lanes name one contiguous 128-byte line. Identical bytes; not identical transactions. docs/library/global.md has said since #11 that a fragment layout is a bad shape to store from — this is the load side of that claim with a clock on it, and it is why a wider CHUNK wins (at 64 columns a chunk's row is a whole 128-byte line).

The 16-row floor costs a second thing, on the launch: a CTA owns 16 · WARPS rows however few rows the problem has, so 6144 rows is 48 CTAs on a 148-SM device. The waves column says so, and it is why the third table is steeper.

What this is not. The magnitudes are not oxide-train's — its two arms were both at 1.8 TB/s where the reference here is near bandwidth, and its second read of a row was L1-resident as this one's is. What reproduces is the sign and the ordering of the two levers, which is the internally controlled part: the four walk arms differ from each other in nothing but two const parameters.

Registers

ptxas, from scripts/modal-run regcount. No spills and no .local depot in any of the five (the shipped-set census is unmoved at 1 of 15):

kernel regs spill stack
rms_norm_per_row 23 0 0
rms_norm_walk_c16_w4 32 0 0
rms_norm_walk_c16_w8 32 0 0
rms_norm_walk_c64_w4 48 0 0
rms_norm_walk_c64_w8 48 0 0

Docs — the boundary, where the idiom is taught

  • docs/library/global.md gets the section this issue asked for: both poles, the five-arm table, and a three-step decision rule (achieved GB/s first; then count what a warp's fragment map names per access against what the kernel it replaces names; occupancy is not the answer to that, and it is two const parameters away, so it is a measurement rather than a wish). It attaches to the section that already argued a fragment layout is a bad shape to store from.
  • docs/library/ldst.md and src/ldst.rs draw the line the two verdicts actually straddle: the walk over a TMA-staged shared tile is the one that went 594 → 5996 GB/s; the walk over global is the one that loses. Quoting either number about "the tile walk" without saying which path it was measured on is how one gets applied to the other.
  • docs/kernels/layernorm.md gets the other pole beside its own 594 → 5996 table: the two poles are not "walk versus no walk" but "a band that does not fit in registers wants streaming, and a row already coalesced in global memory does not want a fragment map".
  • src/global.rs's module header carries the short form, since that is where a kernel author writing load_rows lands.
  • GAPS.md records the two structural couplings, in the entries a future attempt would read: §1.3 gets BaseLdtm's 16-row floor with the numbers it costs, and §3.2 gets the one shape the walk genuinely cannot express — a band split across warps by column, whose statistic is a RegVec<16> spanning warps, where sync::block_reduce folds one scalar a warp and has no vector form. Filed nowhere, and this measurement is the reason to price the transactions before building it.
  • experiments/README.md carries the full run record, all three shapes.

Gates

  • tier 1 locally: scripts/fmt --check, cargo test (87 doctests), cargo doc --no-deps, clippy --all-targets -D warnings clean on the library.
  • scripts/modal-run build — green (clippy across four crates, host tests, cargo doc --features host, sm_100a codegen of all three kernel crates).
  • scripts/modal-run regcount — green, table above.
  • scripts/modal-run examples — green, including the new row: pass norm_occupancy 512x1024 normalized by all 5 arms, worst relative error 2.88e-3. The five arms are on the correctness gate because an occupancy table whose arms computed different norms would be ordered by whichever dropped a pass.

A block-per-row rms norm against the tile walk at both of the walk's
levers -- CHUNK, which is fp32 a lane, and WARPS, which is threads a
block -- so the downstream revert's verdict can be reproduced here and
attributed to one of the two. Every arm reads the row twice and writes
it once, so the five issue identical bytes.

`bench --case norm-occupancy`, checked before timed, with the driver's
registers, frame and blocks/SM beside the clock.
The library docs said a fragment layout is a bad shape to store from; the
same claim on the load side now has a clock on it, and the boundary is
recorded where each half of the idiom is taught: global.md gets the
five-arm table and the rule, ldst.md gets the distinction between the
walk that wins and the walk that loses, layernorm.md gets the other pole
beside its own 594 -> 5996, and GAPS.md records the two couplings a
future attempt would have to move.
@feitreim
feitreim merged commit 41f9e57 into main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When a tile walk loses: the occupancy pole of the idiom, measured

1 participant