Skip to main content

spill-latency: reading the reload points across local memory allocations (registered design, draft)

Status: redone and adopted on 2026-11-27, with the reload points sized to 2.0 ms (the redo, the result). Earlier status: withdrawn on 2026-11-27. The adoption check had no valid round, so this design and the serial 1 KiB exception are withdrawn together (the result). Before the check: draft, registered before any implementation or run; to be reviewed and approved before either. Nothing in the design or the adoption check changes after the adoption capture is taken.

Why​

In the first GB10 0.23.0 capture (main 42e039d), the eight 4 KiB l2_spill points with reloads failed rule 3: their round medians spread 24% to 31%, every point in the same order of rounds. The allocation diagnostic (gb10-spill-alloc-plan.md on the branch s8/diag-spill-alloc, result f8e0ff8, post-hoc note e264c84) found the cause: the level of these points is set by the local memory allocation the frames live in and stays fixed while it lives (18 of 18 rereads of one allocation within 0.008, 18 of 18 allocations stable), while a new allocation draws a new level (spans 0.23 to 0.35 within a process). A process normally keeps one allocation for all its launches, so each round of the capture had one level. The points without reloads do not move (spans at most 0.006). The same note found that the stack limit itself changes some points (the batched 512 B point at 128 reloads takes 1.75 ms at 4 and 5 KiB of stack and 1.29 ms at 6 KiB and at the default), so new allocations here come from new contexts at the default stack limit, not from stack-limit raises.

This is a change of how the points are measured, not a device exception and not a removal of points. The points are registered scoring objects of the spill decision (ad1d505, issue #15); its author agreed to the change in issue #21 on four conditions, all part of this registration:

  1. It is registered before any capture, with the number of allocations fixed (N below).
  2. The first GB10 0.23.0 capture stays recorded as failing rule 3 for spill-latency; it is not rewritten.
  3. Each point still has one extra_ns_vs_zero, so that scripts/spill_decision.py reads the profile unchanged. The profile's existing spill fields keep their shape; the implementation adds a test that runs the read path of spill_decision.py on a merged output of this method.
  4. Each point stores the span of its per-allocation medians, and the level spread (about +/-15% on GB10) goes into design.md 9.2 as a known limit.

Design​

  • Each spill-latency process reads every point with reloads (all six frames, both dependency modes, 8, 32, 68 and 128 reloads: 48 points) in N local memory allocations, N = 15, each in a new context (cudaDeviceReset) at the default stack limit, at the frozen steps of the point, 15 samples and 3 warm-ups per allocation, in the usual point order within an allocation. The first allocation is the process's first context.
  • Within an allocation a point is read as now (15 samples) and summarized by their median. The point's estimate is the mean of its N per-allocation medians. So that rules 1 to 3 and long_capture.py still see 15 samples per point, the point's sample j is the mean over the N allocations of their j-th smallest sample: the median of these 15 samples is exactly the mean of the per-allocation medians, and their spread is the within-allocation spread, averaged over allocations. Every allocation's samples are kept in the raw output (allocation_launch_ns, a list of N lists, named without the _samples suffix so that the merge and profile_launch.py do not take it for a value), with the allocation's context index.
  • Each point also records, as a description that no rule judges, the span of its N per-allocation medians over their median: in the raw output, and in the profile as an optional allocation_span on the spill point (the schema gains this optional field; every existing field keeps its name, type and meaning, so readers of the profile, spill_decision.py included, are unaffected).
  • The points without reloads are read once, in the first allocation, as now.
  • In the profile, a point's per-step time (iter_time_ns) has a rel_uncertainty of at least half the span of all its per-allocation medians over the valid rounds (the largest minus the smallest of the 5 x N per-step medians, pooled), divided by its value; its extra_ns_vs_zero at least the same absolute half-span divided by its value, and its ns_per_reload (the extra over the reload count) the same relative uncertainty as the extra. (Wording aligned after registration and before any capture: the half-span is per step and ns_per_reload per reload, so the earlier "same absolute half-span divided by their own values" was not consistent for it; the design is unchanged.) The usual uncertainty is kept where it is larger, and every value is capped at 1, the schema's maximum. This makes the uncertainty cover the allocation levels.
  • The 1.0 ms rule applies to real launches: long_launch.verify checks every one of a point's N x 15 launches in the raw output (225 per point and round), not only the rank means, and the profile's launch.min_ns is the shortest of those real launches over the valid rounds.
  • One method for every point with reloads, so that no frame is a special case: the 4 KiB frames need it, and the small frames lose nothing by it (at an unchanged stack limit the batched 512 B point at 128 reloads differed by at most 1.4% between allocations).

Why the mean, N = 15, and samples by rank​

The quantity estimated is the reload latency's expectation over local memory allocations. The levels of the allocations come in clusters; the mean of the per-allocation medians is a consistent estimate of that expectation, while the median of a small number of allocations jumps between clusters. Each allocation is still summarized by the median of its 15 samples, so the mean is taken over allocation medians, not over raw launches.

N was chosen before any capture of this design, with reference to the diagnostic's 18 allocation levels (resampled into five processes, rule 3 passing when the five process values span at most 10%): the mean over N allocations passes with probability 0.93 at N = 12 and 0.97 at N = 15 (with the 18 levels themselves resampled, the 10th percentile at N = 12 is 0.85); the median over allocations, which the brief and the agreement in issue #21 first named, reaches 0.96 only at N = 45. N = 15 is fixed here. The author of the spill decision agreed in issue #21 to the mean over 15 fresh contexts. Only 6 of the 18 levels come from new contexts at an unchanged stride; the others come from stack-limit raises, which also change the stride between frames (the post-hoc note of the diagnostic, e264c84: the batched 512 B point at 128 reloads takes 1.75 ms at 4 and 5 KiB of stack and 1.29 ms at 6 KiB and at the default). That is why allocations here come from new contexts, and why the adoption check is the only test of these choices; N is not changed after it.

The samples by rank keep rules 1 and 2 on what they judge, the spread of repeated launches in one setting. The alternative, sample j as the mean of the allocations' j-th samples in launch order, would mix allocations within each sample and narrow the spread by averaging: estimated on the first capture's seven rounds taken as allocations, it would keep the serial 1 KiB points under rule 1 in 27% to 74% of draws, while samples by rank flag all four in every draw. It is not used, because it would pass rule 1 by averaging rather than by stable launches.

The points without reloads and the launch cost of PR #19​

The points without reloads stay as they are because they do not move with the allocation (spans 0.004 to 0.007 at 4 KiB and 0.003 to 0.005 at 512 B). extra_ns_vs_zero then subtracts a single-allocation zero point from an allocation-averaged point, which is consistent because the zero point is the same in every allocation. The launches with no steps of PR #19 time the per-launch frame cost, which is the cost the zero point carries; it does not move with the allocation either, so the cost taken out per step is unchanged.

The serial 1 KiB points​

The four serial-chain points at 1 KiB frames with reloads take one of two states per launch within one allocation, a rule 1 problem unrelated to the allocation level. They are kept, measured by the same method, and covered by a device exception registered separately and checked together with this design: v0.3-gb10-spill-serial-boundary-exception-registration.md. The earlier offline account of 8 failing points out of 56 (four serial points left out, rule 3) belongs to the old single-allocation measurement and is not used here.

Adoption check​

This check decides this design and the serial 1 KiB exception together.

  • GB10, a long-launch capture of spill-latency alone with microbench/long_capture.py: pilot and 5 rounds, with the usual gates and the protocol's limit of 2 extra rounds.
  • Rules 1 and 3 are judged without the four excepted points and rule 2 on all 60 (the exception's registration). Adopted when all 5 valid rounds pass rules 1 and 2 and rule 3 passes across them. Otherwise this design and the exception are both withdrawn and the mode stays as it is; N is not changed and the check is not repeated.
  • Reported either way: every point's per-allocation spans, the rule counts per round, and which points fail.

Limits​

This design reports the level averaged over local memory allocations. A real kernel runs in one allocation and lands on one level: on GB10 the 4 KiB reload points moved with a standard deviation of 10% of the mean over 18 allocations (from 12% below to 22% above it; 12 of these allocations came from stack-limit raises). This goes into design.md 9.2 as a known limit of the reload latency (condition 4; the wording is the core owner's). The design does not explain why the level depends on the allocation, nor the stride effect of the stack limit, which a kernel with a larger stack would meet.

The batched 1 KiB points at 68 and 128 reloads are not in the exception: they do not take two states (no sample above 1.4 times their lower quartile in ten processes) but are wide (interquartile range 6% to 18% of the median). With the four serial points left out, rule 1 judges 56 lists and allows 2 failures; in the first capture these two batched points made 2, 2, 2, 1, 1, 0 and 2 failures in the seven rounds, at the limit in four. With samples by rank, the first capture's rounds taken as allocations make the point at 128 reloads flag rule 1 in 99% of draws and the point at 68 reloads in 22%. One more failing list in a round makes the check fail. If it fails, both registrations are withdrawn; neither promises a further plan.