Repository navigation
The depot was the tile behind a rolled walk, and the mover walks now unroll (#166) - #180
Merged
Merged
Conversation
…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.
… 255 registers and 208 spills
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'srow 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 rolledreader is enough: in the staged x8x4 PTX the drain built all 64 values
scalar into
__local_depot22[256](fully unrolled, indices folded throughplace_block) and the rolledstmatrixpack loop read pairs back — insidethe per-tile epilogue, which #144 had already named as the gap.
tile_x8_batched's hand-unrolledif ISSUES > 0ladder 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 theMIR importer reads, and library code can emit the call directly — but the
backend's trip-count analysis sees
M / 16as a runtime division, warns, andleaves the loop rolled. The pair that works is the marker plus an
inline-
constbound:while row_block < const { M / 16 }. Every moverwalk in
ldst,tmemandglobalnow carries both.Measured
regcount, sm_100a): the staged x8x4 family, everygemm_solrung,
gemm_cg2and 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).gemm_sol_m25696 → 89–91 clean;gemm_cg2168 → 155 with the528 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.localfewer than the frame it replaces.bench --case gemm(B200, in-container cuBLASLt control, both checkedbefore 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 wasabout 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.regcountend to end: occupancy gate, timed twins, determinism-adjacentchecks all green.
What is deliberately not done
The
reg.rsmap/reduce walks stay rolled, and the census stays a reportrather than arming. The blanket sweep was built and measured first:
flash_forwardwent 168 → 255 registers with 208/208 ptxas spill st/ldagainst 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 aper-kernel answer for them — partial
#[unroll(N)], or the 16-columnchunking oxide-train#74 shipped — rather than on attribution.
Gates
scripts/fmt --check,clippy --all-targets -- -D warnings,cargo test,RUSTDOCFLAGS=-D warnings cargo docclean. Tier 2/3 runs above were fromthis branch via
scripts/modal-run.docs/kernels/gemm.md's drain sectionnow carries the depot chapter, and the census section comment in
modal_app.pyrecords the attribution and the map-walk measurement so thenext reader does not re-derive either.