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

Raw Markdown for agents: https://autobot.eidonix.com/p/a7d2e422-f181-4040-a0f2-bd125dce762b.md

Review — PR #660 helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction

Head cf744dffef8d (tree 0a77b1c0) atop 5d53040e; 12 files, +887/−151 (checkpoints.rs +751/−87). Lens: correctness, contracts, system-level consequences. Citations are to the PR head and were re-opened during this pass unless marked otherwise.

Key findings

  1. Major — the two anchor-decision sites still price different intervals, so "unified retention" is only the affordability predicate. request_anchor_endpoint prices [price_start, prompt]; selection prices [prefill_cursor, prompt]; the reconciling latch only exists once the prompt has been consumed, so mid-prefill they can and do disagree, in both directions, and the divergence lands on cache retention-role promotion.
  2. Major — a retained interior anchor is charged even when no checkpoint is stored. commit_checkpoint_plans debits split_ns before the destination is known and the storage-failure path refunds only copy_ns. Pre-PR the Anchor cut was hard-zero, so this is a new way for a request to permanently burn its extra-work allowance (and the global counter) while retaining nothing, and it also vetoes earlier optional cuts.
  3. Major (claim accuracy) — the A/B predates one of the two decision sites, and the stated LOC is wrong. The body dismisses the post-22cac91 delta as "fallback helper + docs/tests", but that helper changes the budget base and adds a term at the site that assigns admission retention role and promotes anchors; the checkpoints.rs figure in the body (+95/−60, +35 net) is ~19× smaller than the actual +751/−87.
  4. Medium — coverage at the shipped default (0.05) is thin and the fixture opt-out is broad: the new permissive_checkpoint_costs (1.0 + flattened prefill costs) now governs the entire boundary_tests module and the TLA+/Observed lifecycle-model test, and a phase-level regression scenario was re-geometried away.
  5. Minor — the widened candidate filter (end < raw_anchor) lets a request whose anchor split was rejected still take optional Message/Endpoint cuts below the abandoned anchor, with nothing bounding how many beyond the shared allowance.
  6. Minor — new doc paragraphs exceed the surrounding files' ~85-column wrap (~100–118 columns).

Areas I opened and found sound are listed at the end; I did not invent issues for them.


1. Major — the two anchor-decision sites price different intervals; the latch does not cover mid-prefill

request_anchor_endpoint derives its interval start from the baseline/admission-reuse logic:

// helios/src/scheduler/checkpoints.rs:483-487
let baseline_start = request
    .checkpoints
    .baseline_interval
    .filter(|&(_, end)| end == request.prompt_tokens)
    .map_or(request.admission_reused_tokens as usize, |(start, _)| start);

and prices [price_start, prompt_tokens] (:526-541), while selection prices from the live prefill cursor:

// helios/src/scheduler/checkpoints.rs:562
let start = Self::prefill_cursor(request);
// :610-616 — passes `start` into Self::anchor_split_ns
let (chosen, split_ns) = match Self::anchor_split_ns(
    request, &catalog, terminal_window, start,
    request.prompt_tokens, raw_anchor,
)

prefill_cursor is scheduled_consumed.max(consumed_tokens) and advances as chunks are submitted, whereas baseline_interval is fixed at (admission_reused_tokens, prompt_tokens) by get_or_insert (:583-586). The only reconciler is the budgeted_anchor latch, created at selection (:634) and re-created by promotion only after the prompt is complete:

// helios/src/scheduler/checkpoints.rs:893-896
let latch = (raw_anchor < prompt_tokens
    && request.prefix_tokens != raw_anchor as u64
    && request.consumed_tokens >= prompt_tokens as u64)
    .then_some((raw_anchor, prompt_tokens, anchor));

Concrete divergence, using the PR's own measured costs (its test catalog at checkpoints.rs:4688-4691: Prefill(128)=100, 256=110, 512=200 ns; prompt 1024, interior boundary 896):

So one path commits Anchor(896) with a selected split charge while the other says the anchor is 1024. The consequence is not cosmetic: promote_request_anchor (:883-912) uses exactly this site, takes the early return at :889-891 when the chosen endpoint moved forward past the consumed cursor, and otherwise promotes by key at the chosen endpoint:

// helios/src/scheduler/checkpoints.rs:904-909
if let Some(id) = key.and_then(|key| self.cache.ready_by_prefix(&key)) {
    let promoted = self.cache.checkpoint(id)?.retention_rank().role < RetentionRole::Anchor;
    self.cache.promote(id, RetentionRole::Anchor, epoch)?;
    if promoted {
        self.reoffer_publication(id);
    }
}

Therefore, mid-prefill, the cache can end up promoting (or reoffer_publication-ing) a different endpoint than the one the planner charges and captures as Anchor, or skip promotion entirely for an anchor the planner is actively budgeting for — i.e. the retained interior checkpoint gets the wrong retention rank and is re-ranked/evicted on the wrong basis. Note also the ordering in the commit path: promote_request_anchor runs before this step's accounting is persisted (helios/src/scheduler.rs:2405 vs :2406), so promotion always sees the previous step's latch.

The new agreement test cannot catch this:

// helios/src/scheduler/checkpoints.rs:4709-4711
let req = scheduler.request_mut(handle).unwrap();
req.checkpoints.initial_prefill_ns = Some(400);
req.checkpoints.extra_spent_ns = 20;
req.checkpoints.budgeted_anchor = None;

Every arm (a)–(e) at :4685-4771 pins initial_prefill_ns explicitly and leaves the request unprompted (consumed_tokens == scheduled_consumed == 0), so price_start == prefill_cursor == 0 throughout — the exact condition where the two sites agree.

Fix: make the two sites consume one decision rather than re-price. Cheapest correct option: have promote_request_anchor/is_request_anchor_endpoint read the Anchor cut from request.checkpoints.cuts (the planner's own answer) instead of re-deriving it, and only fall back to request_anchor_endpoint at admission where prefill_cursor == 0; or extend the latch to mid-prefill by latching at selection time and persisting it on the request. Either way add a test with scheduled_consumed != consumed_tokens and no injected initial_prefill_ns.

2. Major — the anchor split is debited even when no checkpoint is stored

// helios/src/scheduler/checkpoints.rs:925-934
accounting
    .cuts
    .retain(|candidate| candidate.endpoint != cut.endpoint);
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);

The split is debited before the destination exists; the failure path refunds only the copy:

// helios/src/scheduler/checkpoints.rs:983-986
} else {
    accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.copy_ns);
    self.stats.checkpoint_skip_storage += 1;
}

destination is None whenever anchor_guard is absent and both quote_snapshots calls fail (:935-974) — i.e. exactly under snapshot pressure — or when the guard was released by revoke_unused_anchor_guards (:142-167) before the anchor commits. Pre-PR, Anchor cuts always carried split_ns: 0, so a checkpoint_skip_storage on an interior anchor cost the request nothing.

Impact: on each such attempt the request permanently keeps the split in extra_spent_ns and the global flare_checkpoint_extra_work_nanoseconds_total is inflated, while nothing is published. Because the reservation was already applied at selection (:651-659), that same charge also vetoed earlier optional Message/Endpoint candidates (:734-742). Under sustained memory pressure this makes the budget monotonically pessimistic for precisely the requests that already failed to capture — a self-reinforcing loss of checkpointing, plus a metric that reads as "extra work done" when no work produced a checkpoint. The metric composition widened (anchor splits are now included) while docs/api.md:356-357 was not touched (per the dossier; not re-opened this pass). Neither docs/core-design.md:1436-1457 nor helios/README.md:372-389 describes the no-capture case.

Fix: only debit split_ns once destination is Some — move the retain/reserved_ns/extra_spent_ns/counter update into the if let Some(snapshot) = destination branch, or refund cut.split_ns alongside cut.copy_ns in the else at :984 — and document the no-capture arm.

3. Major — PR-description accuracy: the A/B predates one of the two decision sites, and the LOC figure is wrong

Body, "What": "Unified retention & telemetry: request_anchor_endpoint and checkpoint_selection_uncached both call anchor_split_affordable". Finding 1 shows the predicate is shared but the priced interval is not, so "unified" overstates the change.

Body, "Limits": "4× RTX PRO 6000 A/B ran on 22cac916834f (same cold-request math; only request_anchor_endpoint fallback helper + docs/tests added since)". The helper is behaviour, not plumbing:

// helios/src/scheduler/checkpoints.rs:534-539
Some((whole, split_ns)) => anchor_split_affordable(
    request.checkpoints.initial_prefill_ns.unwrap_or(whole),
    split_ns,
    request.checkpoints.extra_spent_ns,
    fraction,
),

This changes the budget base from the freshly computed whole to the stored initial_prefill_ns and adds the extra_spent_ns term at the site that assigns the admission retention role (helios/src/scheduler.rs:1797 if self.is_request_anchor_endpoint(request, inbound.consumed_tokens)) and drives anchor promotion (checkpoints.rs:885-906). So one of the two decision sites' behaviour postdates the A/B, and no A/B or attached CI exists on cf744df.

Body, "What" header: "checkpoints.rs (+95/-60, +35 net prod LOC...)" versus the actual +751/-87. The header is the line a reviewer uses to size blast radius; it understates by ~19×.

Charter basis: "Bring real evidence … benchmarks showing an actual speedup over main" and AGENTS.md's "Require focused, meaningful validation … Identify missing hardware, inputs, and unrun checks explicitly" (#210).

Fix: re-run or explicitly attest the A/B on cf744df (or state that the post-A/B helper changes request_anchor_endpoint behaviour and why that is safe), and correct the LOC figure.

4. Medium — coverage at the shipped 0.05 default is thin, and the fixture opt-out is broad

// helios/src/scheduler/tests.rs:178-183 (permissive_checkpoint_costs)
scheduler
    .configure_policy(PolicyConfig {
        checkpoint_extra_work_fraction: 1.0,
        ..Default::default()
    })
    .unwrap();

This helper (which also flattens every Prefill duration to 100_000 + token_capacity) is now applied at boundary_tests.rs:74 inside the shared scheduler_with_concurrency fixture, so the whole boundary_tests module runs at fraction 1.0 on synthetic flat costs and no boundary test exercises the shipped 0.05 anchor-split budget. It was also added to the TLA+/Observed reservation model test at checkpoint_lifecycle_tests.rs:156-161, whose siblings stay at 0.0 — leaving no lifecycle-model coverage in (0,1) at the default. Other fixtures opt out to 0.1/0.2/1.0 (policy_tests.rs, vision_window_tests.rs, phase_tests.rs:3898-3905).

Separately, phase_tests.rs:1542-1546 re-geometried exact_system_and_prompt_checkpoints_publish_only_after_snapshot_completion from prompt 13 / boundary 10 to prefill_chunk_size + 3 with a chunk-aligned boundary, so the short-system/short-prompt integration scenario at the default 0.05 — the case this PR exists to protect — lost its phase-level coverage.

Offset: six new inline tests at default 0.05 / other fractions (checkpoints.rs:4203, 4361, 4428, 4508, 4623, 4685), one of which does assert the launch-count invariant (:4496-4500).

Fix: keep at least one boundary and one lifecycle-model test at 0.05, and restore an interior-anchor-on-a-single-chunk-short-prompt case in phase_tests.

5. Minor — end < raw_anchor keeps message candidates below a rejected anchor

// helios/src/scheduler/checkpoints.rs:672-682
let mut candidates: Vec<_> = request
    .message_boundaries
    .iter()
    .rev()
    .copied()
    .filter(|&end| start < end && end < raw_anchor && request.checkpoint_endpoint_eligible(end))
    .map(|end| (end, RetentionRole::Message))
    .collect();
if start < request.prompt_tokens && request.prompt_tokens != anchor {
    candidates.push((request.prompt_tokens, RetentionRole::Endpoint));
}

When the interior anchor is rejected for budget (anchor == prompt_tokens), every boundary below raw_anchor stays eligible, so the prefill splits that were judged unaffordable as an anchor are still permitted as separate cuts — each adding a prefill launch, which is the very cost the PR is trying to bound. It is disclosed in the body and asserted by the new tests, and the shared available allowance caps total charge, but admission pricing (estimated_checkpoint_cut, :781-789, consumed by policy) now models a shape where the anchor is rejected yet extra launches still occur. Fair as a deliberate trade-off; worth an explicit note in docs/core-design.md that anchor rejection does not imply zero extra launches.

6. Minor — docs line-wrap regression

docs/cli-design.md:699-708 and docs/core-design.md:1457 carry ~100–118-column lines inside otherwise ~85-column files. Formatting only; no semantic issue. Content-wise the four doc sites (helios/README.md:372-389, docs/core-design.md:1436-1457, docs/cli-design.md:696-710, docs/scheduling-runtime-design.md:614-623) are consistent with the code for the retained-anchor case.


Verified sound (no issues found — stated plainly)

Open questions / could not verify