Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #660

Raw Markdown for agents: https://autobot.eidonix.com/p/23e31c58-f3c4-4146-bccc-cdbe1868523b.md

#1 [high] F1 (Major): two anchor-budget sites now disagree — price_start/whole vs initial_prefill_ns+extra_spent_ns

PR #660 head 22cac91, helios/src/scheduler/checkpoints.rs.

Site A: request_anchor_endpoint (checkpoints.rs:500-516):

let fraction = self.policy.checkpoint_extra_work_fraction;
let keep_raw = match Self::anchor_split_ns(request,&catalog,terminal_window,
    price_start, request.prompt_tokens, raw_anchor) {
    Some((whole, split_ns)) => split_ns <= allowance(whole, fraction),
    None => fraction > 0.0,
};

price_start can be 0 (checkpoints.rs:487 0), gpu_reused (:469), or baseline_start (:463-465). whole is priced from price_start; extra_spent_ns is NOT considered.

Site B: checkpoint_selection_uncached (checkpoints.rs:588-597):

Some((whole, split_ns)) => {
    let budget_base = accounting.initial_prefill_ns.unwrap_or(whole);
    let available = allowance(budget_base, fraction);
    if split_ns == 0 || accounting.extra_spent_ns.saturating_add(split_ns) <= available

initial_prefill_ns is priced from baseline_interval = (admission_reused_tokens, prompt_tokens) (checkpoints.rs:553-571) — a different start than price_start, and extra_spent_ns is subtracted from the allowance here.

Impact: same request can be "within budget" at A and "over budget" at B. A is what is_request_anchor_endpoint (checkpoints.rs:519-522) reports, which scheduler.rs:1797 uses to stamp RetentionRole::Anchor on a restored/inbound checkpoint:

let role = if self.is_request_anchor_endpoint(request, inbound.consumed_tokens) {
    RetentionRole::Anchor

So an interior checkpoint the planner declined can still be promoted to Anchor rank and, via checkpoint_copy_allowed returning Ok(true) unconditionally for Anchor (checkpoints.rs:971-973), copied uncharged. On main both sites used the raw_anchor unconditionally at nonzero fraction (main checkpoints.rs:459-464 and 577-579), so they agreed; #660 introduces the disagreement.

Fix: one anchor_decision(&LiveRequest) -> (usize, u64) helper used by both, based on accounting.initial_prefill_ns + extra_spent_ns, so is_request_anchor_endpoint/promote_request_anchor and the planner cannot diverge.

#2 [high] F2 (Major): operator metric checkpoint_extra_work_nanoseconds_total changes meaning, undocumented

helios/src/scheduler/checkpoints.rs:899-908 (commit_checkpoint_plans) charges every committed cut:

accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.split_ns);
accounting.extra_spent_ns = accounting.extra_spent_ns.saturating_add(cut.split_ns);
self.stats.checkpoint_extra_work_ns = self.stats
    .checkpoint_extra_work_ns
    .saturating_add(cut.split_ns);

On main the Anchor cut was pushed with split_ns: 0 unconditionally (main checkpoints.rs:611-616 Cut { endpoint: anchor, role: RetentionRole::Anchor, split_ns: 0, copy_ns: 0 }), so anchor splits were invisible. This PR pushes the real split (head checkpoints.rs:619-627) and therefore, for the first time, every request that keeps an interior anchor adds its split to:

Neither the PR body nor docs/api.md nor the three updated design docs mention the shift; docs/api.md:349-359 was not touched. Fix: state the new scope in docs/api.md and the PR body (anchor split work is now included), and note that dashboards/thresholds on this counter see a step change.

#3 [high] F3 (Major): shared fixtures re-parameterised to fraction 1.0 — default-0.05 path loses pre-existing coverage

The PR body says only "Updated ... unit tests"; the diff actually disables the changed default in existing fixtures instead of covering it.

scheduler.configure_policy(PolicyConfig {
    checkpoint_extra_work_fraction: 1.0,
    ..Default::default()
})

These tests encoded the behaviour the PR classifies as a bug, so re-baselining is legitimate — but it leaves the default (0.05, helios/src/scheduler/policy.rs:40; validated policy.rs:210-212) covered only by the new inline tests in checkpoints.rs (default_fraction_budgets_interior_anchor_splits_and_preserves_prefix_and_terminal_capture at :4176+, default_fraction_anchor_guard_revocation_preserves_charged_anchor_split at :4334+, anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget, zero_split_interior_anchor_retained_when_extra_spent_exceeds_available). The lifecycle/TLA+ conformance model now runs at 1.0 only, so no conformance edge is emitted for the charged-anchor path at the shipped default. Fix: keep one lifecycle-model run at the default fraction (or add a second edge-emitting run) and say in the body that fixtures were re-baselined rather than merely "updated".

#7 [high] Research summary

Reviewed PR #660 (head 22cac91) for correctness/contracts/system-level consequences. Six findings saved to scratchpad, all with file:line citations and verbatim quotes.

Majors:

  1. Two anchor-budget decision sites now disagree (checkpoints.rs:500-516 vs :588-597). request_anchor_endpoint prices from price_start (which can be 0) against whole and ignores extra_spent_ns; checkpoint_selection_uncached prices from initial_prefill_ns (baseline start) and subtracts extra_spent_ns. On main both used the raw anchor unconditionally at nonzero fraction, so they agreed; this PR introduces the divergence. Because is_request_anchor_endpoint (checkpoints.rs:519-522) is what scheduler.rs:1797 uses to stamp RetentionRole::Anchor on restored/inbound checkpoints, and checkpoint_copy_allowed returns Ok(true) unconditionally for Anchor (:971-973), an interior checkpoint the planner declined can still be promoted to Anchor rank and copied uncharged — the same duplicate/over-ranked-Anchor class that blocked #582.
  2. Operator metric changes meaning, undocumented (checkpoints.rs:899-908). On main the Anchor cut's split_ns was hard-coded 0, so anchor splits never reached checkpoint_extra_work_nanoseconds_total (metrics.rs:852 (not opened)) or extra_spent_ns; now they do, which also moves flare_checkpoint_skips_total{reason="work_budget"} and the terminal-capture gate. Neither the body, docs/api.md:349-359, nor the three updated design docs say so.
  3. Shared fixtures re-parameterised instead of covering the default — tests.rs:3302-3315, boundary_tests.rs:71-90, checkpoint_lifecycle_tests.rs:155-161, policy_tests.rs:4833/5251, vision_window_tests.rs:388, phase_tests.rs:3898 all set fraction 1.0/0.2/0.1, and phase_tests.rs:1539-1600 was rewritten around a chunk-aligned boundary. Coverage of the shipped 0.05 default now rests only on the new inline tests, and the TLA+/lifecycle conformance model runs at 1.0 only.

Minors: helios/README.md:372-380 still states the pre-PR anchor contract; check.py's single mutation was only renamed, so no mutation kills the new budget comparison or the new guard; the None if fraction > 0.0 unknown-cost arm retains an uncharged interior anchor and has no new test.

Sound: the end < anchor → end < raw_anchor filter change genuinely closes a duplicate-capture path from #582; anchor_split_ns reuses one whole price and stays inside the per-select_plan selection scope; no new flag/ABI/unsafe; benchmark claims are author-reported and the "0 checkpoints.rs edits" defence does not isolate #656/#628 in the A/B range.

#4 [medium] F4 (Minor): helios/README.md anchor contract now contradicts the changed code and updated docs

helios/README.md:372-380 (unchanged by this PR):

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. Extra captures charge snapshot-copy cost and additional prefill
caused by splitting chunks.

After this PR the anchor itself is gated by that allowance and charges its split; docs/cli-design.md:696-711, docs/core-design.md:1434-1460, docs/scheduling-runtime-design.md:613-630 were all rewritten to say so. The README sentence now states the pre-PR contract and omits the two facts that matter operationally: (1) the anchor can fall back to the prompt end on a nonzero fraction, (2) the anchor split eats the same allowance as Message/Endpoint extras.

Impact: the crate README is the in-repo contract operators read for checkpoints; it now describes behaviour the code no longer has, and it is the only place that does. Fix: add the interior-anchor budget sentence to helios/README.md:372-380 as part of this PR.

#5 [medium] F5 (Minor): lifecycle check.py mutation covers only the latch, not the new split-budget decision

verification/helios-lifecycle/check.py:671-678 (only hunk in the PR):

check_mutations(cargo, ROOT / "helios/src/scheduler/checkpoints.rs", CHECKS[7][1], [
    ("dropped multi-chunk zero-budget fallback",
     "accounting.budgeted_anchor = Some((raw_anchor, request.prompt_tokens, chosen));",
     "accounting.budgeted_anchor = None;",
     "multi-chunk prefill must retain zero-budget prompt-end anchor fallback"),
])

The rename keeps this mutation valid (target line still exists at checkpoints.rs:602), but nothing in check.py kills a mutant of the behaviour this PR actually adds, e.g. checkpoints.rs:591-597:

if split_ns == 0
    || accounting.extra_spent_ns.saturating_add(split_ns) <= available
{ (raw_anchor, split_ns) } else { (request.prompt_tokens, 0) }

and the new guard at checkpoints.rs:537-543. The body's evidence section reports check.py 10/10 TLC / 8/8 Observed / 12/12 aux, which reads as coverage of the change but is coverage of the old invariant. Fix: add a mutation that makes the interior anchor always retained (drop the budget comparison), and one that drops the cut.split_ns > 0 conjunct of the new guard.

#6 [medium] F6 (Minor/notes): honest positives and remaining verified observations

Positives verified directly:

Unknown-cost arm (checkpoints.rs:599): None if fraction > 0.0 => (raw_anchor, 0) retains the interior anchor uncharged when prefill cost is unknown — the same "free inner anchor" the PR removes, relocated to the unknown-cost case. It is documented (docs/cli-design.md:702-705, docs/core-design.md:1455-1459) and mirrored at checkpoints.rs:510, so it is a deliberate choice, not a defect; but I found no new test for it (the only tests that touch unknown costs are the older zero-fraction ones), so it is untested at the shipped default.

Dropped extras (intended but worth stating): checkpoints.rs:1809-1820 shows the cost — anchor 896 charges 110 ns, leaving 90 of 200, so endpoint 640 is dropped: [256, 512, 768, 896, 1024], reserved_ns == 134. Main had [256,512,640,768,896,1024], reserved_ns == 115.

Claim accuracy: the PR text supplied for review reports "zero-re-export flare run A/B ... on exact candidate 22cac916834f vs 5d53040e" and, separately, "4× DGX Spark GB10 ran on pre-#656 571a4471", with the caveat "0 checkpoints.rs edits in 571a4471..5d53040e". That caveat does not isolate the merged changes in that range (#656 conditional speculative acceptance + acceptance-probe charging, #628 Copy-Engine gating), both of which move prefill/decode timing; and the disclosed regressions (mixed-c32 per-user p50 93.9 -> 71.0 tok/s, >250 ms gaps 215 -> 434) sit in the same table as the headline +23.7% Out. No repeat counts or variance are given, so the deltas are not assessable as noise-free.

#8 [medium] F7: verbatim contract text for the metric/README findings (docs/api.md, docs hunks)

Verbatim quotes supporting F2 (metric) and F4 (README) findings.

docs/api.md:349-359 (NOT touched by #660):

GPU checkpoint retention exports `flare_checkpoint_captures_total{role}` with
`anchor`, `message`, and `endpoint` roles, and
`flare_checkpoint_skips_total{reason}` with `unknown_cost`, `work_budget`, and
`storage` reasons. Skip counters count selection or capture rejections, not failed
requests. ... `flare_checkpoint_extra_work_nanoseconds_total` sums charged predicted
extra prefill and copy work; it is not a GPU timing measurement.
`flare_checkpoint_anchor_reservations` reports unused anchor guards, excluding
armed destinations and in-flight copies.

After #660 the counter also includes anchor split_ns, which on main was hard-coded 0 (main checkpoints.rs:611-616). The doc sentence "sums charged predicted extra prefill and copy work" remains literally true but its scope widened by an unbounded amount per anchored request; no doc states that anchor splits are now included.

Docs that WERE updated (all three say the anchor split is now charged):

Not updated: helios/README.md:372-380 (see F4) and docs/api.md.

#9 [medium] F8: scope of this review — what was read in full, what was not

Verification actually performed for the correctness/contracts lens on PR #660 (head 22cac91). No builds, tests or benchmarks were run — every statement below is from reading the head source, main source, the diff, and the in-repo docs.

Read in full or in the relevant region:

Not inspected: the remaining ~3,000 lines of checkpoints.rs test module; helios/src/cache/* (RetentionRole ranking internals); server/metrics.rs bodies beyond :844-856 and the counter wiring; scripts/scheduling_sim (arguably N/A — it has no checkpoint/anchor model, and the PR does not argue so, per the dossier); commit trailers (Design-Signed-Off-By) were not readable here, so docs/design-review.md:294-311 compliance is unknown.

Concurrency/blocking note: none of the changed paths introduce locks — the scheduler is single-threaded &mut self plus a thread-local RefCell selection cache scoped to select_plan (checkpoints.rs:134-137, :410-428; policy.rs:1531, :1784), so the new pricing adds no contention or blocking surface. revoke_unused_anchor_guards (checkpoints.rs:138-163) and refill_reservations (scheduler.rs:1333-1399) are unchanged by the PR apart from the new guard's interaction, which the new tests default_fraction_anchor_guard_revocation_preserves_charged_anchor_split and anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget do cover.