Repository navigation
Where a warp's TMEM lanes are, measured: a second warpgroup shares them - #193
Merged
Merged
Conversation
`TmemTile`'s drains and stores were documented as the *owning* warp's without
saying which lanes a warp owns, and with one warpgroup per launch "the owning
warp" and `32 * warp_id()` are the same number. oxide-train#94's pass split
needs them told apart.
Measured on a B200 (driver 580.95.05) by `device-tests`' `tmem across
warpgroups`, fourteen launches over one accumulator at 256 threads: a warp
addresses the 32 lanes at `warp_id() % 4` and no others, whichever warpgroup it
is in. Correct alone, correct with both warpgroups reading the same lanes at
once, at the `[32, 16]` chunk, the `[32, 128]` drain and the `[32, 64]` half
oxide's kernels use, over an MMA-written accumulator as well as a stored one,
and in the store direction too. No `tcgen05.fence::before/after_thread_sync` is
required around the hand-off — which closes the question `store_fragment`
carried as open, against the hardest case rather than the easiest.
Crossing the bound is silent: the lane reached is the one at the same offset
inside the warp's own quadrant. Hence `tmem::warp_lanes()`, so the rule is
spellable, and `const { assert!(M <= 32) }` on the four composed drains, so the
composed spelling of that aliasing is a compile error.
This was referenced Aug 5, 2026
feitreim
added a commit
that referenced
this pull request
Aug 6, 2026
…equired of the tensor core either (#198) * A device-tests case whose reader is an MMA, not a drain: the hand-off #177 asks about `sttm round trip`, `ldtm x8 map` and `sttm restage` all read a stored segment back with another LDTM, which is the one consumer a kernel never has. This case hands the segment to an MMA. `mm_abt` writes it, each warp drains its own quadrant, scales it by 4 and `store_tile`s it back at the same columns, and a second `mm_abt` with `accumulate = true` takes the same segment. Both MMAs multiply the same operands, so every value is a multiple of the cell identity the first product already carries and a wrong one names the term that is missing: 5x is the claim, 2x is the accumulator as it stood before the rescale. Eight rows over three axes -- the fence ladder `tmem_warpgroup` runs, the warp that issues the second MMA, and whether `store_wait` is there at all -- plus the control that stores nothing, which is required to come back at 2x so that the two readings are known to differ before any row asserts which one arrived. Refs #177 * The fence pair is not required of the tensor core either, and store_fragment says so Measured on a B200, `sttm into mma`, 16384 values a row: control: no store at all every cell at 2x (the stale reading) both fences, issuer stored too every cell at 5x both fences, issuer is warp 2 every cell at 5x neither fence (what ships) every cell at 5x neither fence, issuer is warp 2 every cell at 5x no fence::after_thread_sync every cell at 5x no fence::before_thread_sync every cell at 5x no store_wait every cell at 5x (reported, gates nothing) So `store_wait` plus the rendezvous that publishes the write is the whole of it, for an MMA taking the segment as accumulator as much as for a drain in the other warpgroup, and `store_fragment`'s contract states it as a rule for both readers rather than naming only the one #193 measured. The control is what makes the rest mean anything: a case whose stale and rescaled readings were indistinguishable would pass whatever the hardware did. The `no store_wait` row is the negative control and **it did not fire** -- every cell was exact, exactly as `tmem across warpgroups`' own dropped-wait row was. Neither case is therefore evidence about the wait, and the doc says so: a race that resolved in order is not an ordering, and `store_wait` stays required on the strength of what it is. Refs #177
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.
TmemTile's drains and stores have always been documented as the owning warp's — "all 32 lanes of the warp owning TMEM rowsrow..row + Mcall this together" — and the documentation never said which rows a warp owns. It did not have to. Every kernel in this repository and in oxide-train launches one warpgroup, spells the row32 * warp_id(), and gives its four warps the four quadrants of a 128-lane accumulator. Under that arrangement "the owning warp" and32 * warp_id()are the same number, and no experiment here could tell the two readings apart.feitreim/oxide-train#94 is the first thing that needs them told apart. Its flash backward is pass-bound — the phase probe on that issue prices the register pass at 38–43% of a key-tile visit and the MMA issue at 42–49%, with every wait in the kernel under 100 ticks out of 4 300 — and its remedy 3 is to split the pass across two warpgroups. The whole remedy rests on one sentence:
That is a plausible reading of the PTX ISA and it is not this library's contract. Guessing wrong is not a hang and not a fault — it is silently wrong gradients, as the last section below shows precisely.
Measured
device-tests/src/tmem_warpgroup.rs— one accumulator, 256 threads (the first launch in that harness wider than one warpgroup), fourteen launches. Warpgroup 0 seeds every lane with the integerlane * 512 + column + 1, so a read that lands somewhere else decodes to where it landed; the case reports an offset rather than the word "wrong". One launch per row, the undefined rows last, so a fault would be a table row naming itself and not a cascade. B200, driver 580.95.05,sm_100a.fence::after_thread_syncfence::before_thread_syncstore_waitsync_threadsalonetile_x8[32, 128]rescale_half, both waysThe shapes are oxide-train's own, not toys: the
[32, 16]chunk its backward register pass reads throughTmemTile::tile, the[32, 128]band it drains throughtile_x8, and the[32, 64]half the forward both reads and stores back inrescale_half. Therescale_halfrow is the only one where the second warpgroup writes, and it checks that the write landed in the 64 columns it named and nowhere else.The answer, in one sentence
Three things follow that the first does not give you:
The fence pair was never needed.
store_fragmenthas carried this as open since it was written — "whether atcgen05_fence_before_thread_sync/tcgen05_fence_after_thread_syncpair is additionally required around such a hand-off is open. This crate uses neither on any path, and that is not a guarantee that they are unnecessary." It is closed now, in the direction the crate had already bet on, and closed against the hardest case rather than the easiest: the consumer is in the other warpgroup.store_waitplus a block barrier is the whole publication, and each layer was removed on its own and both together to say so.store_waitstays required anyway. The row that dropped it read every cell correctly too — and that row is a race whose two sides happened to arrive in order, which is not an ordering. It is reported and gates nothing. It is the one place in the table where "it worked" is not evidence, and the docs say so rather than quietly taking the win.Crossing the bound is silent. Not a fault, not garbage: the lane a warp reaches is the one at the same offset inside its own quadrant. The address's quadrant bits are dropped and the low five kept.
All 8192 values decoded to real cells at that offset, and the last line is inside one warpgroup — so this is a property of the warp, not of the warpgroup boundary. There is nothing to catch: no fault, no NaN, just another warp's plausible accumulator values.
What changed
tmem::warp_lanes()— the first of the 32 lanes this warp addresses,32 * (warp_id() % 4). Four characters of arithmetic, and the four characters are the whole finding:32 * warp_id()is not wrong inside one warpgroup and is not the rule, the two agree there and nowhere else, so a kernel that grows a second warpgroup silently stops being correct.#94's pass split is now expressible —scores.tile(warp_lanes(), column)is correct from either warpgroup — and every doc example intmem.rsis spelled that way.const { assert!(M <= 32) }ontile,tile_x8,tile_x8_batchedandstore_tile.M > 32was never sound and the clause never said so, becauseBaseLdtmimplements the layout up to 512 rows and nothing ever asked for more than 32. The composed spelling of the aliasing bug above is a[64, N]band, and it is worth a compile error. No caller in either repository passes more than 32, so this breaks nothing.The five ownership clauses now say what "owning" means:
row..row + Mlies inside the calling warp's ownwarp_lanes()quadrant.Docs.
docs/library/tmem.mdgains the section and the table, replacing "Open: fences around a store hand-off".GAPS.md§2.1 records the map, the entry point, and what is still unestablished.tests/gaps.rsnameswarp_lanesandLANE_QUADRANTS, because a rename to something meaning32 * warp_id()would pass every test in this repository except the one that needs a B200 to run.Not established
The same question under
cta_group::2, where one allocation spans a CTA pair —commit_multicast_cg2andmma_walk_cg2are still onGAPS.md§2.4's list and this does not touch them. And any of it on silicon that is not a B200.scripts/fmtclean.