Skip to content

Semaphore cluster-scope arrival: the GEMM deadlocks without a workaround #50

Closed

Description

@feitreim

Split out of #24 (item 2 / examples/README.md §6), which is an umbrella whose
other items have since been retracted, closed, or reassigned — this one is
load-bearing and was getting lost in it.

Semaphore arrives .shared::cta. A 2-CTA MMA consumes four tiles staged by
two CTAs, so the issuer needs one barrier saying the whole stage is present —
the peer's TMA has to complete on the leader's copy.

This is not theoretical: it is the bug #8 hit

The GEMM hung on its first real run. 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 working fix is tma_load_2d_multicast_cg2 with the CTA's own bit as the
entire mask
onto Semaphore::multicast_alias — no replication, purely to get
a .shared::cluster barrier operand. It works and is in examples/src/gemm.rs
today. 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, and every future
cluster kernel would have to rediscover the trick.

Any cluster kernel staging operands from both CTAs deadlocks without it.

The design question, which is real

Semaphore::expect_tx lowers to mbarrier.arrive.expect_tx … .shared::cta, so
it cannot charge a remote barrier even if handed one. Upstream's
mbarrier_arrive_cluster takes a remote address but carries no transaction
bytes
. So the two halves of what is needed — remote addressing and byte
accounting — are split across two intrinsics that do not compose.

That makes the byte accounting a design decision, not a transcription: which
CTA's barrier counts which bytes, and whether a producer charges its own
transfers or the leader charges the whole stage. Decide it deliberately.

Wanted, roughly: Semaphore::at_rank(rank), plus an answer to the above.

Related: #29 (the general expect_tx accounting problem — whatever lands here
must not make that harder), #24 (the umbrella), #46 (the TMEM allocator half of
the same "cluster primitives are missing" story).

Acceptance

examples/src/gemm.rs states the intent directly instead of through a
degenerate-mask multicast load, and still runs exact
(modal run modal_app.py::examples).

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