Repository navigation
Description
Split out of #24 (item 3 / examples/README.md §7), which is an umbrella whose
items have diverged in status — this one deserves its own tracking.
pipeline::run's work-item map is blockIdx.x strided by gridDim.x, so the
two CTAs of a cluster get different items — exactly wrong for a cooperative
MMA, where the pair must work on the same output tile.
The indictment
examples/src/gemm.rs therefore does not use the persistent scaffold at all.
It is one cluster per output tile with the K loop as its pipeline. The one
kernel that most wants a persistent pipeline cannot use ours, which is about as
direct a statement of the problem as there is.
Note this is not a porting oversight: ThunderKittens' prototype::lcf predates
clusters too. It is our scaffold needing a way to say who a work item belongs
to.
What it needs
Cluster-aware striding — one item per cluster, not per CTA — and a way to
ask which rank within the cluster the calling CTA is.
The rank question is where this meets #3 (scope parameterization). But note
#6's finding on that issue: #3 as filed cannot do its job, because a block-scope
operation needs storage the Scope trait does not supply, and its real
prerequisite is #13 (shared vectors). So this issue should not simply wait on #3
as written — the cluster-rank half may be separable from the storage half, and
that is worth checking before sequencing them.
Related, and cheaper
#15's lcsf has become more attractive since it was filed. It depended on
#9, which has landed — and specifically on tma_store_wait_read, which releases
the shared buffer as soon as the engine has read it without blocking on global
visibility. That is exactly what lets an epilogue overlap the next tile's first
K loads. With the store folded into finish as lcf has it, a persistent GEMM
cannot overlap those at all.
#47 is the same shape one level down: softmax is latency-bound with a flat
~51 us floor because nothing is ever in flight. Both are "the pipeline layer
exists and the kernels that need it cannot use it".
Acceptance
examples/src/gemm.rs uses pipeline::run, and still runs exact
(modal run modal_app.py::examples). Re-measure with
modal run modal_app.py::bench against the table in #40 — a persistent GEMM
that is slower than the current one is a finding, not a success.
Activity
A work item belongs to a cluster, and the GEMM that proved it got slo…
feitreim commentedon Jul 28, 2026
Closed by #80, and the acceptance clause was met and then deliberately walked back — which is the outcome this issue asked for in writing, so recording why.
The filed defect is fixed.
pipeline::run's item map is%clusteridstepping by%nclusterid. That is not a second schedule beside the old one: a launch declaring no cluster runs clusters of one CTA, where those registers are%ctaid/%nctaid, so a block-scope job gets back precisely the loop it had.blockIdx.xwas the same map written one level too low.Job::RANKSwidens the per-item barrier boundary tobarrier.clusterwhere peers name each other's barriers, at no extra barrier count — and folds away atRANKS == 1.The rank half did not need #3, and this issue's suspicion about that was right.
cluster::block_rank()reads%cluster_ctarank: no storage, no collective, no barrier — exactly what #6 foundScopecould not supply for the block-reduction half. So the two halves separate, and no rank API was added, on the grounds that wrapping an existing primitive in a trait adds a name without adding a fact.gemm.rsdid adopt it, ran exact on a B200, and then came back out. The port is at commit08e5e08so the kernel the numbers were taken on is in the history rather than described in prose. Min ms over 30 timed launches, B200:=0.0478=marks rows where the problem has fewer tiles than the cap, so the grid is identical and each cluster runs one item — a free control, and it says the scaffold's own cost is zero. The regression is entirely the grid cap.lcfat one item per cluster is the launch-per-tile kernel — same rings, same barriers, drained at the same points — so persistence changes only how many clusters exist.Shipping that would have been a regression, and #51 says in terms that a slower persistent GEMM is a finding rather than a success. So
examples/src/gemm.rsonmainis byte-identical to what it was, and the scaffold ships with no caller. The reason it has none changed, though, and that was the point: it used to be that the cluster kernel could not use it, and it is now that the one that can does not want to.Two things this leaves owed, both filed elsewhere
ClusterSemaphore::arriveis still called by nothing. #50 predicted this issue would want it; it does not — an item boundary is a rendezvous, and building one out of mbarriers hand-rollsbarrier.clusterat the price of a barrier and a spin per rank.sync.rs's doc now says so.gemm runs on the scaffold, at the cap a clock had to find (#51)
gemm runs on the scaffold, at the cap a clock had to find (#51) (#83)
Count the CTAs instead of asking, and flash_forward's 1 is real for t…