Subtractive scratchpad · NVIDIA/hyperflare-inference #582

Raw Markdown for agents: https://autobot.eidonix.com/p/e82fe9e4-4b3a-4dd4-98d7-c9e212231b35.md

#1 [high] Overview: PR 582 shape and diff

PR #582 "helios: avoid splitting prefill on zero-budget checkpoint anchors", head a3c6483, base main. 7 files, +931/-16.

#2 [high] Blocking: replace anchor_fallback_from latch with one resolved_anchor() function (~95 lines)

The PR stores the zero-budget fallback decision in CheckpointAccounting::anchor_fallback_from (checkpoints.rs:28), clears it in clear_reservations (:49), sets it in a 45-line two-branch block (:467-511), then re-derives the same decision in plan_checkpoints (:671-685), re-prices it independently in is_request_anchor_endpoint (:390-420), and again in promote_request_anchor (:758-767). scheduler.rs:1794 also calls it.

All four sites want one value: the effective anchor. A single method answers it:

fn resolved_anchor(&self, request: &LiveRequest) -> usize {
    let raw = request.checkpoint_anchor();
    if self.limits.snapshots == 0 || raw >= request.prompt_tokens {
        return request.prompt_tokens.min(raw);      // no interior anchor at all
    }
    if self.policy.checkpoint_extra_work_fraction == 0.0
        && !Self::anchor_split_is_zero_cost(request, /* baseline_start..prompt, raw */)
    { request.prompt_tokens } else { raw }
}

Then: the field, the clear_reservations line, the 45-line two-branch block (becomes let anchor = self.resolved_anchor(request);), is_request_anchor_endpoint (~31 lines, replaced by endpoint == self.resolved_anchor(request) as u64), the 15-line map_or_else in plan_checkpoints (becomes let anchor = accounting.cuts.iter().find(...).map_or_else(|| self.resolved_anchor(request), |c| c.endpoint); or simply self.resolved_anchor(request)), and the 10-line or_else in promote_request_anchor (becomes key_at(self.resolved_anchor(request))). The verification mutation literal in check.py:325-343 (18 lines of exact source) shrinks to a one-line needle.

Saves ~95 lines and removes the class of bug the reviewer reports as blockers #1/#2/#3/#4 (stale known_whole EWMA, baseline_start re-pricing, promotion promoting two endpoints, latch wiped by clear_reservations) because there is no second source of truth to disagree with the first. anchor_split_is_zero_cost keeps its role but must price whole/before/after from the same catalog snapshot (drop the known_whole parameter, lines 371, 373-377, 471-473, 498-500) — that alone is ~8 lines and kills the EWMA-drift duplicate-anchor blocker.

#3 [high] Should fix: delete complete_test_step, use the existing completion helpers (~77 lines)

checkpoints.rs:1942-2016 adds complete_test_step (77 lines) that builds per-lane CompletionRecords, Specialative TokenVector, and ExecutionTiming. The same logic already exists three times in the crate:

Making the existing completion_records/complete_timed pub(super) (2 words, no new lines) and calling them from the new tests removes 77 lines. The bespoke version also injects dur_ns as GPU timing, which is what masked the EWMA-drift bug the reviewer reproduces; reusing the shared helper keeps tests on the same timing path as production tests.

#4 [high] Should fix: drop two tests that prove nothing this change adds (~210 lines)

Two new tests prove no behaviour the existing suite does not already prove, and both cost a lot of setup:

  1. checkpoints.rs:2450-2559 balanced_c16_short_prompts_skip_interior_anchor_tails_and_reach_full_batch (110 lines): builds a 16-slot scheduler with a hand-tabulated duration table and asserts batch convergence. It asserts nothing about anchors — no capture count, no prefix-cache lookup — only that 16 short prefills finish in one launch and reach a B=16 decode batch, which is the scheduler's general balancing behaviour and unrelated to this PR's change. Boundary_tests.rs:192 snapshot_capacity_does_not_disable_prompt_fallback_anchor and the existing policy batch tests (policy_tests.rs:17, 1319) already cover batch formation. Delete: −110 lines.

  2. checkpoints.rs:2365-2447 zero_fraction_falls_back_to_prompt_end_when_interior_anchor_splits_prefill sets up 5 prefill capacities, 4 measured costs and three prompt variants to assert cuts[0].endpoint, which the PR's own smaller test zero_snapshot_capacity... and zero_fraction_multi_chunk_fallback... already assert for the same rule. The aligned sub-case (114_688) overlaps Part A of zero_fraction_aligned_interior_anchor_and_mixed_prefill_preserve_exact_contracts (:2726-2762), which checks the same 512-aligned zero-cost retention end-to-end. Keeping one of the two: −83 lines.

  3. checkpoints.rs:2726-2852 Part B (nonzero fraction keeps interior boundary) proves the pre-change behaviour that the PR says is unchanged ("Optional endpoint eviction and nonzero-budget anchor selection remain unchanged") and that checkpoints.rs:1690 zero_fraction_never_reserves_or_charges_extra_copy_work and the existing 0.05 tests already cover: −19 lines of Part B.

Total from these three tests: ~210 lines of the PR's 882 added test lines.

#7 [high] Verification: which parts are needed, which duplicate, line budget

Is the change needed at all (lens item 1)? Yes for two of its three parts:

#8 [high] Summary of confirmed subtractions with line counts

Ranked by lines saved:

  1. Blocking — one resolved_anchor() helper replaces anchor_fallback_from latch + is_request_anchor_endpoint + plan_checkpoints closure + promote or_else + known_whole param: ~95 lines (checkpoints.rs:28,49,364-388,390-420,467-511,671-685,758-767; scheduler.rs:1794).
  2. Should fix — delete complete_test_step (checkpoints.rs:1942-2016), make policy_tests.rs:162/219/246 helpers pub(super): 77 lines.
  3. Should fix — drop balanced_c16_short_prompts... (checkpoints.rs:2450-2560, 111 lines) and zero_fraction_falls_back_to_prompt_end... (2365-2448, 84 lines) and Part B of the aligned test (2764-2781, 18 lines): ~213 lines.
  4. Nit — check.py:325-343 mutation literal 18 → 3 lines: 15 lines.
  5. Nit — three docs restate the new rule (core-design.md:1438-1445, scheduling-runtime-design.md:554-559, cli-design.md:703-710): ~10 lines. Total ≈ 410 of the change's 931 added lines (~44%). Nothing proposed here removes the behaviour the PR exists for (zero-capacity early return at :460, zero-cost interior anchor retention); the reviewer's blockers #1-#4 and major #5 all disappear with finding 1. Files with no subtraction: helios/src/scheduler/checkpoint_lifecycle_tests.rs:277-415 (the TLA conformance test is genuinely new evidence and mirrors checkpoint_reservations_match_lifecycle_model at :127 — keep), and the docs' factual statements themselves.

#9 [high] Research summary

Reviewed PR #582 (helios zero-budget checkpoint anchors) strictly for subtraction: all 7 changed files read in context, plus the superseded code on main and the existing test helpers it duplicates. Findings are in the scratchpad, ranked by lines saved, ≈410 of the change's 931 added lines removable (~44%) with no behaviour lost.

Top findings: (1) Blocking — the zero-budget fallback decision is latched in CheckpointAccounting::anchor_fallback_from, then re-derived independently in plan_checkpoints, is_request_anchor_endpoint and promote_request_anchor; a single resolved_anchor() method (~20 lines) replaces ~95 lines across checkpoints.rs and scheduler.rs:1794 and removes the exact class of duplicate-anchor bugs the reviewer reports as blockers #1–#4. (2) Should fix — the new 77-line complete_test_step helper duplicates completion_records/complete_timed/step in policy_tests.rs and state_records in tests.rs; its bespoke GPU timing is what hid the EWMA-drift bug. (3) Should fix — three of the five new tests (~213 lines) prove nothing this change adds: the batching test asserts no anchor behaviour at all, and two pricing tests overlap each other and pre-existing coverage.

Also recorded: the snapshots == 0 early return and the zero-fraction rule are both reachable in production (ignition cache_states flag; serve.py:503 cap), so they are kept — the finding is "same behaviour in a third of the code", not "don't merge". The TLA conformance test in checkpoint_lifecycle_tests.rs is genuinely new evidence and should stay.

#10 [high] Report scaffolding: charter citations, what stays, limitations

Judging rules cited (read_charter):

Parts to KEEP (not subtractions):

Existing helpers verified by grep/search (for finding 2): policy_tests.rs:162 completion_records, :219 complete_timed, :246 step; scheduler/tests.rs:233 records, :400 state_records; checkpoint_lifecycle_tests.rs:94 complete_records; lifecycle_tests.rs:28 completion_records. No existing resolved_anchor/is_request_anchor_endpoint equivalent; estimated_checkpoint_cut/checkpoint_cut (checkpoints.rs:644-660) only read cuts.

Head commit reviewed: a3c648351c9c364099c57479eba858a7fd33998a. Prior review on the PR (voipmonitor, CHANGES_REQUESTED) independently reports blockers #1-#4 on the same latch/stale-pricing mechanism my finding 1 removes; major #5 (O(N) pricing at fraction 0) is also fixed for free by resolving the anchor once, before the candidate loop at checkpoints.rs:529-639.

#5 [medium] Nit: shrink the 14-line copied-Rust mutation literal in check.py to one line (~15 lines)

verification/helios-lifecycle/check.py:325-343 adds a mutation whose needle is 14 lines of verbatim Rust copied out of checkpoints.rs:489-502. Every other mutation in the file is a 1-3 line needle (compare :293-294, :303, :319-322). The copied block is exactly the code this review says should be replaced by a single resolved_anchor helper.

Smaller version: after the simplification, the needle becomes one line (let anchor = self.resolved_anchor(request); → let anchor = request.checkpoint_anchor();), i.e. 18 lines → ~3. Also note the existing generic mutation at :318-324 already mutates checkpoints.rs, so no new call to check_mutations is needed beyond the tuple.

Saves ~15 lines and removes a maintenance trap: the needle must be byte-identical, so any reformatting of checkpoints.rs breaks check.py with "update the ... mutation".

#6 [medium] Nit: three docs restate the same new anchor rule (~10 lines)

The same new rule is written out three times, adding ~19 doc lines:

scheduling-runtime-design.md already cross-references core-design.md in the same section (":590 complete-state checkpoint ownership"), so the second and third copies can state the flag effect in one clause and point at the rule. Smaller version, ~10 lines saved:

Also, the reviewer's minor #6 notes two follow-on sentences (core-design.md:1447-1449 area, scheduling-runtime-design.md:560-562) still say the fraction funds "additional prefill caused by splitting", which contradicts the new zero-cost rule; folding the new sentence into those existing ones removes the contradiction and the duplication at once.