Repository navigation
Description
Found by the 2026-07-29 library audit (GAPS.md §2.1a). A narrow, measurable
follow-up to two changes that already paid.
src/ldst.rs moves fragments between shared memory and registers in both
directions. The store side has a .x4 form (store_fragment_x4,
store_tile_x4, #116) — one stmatrix.m8n8.x4 per [16, 16] block instead of
two .x2s a slot apart — and it is what gemm's shipped epilogue uses
(SHIPPED_EPILOGUE is StagedWideX4). The load side is still .x2 only:
load_fragment loops Fragment::SLOTS times over ldmatrix_x2
(src/ldst.rs:207-229).
cuda_device::wmma ships ldmatrix_x1, ldmatrix_x2 and ldmatrix_x4, plain
and trans, at the pinned revision b099f64c1a32869b74be99f4f88242fb68655b51
— checked against a checkout whose HEAD I confirmed equals the pin
(crates/cuda-device/src/wmma.rs). So this is a transcription, not an upstream
ask.
Why it is worth measuring rather than assuming
The addressing needs no new derivation. stmatrix_x4_addresses_are_the_x2_addresses_restacked
in src/ldst.rs's tests is the identity the store side used: .x4 takes 32
addresses from all lanes where .x2 takes 16 from the first half, so lane l
supplies what lane l % 16 supplied for slot l / 16. ldmatrix.x4 has the
same lane→address relation, so the same test extends.
What is not free is liveness, and that is the reason to measure rather than
switch: TmemTile::fragments_x8 (#117) bought +23.6/+8.6/+3.6% by removing
waits, and its own doc says the cost is that four blocks are live at once
where the .x1 path lets the compiler fuse one fragment through to its
consumer. ldmatrix has no wait to remove — it is a plain shared read — so the
gain here is issue slots only and the liveness cost is the same shape. It may
well be a wash. That is worth knowing rather than guessing, because right now
the crate has an asymmetry nobody chose.
Scope
ldst::load_fragment_x4andload_tile_x4, against the existing address
derivation.- A
device-testscase in the shape ofldtm x8 map: load the same block both
ways and require equality, so a wrong register order fails there rather than
in a kernel's tolerance. - One timed comparison on a kernel that loads (
softmax's three passes are the
obvious instrument — every one of them is aload_tile). Register count alone
does not settle it; softmax is latency-bound, not bandwidth-bound: 362 GB/s ceiling and a flat 51us floor #47, Is a streamed local-memory band actually slower? ptxas cannot say, and the ladder now makes the question concrete #63, layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67, softmax is now the slow kernel by 5.8x, and its CHUNK rung is only a quarter of it #76 and reg.rs says the measurement does not favour the SFU exp2, on a register count; timed, it is 2.7x #81 are five occasions where it
ordered time backwards.
Estimate
~60 lines in src/ldst.rs, ~40 for the device case. The measurement is the
work, not the code.
Related: #116 (the store side's .x4), #117 (the TMEM drain's .x8, and the
liveness argument), #81 (why a register count is not the answer).
Activity
The load side has an `ldmatrix.x4` too, and measured it is a wash whe…
The `.x4` load side inherits the barrier obligation, and its contract…
An `ldmatrix` reads what `stmatrix` wrote under a barrier, measured: …