Correctness scratchpad · NVIDIA/hyperflare-inference #582

Raw Markdown for agents: https://autobot.eidonix.com/p/df87f0ef-9bd2-46fe-8551-3538ada9506a.md

#1 [high] Should fix: zero-fraction anchor fallback decision uses two different interval starts, so it can flip and emit a duplicate prompt-end Anchor

File: helios/src/scheduler/checkpoints.rs:467-511 (new anchor selection in checkpoint_selection_uncached), plus :405-419 (is_request_anchor_endpoint), :753-776 (promote_request_anchor).

Two code paths decide "does the interior message boundary lose to the prompt end?" with different interval starts:

start equals baseline_start only on the first selection after a fresh admission (CheckpointAccounting::for_epoch sets baseline_interval = (consumed, prompt), and start = consumed). It does not hold when the request is preempted and re-admitted with carried accounting: runtime.rs:2739-2746 / 2750-2790 pass Option<CheckpointAccounting> back through admit_planned_with_checkpoint_accounting (scheduler.rs:1592-1597), which preserves baseline_interval (checkpoints.rs:441) while start becomes the new, larger consumed_tokens (scheduler.rs:1726 clear_reservations() also nulls anchor_fallback_from, so there is no persisted decision to fall back on).

Consequence: branch A can price the split over the short interval [start, prompt] and conclude zero-cost (keeping the interior anchor at raw_anchor, committing that Anchor cut and publishing it), and after prefill passes raw_anchor branch B re-prices over [baseline_start, prompt], concludes nonzero, sets anchor_fallback_from = Some(raw_anchor) and pushes a cut at request.prompt_tokens — a second Anchor capture at prompt end. That is exactly the duplicate prompt-end anchor the PR claims to avoid ("Zero-cost aligned interior anchors remain eligible without adding a duplicate prompt-end anchor"), and it spends an extra padded prefill launch + snapshot row in the budget the PR wants to protect. Similarly is_request_anchor_endpoint's 0 start disagrees with checkpoint_selection, so promote_request_anchor and the inbound ticket role (scheduler.rs:1794) can call prompt end "the anchor" while selection still treats raw_anchor as the anchor, promoting/stamping a checkpoint as Anchor that selection never chose.

Fix: use one interval start for the decision everywhere — baseline_start in all three places (the first chunk when start == baseline_start prices identically), or thread the decided interval through CheckpointAccounting instead of re-deriving it. A test that preempts a zero-fraction request after its interior anchor cut commits, re-admits it with the carried CheckpointAccounting, and asserts no prompt-end Anchor capture would settle it; the new tests in this PR (checkpoints.rs:2483-2880) only cover uninterrupted single-admission flows, and checkpoint_lifecycle_tests.rs:277-410 only covers one admission.

#3 [high] Coverage note: files read, checks that came out clean, and open items

Files reviewed in context (lens: correctness):

Checked and found correct (no finding): the snapshots == 0 early return does not leak reserved_ns or leave a stale cut; clear_reservations now also resets anchor_fallback_from; estimated_checkpoint_cut (quote-free) and checkpoint_cut share the same accounting so policy's prefill_work_through cut and plan_checkpoints stay consistent; the zero-cost verdict uses the same prefill_catalog_costs and terminal_prefill_window (incl. prompt_logprobs ⇒ terminal_window 0) as real pricing; anchor_split_is_zero_cost returns false (i.e. falls back to prompt end) whenever a price is unknown, which is the conservative direction under a zero budget.

Open items I could not settle before the limit:

  1. Whether Mixed lanes and window-restore (conditioned_windows) paths reach branch A with start != baseline_start on their very first selection, which would widen finding 1's exposure beyond preemption/re-admission.
  2. Whether promote_request_anchor's new prompt-end fallback (checkpoints.rs:762-767) can promote a prompt-end checkpoint for a request whose real ancestor prefix is shorter, i.e. the ready_by_prefix hit at prompt end belonging to a different lineage. Settling it needs a runtime trace or a test with two prompt-end checkpoints of different histories.
  3. The three new heavyweight tests (checkpoints.rs:2313-2880) were read but not executed here; the PR reports them green.

#2 [medium] Should fix: is_request_anchor_endpoint re-walks the whole prefill interval on every commit lane and every admit

File: helios/src/scheduler/checkpoints.rs:390-420, called from scheduler.rs:1794 (admit_planned) and from promote_request_anchor (checkpoints.rs:763), which scheduler.rs:2411 runs as for lane in &step.lanes { self.promote_request_anchor(lane.request)?; } on every commit.

is_request_anchor_endpoint bypasses the checkpoint_selection_cached result and calls prefill_catalog_costs (allocates a Vec, checkpoints.rs:163-206) plus up to three interval_prefill_ns walks over the full prompt on each call. The only cheap short-circuit is request.checkpoints.anchor_fallback_from == Some(raw_anchor) (line 402), which is None at admission (clear_reservations, line 49) and until the first checkpoint plan commits, and is permanently None in the aligned-interior-anchor case where the split is genuinely zero cost — precisely the case the PR wants to keep. So for zero-fraction requests with an aligned interior boundary, every decode commit of every lane pays a full-interval re-price even though the answer cannot change (it depends only on prompt, boundaries, spans, window ends and measured costs).

Correctness impact: none, but it is on the commit hot path next to plan(), and it contradicts the module's own caching design (SelectionCache, checkpoints.rs:11-19, and the checkpoint_planning_scope at policy.rs:1208/1453 which exists to bound selections per planning round). Note the tests that count selections (waiting_prefills_do_not_simulate_checkpoint_storage, scheduler/tests.rs:257-311, and STRIDE_RUNS) do not cover this new path.

Fix: answer from checkpoint_selection(request)'s accounting (it already records anchor_fallback_from) and/or memoize the zero-cost verdict on the request for the current (prompt_tokens, raw_anchor, window_ends, span) shape.