How the core charges barrier synchronization (registration)
Status: amended before any capture by the amendment, which corrects the barrier count of sync_stage_loop_kernel (two per step) and what follows for the regression check. As registered: a design, registered before any core change, implementation or capture. It answers the two open ROADMAP.md items on sync_ns with one candidate form and the test that decides it. Nothing below changes after the test's capture is taken.
What is known
- How the core charges barriers now. Per pipeline step it charges one
sync_ns, looked up in the profile'spipeline.fixed_sync_nsby warp and buffer count (Machine::sync_ns,Phase::Maininsim.rs). - What that value measures. It comes from
fixed_sync_empty_kernel: per step onecp.async.wait_group, one__syncthreads()and onecp.async.commit_group. On GB10 (profiles/gb10-0.23.0.json) it is 26.0 ns at 4 warps and 29.2 ns at 8 warps, one buffer. - The barrier count the core ignores. The kernel IR carries the barriers per loop step: the
countof the pipeline loop'sbarrierop, written by the Triton frontends from the PTX loop (triton_gemm.py,triton_attention.py). The core does not read it (from_ir.rs): removing the op or changingresources.barriersleaves predictions unchanged. - Real kernels. The v0.2 kernels have 2, 3, 10 or 14 barriers per step (v0.3-barrier-count-posthoc.md). The synthetic kernels of the non-MMA check have none.
- The barrier-step measurement (v0.3-barrier-step-gb10-result.md, 72 points on GB10), which is discovery data for this design:
- On an empty step, each further barrier costs 7.80 ns at 4 warps and 10.92 ns at 8 warps, linearly. These are the slopes at all SMs, the median of three processes; at one CTA they are 7.86 and 10.93 ns. That is about a third of
fixed_sync_ns. - With 64 instructions per warp per step the first few barriers are partly hidden, and later ones add about 8 to 9 ns each.
- With 512 instructions per warp at 4 warps the barriers cost nothing.
- With 512 instructions per warp at 8 warps the first barrier adds 113 to 125 ns, and further ones about 5 ns each.
- Whether a step with no barrier pays the step charge is unresolved in 8 of its 12 configurations.
- On an empty step, each further barrier costs 7.80 ns at 4 warps and 10.92 ns at 8 warps, linearly. These are the slopes at all SMs, the median of three processes; at one CTA they are 7.86 and 10.93 ns. That is about a third of
- The earlier counterfactual. Charging the full
fixed_sync_nsonce per barrier made absolute error and ranking no better on the opened v0.2 labels (the post-hoc look). By the measurement above, it charges each extra barrier about three times its empty-step cost. - Agreed with the author of the barrier-step measurement. She has no core form or new microbenchmark in progress. The 113 to 125 ns jump is untested. The barrier part of
fixed_sync_nscannot be separated without a variant of that kernel without the asynchronous copy, which nobody has measured.
The candidate form
Per pipeline step, with n the loop's barrier count from the IR and w the kernel's warp count:
sync per step = fixed_sync_ns(w, buffers) + max(n - 1, 0) x m(w)
- m(w) is the measured cost of one more barrier on an empty step at the nearest measured warp count. It is a new optional profile field,
pipeline.barrier_step_ns(one value per warp count, from thebarrier-stepmode's points with no other work, at all SMs). For GB10 it is 7.80 ns at 4 warps and 10.92 ns at 8 warps, taken from the barrier-step capture until a profile capture includes the mode. A profile without the field charges as today. - No parameter is fitted to kernel timings: m is measured, and n is read from the IR.
- n - 1, not n, because
fixed_sync_nsalready contains one barrier per step. - A loop with no barrier (n = 0) keeps today's charge. This decides the first roadmap item as "unchanged" for v0.3: barrier-step leaves it unresolved in 8 of 12 configurations, no v0.2 kernel has such a loop, and the only kernels with none are the synthetic non-MMA kernels, whose registered check is not reopened by this design.
Not proposed
- The full
fixed_sync_nsper barrier. It charges each extra barrier about three times its measured cost, and it was no better on the opened labels. - Hiding the barriers behind the step's work. At 512 instructions per warp and 4 warps the barriers cost nothing, while the form charges them on the CTA's chain whatever the work. A hiding term needs a rule for when the work covers the barrier. That rule would be a new mechanism, and barrier-step gives one configuration to set it on. The test below shows how much this matters in a pipelined step.
- The 113 to 125 ns first barrier at 8 warps and 512 instructions. Without barriers that step issues about 4 warp instructions per cycle, close to GB10's issue limit; with one barrier, about 3.1. One reading is that the barrier stops each warp's dependent tail from overlapping the next step, but nothing has tested it.
- Charging it needs a mechanism for issue slots lost at a barrier when the issue is nearly saturated, with its own constant.
- It appeared in 2 of the 12 configurations, both at one geometry.
- It is left out of the form. The test below reports, as a description, whether a first barrier costs far more than
fixed_sync_nsin pipelined steps at 8 warps.
The test
The barrier-step points are discovery data, and m comes from them, so they cannot test the form.
The existing microbenchmarks of fixed_sync_ns, stage_sync_overhead_ns and sync_stage_loop have one barrier per step. On them the form gives exactly today's prediction (n - 1 = 0), so they are a regression check, not a test: their predictions must be unchanged.
So the test needs new points: pipelined steps with several barriers, on GB10.
-
Kernel. The
sync-loophot-L2 kernel withcp.asyncstages (mem_levell2,transfer_modecp_async), with B__syncthreads()per step in total, the extra ones after the MMA chain. The assembler check of barrier-step is repeated before the capture: each instance must have exactly BBAR.SYNCper loop iteration. -
Points. B = 0, 1, 2, 4, 8 and 14; 4 and 8 warps; 4 and 16 KiB stages; MMA chains of 0 and 16; 1 and 2 CTAs per SM. That is 96 points in 16 configurations of 6 barrier counts. A point whose kernel does not fit its CTAs per SM, or uses local memory, is excluded before the capture.
-
Protocol. The long-launch protocol of long-launch-capture.md for one opt-in mode:
- pilot at 1.25 ms and lengths frozen before the capture;
- 5 rounds, each a separate process behind the thermal and quiet-host gates;
- rules 1 to 3 with no exception, at most 2 extra rounds.
The predictions of the current core and of the form are frozen after the pilot and before the capture, from the IR of each point with its barrier count B.
-
Gate. A configuration is judged only if the current core predicts its B = 1 point within 10%, so that a miss of the base step does not decide the barrier term. If fewer than 8 of the 16 configurations pass the gate, the form is not judged.
-
Pass. On the B >= 2 points of the judged configurations, the form passes when all of these hold:
- its MAPE is under 15%;
- its MAPE is lower than the current core's;
- every barrier count's median error is within 10%;
- the B = 1 predictions and the regression check above are unchanged.
-
Reported, not judged.
- The B = 0 points: whether a barrier-free pipelined step costs what the step charge says (the first roadmap item).
- The first barrier's cost, t(1) - t(0), at 8 warps against
fixed_sync_ns. - The current core's errors.
- Every point's measured value and both predictions.
-
On failure. If the form fails or is not judged, the core keeps charging one
sync_nsper step, and both roadmap items are recorded as known limits in design.md.
Expected effect on real kernels
This is computed on the v0.2 formal IRs with the current core (compiled sources of 71304a4, unchanged on main) and profiles/gb10-0.23.0.json, with m as above. It compares predictions only: no label was read, so it says nothing about accuracy. There are 512 configurations that the core predicts (warm). The script and its output are expected_change.py and expected-change.json; the IRs are the archived v0.2 formal set, not in the repository.
| Kernels | Barriers per step | Warps | Configurations | Median change | Range |
|---|---|---|---|---|---|
| GEMM | 2 | 4 | 162 | +0.00% | -1.42% to +2.00% |
| GEMM | 2 | 8 | 162 | +0.00% | -5.73% to +4.65% |
| Attention | 2 | 4 | 72 | +0.60% | -3.03% to +4.80% |
| Attention | 2 | 8 | 72 | +0.83% | +0.11% to +1.68% |
| Attention | 10 | 4 | 22 | +6.40% | +1.95% to +7.94% |
| Attention | 10 | 8 | 12 | +7.17% | +5.87% to +8.14% |
| Attention | 14 | 8 | 10 | +6.43% | +3.91% to +7.56% |
- Size. The form moves the 2-barrier kernels by about a percent and the 10- and 14-barrier attention kernels by about 6% to 7%, slower, which is the direction of their current residuals in the post-hoc look.
- Not monotone. Some configurations get faster when the step charge grows, by up to 5.7%. The core's time is not monotone in this term: the charge also enters the queueing network's service time. The test's points will show whether this matters there.
- The RTX 4070. Its profile has no
barrier_step_nsuntil the RTX 4070 half of barrier-step is captured, so its predictions do not change.