Conventions report · NVIDIA/hyperflare-inference #582

Raw Markdown for agents: https://autobot.eidonix.com/p/613cb4db-871a-424c-8509-211a3f97bca5.md

Review: PR #582 (helios: avoid splitting prefill on zero-budget checkpoint anchors) — conventions and duplication lens

Key findings

No blocking issue. The change is conventional where it matters: the new mutation registration in verification/helios-lifecycle/check.py copies the existing entries exactly, the new CheckpointAccounting field follows the existing reset path, and the new early return preserves the "always carry a prefill price" contract of the function's other early returns (details in "Checked and clean" below).

The real problems are both duplication of the same rule in multiple places:

  1. One specification, four copies, three updated. The anchor-selection paragraph lives in helios/README.md, docs/cli-design.md, docs/core-design.md and docs/scheduling-runtime-design.md. This PR updates three and leaves helios/README.md:372-379 contradicting the code on both new rules.
  2. One definition became three derivations. LiveRequest::checkpoint_anchor() used to be the anchor. The PR adds a memoized re-derivation in checkpoint_selection_uncached, a second re-derivation inline in plan_checkpoints, and a third in is_request_anchor_endpoint that prices a different interval.
  3. anchor_split_is_zero_cost duplicates the split-price expression already inline in the candidate loop, minus its interval cache, and with a different unknown-cost policy.
  4. A fourth completion-record test driver was added rather than reusing one of the three that exist.

Severity ordering below is: the README contradiction first (a one-file docs fix any reviewer can confirm from the diff), then the anchor-triplication, then the split-price and test-driver duplicates, then three nits.


Should fix

1. helios/README.md:372-379 states the anchor rule and was not updated — it now contradicts the code on both new rules

The rule is stated four times in the tree. This PR updates three:

and leaves the fourth unchanged. helios/README.md:372-379 still reads:

"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."

Both halves of that are now false:

Why it matters: helios/README.md is the runtime's own front-door description, and this paragraph is the described contract for --scheduler-checkpoint-extra-work-fraction (its sibling text immediately cross-references ../docs/core-design.md#exact-endpoint-capture at line 383). A reader who trusts the README will expect a padded interior cut at fraction 0 — precisely the bug this PR removes.

Precedent for keeping these copies in lock-step: the neighbouring checkpoint PRs update the shared prose together — #568 ("Bound optional Endpoint checkpoint eviction…", 5 shared files), #550 ("Restore prefix checkpoints on prefill catalogs without terminal prefill"), #426. docs/api.md:696 is fine as is: it only cross-references core-design for anchor priority.

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

2. checkpoints.rs:390-420, :467-511, :671-685 — the effective anchor is derived three times, from three different intervals

Before the PR there was one definition of the anchor for a live request — LiveRequest::checkpoint_anchor() — consumed by selection, by plan_checkpoints, by promote_request_anchor, and by the inbound role classification. The PR adds two competing derivations:

  1. checkpoint_selection_uncached (checkpoints.rs:467-511) computes the effective anchor and records it in accounting.anchor_fallback_from.
  2. plan_checkpoints's closure (checkpoints.rs:671-685) re-derives it from that memo: take the Anchor cut's endpoint, else accounting.anchor_fallback_from == Some(raw_anchor) ? request.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:763), with a different pricing interval: it prices 0..prompt_tokens (line 415), whereas selection prices start..prompt_tokens (line 478) or baseline_start..prompt_tokens (line 495). It also consumes the memo only as the Some(raw_anchor) early accept at line 402, so on the inbound path — which runs during admit, before any planning — it must recompute from the catalog.

Consequences visible in the code:

Fix: one fn effective_anchor(&self, request, start, baseline) -> usize that selection, the plan_checkpoints closure, the inbound classification and promote_request_anchor all call, reusing anchor_fallback_from rather than re-pricing. That also deletes the closure at checkpoints.rs:675-683.

Caveat stated honestly: I did not construct a runnable case where the three derivations disagree with observable effect. What would settle it is a test that admits an inbound ticket (scheduler.rs:1794) for a zero-fraction request with consumed_tokens > 0 whose interior boundary prices zero over consumed..prompt but not over 0..prompt (or the reverse), and asserts the ticket role matches the eventual capture.

3. checkpoints.rs:364-388 — anchor_split_is_zero_cost duplicates the candidate-loop split price with different caching and unknown-cost handling

The new helper is a near-copy of the expression already inline in the selection loop at checkpoints.rs:557-591:

let split = if endpoint == right { Some(0) } else {
    let whole = match between { Some((interval, nanos)) if interval == (left, right) => nanos, _ => … };
    whole.and_then(|whole| {
        let before = interval_prefill_ns(request, &catalog, terminal_window, left, endpoint)?;
        let after  = interval_prefill_ns(request, &catalog, terminal_window, endpoint, right)?;
        Some(before.saturating_add(after).saturating_sub(whole))
    })
};

anchor_split_is_zero_cost computes the same before + after - whole and compares to zero. Three differences matter:

Fix: one fn split_prefill_ns(request, catalog, terminal_window, left, endpoint, right, known_whole) -> Option<u64> used by both the candidate loop and the zero-cost test, with == 0 compared at the call site, and unknown handled in one place.

4. checkpoints.rs:1942-2018 — complete_test_step is a fourth completion-record test driver

Three helpers already build CompletionRecords from a ScheduledPlan:

The new checkpoints.rs:1942 complete_test_step re-implements the same emitted/consumed/status logic, adds output publication, and takes dur_ns for ExecutionTiming.gpu_ns[0]. It is closest to complete_timed. Two conventions depart:

Fix: hoist one shared driver (a natural home is helios/src/scheduler/tests.rs, which already shares duration_graphs at :157 and scheduler() across all four modules) and parameterise accepted; or at minimum take accepted as a parameter here.


Nits

5. New tests hand-build GraphDescriptors that extra_graphs() already builds

zero_fraction_falls_back_to_prompt_end_when_interior_anchor_splits_prefill (checkpoints.rs:2382-2398) rebuilds a scheduler with RequestScheduler::new(…, SchedulerLimits{..template.limits}, template.capabilities.clone()) and pushes hand-written descriptors for the two larger prefill capacities. The graph closure in extra_graphs() (checkpoints.rs:1094-1116) builds exactly that shape (tuned_bindings, confidence_width, draft_tokens, packed_token_capacity, sampling_mode, prefill_capacity), 1,250 lines above in the same file. Likewise Part C of zero_fraction_aligned_interior_anchor_and_mixed_prefill_preserve_exact_contracts (:2793+) hand-builds a GraphKind::Mixed descriptor that extra_graphs() already provides (:1114 graphs.push(graph(GraphKind::Mixed, 2, 1, 512))), and walk_scheduler (:1118-1138) already registers it via mixed_graphs(&[(2, 1, 512)]). Consequence: adding a field to GraphDescriptor now requires edits in four places in this file.

6. Duplicated catalog + terminal_window derivation

checkpoints.rs:405-410 (is_request_anchor_endpoint) and :445-450 (checkpoint_selection_uncached) are character-identical:

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

The sibling catalog choice (request.prompt_logprobs ? scored_prefill_catalog : prefill_catalog) is likewise duplicated between prefill_catalog_costs (:163-168) and the new function's call. A single fn pricing_inputs(&self, request) -> (Vec<PrefillCatalogCost>, usize) would state once the invariant "scored-prefill requests price with no terminal window" and remove the risk of the two drifting — the same motivation that the prefill_catalog_costs doc comment gives for its own existence.

7. The three updated docs name one object three ways; cli-design.md inserts the sentence mid-paragraph

The code calls these message_boundaries / checkpoint_endpoint_eligible. Pick one term. Separately, docs/cli-design.md:700-711 puts "Zero snapshot capacity disables all checkpoint cuts." between the anchor rule and "Earlier messages and a distinct prompt end consume the fraction…", breaking the paragraph's anchor → extras → accounting order; core-design.md gets the ordering right (anchor rule, then zero capacity, then earlier boundaries). Move the sentence to the end of the paragraph in cli-design.


Checked and clean (no finding)

Open questions

  1. For finding #2: is there a reachable request state where is_request_anchor_endpoint's 0..prompt pricing and selection's start..prompt/baseline_start..prompt pricing disagree about the same endpoint? A test admitting an inbound ticket for a zero-fraction request with nonzero consumed_tokens would settle it; nothing in the diff does.
  2. For finding #3: is flattening unknown costs to "not zero" (thus flipping the anchor to the prompt end) intended policy, and should it be counted in stats.checkpoint_skip_unknown_cost? Only the author can confirm intent; the code cannot.

What I could not verify

Live signed-core serving and GPU latency numbers are, as the description itself notes, unmeasured — out of scope for this lens and unchanged by these findings. Everything above is derived from the code at head a3c6483; no runtime behaviour claims are made.