Repository navigation
Shared to register load: ldst::load_fragment - #33
Merged
Merged
Conversation
bf16 -> fp32 is a shift, not an instruction: cuda-device exposes cvt_* in the narrowing direction only, and there is nothing here for one to do. So unlike pack, unpack is ordinary bit math and holds on the host, which is what the test asserts.
Extracts store_fragment's chunk/row derivation into fragment_address, which both directions now call. ldmatrix and stmatrix share an address convention -- 16 addresses from lanes 0..15, data over all 32 -- so the two directions are one derivation with the data flowing opposite ways, and cannot drift. Being a free function it is also host-testable for the first time; four tests pin it against BaseLdtm's own map. cuda_device::wmma::ldmatrix_x2 lowers cleanly for sm_100a, so the load needs no ptx_asm! counterpart to stmatrix_m8n8_x2's. That it is filed under wmma is an accident of module layout.
TMA a [TILE, TILE] tile of position identities into shared, load every [16, 16] block of it through load_fragment, dump by thread coordinate, let the host apply Fragment::coordinate. The tile's contents are placed by the TMA engine -- checked independently by the swizzle round trip case -- and the values are identities the register path never computes, so this pins ldmatrix's ownership map to BaseLdtm against silicon rather than showing load and store are mutual inverses. It shares nothing with the stmatrix case but fragment_address.
…ks it softmax's invented load_tile becomes load_fragment in the block loop that #22 is filed to delete. It is still aspirational: chunk_writer const-asserts a one-subtile tile (#25), so a 128-wide tile has no register/shared path in either direction, and #5/#6/#9 are untouched. Halve COLUMNS and the rest of the kernel would run. README item 1, "there is no shared to register path at all", is closed and says what replaced it; items 2 and 3 pick up what is left, which is shape rather than direction. GAPS gains 2.1a, and its cuda-oxide support table stops calling ldmatrix Hopper-only.
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.
The
ldmatrixhalf ofldst.ldstwas store-only, so the only ways intoregisters were an MMA accumulator drain or arithmetic on registers already
held — any kernel whose input is not an MMA operand could not start.
What landed
ldst::fragment_address—store_fragment's chunk/row derivation, liftedout into a
const fnboth directions call.ldmatrixandstmatrixshare anaddress convention (16 addresses from lanes 0..15, data spread over all 32), so
the two directions are one derivation with the data flowing opposite ways and
cannot drift. Being a free function it is host-testable for the first time: four
tests pin it against
BaseLdtm's own map — that the 16 addressing lanes nameexactly the slot's 8 rows in each of the
.x2's two matrices, that an addresslane's row is the row its quad's data lanes own, that the second chunk holds
the columns
BaseLdtmgives values{2, 3}, and that no lane (including 16..31,whose addresses the instruction ignores but still forms) leaves the block.
ldst::load_fragment— mirrorsstore_fragment's signature and itsElement<Unpacked = [f32; 2]>bound, for the same reason:ldmatrix.m8n8.x2moves two b16 matrices, and a 4-per-word element should fail to typecheck rather
than read half the bytes it asked for.
[16, 16]only; composing larger shapesis #22.
Element::unpack— the inverse ofpack, implemented forBf16.Device case
ldmatrix map, and doc updates toexamples/andGAPS.md.Which
ldmatrixpath, and whycuda_device::wmma::ldmatrix_x2directly — noptx_asm!needed. It buildsfor
sm_100aunder a realcargo oxide build, and the kernel runs correctly ona B200. The plan flagged that it might hit the same wall
stmatrixdid (whichdrops to
ptx_asm!to dodge an unresolved LLVM declaration); it does not. Thatldmatrixis filed under awmmamodule is an accident of upstream modulelayout — it is a plain shared-memory read with nothing to do with the wmma MMA
path this crate does not use.
stmatrix_m8n8_x2's doc now records the asymmetryso nobody re-derives it.
What the device test proves, and does not
ldmatrix mapTMAs a[TILE, TILE]tile of position identities into shared,reads every
[16, 16]block of it throughload_fragment, and dumps by(block, lane, slot, value); the host appliesFragment::coordinate.It proves
ldmatrix's ownership map isBaseLdtmandload_fragment'saddressing is the one the hardware uses. The tile's contents are placed by the
TMA engine, which the existing
swizzle round tripcase checks independently,and the values are identities the register path never computes — so this is not
a round trip, and a load and a store agreeing on the same wrong map would not
pass it. It shares nothing with
stmatrix round tripexcept thefragment_addressderivation, so the two directions are pinned to siliconseparately.
It does not cover the
.transform, elements other than bf16, tiles widerthan one swizzle subtile, or composition above
[16, 16].Softmax: not promoted, and why
softmaxstays aspirational, but itsGAPfence for the missing load isgone — it calls
load_fragmentfor real now, in the block-composition loop #22is filed to delete. What still blocks it:
SharedTile::chunk_writerconst-asserts a one-subtile tile, so a[128, 128]bf16 tile has no register↔shared path in either direction. Thisis the hard blocker: halve
COLUMNSand the rest of the kernel would run.[16, 16]-block, and there is nostore_tilemirror at all.
examples/README.md's "Not covered by any open issue" item 1 is struck throughand says what replaced it; items 2 and 3 pick up what is left, which is shape
rather than direction. The status table and
layernorm's header (which claimedload_tile/store_tilehad no issue behind them) are updated to #22/#25.GAPS.mdgains §2.1a and its cuda-oxide support table stops callingldmatrixHopper-only.
Different from the plan
Bf16::unpackis host-testable. The plan expected it to mirrorpack'sunreachable!()host body. It does not:cuda-deviceexposescvt_*in thenarrowing direction only, because widening bf16→fp32 is a shift and needs no
instruction. So
unpackis ordinary bit math and has a real host test.modal_app.pyhas noregcountfunction onmain, so that check couldnot be run.
store_fragment's emitted code is unchanged by construction — theextracted helper is a
const fnreturning the same two values the inlineexpressions did.
Verified
modal run modal_app.py::build— clippy (lib + harness), host tests (26, allpass), real
cargo oxide build --arch sm_100afordevice-testsand theexamples crate. Clean.
modal run modal_app.pyon a B200, once: 8 of 8 cases pass, including thenew
ldmatrix map("4096 elements, all at BaseLdtm's coordinates").cargo clippy --all-targetsandcargo fmt --checkclean.Closes #21