Repository navigation
Description
pipeline::run schedules statically: item = cluster_idx(), then
item += num_clusters(). Every cluster takes a fixed share, decided before the
kernel starts. cuda-oxide already exposes Blackwell's hardware alternative and
nothing here references it.
cuda_device::clc — Cluster Launch Control:
clc_try_cancel(response, mbar)andclc_try_cancel_multicast(the
cluster form, which is the one this repo's 2-CTA kernels need)clc_query_is_canceled,clc_query_get_first_ctaid_{x,y,z}
Its own module doc: "CLC replaces software atomic counters for persistent
kernel tile scheduling. Instead of a fixed number of persistent CTAs competing
on a global counter, CLC uses hardware-managed work-stealing: launch a full grid
(one CTA per tile), and running CTAs call try_cancel to steal not-yet-launched
tiles." The response is a 16-byte value delivered through an mbarrier,
which is sync::Semaphore — the machinery is already here.
cuda_device::atomic also has fetch_add / compare_exchange, so a software
counter is available as a fallback and as a control to measure CLC against.
What it is worth, quantified before anyone builds it
The static stride's loss is the ragged last wave. At MAX_CLUSTERS = 222 with
[256, 128] tiles:
| shape | tiles | waves | wave efficiency |
|---|---|---|---|
| 2048³ | 128 | 1 | 57.7% |
| 4096³ | 512 | 3 | 76.9% |
| 8192³ | 2048 | 10 | 92.3% |
| 16384³ | 8192 | 37 | 99.7% |
So the ceiling on this is about 8% at 8192³, 23% at 4096³, and nothing at
16384³. State that plainly up front, because it cuts against the headline
ambition: at the sizes that will define a peak-throughput claim the static
stride is already 99.7% efficient. CLC is a fix for mid-sized problems and
ragged tails, not a route to peak. It is worth doing anyway for the second
reason below, but a measurement showing ~0 at 16384³ is a success, not a
failure, and should not be tuned against.
The other reason, which may matter more
It deletes the tuning constants. #83 had to hand-pick SMS = 148 and
CTAS_PER_SM = 3, and its own doc concedes a device with a different SM count
computes the same GEMM off a wave that is not quite a wave. #84 then showed
CTAS_PER_SM is a measured property that no query in the table reports, so it
cannot be derived at compile time and cannot be right on unseen hardware. Under
CLC the hardware decides and both constants go away.
That also makes the persistent scaffold portable rather than B200-shaped, which
is the difference between an example and a library feature.
Scope
- A CLC-backed item source for
pipeline::run, sitting behind the sameJob
interface sogemm.rsdoes not care which scheduler it got. The existing
static stride stays as the fallback and as the control to measure against —
this is one of the few places keeping two paths is justified, and only until
the comparison is done. - Use
clc_try_cancel_multicastfor cluster jobs. A 2-CTA cluster stealing per
CTA would split a pair across two output tiles, which is pipeline::run cannot schedule a cluster: work items are blockIdx.x-strided #51's bug again. - The response arrives on an mbarrier, so the steal can be prefetched — issue
thetry_cancelfor the next item while the current one's MMA is still
running, and the latency hides. A steal on the critical path would be a
regression; say which one was measured. - Tile coordinates come back as grid coordinates, so an L2-aware traversal
composes with this rather than conflicting — see the traversal issue.
Acceptance
gemm exact at every size, and a before/after against the static stride at
2048³, 4096³, 8192³ and 16384³ — the sizes are the point, since the predicted
gain varies from 23% to nothing across them. Report the ragged-wave prediction
beside the measurement.
Related: #83 (the constants and the static stride), #84 (why CTAS_PER_SM
cannot be derived), #86 (the bound), #51.
Activity
CLC work-stealing scheduler behind Job, with the static stride as con…
Ask the hardware for the schedule, and find out the ragged wave was n…
Delete the prefetched steal the measurement ruled out, and fmt all th…
Ask the hardware for the schedule, and find out the ragged wave was n…