Skip to content

Where a warp's TMEM lanes are, measured: a second warpgroup shares them - #193

Merged
feitreim merged 2 commits into
mainfrom
tmem-cross-warpgroup
Aug 5, 2026
Merged

feitreim merged 2 commits into
mainfrom
tmem-cross-warpgroup

Conversation

@feitreim

@feitreim feitreim commented Aug 5, 2026

Copy link
Copy Markdown
Owner

TmemTile's drains and stores have always been documented as the owning warp's — "all 32 lanes of the warp owning TMEM rows row..row + M call 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 row 32 * warp_id(), and gives its four warps the four quadrants of a 128-lane accumulator. Under that arrangement "the owning warp" and 32 * 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:

the TMEM sub-partition a warp reads is warp_id % 4, so both warpgroups address the same lanes and only the columns differ

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 integer lane * 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.

row gated wrong of the dump
control: warpgroup 0, own quadrant yes 0 every cell as seeded
warpgroup 1, opposite number yes 0 every cell as seeded
both warpgroups, same lanes yes 0 every cell as seeded
no fence::after_thread_sync yes 0 every cell as seeded
no fence::before_thread_sync yes 0 every cell as seeded
neither fence (what ships) yes 0 every cell as seeded
no store_wait report 0 every cell as seeded
sync_threads alone report 0 every cell as seeded
#94's split: half the columns each yes 0 every cell as seeded
backward drain, tile_x8 [32, 128] yes 0 every cell as seeded
forward's rescale_half, both ways yes 0 every cell as seeded
MMA-written accumulator yes 0 every cell as seeded
cross quadrant (undefined) report 8192 aliased, see below
warp 0 reaches lane 32 (undefined) report 256 aliased, all from lane −32

The shapes are oxide-train's own, not toys: the [32, 16] chunk its backward register pass reads through TmemTile::tile, the [32, 128] band it drains through tile_x8, and the [32, 64] half the forward both reads and stores back in rescale_half. The rescale_half row 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

A warp addresses the 32 TMEM lanes at warp_id() % 4. Which warpgroup it is in does not matter, and it addresses no others.

Three things follow that the first does not give you:

The fence pair was never needed. store_fragment has carried this as open since it was written — "whether a tcgen05_fence_before_thread_sync / tcgen05_fence_after_thread_sync pair 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_wait plus a block barrier is the whole publication, and each layer was removed on its own and both together to say so.

store_wait stays 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.

warp 4 (quadrant 0) asked for lane 32 -> read lane 0
                    asked for lane 40 -> read lane 8
warp 7 (quadrant 3) asked for lane  0 -> read lane 96
warp 0 (quadrant 0) asked for lane 32 -> read lane 0

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 in tmem.rs is spelled that way.

const { assert!(M <= 32) } on tile, tile_x8, tile_x8_batched and store_tile. M > 32 was never sound and the clause never said so, because BaseLdtm implements 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 + M lies inside the calling warp's own warp_lanes() quadrant.

Docs. docs/library/tmem.md gains 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.rs names warp_lanes and LANE_QUADRANTS, because a rename to something meaning 32 * 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_cg2 and mma_walk_cg2 are still on GAPS.md §2.4's list and this does not touch them. And any of it on silicon that is not a B200.

scripts/fmt clean.

`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.
@feitreim feitreim added the gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes) label Aug 5, 2026
@feitreim
feitreim merged commit e26c75c into main Aug 5, 2026
4 checks passed
@feitreim
feitreim deleted the tmem-cross-warpgroup branch August 5, 2026 19:29
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant