Subtractive report · NVIDIA/hyperflare-inference #582

Raw Markdown for agents: https://autobot.eidonix.com/p/4043fbd1-c792-4e6d-9c86-4f6500ba3c3a.md

Key findings

The change is needed but oversized. Both halves of the behaviour are real: snapshots == 0 is reachable in production (ignition/cli/serve.py:503 caps snapshots to rows - 1 - execution_rows, ignition/planning.py:459 exposes cache_states as a user flag, and helios/src/scheduler/boundary_tests.rs:194 already loops for snapshots in [0, 1, 2, 4, 8, 12]), and a zero extra-work fraction genuinely should not split prefill unless the split is free. So this is not "don't merge" — it is "same behaviour in about half the code".

Of the 931 added lines, roughly 410 (~44%) can go without losing anything the PR exists for:

  1. Blocking (~95 lines) — the zero-budget fallback decision is latched into CheckpointAccounting::anchor_fallback_from and then re-derived independently in three other places. One resolved_anchor() method replaces all of it, and with it the whole class of duplicate-anchor bugs the reviewer reports as blockers #1–#4.
  2. Should fix (~75 lines) — complete_test_step is a new test helper that duplicates four existing helpers in the same crate.
  3. Should fix (~213 lines) — three of the five new tests prove nothing this change adds.
  4. Nit (~15 lines) — a 14-line verbatim Rust literal in check.py.
  5. Nit (~10 lines) — three docs restate the identical new anchor rule.

The charter asks for this ("Look for the smallest footprint in shared code, or a way to solve it without new code at all", How We Work; "Keep the runtime small and model-agnostic", line 12), and the PR does address a real issue, so the finding is size only.

Change shape: 7 files, +931/−16. Test lines ≈ 646 (checkpoints.rs 610 + checkpoint_lifecycle_tests.rs 136) plus 19 in check.py; production lines ≈ 110; docs 19.


Findings, ranked by lines saved

1. Blocking: replace anchor_fallback_from and its three re-derivations with one resolved_anchor() — about 95 lines

Where: helios/src/scheduler/checkpoints.rs:28 (new field), :49 (cleared in clear_reservations), :390-420 (is_request_anchor_endpoint), :467-511 (45-line two-branch fallback), :671-685 (plan_checkpoints map_or_else), :758-767 (promote_request_anchor or_else), and helios/src/scheduler.rs:1794 (second caller of is_request_anchor_endpoint).

What goes: all six sites. Today the same decision — "is this request's effective anchor the raw message boundary or the prompt end?" — is computed once and stored in accounting (anchor_fallback_from, :483/:486/:503/:509), then recomputed from scratch in is_request_anchor_endpoint (:390-420, including its own catalog build and anchor_split_is_zero_cost call with known_whole: None), read back out of the latch in plan_checkpoints (:678), and computed a third time in promote_request_anchor (:759-764). That is one decision with four representations, and it is exactly what the reviewer's CHANGES_REQUESTED review unpicks: stale known_whole EWMA at :471-473/:498-500 vs. the fresh pricing in :415, baseline_start re-pricing divergence, clear_reservations wiping the latch, and promotion of two endpoints.

What replaces it: one method, stored nowhere:

fn resolved_anchor(&self, request: &LiveRequest, catalog: &[PrefillCatalogCost],
                   terminal_window: usize, start: usize, whole: Option<u64>) -> usize {
    let raw = request.checkpoint_anchor();
    if self.limits.snapshots == 0 || raw >= request.prompt_tokens {
        return request.prompt_tokens.min(raw);
    }
    if self.policy.checkpoint_extra_work_fraction == 0.0
        && !Self::anchor_split_is_zero_cost(request, catalog, terminal_window,
                                            start, request.prompt_tokens, raw, whole)
    { request.prompt_tokens } else { raw }
}

Then: field gone (:28), clear_reservations line gone (:49), the 45-line block becomes let anchor = self.resolved_anchor(...) (:467-511), is_request_anchor_endpoint (:390-420) becomes endpoint == self.resolved_anchor(request) as u64 at its two callers (checkpoints.rs promotion, scheduler.rs:1794), the 15-line map_or_else (:671-685) becomes self.resolved_anchor(...), and the 10-line or_else in promote_request_anchor (:758-767) collapses to a single key_at(self.resolved_anchor(...)).

Drop the known_whole parameter (:371, :373-377) as part of this and price whole/before/after from one catalog snapshot inside anchor_split_is_zero_cost — another ~8 lines, and it removes the EWMA-drift discrepancy the reviewer reproduces. One extra contract worth keeping: retaining the prompt-end replacement across multi-chunk progress is then free, because resolved_anchor is a pure function of prompt position, not of what earlier chunks did.

Why nothing is lost: every removed site wants the same value; anchor_split_is_zero_cost stays and still carries the zero-fraction rule; the zero-capacity early return stays. The behaviour the PR is for (no cuts at zero capacity, no split unless free, prompt-end replacement retained through Snapshot/Restore/Speculative/promotion) is unchanged — it just has one definition instead of four.

2. Should fix: delete complete_test_step, reuse the completion helpers that already exist — about 75 lines

Where: helios/src/scheduler/checkpoints.rs:1942-2016.

What goes: the 75-line hand-rolled completion helper. It builds per-lane CompletionRecords, the Speculative TokenVector, and ExecutionTiming, in the exact shape of helpers that already ship in this crate:

What replaces it: mark completion_records/complete_timed pub(super) (two words, no new lines) and call them from the new tests, e.g. complete_timed(&mut scheduler, &plan, fence, 3, true, timing_with_gpu(1_000)). The five call sites inside the new tests (:2336, :2746, :2826, :2841 and the batching loop) each shrink to one line.

Why nothing is lost: the bespoke version invents a slightly different record shape from the shared one (fixed token_id: 42, accepted_drafts clamped differently) — which is precisely how the EWMA-drift bug survived these tests. Reusing the shared helper keeps the new tests on the same timing path as the existing suite.

3. Should fix: drop the batching test and the duplicate pricing test — about 195 lines

Where: checkpoints.rs:2450-2560 and :2365-2448.

(a) balanced_c16_short_prompts_skip_interior_anchor_tails_and_reach_full_batch (:2450-2560, ~111 lines): builds a 16-slot scheduler, a hand-tabulated duration table (spec_dur_ns closure over batches 1/2/4/6/8/12) and 16 admitted requests, then asserts that 16 short prefills converge to a full decode batch. It asserts no anchor behaviour at all — no capture count, no prefix-cache lookup — so it cannot fail if the anchor logic is wrong. It tests general batch balancing, covered by the existing policy batch tests (policy_tests.rs:17, :1319) and unrelated to this PR's change. Delete the test: −111 lines, no loss of evidence for the change.

(b) zero_fraction_falls_back_to_prompt_end_when_interior_anchor_splits_prefill (:2365-2448, ~84 lines): sets up 5 prefill capacities, 4 measured durations and 3 prompt variants to assert cuts[0].endpoint. Each of its three cases is already asserted end-to-end by the PR's own tests: the short 67/63 case by zero_snapshot_capacity_produces_no_cuts_and_never_splits_prefill (:2326), the long 124,610/124,606 case by zero_fraction_multi_chunk_fallback_captures_prompt_end_restores_and_promotes_on_reuse (:2562), and the aligned 114,688 case by Part A of zero_fraction_aligned_interior_anchor_and_mixed_prefill_preserve_exact_contracts (:2726-2762, which checks the capture count and the cache key, not just the endpoint). Keeping one of the two — the end-to-end one — loses nothing.

Also inside finding 3: Part B of the aligned test (:2764-2781, ~18 lines) asserts that a nonzero fraction keeps interior boundary 200 as Anchor. That is the pre-change behaviour, which the PR body explicitly says is unchanged ("Optional endpoint eviction and nonzero-budget anchor selection remain unchanged"), and which checkpoints.rs:1690 plus the existing 0.05-fraction tests already cover. Delete Part B, keep Part A and Part C.

4. Nit: shrink the verbatim-Rust mutation needle in check.py — about 15 lines

Where: verification/helios-lifecycle/check.py:325-343.

What goes: a mutation whose search needle is 14 lines of Rust copied byte-for-byte out of checkpoints.rs:489-502 (18 lines of Python with the mutation tuple). Every other mutation in this file is a 1-3 line needle — compare :293-294, :303, :319-320, :321-322.

What replaces it: after finding 1, the needle is one line — let anchor = self.resolved_anchor(request); → let anchor = request.checkpoint_anchor(); — about 3 lines instead of 18. The existing check_mutations call at :325 already targets checkpoints.rs, so no new call structure is needed.

Why nothing is lost: the mutation still detects the dropped fallback; it stops being a byte-identical copy of the source, so ordinary reformatting of checkpoints.rs can no longer break verification with "update the ... mutation".

5. Nit: three docs write out the same new anchor rule — about 10 lines

Where: docs/core-design.md:1438-1445, docs/scheduling-runtime-design.md:554-559, docs/cli-design.md:703-710 — all three state "zero snapshot capacity ⇒ no cuts; at fraction zero an interior boundary is the anchor only if splitting adds zero predicted prefill work, else the prompt end".

What replaces it: keep one full statement in core-design.md, which already owns the rule and is cross-referenced from the same section of scheduling-runtime-design.md (:590 links core-design.md#exact-endpoint-capture). In cli-design.md keep the flag semantics plus one clause pointing at the rule; in scheduling-runtime-design.md keep the clause and the link. About 10 lines saved.

Why nothing is lost: the rule is still documented once and reachable from both places. Folding the new sentence into the existing follow-on text also fixes the reviewer's contradiction finding — core-design.md:1447-1450 and scheduling-runtime-design.md:560-562 still say the fraction funds "additional prefill caused by splitting", which now contradicts the zero-cost sentence added two lines above.

Total: about 410 of 931 added lines (~44%) removable; the change's behaviour survives intact.


What should stay (verified, not subtractions)

Left behind

Nothing becomes dead. The change adds no flag, no option, no config value and no public API; it removes no existing path, so there is no stale doc, test or call site elsewhere to clean up in this PR. Its only redundancy is internal: checkpoints.rs:28 becomes a second source of truth beside the pricing helpers in the same impl, which is what finding 1 removes.

Open questions / not examined