Skip to content

Where a replicating TMA multicast's bytes are counted, measured - #190

Merged
feitreim merged 1 commit into
mainfrom
80-multicast-accounting
Aug 5, 2026
Merged

feitreim merged 1 commit into
mainfrom
80-multicast-accounting

Conversation

@feitreim

@feitreim feitreim commented Aug 5, 2026

Copy link
Copy Markdown
Owner

tma_load_2d_multicast_cg2 has taken an arbitrary cta_mask since it was written, and its own documentation has said outright that nobody knew what that mask does to the barrier:

The charge handed back is one tile — what a single destination receives. A caller replicating into several CTAs owns the question of whether the one barrier it named sees that once or once per destination; it has not been answered against hardware.

It was never going to be answered by accident. Every multicast in this repo — and in cuda-oxide's own gemm_sol_final — uses a one-bit mask: the own-bit form, which replicates nothing and exists only to reach a .shared::cluster barrier operand. The replicating form has never run.

oxide-train#80 needed it, because the named exit from that issue's residual is a 4-CTA cluster running two cta_group::2 pairs on adjacent tiles of one tile-row with A multicast between them — the only structure that gets the narrow tile's wave quantization at the wide tile's arithmetic intensity. That kernel cannot be written without knowing where the bytes are counted, and guessing wrong is silent: it hangs.

Measured

gpu/gemm/src/mcast_probe.rs in oxide-train — five variants over one 4-CTA cluster on a B200, every wait against a globaltimer deadline so a wrong answer comes back as a row of a table instead of a launch that never returns. Each CTA also reports the row range it received, which separates delivery from accounting.

variant issuer mask [mbar] charged result
0 rank 0 {0,2} own ranks 0, 2 — one tile each both complete, both hold rows 0..128
1 rank 1 {1,3} rank 0's mapa'd rank 0 — one tile completes
2 rank 1 {1,3} rank 0's mapa'd rank 0 — two tiles does not complete
3 rank 1 {1,3} rank 0's mapa'd ranks 0, 2 — one tile each both complete
4 ranks 0+1 {0,2}, {1,3} rank 0's mapa'd ranks 0, 2 — two tiles each both complete

One model fits all five:

The copy landing in CTA d completes on the barrier at the supplied offset, in whichever CTA of d's own cta_group::2 pair the supplied address's rank parity names.

Variant 3 is what rules out the "one absolute barrier" reading: rank 2 was never named by anything, and it completed. Variant 2 rules out "once per destination at the named barrier".

What that changes here

Two consequences, neither guessable and neither in the ISA text:

  • An even-rank address means "each destination's pair leader", not "rank 0". mask = {1,3} with sem.at_rank(0) charges ranks 0 and 2. The absolute rank is not what is read; its parity is. This is the whole reason a cluster of several pairs can be fed and accounted for by one instruction while keeping one barrier per pair.
  • The named barrier is not charged once per destination. Charging one barrier n tiles for an n-bit mask over-charges it and hangs the block.

The diff

Documentation only — no code, no API change, and the charge the method already handed back turns out to be the correct unit.

  • src/shared.rs — the paragraph that said "it has not been answered" now says what the answer is, with both traps spelled out.
  • docs/library/shared.md — a new subsection under the own-bit multicast, since that section explicitly set up the question.
  • GAPS.md §2.4 — tma_load_2d_multicast_cg2 comes off the cluster-ops ask. It was listed as hardcoding the 2-CTA pair; it never did. Its mask was always the caller's, and the _cg2 in the name is the cta_group qualifier the instruction carries, not a limit on the mask. commit_multicast_cg2 and mma_walk_cg2 stay on the list — those really do hardcode the pair.

scripts/fmt clean.

`tma_load_2d_multicast_cg2` has taken an arbitrary cta_mask since it was
written, and its documentation has said outright that nobody knew whether the
one barrier it names sees the charge once or once per destination. Every
multicast in this repo, and in cuda-oxide's own gemm_sol_final, uses a one-bit
mask, so the replicating form was never exercised.

oxide-train#80 needed it for a 4-CTA cluster and measured it on a B200
(`gpu/gemm/src/mcast_probe.rs`: five variants over one cluster, every wait
against a globaltimer deadline so a wrong answer came back as a table row rather
than a launch that never returned):

  The copy landing in CTA d completes on the barrier at the supplied OFFSET, in
  whichever CTA of d's own cta_group::2 pair the supplied address's rank PARITY
  names.

An n-bit mask therefore produces n completions of one tile each, at n different
barriers — so the charge this method hands back was already the right unit. Two
consequences neither guessable nor in the ISA text: an even-rank address means
"each destination's pair leader" and not "rank 0" (mask {1,3} with at_rank(0)
charges ranks 0 and 2), and the named barrier is NOT charged once per
destination, so charging it n tiles over-charges it and hangs the block.

GAPS §2.4 drops `tma_load_2d_multicast_cg2` from the cluster-ops ask: nothing
was missing from it but the semantics.
@feitreim
feitreim merged commit 5e4d3ff into main Aug 5, 2026
3 checks passed
@feitreim
feitreim deleted the 80-multicast-accounting branch August 5, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant