Skip to content

Cluster scope: the library is CTA-scoped, and the GEMM works around it four ways #24

Closed as not planned

Description

@feitreim

Writing the GEMM example (#18) turned up four separate cluster-scope gaps. All
of them were worked around in-file, each fenced with the signature it wanted.
None had an open issue. This was the surprise of that exercise — the gaps were
expected to be compute-side, and instead the compute layer was fine and the
scaffolding was not.

The library has mma_walk_cg2 and commit_multicast_cg2, so it can issue a
CTA-pair MMA — but nothing around that MMA is cluster-aware.

1. No cluster-scope TMEM allocation

tmem::alloc_block is cta_group::1. A cta_group::2 MMA writes an accumulator
the CTA pair shares, and there is no alloc_block_cg2. cuda-device exposes
tcgen05_alloc_cg2 / tcgen05_dealloc_cg2 (the gemm_sol example uses them).

2. No cluster-scope semaphore arrival

Semaphore arrives .shared::cta. A CTA waiting on its peer's progress cannot
be signalled. Related and not a transcription job: Semaphore::expect_tx
also lowers to .shared::cta, so under a cluster the transaction-byte
accounting is a design question — which CTA's barrier counts which bytes.
Decide that deliberately rather than by mirroring the CTA-scoped form.

3. pipeline::run cannot schedule a cluster

Work items are blockIdx.x-strided, so the two CTAs of a pair get different
items — exactly wrong for a cooperative MMA. The GEMM example therefore does
not use the persistent scaffold at all, which is a real indictment of it: the
one kernel that most wants a persistent pipeline cannot use ours.

Needs cluster-aware striding (item per cluster, not per CTA) and a way to ask
which rank in the cluster the calling CTA is.

4. Multicast has no geometry to live in

tma_load_2d_multicast_cg2 has nothing to broadcast under 2-CTA UMMA: both
operands are already split between the pair, so there is no tile two CTAs both
need. It only pays off at cluster >= 4 — which _cg2 rules out by name.

So either the multicast path is dead code as shaped, or it needs a cluster
geometry the library cannot currently express. Worth resolving before anyone
builds on it.

Suggested order

(1) and (2) are prerequisites for any correct cluster kernel and are small.
(3) is a redesign of pipeline::run's indexing. (4) is a question to answer
before it is a change to make.

Promoting the GEMM example from "compiles with four workarounds" to "uses the
library" is the acceptance test for this issue.

Activity

  1. added
    area:scaffolding
    on Jul 27, 2026
  2. feitreim commented on Jul 27, 2026

    @feitreim
    OwnerAuthor

    Acceptance: update examples/ as part of closing this.

    gemm compiles today with several cluster-scope workarounds, each fenced in-file with the signature it wants. Deleting those fences is the acceptance test for this issue.

    The examples crate (#18) exists so that "done" is checkable in the terms a kernel author cares about, rather than as a claim about a primitive nobody has tried to hold. Concretely, on closing this:

    • Delete any workaround or GAP fence in examples/src/ that this issue removes the need for, and replace it with the real API.
    • If a kernel becomes fully unblocked, move it from aspirational to compiles: flip its header, take it out of its feature gate, and confirm modal run modal_app.py::build builds it for sm_100a.
    • Update the status table and the blocked-on lists in examples/README.md.

    If the example still does not compile afterwards, that is a finding worth writing down — say what is still missing rather than leaving the README stale.

  3. feitreim commented on Jul 27, 2026

    @feitreim
    OwnerAuthor

    Item 8 is wrong, and a running GEMM is what corrected it. Item 6 is more urgent than filed.

    Found while implementing #8, which got examples/src/gemm.rs executing on a B200 against a CPU reference (pass gemm 512x256x256 exact).

    Item 8 — "Multicast has no geometry to live in" — retract

    This issue and examples/README.md §8 both claimed the GEMM "uses the commit and the walk and cannot use the load", on the reasoning that under a 2-CTA UMMA both operands are already split across the pair, so nothing is replicated and multicast has nothing to broadcast — hence it only pays at cluster >= 4, which _cg2 rules out.

    The replication argument is correct and the conclusion drawn from it is not. The GEMM hung on its first real run. Cause: a plain cp.async.bulk.tensor completes on a barrier in the issuing CTA's shared memory, so the peer's 24 KiB never reached the leader's 48 KiB expect_tx charge and the leader waited forever.

    The fix is tma_load_2d_multicast_cg2 with the CTA's own bit as the entire mask — no replication at all — onto Semaphore::multicast_alias. What that buys is not delivery to two CTAs; it is a .shared::cluster barrier operand, which the plain form cannot take.

    So: what a cluster kernel needs from the multicast load is the address space, not the broadcast. Both primitives were already in the library and the pairing was simply never made. This deletes gemm.rs's at_leader gap block.

    Generalizing the cluster mask beyond pairs may still be worth doing on its own merits, but it is not what this item claimed, and the multicast path is not dead code as shaped.

    Item 6 — cluster-scope semaphore arrival — promote

    The above is the concrete form of item 6, and it is not a nice-to-have: a cluster kernel that stages operands from both CTAs deadlocks without it. The workaround exists and works, but it is a multicast load with a degenerate mask standing in for "arrive on a cluster-scoped barrier", which is not what it says. Semaphore::at_rank (or whatever shape it takes) should make the intent expressible directly.

    The transaction-byte accounting question in the original text still stands, and #29 is where the general version of it lives.

    Items 1, 3, 5, 7 — unchanged

    Still open as filed. Item 5 (cluster-scope TMEM allocation) is exercised by the running GEMM through an open-coded alloc_cluster, so it now has a working reference implementation to lift rather than a design to invent.

  4. feitreim commented on Jul 28, 2026

    @feitreim
    OwnerAuthor

    Split into per-item issues. This one is now an index, not work.

    Filing four cluster gaps as one umbrella made sense when none of them were understood. They have since diverged badly — one was retracted, one turned out to be a live deadlock, one has a hardware-verified reference implementation sitting in an example — so tracking them together now hides more than it groups.

    Item (original numbering) Status
    1. Cluster-scope TMEM allocation -> #46. alloc_cluster exists and is hardware-verified in examples/src/gemm.rs; #46 lifts it into tmem.rs, along with the cta_group::1 relinquish bug that shares its root cause.
    2. Cluster-scope semaphore arrival -> #50. Promoted: this is the deadlock #8 hit, not a nice-to-have. The current fix is a degenerate-mask multicast load standing in for cluster-scoped arrival.
    3. pipeline::run cannot schedule a cluster -> #51.
    4. Multicast has no geometry Retracted in part (see the correction comment above — the multicast load is what a cluster kernel needs for its barrier address space, not for replication). The surviving half — generalizing the mask beyond pairs, for cluster >= 4 replication — is -> #49.

    Closing this in favour of those four. The correction comment above stays worth reading: it is the record of why "multicast is dead code as shaped" was wrong, and the reasoning generalizes — what a cluster kernel needs from a primitive is not always the thing the primitive is named for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:scaffolding

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions