Plan: the missing mechanism of synchronous-load GEMM on GB10 (registration)
Plan, not a result. Registered before any code or capture, for the ROADMAP.md item "Synchronous load GEMM (num_stages = 1, +9.1% warm): find the missing mechanism with a microbenchmark". It produces measurements only; a core change, if any, is a separate pull request.
The residual
GEMM configs with num_stages = 1 are predicted slow on the development set: median error +9.1% warm and +2.2% cold (core 7b1be46, profile 0.21.0; design.md 9.2). The core treats them as synchronous loads, prefetch distance 0: each stage costs a round trip plus its compute, hidden only across the CTAs of an SM (model-core.md).
Explanations already ruled out
From design.md 9.1 and 9.2 and the post-hoc look at phases 1 and 2, each by a microbenchmark without GEMM timings:
- MMA chain fill and drain (
mma_chain_latency); shared memory to register latency (serial_stage_overhead_ns); serial shared memory fill as an addition to the round trip (serial_stage_fill); tensor, issue, shared memory port and scheduler contention between co-resident CTAs (dram_closed_loop_mma); register spills (none reported). - A register-staging cost the model misses: on
sync_stage_loopwith two or three CTAs per SM, register-staged loops are predicted with MAPE 4.2% (RTX 4070) and 8.3% (GB10); with one CTA per SM the model keeps the shared memory stores on the CTA's chain, and taking them off makes it worse. - Round trips in phase on the port:
7b1be46shares the port out of phase, assync_stage_loopwith 1 to 8 CTAs per SM shows.
What the kernels do (checked for this plan, CPU only)
The validation GEMM kernel (dense_gemm in validation/runner.py) compiled by Triton 3.9.0 for sm_121 and sm_89 (2048 cubed, BM x BN x BK = 128 x 128 x 64 and 64 x 64 x 32, 4 warps, 16-byte aligned pointers):
num_stages = 1loads withld.global.v4.b32, the default cache operator, which allocates in L1.num_stages2 and 3 load withcp.async.cg, which bypasses L1.- In the
num_stages = 1loop the assembler issues the A loads, a barrier, the B loads, then all shared memory stores, a barrier, and theldmatrixand MMA work; the loop starts with the loads and ends with the MMAs. No load of the next iteration is issued before the current MMAs.
So one candidate is ruled out here: the compiler does not prefetch the next stage through registers, and the barrier between the A and B loads can only make the real loop slower, the opposite of the residual.
Candidates not ruled out
- L1 reuse of synchronous loads (tested here). Only the synchronous path's loads can hit in L1. CTAs on one SM that read the same A or B tile in the same K step can then take it from L1 instead of L2, which the core cannot see: it has no L1 for global loads (the tensor cache policy reaches only the L2 split). This would make the real loop faster than predicted, more where data is L2-resident (warm) than where the round trip is to DRAM (cold), as the residual is.
- A different round trip for
ld.globalthan for the curves the core reads (tested here as a by-product). The core's synchronous round trip comes from latency and bandwidth curves measured withcp.asyncandld.global.cg. A default-cachedld.global.v4through L1 may differ even without reuse. - Warps of a CTA out of step within a stage (left for later): the barriers bound it, and nothing points to it yet.
What is measured
A new mode, sync-load-reuse: the single-buffer register-staged loop of the kernels above (load A, barrier, load B, store both to shared memory, barrier, a fixed block of ldmatrix and mma.sync work), one stage of 16 KiB per CTA (8 KiB A, 8 KiB B), 4 warps, grid = CTAs per SM x 48. Each CTA records %smid, so co-residency is checked rather than assumed.
Arms, every combination of:
load:ld.global.v4with the default cache operator, as Triton emits;ld.global.cg.v4, which bypasses L1.sharing: the CTAs on one SM read the same A and B addresses in each step (shared), or each reads its own (disjoint). Within a CTA the addresses are the same in both arms; only who else reads them changes.ctas_per_sm: 1 and 2 (sharedanddisjointare the same at 1 CTA).level: L2-resident (each CTA walks a region of 64 KiB, four stages, read before timing, as warm) and DRAM (regions of at least 16 times the L2 size in total, behind the read-only flush, as cold). Amended before any implementation or capture; see below.
Every CTA requests enough dynamic shared memory that only the largest carveout fits: 50176 B at two CTAs per SM (with the 1 KiB reserved per CTA, 102400 B, the largest of GB10's carveout options [0, 8192, 16384, 32768, 65536, 102400]), and 101376 B at one CTA per SM. It uses 16 KiB of it.
Amendment (before any implementation or capture)
The registration as first merged (51b6114) set the L2-resident level as one 4 MiB region and left the carveout to the driver. Writing the kernel showed that this mixes L1 capacity into the reading:
- Spread over the 96 CTAs of the
disjointarm at two CTAs per SM, 4 MiB gives each CTA about 42 KiB and each SM about 85 KiB; in thesharedarm the two CTAs of an SM share one region, about 42 KiB per SM. - How much L1 the driver would leave for two CTAs of 16 KiB each was not measured. It was inferred to be about 28 to 64 KiB (a 64 KiB carveout), but the GB10 carveout probe has shown that such an inference can be wrong: a 128-thread CTA with no shared memory request got an L1 like the 16 KiB request's, not the largest (second registration, result).
- With per-SM working sets on both sides of the L1 size, a CTA in the smaller
sharedworking set could hit its own earlier reads in L1 where thedisjointarm does not, and reading 2 would take that capacity effect for reuse between CTAs.
What changes, and why it removes that:
- The carveout is forced, not inferred. Each CTA's shared memory request leaves the largest carveout as the only one that fits (architectural: the requests must fit the carveout). The L1 left at that carveout is measured:
profiles/gb10-0.23.0.jsonputs the pointer chase's L1 cliff at 28680 B for a 101376 B request (l1_to_l2_spill_threshold_by_carveout). - Each CTA's region is 64 KiB at the L2-resident level, at one and two CTAs per SM. The per-SM working set is 64 KiB (
shared, and one CTA) or 128 KiB (disjoint), both above the 28 KiB L1, and a CTA returns to a stage only after 64 KiB of its own reads, so neither arm reuses its own data in L1. In thesharedarm the other CTA reads the same 16 KiB stage in the same step, which still fits in L1, so the reuse this plan tests is not removed. The L2-resident footprint is 6 MiB (disjoint) or 3 MiB, about a quarter of the 24 MiB L2 and outside GB10's bistable band. - The DRAM level, the arms, the readings and their thresholds are unchanged.
The cost: at the forced carveout the L1 is smaller than what Triton's num_stages = 1 kernels get. This plan asks whether reuse between CTAs exists, not how large it is in a real kernel's L1; a positive reading says the mechanism exists, and sizing it for real kernels is a separate step.
Launch protocol
As every scheduled mode (long-launch-capture.md): pilot to 1.25 ms per launch, frozen schedule with the arms as design fields, every launch at least 1.0 ms, --clock-probe. 15 samples and 3 warm-ups. Spark 1 under the GPU lock after the quiet-host gate, three processes in one session, each host-checked; a failed host check voids that process, replaced once. A launch whose CTAs are not two per SM on every SM (from %smid) voids the point.
Quantities
The time per step of each point: the median of its samples over steps, per process; over processes, the median of three.
Frozen reading
At two CTAs per SM, per level:
- Capture rules, as usual. A failing point is reported, not dropped. A level with a point that fails a rule gets neither reading below: it is not resolved.
- L1 reuse is shown when, in all three processes, the default-cached
disjointstep is at least 5% slower than the default-cachedsharedstep, and the.cgdisjointandsharedsteps differ by less than 2%. Not shown when, in all three, the default-cachedsharedanddisjointsteps differ by less than 2%. Otherwise not resolved. - Reading 2 at the L2-resident level decides candidate 1. The DRAM level is reported with the same reading and does not decide it.
At one CTA per SM, per level:
- The default-cached path differs when, in all three processes, the default-cached and
.cgsteps differ by at least 5%; does not when they differ by less than 2% in all three; otherwise not resolved. This is reported for candidate 2 and does not decide candidate 1.
Reported without a verdict
- For each
num_stages = 1configuration of the archived v0.2 GB10 holdout IRs (opened data, CPU only): how many CTAs share an SM at the core's occupancy, and whether co-resident CTAs under the round-robin dispatch read the same A or B tiles. This says where the mechanism could act; no residual is fitted to it. - The SM clock and per-cycle step times.
Not covered
- More than two CTAs per SM, other stage sizes and warp counts.
- The RTX 4070: the same plan applies later, under the quiet desktop gate.
- How the core would model L1 for global loads.
Owners: 7; review 6; earlier analysis of this residual 4.