Skip to content

pipeline::run cannot schedule a cluster: work items are blockIdx.x-strided #51

Closed

Description

@feitreim

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.

Related: #3, #13, #15, #24, #47.

Activity

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

    @feitreim
    OwnerAuthor

    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 %clusterid stepping 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.x was the same map written one level too low. Job::RANKS widens the per-item barrier boundary to barrier.cluster where peers name each other's barriers, at no extra barrier count — and folds away at RANKS == 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 found Scope could 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.rs did adopt it, ran exact on a B200, and then came back out. The port is at commit 08e5e08 so the kernel the numbers were taken on is in the history rather than described in prose. Min ms over 30 timed launches, B200:

    shape launch per tile cap 74 (1 cluster/SM) cap 148 (2/SM)
    2048³ 0.0451 0.0593 = 0.0478
    4096³ 0.1891 0.2808 0.2059
    8192³ 1.0169 2.1036 1.2130

    = 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. lcf at 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.rs on main is 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::arrive is 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-rolls barrier.cluster at the price of a barrier and a spin per rank. sync.rs's doc now says so.

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