Repository navigation
A per-column operand in global memory reaches registers without a tile's worth of them (#172) - #173
Merged
Merged
Conversation
…e's worth of them (#172) `ldst::load_vec` reads a `ColVec` out of a `SharedVec` and `global::load_rows` reads a `RegTile` out of global memory; there was no third call, so a parameter vector whose length is a runtime number — oxide-train's RMSNorm weight, which cannot be a `SharedVec<E, N>` for that reason — could only reach the registers that multiply by it through a stride-zero cursor feeding `load_rows`. That spells `L::VALUES` distinct numbers as `L::SLOTS * L::VALUES` registers, and on a B200 it is a cliff rather than a rounding error: the RMSNorm port measures 0.83x of the shipped kernel at a 32-column chunk and 0.15x at 64, where the chunk width is the only knob that buys memory-level parallelism. `load_cols` is that third call — the same addresses `load_rows` walks, on one row, into a `ColVec`. The pairing decision is shared rather than restated, which is why `pairs_are_one_access` loses its `M` and its `FragmentLayout` bound: the claim it tests is about columns alone, and the vector mover spends it too. No `store_cols`. A kernel that produces a per-column result produces it from `col_reduce` across a grid and wants an atomic, not a plain store. GAPS 2.2 gains the entry, 1.4 and 3.1 lose the half of their hole this closes, `tests/gaps.rs` names it beside the tile movers, and `global column map` is its device case — a separate one from `global rows map` because a mover that silently read the tile's rows would pass there and cannot pass here.
This was referenced Aug 3, 2026
feitreim
added a commit
that referenced
this pull request
Aug 3, 2026
…ts per-column statistic (#179) An attention backward pass is the first kernel to score `K·Qᵀ` rather than `Q·Kᵀ`, and both halves of what a band needs turned out to exist on one diagonal only. `RegTile::make_causal_t_at` is `make_causal_at`'s twin: the block-origin form of the transposed causal mask, row origin first as in the other. The argument for the `_at` spelling is stronger here than where it already existed — a CTA owning a block of keys streams the queries at and after them, so `key_base - query_base` is negative on every visit but the first, and the `u32` subtraction a call site would otherwise write wraps to a huge positive number and masks nothing. `global::load_col_vec` is `load_row_vec`'s: the same addresses — one element per band position, down a single global column — delivered as the `ColVec` a `sub_col_assign` takes instead of the `RegVec` a `sub_row_assign` does. Which axis a saved statistic broadcasts along is a property of the band, not of the statistic: the query-parallel backward reads the log-sum-exp per row, and the key-parallel one needs the same numbers per column. It is deliberately not `load_cols` (#173), which reads a run *along* one row and pairs consecutive values into one access. Two movers returning `ColVec` off the same argument list is a hazard, so the device case is a separate one: `global column statistic` beside `global column map`, over the same matrix and origin, where a mover that took the other walk delivers an element that names itself and the failure prints which walk actually ran. Gates: `scripts/fmt --check`, `clippy --all-targets -D warnings`, `cargo test` (110 unit + 80 doctests, including two new host tests — the transposed mask against the band's global origin, and `load_col_vec` against `load_row_vec`'s own addresses), `RUSTDOCFLAGS=-D warnings cargo doc`. GAPS.md 2.2 and 3.4 gain the entries; `tests/gaps.rs` names both.
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 #172.
ldst::load_vecreads aColVecout of aSharedVec;global::load_rowsreads aRegTileout of global memory. There was no third call, so a per-column operand that lives in global memory — a norm's weight, a bias — had no way into the registers that multiply by it.The consumer is the RMSNorm port in feitreim/oxide-train#70. Its weight is
[dim]fp32 withdima runtime number, so it cannot be aSharedVec<E, N>forload_vecto read, and staging a chunk of it per iteration would cost two barriers per chunk in a kernel that otherwise has none. The only spelling available was a stride-zero cursor feedingload_rows, which broadcasts the vector into a fullRegTileand holds every value once per row the thread owns —L::SLOTS * L::VALUESregisters forL::VALUESdistinct numbers.What changed
global::load_cols, the same walkload_rowsdoes over one row:pairs_are_one_accessloses itsMand itsFragmentLayoutbound in the process: the claim it tests is about columns alone, and sharing it is what keeps the vector mover from restating the pairing decision (CONTIGUOUS_VALUES+runs_aligned) a second time and drifting from it.No
store_cols. A kernel that produces a per-column result produces it fromcol_reduceacross a grid and wants an atomic, not a plain store — so it has no consumer, and the rule is to ship what a kernel needs.Measured
RMSNorm forward and backward, 24576 x 3072 fp32 on a B200, tile port against the shipped block-per-row kernel, sweeping the chunk width (
modal run modal_app.py::main --kernel ops --sweep ...in oxide-train):load_rowsat stride 0)load_cols)Two things worth saying plainly, since both are the sort of claim this file exists to keep honest.
Its motivating consumer did not ship, and that is yours to weigh. The RMSNorm port stayed flat — see the numbers below — so
load_colslands with a device case and no kernel in any repo calling it. I am not going to dress that up: what justifies it is that #172's gap was filed off a real kernel's real need,GAPS.md§1.4 and §3.1 named the hole before this PR existed, and the API is the missing third call in a set of three rather than a new idea. If you would rather it wait for a consumer, close it and #172 stays filed with the measurements attached.It does not rescue the port. The RMSNorm family stays flat in oxide-train — the shipped kernel is at 4.17 TB/s forward and 5.64 TB/s backward and the best tile shape reaches 0.83x/0.91x of it, for a reason
load_colscannot touch: a warp-per-band kernel has 24576 threads where the block-per-row one has 6.3M, and it cannot hold enough loads in flight. The numbers, and the four other families #70 covers, are on oxide-train#70; the one that did win — SwiGLU, from the measure-first tier — is oxide-train#73 and uses none of this.The cliff past 32 columns is not the parameter tile. Removing it moved chunk 64 from 0.151x to 0.165x and no further, so what collapses there is something else — a
.localdepot in the register-file arithmetic, which is exactly whatregcount's census (#167) was built to see. That is not this PR's, and it is worth its own issue; what this PR claims is the register count, not the cliff.What
load_colsdoes buy is the spelling: the kernel now saysmul_col(load_cols(...))where it saidmul(load_rows(stride_0, ...)), and the operand isVALUESregisters instead ofSLOTS * VALUES.Gates
scripts/fmt --check,clippy --all-targets -- -D warnings,cargo test(75 doctests),RUSTDOCFLAGS=-D warnings cargo doc --no-deps— all clean.scripts/modal-run device_testson a B200, 43 of 43 cases passed, including the new one:global column mapis a separate case fromglobal rows maprather than a line added to it: a mover that silently read the tile's rows would pass there and cannot pass here. Its column origin (40) is neither a 16-column block boundary nor the row's start, and both it and the pitch are even, so it takes the pairedld.global.v2arm — the scalar arm isload_rows' own and covered by the case beside it.GAPS.md2.2 gains the entry; 1.4 and 3.1 lose the half of their hole this closes and keep theRegVechalf, which is still #130's.tests/gaps.rsnames it inglobal_movers_carry_an_element, beside the tile movers it shares a cursor and a pairing test with.