Skip to content

The depot was the tile behind a rolled walk, and the mover walks now unroll (#166) - #180

Merged
feitreim merged 3 commits into
mainfrom
probe/local-depot-attribution
Aug 3, 2026
Merged

feitreim merged 3 commits into
mainfrom
probe/local-depot-attribution

Conversation

@feitreim

@feitreim feitreim commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Progresses #166 — attribution, the mover fix, the measured reason the map
walks are left alone, and the census comment updated to carry all three.

Attribution

The frames are the register tiles themselves. A storage walk —
store_tile_x4's block loop, tmem::tile's compose loop, global's
row walks — stops unrolling past LLVM's budget near 32 fp32 columns, its
counter stays a runtime value, the tile access stays a dynamic GEP, and SROA
cannot split the aggregate. The whole tile is homed to .local. One rolled
reader is enough: in the staged x8x4 PTX the drain built all 64 values
scalar into __local_depot22[256] (fully unrolled, indices folded through
place_block) and the rolled stmatrix pack loop read pairs back — inside
the per-tile epilogue, which #144 had already named as the gap.
tile_x8_batched's hand-unrolled if ISSUES > 0 ladder is this fight,
fought before the mechanism had a name.

The fix, and the two halves it needs

cuda-oxide's #[unroll] lowers to a __unroll_config::<0>() marker call the
MIR importer reads, and library code can emit the call directly — but the
backend's trip-count analysis sees M / 16 as a runtime division, warns, and
leaves the loop rolled. The pair that works is the marker plus an
inline-const bound
: while row_block < const { M / 16 }. Every mover
walk in ldst, tmem and global now carries both.

Measured

  • Census (regcount, sm_100a): the staged x8x4 family, every gemm_sol
    rung, gemm_cg2 and its whole experiment family read zero .local.
    Shipped kernels carrying a frame: was all 12, now 3 (flash_forward,
    groupnorm_tile ×2 — the map-walk remainder).
  • Registers: gemm_sol_m256 96 → 89–91 clean; gemm_cg2 168 → 155 with the
    528 B frame gone; staged x8x4 stays 80 with 12/16 ptxas spill st/ld and
    8 B stack — the residue of the round-trip at the launch's register budget,
    64 scalar st.local fewer than the frame it replaces.
  • bench --case gemm (B200, in-container cuBLASLt control, both checked
    before timing): 0.978 of cuBLASLt at 8192³ (1772.9 TFLOP/s) against
    the recorded 0.939 (1645.0) in docs/kernels/gemm.md — the depot was
    about a third of The epilogue is the gap, and at 4K it is only a fifth of it (#138) #144's epilogue gap at that shape. 16384³ holds at 0.958
    median; 2048³ crosses 1.0.
  • device_tests: 46 of 46 on a B200 with the unrolled walks.
  • regcount end to end: occupancy gate, timed twins, determinism-adjacent
    checks all green.

What is deliberately not done

The reg.rs map/reduce walks stay rolled, and the census stays a report
rather than arming. The blanket sweep was built and measured first:
flash_forward went 168 → 255 registers with 208/208 ptxas spill st/ld
against the 1058-store depot it replaced — #94's lesson (a kernel can pay a
frame and win) as a number. One rung of the ladder also lost its timed twin
(48x64 open_coded, 48 vs 40 regs) under the sweep, and both effects vanished
on revert. The remainder on #166 is exactly the map walks of
flash_forward/groupnorm_tile, and the arming condition now waits on a
per-kernel answer for them — partial #[unroll(N)], or the 16-column
chunking oxide-train#74 shipped — rather than on attribution.

Gates

scripts/fmt --check, clippy --all-targets -- -D warnings, cargo test,
RUSTDOCFLAGS=-D warnings cargo doc clean. Tier 2/3 runs above were from
this branch via scripts/modal-run. docs/kernels/gemm.md's drain section
now carries the depot chapter, and the census section comment in
modal_app.py records the attribution and the map-walk measurement so the
next reader does not re-derive either.

…it (#166)

Every loop that indexes RegTile/RegVec/ColVec storage with its counter gets
cuda-oxide's __unroll_config::<0>() marker and an inline-const bound: the
backend's trip-count analysis sees 'M / 16' as a runtime division, so the
const block is what makes the bound a literal and the marker take.

A rolled walk leaves dynamic GEPs into the aggregate, SROA cannot split it,
and the whole tile is homed to a .local depot — the staged family's 256 B
frame, 64 scalar st.local per drained tile re-read by the stmatrix pack loop
inside the per-tile epilogue. With the movers and the reg/global walks
marked, the staged-x8x4 family and every gemm_sol rung read zero in the
census; flash_forward and groupnorm_tile drop by ~25% from the movers alone.
@feitreim feitreim added the gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes) label Aug 3, 2026
@feitreim
feitreim merged commit ec36480 into main Aug 3, 2026
4 checks passed
feitreim added a commit that referenced this pull request Aug 6, 2026
…, and both 256-wide entries take it now (#197)

* The warpgroup split lost to a `.local` depot rather than to the lanes, and both 256-wide entries take it now

`bench sol-ablate`'s table 6 recorded the epilogue's column split losing 1.4 to
1.8% at 4096³ and winning 0.3 to 0.4% at 8192³, and the reading offered was
hardware: warps 0 and 4 own the same 32 tensor-memory lanes, so splitting an
accumulator's columns puts two requesters on each of four sub-partitions rather
than spreading over eight.

That argument is still true and it was not what the table measured. Every row
of it was taken through a `.local` depot the library no longer emits —
`store_tile_x4` homed each drained band to local memory until the rolled walks
were marked (#166, landed in #180/#181/#184), and a band *is* the frame, a
`RegTile<32, 64>` being 64 f32 being 256 B. The split pays that frame twice per
accumulator where one warpgroup pays it once, so the arm doing more of the
broken thing read as the arm that was worse.

Re-run at f64a27b, same table, same two round-robin passes, `regcount` reading
zero stack and zero spill on every `gemm_sol` rung:

  4096³ [256, 256]   launch +0.8%, +0.9%   drain 3.35 -> 3.10, 3.28 -> 3.17 us
  8192³ [512, 256]   launch +2.1%, +2.1%   drain 4.72 -> 3.05, 4.70 -> 3.04 us

The sign reverses at both entries and both passes, and the term that was blamed
is the term that moves: the drain gets 35% cheaper at [512, 256] rather than
slower. The `no drain` control at its own 320 threads still matches the
192-thread one to a tenth of a percent, so the extra warps remain free when
they do nothing.

`SHIPPED_GROUPS` is `TWO_WARPGROUPS` for `gemm_sol_m256` and `gemm_sol_m512`.
The shared plan is byte-identical either way — eight warps stage half the
columns each — so no `dynamic_shared` moves; what moves is the block, to 320,
which is why `Variant::threads` now sits beside `Variant::shared_bytes` and the
launcher asks the variant instead of reading one `THREADS`.

`gemm_sol_m256_n128` keeps one warpgroup. The split is legal there and the
asserts cover it; table 6 simply has no `[256, 128]` arm, and shipping it would
be shipping a geometry nothing here has timed.

The ablation and watch probes are pinned to `ONE_WARPGROUP` explicitly rather
than following `SHIPPED_GROUPS`. They were reading the shipped constant to mean
"the geometry this ladder is held at", and those are two different facts: with
`SHIPPED_GROUPS` flipped, thirty-three probe kernels would have silently
reshaped and every historical arm would have stopped comparing to itself.

The three entries join `GATED_KERNELS`. Their residency is fixed by the shared
plan and no register count can raise it, but at 320 threads a thread may have
168 registers before an SM cannot place one CTA at all — a launch the driver
refuses rather than a slow one. They read 82 and 83 against that step.

* The PR number the three notes point at is 197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant