Repository navigation
The column map reads its operand once a column, and the shape it was filed on cannot tell (#196) - #199
Merged
Conversation
…filed on cannot tell (#196) `col_map` / `col_map_assign` were documented as the column mirror of the row maps and were not written as one: the `ColVec` read sat in the inner loop, so the operand was read `SLOTS × VALUES` times where `row_map_assign` reads its `RegVec` `SLOTS` times. Swapping the nesting is bit-identical — elementwise, independent ops, and `RegTile`'s storage is `[[f32; VALUES]; SLOTS]` either way — so only the order the storage is walked in changes. `axis_map_probe` is what prices it, and it prices both loop orders in one build: the pre-#196 walk is open-coded as a third arm beside the library's column maps and the row axis, over the register pass oxide-train's two flash backward kernels share. `regcount`, sm_100a, no ptxas spill anywhere: regs frame st.local ld.local 16 row 40 128 36 20 16 col 40 128 36 20 16 col_inner_read 40 128 36 20 128 row 168 2048 712 456 128 col 39 2304 840 519 128 col_inner_read 167 2304 876 600 At the `[32, 16]` chunk the issue was filed on the three forms agree on every column of both tables: sixteen operand reads against four in the source, and four slots by four values is small enough that nothing downstream can tell which loop is outer. The ~1000 ticks a visit #196 measured in the transposed backward pass are therefore not this, and that kernel's arithmetic column is still unattributed. At 128 columns the hoist is worth 128 registers a thread and 81 static `ld.local` on an identical 2304-byte frame — the operand is 32 `f32` there and the local-load column is exactly what reading it four times over costs. The register column alone would not settle it (#63: fewer registers on the same frame can be a streamed band), but the traffic falls with it. `groupnorm_tile` is the one shipped kernel that goes through `col_map`, and it is unmoved: 48 registers, no frame, no spill, as `docs/kernels/layernorm.md` records it.
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.
Closes #196.
The change
col_map/col_map_assignare documented as the column mirror of the row maps and were not written as one — theColVecread sat in the inner loop, so the operand was readSLOTS × VALUEStimes whererow_map_assignreads itsRegVecSLOTStimes. The issue's own fix: swap the nesting so the column walk is outer and hoistcols.get(value). Elementwise, independent ops over[[f32; VALUES]; SLOTS]either way, so the result is bit-identical and only the storage walk order changes. The two doc comments now say the thing the code does, and carry what the hoist measured.reg.rs's host tests pass unchanged (112 + 1 unit/integration, 82 doctests) — as they must, since no host-visible property of these ops moved.What it measured
The instrument is the one the issue asked for:
device-tests' newaxis_map_probe, a codegen probe that prices both loop orders in one build rather than two builds a week apart. The pre-#196 walk is open-coded as a third arm (col_map_inner_read) beside the library's column maps and the row axis, over the register pass oxide-train'sflash_backward_kvandflash_backward_qshare — subtract a saved statistic,exp2, subtract a second, multiply — at both the[32, 16]chunk the issue names and a 128-column band. Both statistics are read out of memory rather than reduced out of the tile, so norow_reduce/col_reduceasymmetry sits between the arms.scripts/modal-run regcount, sm_100a, no ptxas spill anywhere; the last two columns are the depot census's static instruction counts:What contradicts the issue
At
[32, 16]— the shape #196 was filed on — the loop order is free. Sixteen operand reads against four in the source, and the three forms agree on every column of both tables: registers, frame,st.local,ld.local. Four slots by four values is small enough that nothing downstream can tell which loop is outer. So the ~1 000 extra ticks a visit in kernel B's ARITH column are not this, and that kernel's arithmetic is still unattributed — worth re-opening on the oxide-train side against the secondstore_tile, the transposed band's own addressing, or thecol_reduceshuffles the pass needs and the row form does not.At 128 columns the hoist is real: 167 → 39 registers a thread and 600 → 519 static
ld.local, on an identical 2304-byte frame. The operand is 32f32there, and reading itSLOTS × VALUEStimes is exactly what the local-load column counts; the frame not moving is what says the band was homed either way and the difference is the reads. The register column alone would not settle it — #63's lesson is that fewer registers on the same frame can be a band being streamed rather than a band that got cheaper — but the local traffic falls with it, which is not what a streamed band looks like.No clock. The
[32, 128]pair is the one worth timing andladder_benchis the harness shaped for it; the row arm is not the pair to time against at that width, since its operand is an eighth the size.Blast radius
groupnorm_tile(examples/layernorm.rs,mul_col/add_col) is the only shipped kernel that goes throughcol_map, and it is unmoved: 48 registers, no frame, no spill, exactly asdocs/kernels/layernorm.mdrecords it. Every other row ofregcountmatches its recorded baseline —flash_forwardat 168/1568,mask_probe_128_causalat 664st.local. The occupancy-step gate passed and the depot census still reads 1 of 12 shipped kernels.Unrelated, noticed in passing
device-tests/src/main.rscarries a stray#[inline(always)]in the middle ofdrain_identities' doc block (line 1240 onmain), which recent rustc warns on asunused_attributes. Left alone here.