Conventions scratchpad · NVIDIA/hyperflare-inference #582

Raw Markdown for agents: https://autobot.eidonix.com/p/328bba71-2836-434e-9afc-763c5534b8af.md

#1 [high] Should fix: helios/README.md left stale on anchor selection (third copy of the spec)

The anchor-selection contract is stated in four places. This PR updates three: docs/cli-design.md:700-711, docs/core-design.md:1435-1445, docs/scheduling-runtime-design.md:551-561. It leaves helios/README.md:372-379 unchanged:

"Checkpoint selection prioritizes the last eligible message boundary, using the prompt end when no message boundary is eligible. Earlier messages and a distinct prompt end compete within a work allowance of scheduler_checkpoint_extra_work_fraction times estimated uncached prefill work, defaulting to 0.05. ... Unknown costs exclude extras while preserving best-effort anchor retention."

That now contradicts the code on both new rules:

Precedent for keeping the copies in sync: the recent checkpoint PRs updated the prose copies together (#568 touched 5 shared files; #550/#426 same area). docs/api.md:696 only cross-references core-design, so it is fine.

Fix: add the two conditions to helios/README.md:372-379 in the same wording used in docs/cli-design.md:703-709, or replace that paragraph with a cross-reference to docs/core-design.md#exact-endpoint-capture.

#2 [high] Should fix: effective anchor is now derived in three places instead of one

Before the PR there was one definition of the anchor: LiveRequest::checkpoint_anchor() (checkpoints.rs:109-116), used by selection, plan_checkpoints, promote_request_anchor and the inbound role classification. The PR adds two more derivations:

  1. checkpoint_selection_uncached (checkpoints.rs:467-511) computes the effective anchor and memoizes it in accounting.anchor_fallback_from.
  2. plan_checkpoints (checkpoints.rs:671-685) re-derives it: takes the Anchor cut, else accounting.anchor_fallback_from == Some(raw_anchor) ? prompt_tokens : raw_anchor.
  3. is_request_anchor_endpoint (checkpoints.rs:390-420) re-derives it a third time for the inbound ticket role (scheduler.rs:1794) and for promote_request_anchor (checkpoints.rs:757-767), but with a different interval: it prices 0..prompt_tokens (line 415) while selection prices start..prompt_tokens (line 478) or baseline_start..prompt_tokens (line 495). It also ignores the anchor_fallback_from memo except as the Some(raw_anchor) early accept, so it must recompute whenever selection has not yet run (the inbound path runs during admit, before any planning).

The consequence is visible in section 2 and 3 of zero_fraction_aligned_interior_anchor_and_mixed_prefill_preserve_exact_contracts (checkpoints.rs:2757+): the tests have to assert the promotion path separately because it does not share selection's decision. Two verdicts for the same request/endpoint pair can disagree when consumed_tokens != 0 and the per-chunk pricing differs from the whole-prompt pricing (e.g. re-admitted or restored requests).

Fix: expose one function that returns the effective anchor for a request (taking start/baseline as parameters and reusing the memo), and have selection, plan_checkpoints, the inbound classification and promotion all call it. That also removes the closure at checkpoints.rs:675-683.

Note on severity: I did not construct a failing case where the two derivations disagree with observable effect; a test that admits an inbound ticket for a zero-budget request whose interior boundary prices zero for the whole prompt but not for consumed..prompt (or the reverse) would settle it.

#9 [high] Research summary

Reviewed all 7 changed files (helios/src/scheduler.rs, checkpoints.rs, checkpoint_lifecycle_tests.rs, three docs, verification/helios-lifecycle/check.py) in context against the charter, AGENTS.md, docs/design-review.md and the repo-prose skill, and recorded 8 scratchpad notes: 2 "should fix", 2 more "should fix"-level duplication notes, 3 nits, and 1 note listing what I checked and found consistent.

Headline findings, all duplication/convention in kind rather than behavioural:

#10 [high] Report summary: findings in severity order, with the one-line ask

Lens: conventions and duplication. Verdict: no blocking finding; the change is conventional where it matters (mutation-guard registration, accounting field lifecycle, early-return shape) and the real problems are that one definition of "the anchor" became three derivations, and one spec paragraph exists in four places while only three were updated.

Ordered findings (entry numbers are scratchpad notes):

  1. Should fix — helios/README.md:372-379 stale (note 1). Same paragraph as docs/cli-design.md:700-711 / core-design.md:1435-1445 / scheduling-runtime-design.md:551-561, all three updated, README not. Now contradicts checkpoints.rs:460-462 (zero capacity) and 467-511 (zero fraction). Fix: port the two conditions into the README paragraph, or replace it with a cross-reference to docs/core-design.md#exact-endpoint-capture.
  2. Should fix — anchor derived three ways (note 2): checkpoints.rs:467-511, the closure at 671-685, and is_request_anchor_endpoint at 390-420 whose pricing interval (0..prompt, line 415) differs from selection's (start..prompt, 478; baseline_start..prompt, 495) and which re-derives because the inbound path runs during admit (scheduler.rs:1794) before planning. Fix: one effective-anchor function reused by all four call sites. Not proven to misdecide in a runnable case; a test admitting an inbound ticket for a zero-budget request with nonzero consumed_tokens would settle it.
  3. Should fix — anchor_split_is_zero_cost (364-388) duplicates candidate-loop split pricing (557-591) minus the between cache, and turns unknown into "not zero" without touching stats.checkpoint_skip_unknown_cost (note 3). Fix: one Option split helper, compare to zero at the call site.
  4. Should fix — complete_test_step (1942-2018) is a fourth completion-record driver alongside policy_tests.rs:162, boundary_tests.rs:93, checkpoint_lifecycle_tests.rs:94; hardcodes 3 speculative tokens (1959) (note 4).
  5. Nit — new tests rebuild GraphDescriptors that extra_graphs()/walk_scheduler (1094-1138) already build (note 5).
  6. Nit — duplicated catalog + terminal_window derivation at 406-410 and 446-450 (note 6).
  7. Nit — three doc updates name the same object three ways; cli-design inserts the zero-capacity sentence mid-paragraph (note 7).

Clean (note 8): check.py:325-343 mutation registration matches existing entries at 296/318; early return at checkpoints.rs:460 keeps the initial_prefill_ns contract of other early returns (520-525); anchor_fallback_from cleared only via clear_reservations (line 49) as used by scheduler.rs:1726; docs/api.md:696 only cross-references core-design so needs no edit.

Lead the report with finding 1: it is a one-file docs contradiction any reviewer can confirm from the diff, and if nothing else is fixed this one should be.

#3 [medium] Should fix: anchor_split_is_zero_cost duplicates the candidate-loop split price

anchor_split_is_zero_cost (checkpoints.rs:364-388) is a near-copy of the split pricing already inline in checkpoint_selection_uncached's candidate loop (checkpoints.rs:557-591):

let split = if endpoint == right { Some(0) } else {
    let whole = ...interval_prefill_ns(left, right)...;
    whole.and_then(|whole| {
        let before = interval_prefill_ns(left, endpoint)?;
        let after  = interval_prefill_ns(endpoint, right)?;
        Some(before.saturating_add(after).saturating_sub(whole))
    })
};

The new helper does exactly before + after - whole == 0 but with three differences worth noting:

Fix: factor the split price into one helper returning Option<u64> (fn split_prefill_ns(request, catalog, terminal_window, left, endpoint, right, known_whole) -> Option<u64>) and let both the candidate loop and the zero-cost test use it, comparing to zero at the call site. Precedent for the pattern: reference_interval_prefill_ns (checkpoints.rs:1023) exists precisely because a second pricing walk was suspected of drifting from the first.

#4 [medium] Should fix: complete_test_step is a fourth copy of the test step driver

Three test-driver helpers now exist that build CompletionRecords from a ScheduledPlan:

The new one is the closest yet to policy_tests::complete_timed and to boundary_tests::run_step; checkpoints.rs tests sit in the same crate and could reach either if made pub(super). Differences from its neighbours: it hardcodes up to 3 speculative tokens (GraphKind::Speculative => 3.min(lane.tokens)..., line 1959) instead of taking an accepted parameter, and it publishes output. The hardcoded 3 couples the balanced-batch test (balanced_c16_short_prompts_skip_interior_anchor_tails_and_reach_full_batch, line 2450) to enable_speculation(&[1, 2, 4, 8]) widths.

Fix: either take the accepted-count as a parameter, or hoist one complete_test_step-style helper into scheduler/tests.rs (already the shared home for scheduler()/duration_graphs) and have policy_tests/boundary_tests/checkpoints use it. Precedent: tests::duration_graphs (helios/src/scheduler/tests.rs:157) is shared across all four test modules for exactly this reason.

#5 [low] Nit: new tests rebuild graph descriptors that extra_graphs() already builds

Both new tests that drive a full request to decode reproduce policy_tests' engine construction instead of using the existing helpers:

Nit-level because tests, but the duplication is the same "second copy of a graph-catalog builder" pattern that extra_graphs was introduced to remove; a new GraphDescriptor field would now need editing in four places in this file.

#6 [low] Nit: duplicated catalog + terminal_window derivation

checkpoints.rs:406-410 and :446-450 are now character-identical:

let terminal_window = if request.prompt_logprobs { 0 } else { self.terminal_prefill_window() };

(is_request_anchor_endpoint and checkpoint_selection_uncached). The same three-line idiom also exists in the test path at checkpoints.rs:1029 for the catalog choice, and the catalog choice itself (request.prompt_logprobs ? scored_prefill_catalog : prefill_catalog) is duplicated in prefill_catalog_costs (line 164).

Fix: a fn pricing_inputs(&self, request) -> (Vec<PrefillCatalogCost>, usize) (catalog + terminal window) used by all three call sites; it also states once that scored-prefill requests price with no terminal window. Precedent: prefill_catalog_costs was itself introduced to read catalog state once per selection (doc comment lines 160-162), so a second, separately-written copy of the sibling derivation works against that intent.

#7 [low] Nit: inconsistent terminology and sentence placement in the three doc updates

The three updated paragraphs use three different names for one object: "the last eligible message endpoint" (docs/cli-design.md:703), "the last eligible complete-message boundary" / "interior message boundary" (docs/core-design.md:1436-1441), "the last eligible completed message" / "interior message boundary" (docs/scheduling-runtime-design.md:555-558). The code calls it message_boundaries / checkpoint_endpoint_eligible (checkpoints.rs:109-125).

Also in docs/cli-design.md:700-711 the new sentence "Zero snapshot capacity disables all checkpoint cuts." is inserted in the middle of the anchor paragraph, between the anchor rule and the sentence "Earlier messages and a distinct prompt end consume the fraction...", so the paragraph no longer reads in the order anchor → extras → accounting it describes.

Nit: pick one term ("message boundary") for the three docs and move the zero-capacity sentence to the end of the paragraph, matching core-design.md's ordering (anchor rule, then zero capacity, then earlier boundaries).

#8 [low] Checked and clean: check.py registration, early return, field reset, api.md

Verified as consistent with existing precedent (no finding):