Repository navigation
Name the cluster-scope arrival, and settle who charges the stage's bytes (#50) - #71
Merged
Merged
Conversation
) `Semaphore::at_rank(rank)` is the leader's copy of a stage barrier, mapped with `mapa` rather than by masking the rank bit out of a local address, and it returns a `ClusterSemaphore` — a barrier you may arrive at, or hand to an engine, and may not wait on or charge. That restriction is the ISA's: `mbarrier.arrive.expect_tx` is `.shared::cta` only and `mbarrier.arrive ... .shared::cluster` carries no transaction count, so a CTA can charge exactly one barrier, its own. Which leaves one decision, argued in `sync.rs`'s module docs: the waiter charges the whole stage. The alternative — every rank charges its own barrier and forwards an arrival — keeps the sum local, which is what #29 wants, and costs a barrier per rank per stage plus a thread spinning to forward a signal the TMA engine could have delivered directly. The locality is recoverable anyway: a cluster stage is symmetric, so the whole-stage charge is the local charge times the rank count. `SharedTile::tma_load_2d_arriving_at` is the load that completes on another CTA's barrier, with the degenerate mask now an implementation detail documented once instead of open-coded per kernel. `tma_load_2d_multicast_cg2` keeps the mask and is now the replication form only (#49).
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.
Closes #50.
gemm.rsno longer says "cluster-scope arrival" by issuing a multicast loadwith a degenerate mask. It says it with
Semaphore::at_rankandSharedTile::tma_load_2d_arriving_at, and still runs exact on a B200.The design question, and the answer
#50 is right that this is a decision and not a transcription, so here is the
argument. It is also in
src/sync.rs's module docs, which is where a futurecluster kernel will actually look.
Half of it is not a decision at all — it is the ISA, and the API should say
so rather than paper over it.
mbarrier.arrive.expect_txtakes.shared::ctaonly;mbarrier.arrive … .shared::clustertakes a remoteaddress and carries no transaction count. Remote addressing and byte
accounting live in different instructions and do not compose. So a CTA may
charge exactly one barrier — its own — and may arrive at any rank's.
That is why
at_rankreturns a new type rather than anotherSemaphore:ClusterSemaphorehas nowaitand noexpect_txbecause there is noinstruction for either. A
Semaphorethat happened to hold a remote addresswould type-check into two hangs the compiler could have caught. The type is
the statement of the constraint.
The half that is a decision is which CTA's barrier a cluster stage
completes on. Two shapes:
on it. Every rank's TMA completes there, named through
at_rank, and thatCTA charges every byte the stage brings in — including bytes it does not
issue.
ClusterSemaphore::arriveto the waiter when its own barrier flips.
This takes (1). What (2) has going for it is that the sum stays local — a
CTA charges exactly what it issued — and that is the one place the argument is
close, because locality of the sum is precisely what #29 wants. It is not
close enough: (2) costs a barrier per rank per stage, a thread per rank
spinning on it, and a second hop on the critical path that carries no
information, since a producer whose own barrier has flipped knows nothing the
TMA engine could not have told the waiter directly.
And the locality is recoverable under (1) anyway, which is what settles it. A
cluster stage is symmetric by construction — every rank stages the same tile
types at the same shared offsets, which is exactly what lets one MMA
descriptor read across the pair — so the whole-stage charge is the local
charge times the rank count, and the rank count is a launch constant. The
GEMM now writes that literally:
RANKS * (ATile::BYTES + BTile::BYTES).On #29, which lands on top of this
Nothing here makes #29 harder, and the
RANKS *form is the interface betweenthem. A charge derived from the loads a producer issued is still derivable
under (1); it is derived once and multiplied. Whichever shape #29 takes —
expect_tiles(&[…])or atma_loadthat returns its own charge — the clustercase is that same total scaled by the ranks staging into the barrier, not a
new mechanism. Had this gone with (2), #29 would have had to grow a whole
second signalling path to go with its accounting.
One more thing #29 should not have to rediscover: the charge and the
completions commute. An mbarrier's transaction count is a signed
accumulator, so the peer's loads may land before the
expect_txthat expectsthem — only the totals have to agree. No sync sits between them in the GEMM
and none is owed.
Addressing:
mapa, not arithmetic on the rank bitSemaphore::multicast_aliasis gone. It masked the CTA rank bit and thesub-word bits out of a local address (
& 0xFEFF_FFF8) — correct, and correctonly for "rank 0 of a 2-CTA cluster", since a 4-CTA cluster's rank field is
two bits wide.
at_rank(rank)lowers tomapa.shared::cluster, which is thedocumented primitive, takes any rank, and stops the DSMEM address encoding
being a thing kernel authors hand-derive. That is also what #49 will want when
it generalizes the geometry.
The load
tma_load_2d_arriving_atowns the own-bit mask that used to sit open-coded ingemm.rs, with the reasoning documented once in the library: nothing isreplicated, and what the multicast form supplies that the plain one cannot is
the
.shared::clusterbarrier operand.tma_load_2d_multicast_cg2keeps itsmask and is now the replication form alone — the #49 story — retyped to take a
ClusterSemaphoresince its barrier operand is cluster-addressed either way.Verification
All run against this branch.
modal run modal_app.py::build— passes. Realcargo oxide build --arch sm_100a.modal run modal_app.py::examples—pass gemm 512x256x256 exacton aB200, plus
pass softmax. This is the gate that matters: the failure modeunder change here is a deadlock or a wrong GEMM.
modal run modal_app.py::device_tests— 29 of 29 cases passed on a B200.cargo fmt,cargo clippy --all-targets -- -D warnings,cargo test(74passed) locally.
ClusterSemaphore::arriveis the one thing here no kernel in the repo callsyet — it is the ISA's own remote-arrival form and the other half of what #24
item 2 asked for (a CTA signalling its peer's progress), and #51's persistent
cluster pipeline is what will want it. Stating it plainly rather than implying
the GEMM exercises it.
GAPS.mdstill namesmulticast_alias; left alone to avoid colliding withconcurrent edits there.
examples/README.md§6 is updated to closed, matchinghow §5 records #46.