Repository navigation
Neither half of the drain has two widths, so neither is a bool - #217
Merged
Merged
Conversation
`Drain<const LDTM_X8: bool, const STMATRIX_X4: bool>` shipped with #126 and the shape is wrong twice over. The TMEM axis has three instructions a drain can issue and not two — `.x1`, `.x8`, and `.x8` with the band's issues batched behind one `tcgen05.wait::ld` — and the third carries an `ISSUES` count no `bool` can hold. And a `bool` puts the rung in the *walk*: each arm is an `if` inside the loop and a position in every dial that reaches it, so a fourth rung edits the epilogue and five launch sites rather than adding an impl. So the axes are traits, in `Swizzle`'s and `Scope`'s idiom: `TmemRead` with `X1`, `X8` and `X8Batched<ISSUES>`, `FragmentStore` with `X2` and `X4`, one unit struct per rung with the instruction on the impl. `Drain::<X8, X4>` is the pair that ships and it says which pair at the launch site where `Drain::<true, true>` said only where in a table it sat — which is the complaint `gemm_ws`' own doc makes about `Ws::<STAGES, true, false, false, true>`, answered on this axis. `experiments`' `Staged` job takes the two rungs the same way, so its five entry points read `Staged::<true, X8, X2>` instead of `Staged::<true, true, false>`. An `adt_const_params` enum would express the same set; it is unstable and this crate takes no incomplete features. The traits need none. Two things are deliberately not rungs, and the docs say why for both. `stmatrix.m8n8.x1` is in the ISA and not in the library: four instructions per block where `.x2` is two and `.x4` is one, at identical addresses, in the direction #117 measured as losing — it is an `ldst` entry point plus an impl whenever someone wants it priced. `TmemTile::fragments_pack16_x8` returns packed b16 words rather than an fp32 `RegTile`, so it is not a width of the read axis but a different route: the only thing that can store its product is `store_packed_x4`, which by its own doc computes a wrong `C`. Admitting it would make the read's product an associated type and bind the write axis to it — the two axes would stop being independent, for an ablation that never ships. `X8Batched` is the rung `gemm_sol`'s drain reads with, and a doctest compiles `Drain::<X8Batched<2>, X4>::staged` so that is checked rather than claimed. It is not enough to migrate that kernel and the axes are no longer what separates them — the walk is. It fills a 128-wide staging tile out of two 64-wide bands on purpose, because four `.x8` issues behind one wait is 176 registers against 96; it drains a column *span* of a wider accumulator because two warpgroups split the tile (#197); and it converges twice a pass. Those are three parameters on the walk, and `gemm_sol` is the tightest register count in the repo, so the migration is a measurement and not a refactor. No instruction moves: this is a pure API change and `regcount`'s opcode census, registers, spills and frames are identical on every kernel.
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.
Drain<const LDTM_X8: bool, const STMATRIX_X4: bool>shipped with #210 and theshape is wrong twice over.
Neither axis has two rungs. The TMEM half has three instructions a drain can
issue —
.x1(tile),.x8(tile_x8), and.x8with the band's issuesbatched behind one
tcgen05.wait::ld(tile_x8_batched) — and the thirdcarries an
ISSUEScount noboolcan hold. It is also the onegemm_soldrains with, so the type could not express the drain of the kernel the repo
tunes hardest.
And a
boolputs the rung in the walk. Each arm is anifinside the loopand a position in every dial that reaches it, so a fourth rung edits the
epilogue, the job struct and five launch sites. That is the thing this change is
actually about: after it, a rung is an impl.
The shape
Two traits in
Swizzle's andScope's idiom — one unit struct per rung, theinstruction on the impl, and
Drain::staged's walk knowing none of them:TmemReadX1,X8,X8Batched<ISSUES>stmatrixwriteFragmentStoreX2,X4Drain::<X8, X4>is the pair that ships. Anadt_const_paramsenum wouldexpress the same set and is unstable; this crate takes no incomplete features,
and the traits need none.
The call sites read as what they are now.
experiments'Stagedjob takes thetwo rungs the same way, so its five launch sites say
Staged::<true, X8, X2>where they said
Staged::<true, true, false>— which is the complaintgemm_ws' own doc already makes aboutWs::<STAGES, true, false, false, true>("says nothing about which rung it is"), answered on this axis.
gemm_ws' fourdrain::*codes map to the four pairs directly.What is deliberately not a rung, and why
stmatrix.m8n8.x1is in the ISA and not in this library: four instructionsper
[16, 16]block where.x2is two and.x4is one, at identicaladdresses, in the direction #117 measured as losing. Adding it is an
ldstentry point plus an impl — the impl is the cheap half, which is the point of
the trait. Stated on
FragmentStore.TmemTile::fragments_pack16_x8— the judgement call you flagged. It returnspacked b16 words rather than an fp32
RegTile, so it is not a width of the readaxis but a different route: the only thing that can store its product is
ldst::store_packed_x4, which by its own doc computes a wrongC— itexists so
experiments'pack16rung can hold every other instruction fixedand take the
cvtcolumn to zero. Admitting it would makeTmemRead's productan associated type and bind
FragmentStoreto it, so the two axes would stopbeing independent, for one ablation that never ships. A packed drain is its own
entry point when something needs one. Stated on
TmemRead.ldst::scatter_tileneeds no judgement: it is the store direction for theelements
stmatrixcannot move, andDrain::staged'sElement<Unpacked = [f32; 2]>bound already excludes them.gemm_sol: the axes are no longer what separates it — the walk isNot migrated, per your instruction and my original reasoning. But the question
is now answerable rather than open, and a doctest on
X8BatchedcompilesDrain::<X8Batched<2>, X4>::staged, so "expressible" is checked and notclaimed. What is left is three things about the walk, none of them a rung:
of the three shipped entries (
gemm_sol_m256,gemm_sol_m256_n128) fill a128-wide staging tile out of two 64-wide bands, because a
[32, 128]bandis four
.x8issues andtmem's own ladder puts four at 176 registersagainst 96 — the batching wins at two and loses at four.
Drain::stagedtiesthe band to
COLS.split the tile (The warpgroup split lost to a
.localdepot rather than to the lanes, and both 256-wide entries take it now #197). The walk covers allNof theTmemTileit is handedand there is no
[M, SPAN]view to hand it:columns_rightshifts the baseand keeps the width.
stmatrix.sync.alignedfor the other edge.The third entry (
gemm_sol_m512, at a 64-wide staging tile where band == tile)needs only the second of those. So the follow-up is a measurement — of a band
width parameter, of a span, and of the second convergence — rather than a
design task, which is what you asked me to establish. It is still not a
refactor:
gemm_solis the tightest register count in the repo.Gates
Hand-run; Actions is still out. Branch is rebased onto
141db57(the fourcommits since
ac79127are README/image only, so the code tree the gates ran onis this one).
scripts/fmt --checkcargo testX8Batcheddoctest)cargo clippy --all-targets -- -D warnings(lib)cargo doc --features host,RUSTDOCFLAGS=-D warningscargo check --all-targetson all three kernel cratesscripts/modal-run buildscripts/modal-run regcountmain, baseline)scripts/modal-run examplesscripts/modal-run device_testsThe codegen claim, measured against
mainrather than assertedregcountrun onac79127and on this branch, and diffed row for row:mma,ldtm,ldtm.wait,tma,stmatrix,ld.sh.v4,st.g.v4,st.g.b32,cvt.bf16x2,bar.sync,bar.warp,mbar.arrive,selp).localdepot censusEvery kernel in all three crates, identical. That is the whole of what a pure
API change should read as, and it is what makes
Drain::<true, true>→Drain::<X8, X4>a rename of the same instructions.Closes nothing on its own; it is the follow-up to #126 / #210.