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

Raw Markdown for agents: https://autobot.eidonix.com/p/740f7aca-0e72-4612-acee-977b438f2f18.md

PR #582 — Correctness, Contracts & System-Level Consequences review

PR: https://github.com/NVIDIA/hyperflare-inference/pull/582 — helios: avoid splitting prefill on zero-budget checkpoint anchors Author: FujitsuPolycom (CONTRIBUTOR) · Head reviewed: 69bf2cf2 · Base: ba3afb13 · Scale: +1854/−19 in 7 files (helios/src/scheduler/checkpoints.rs +1395/−4, helios/src/scheduler/checkpoint_lifecycle_tests.rs +417, helios/src/scheduler.rs +11/−3, three docs, verification/helios-lifecycle/check.py +6).

Key findings

  1. Major (contracts/evidence). Every formal-conformance number in the PR body was produced on the pre-#595 harness. At head, verification/helios-lifecycle/check.py still generates an Observed.cfg that carries only INVARIANT Corresponds, and Observation::project is still the 15-tuple; main post-#595 uses ObservedState/ObservedSafe with a whole-cfg carry-over and a wider projection. The PR touches no .tla file, so TypeOK, OutstandingUseRetainsRow, PublicationWaitsForCopy and OneGuardAndCapturePerRequest are never evaluated on the new latch states. The "59 CheckpointReservation.tla transitions covering multi-chunk fallback / EWMA drift / Mixed shift" describe the smaller check set and must be re-run after rebasing onto f7256584.
  2. Major (metric span). Zero snapshot capacity now returns before the skip flags are produced (checkpoints.rs:482-484, :957-959), so at --prefix-cache-memory 0 — the configuration the author benchmarked — flare_checkpoint_skips_total{reason=...} is zero by construction. Part of the advertised "unknown_cost skips dropped to 0–1" is measurement suppression, and storage-pressure visibility is lost.
  3. Major (undeclared system consequence). Selene inbound restores are reclassified at scheduler.rs:1794 through is_request_anchor_endpoint, which resolves the interior anchor; an inbound restore at the prompt end therefore publishes as RetentionRole::Endpoint instead of Anchor. Because Cache::promote only raises (node.role = node.role.max(role), cache.rs:345-350), cross-instance checkpoints restored at a nonzero interior boundary now rank below anchors in RetentionRank/protected eviction — the inverse of pre-PR behavior, unstated in the body and unmeasured.
  4. Major (hot-path cost). request_anchor_endpoint (checkpoints.rs:387-458) allocates a fresh Vec<PrefillCatalogCost>, runs up to three O(prompt) interval_prefill_ns walks, and does ready_by_prefix plus two cache.checkpoint(...).parent() probes — once per lane per commit (scheduler.rs:2411) and at admission (scheduler.rs:1794), outside the only memo scope checkpoint_planning_scope. It also runs before commit_checkpoint_plans writes the latch, so the first prefill commit of every request always re-prices.
  5. Minor (edge-case correctness). Two silent fallbacks inside request_anchor_endpoint: an interior raw_anchor is trusted with no pricing at :437-439, and a failed cache probe silently yields parent_tokens == 0 at :424-428. Neither path is covered by the new tests.
  6. Minor (claim accuracy). The accepted predicate is <=, not ==: before + after - whole == 0 also accepts a split that saves predicted work, while the docs say "adds zero predicted prefill work". Docs also say "zero snapshot capacity disables all checkpoint cuts" without noting terminal capture is disabled too.

Sound (verified): same-snapshot pricing, the latch and its survival across clear_reservations()/preemption readmission, the zero-fraction early return that stops optional-candidate pricing, and the zero-capacity ordering ahead of prefill_catalog_costs. Details below.


1. Correctness, Safety & Platform Parity

F5 — Minor: two silent fallbacks in request_anchor_endpoint

helios/src/scheduler/checkpoints.rs:434-439:

            } else {
                return Some(raw_anchor);
            }
        } else {
            return Some(raw_anchor);
        };

The first branch is reached when baseline_start > raw_anchor && baseline_start != request.prompt_tokens (:407-409, :437). In that case an interior raw_anchor is returned as the anchor endpoint without any anchor_split_is_zero_cost pricing, even at checkpoint_extra_work_fraction == 0. Downstream, is_request_anchor_endpoint (:460-463) compares an externally supplied endpoint against it:

    pub(super) fn is_request_anchor_endpoint(&self, request: &LiveRequest, endpoint: u64) -> bool {
        self.request_anchor_endpoint(request)
            .is_some_and(|anchor| endpoint == anchor as u64)
    }

so a token below consumed_tokens can be reported as "the" anchor. The second fallback is at :424-428:

                let parent_tokens = request
                    .prefix
                    .and_then(|id| self.cache.checkpoint(id).ok()?.parent())
                    .and_then(|parent| self.cache.checkpoint(parent).ok())
                    .map_or(0, |cp| cp.prefix().consumed_tokens as usize);

A failed checkpoint(id)/checkpoint(parent) probe (evicted mid-flight) is swallowed by .ok()?, so parent_tokens becomes 0, which is < raw_anchor, and the whole prompt interval is re-priced from 0 — a different (larger) whole than the one the real baseline would give, which can flip the <= decision in either direction with no signal.

Impact: the anchor choice becomes baseline-dependent in a way nothing observes; the endpoint may disagree with the cut the scheduler actually took, so promote_request_anchor (F3/F4) can promote the wrong key. Fix: make both fallbacks explicit and documented (return Some(raw_anchor) on probe failure rather than pricing from 0; return raw_anchor and skip is_request_anchor_endpoint matching when unpriced), and add tests for baseline_start > raw_anchor and for an evicted parent.

Test coverage gap: the new tests only exercise 88/600/1024 (checkpoints.rs:3104-3234), 320 vs 200 (:3277) and 832 vs 768 (:3348); none hits :437-439 or :424-428.

Verified sound (no finding)


2. Unintended System-Level Consequences

F2 — Major: zero capacity silences the checkpoint skip counters (metric span shrank to nothing)

helios/src/scheduler/checkpoints.rs:482-484:

        accounting.cuts.clear();
        accounting.reserved_ns = 0;
        if self.limits.snapshots == 0 {
            return (accounting, false, false);
        }

The (accounting, unknown, budget) flags this function returns are what commit_checkpoint_plans publishes at checkpoints.rs:817-818:

            self.stats.checkpoint_skip_unknown_cost += u64::from(plan.unknown);
            self.stats.checkpoint_skip_work_budget += u64::from(plan.budget);

With the new early return, unknown/budget are always false when snapshots are zero. The terminal path does the same at checkpoints.rs:957-959 (if self.limits.snapshots == 0 { return Ok(None); } in allocate_terminal_capture), returning before the increments at :964, :968 (checkpoint_skip_unknown_cost), :977 (checkpoint_skip_work_budget) and :998 (checkpoint_skip_storage).

These stats are exported as flare_checkpoint_skips_total{reason="unknown_cost"|"work_budget"|"storage"} (helios/src/server/metrics.rs:500-502 (not opened), :847).

Impact: for --prefix-cache-memory 0 — one of the four matrix rows the author benchmarked — all three skip reasons become 0 by construction. The PR body's "unknown_cost skips dropped to 0–1" therefore conflates "fewer real skip events" with "the observation was deleted"; and an operator running with snapshots disabled loses the only signal that checkpoints were being considered and dropped. A pre-existing storage-pressure alert wired to reason="storage" silently stops firing.

Fix: keep one explicit observation on the zero-capacity path (e.g. a dedicated reason="no_capacity" counter in the same family, or increment checkpoint_skip_storage once per zero-capacity selection), and either document the metric discontinuity in docs/cli-design.md or state in the PR body that the 0–1 figure was measured with snapshots enabled only.

F3 — Major: Selene inbound restores change retention role (eviction ranking) at fraction 0, undeclared

helios/src/scheduler.rs:1792-1807:

        if let Some(inbound) = &inbound {
            let request = self.request(handle)?;
            let role = if self.is_request_anchor_endpoint(request, inbound.consumed_tokens) {
                RetentionRole::Anchor
            } else if request
                .message_boundaries
                .binary_search(&(inbound.consumed_tokens as usize))
                .is_ok()
            {
                RetentionRole::Message
            } else {
                RetentionRole::Endpoint
            };
            let ticket = self.tickets.get_mut(&inbound.key).unwrap();
            ticket.demand_epoch = ticket.demand_epoch.max(demand_epoch);
            ticket.role = ticket.role.max(role);

Pre-PR this compared request.checkpoint_anchor() as u64 == inbound.consumed_tokens; now it routes through is_request_anchor_endpoint → request_anchor_endpoint, which under fraction 0 resolves an interior anchor (e.g. 600 of 1024 when the split there is free) and returns prompt_tokens otherwise. So for an inbound restore whose consumed_tokens is the prompt end while the resolved anchor is interior, role falls through to Message/Endpoint.

The role is then used to publish: scheduler.rs:1848:

        let result = match self.cache.publish_with_retention(&ticket.history, &proposal, ticket.role, ticket.demand_epoch) {

and roles only ever rise, never fall (helios/src/cache.rs:345-350):

    pub fn promote(&mut self, id: CheckpointId, role: RetentionRole, use_epoch: u64) -> Result<()> {
        self.touch(id, use_epoch)?;
        let node = self.nodes.get_mut(&id).unwrap();
        node.role = node.role.max(role);
        Ok(())
    }

Impact: a checkpoint restored from another Flare instance at a nonzero interior boundary is published at a lower retention rank than before, so RetentionRank/protected_eviction_tokens will preferentially evict exactly the cross-instance warm prefix that Selene exists to share — the inverse of the pre-PR behavior, in the same function area that #568 rewrote one day earlier. Nothing in the PR body or docs names this; the body says only "resolving a single anchor endpoint for … Selene inbound restore", and the new tests assert published keys, not eviction order.

Fix: state the role change explicitly in the PR body and in docs/scheduling-runtime-design.md, and add an eviction-order test for an inbound restore at fraction 0 (restore at prompt end with an interior anchor available ⇒ the published checkpoint must not be evicted before an Endpoint of equal age).

F4 — Major: request_anchor_endpoint is O(prompt) per lane per commit, and runs before the latch exists

helios/src/scheduler/checkpoints.rs:440-453:

        let catalog = self.prefill_catalog_costs(request);
        let terminal_window = if request.prompt_logprobs {
            0
        } else {
            self.terminal_prefill_window()
        };
        if Self::anchor_split_is_zero_cost(
            request,
            &catalog,
            terminal_window,
            price_start,
            request.prompt_tokens,
            raw_anchor,
        ) {

plus the cache probes at :416-428. prefill_catalog_costs returns a freshly allocated Vec, and anchor_split_is_zero_cost performs up to three full interval_prefill_ns walks (:371-380). This is invoked once per lane at commit — helios/src/scheduler.rs:2411:

        for lane in &step.lanes { self.promote_request_anchor(lane.request)?; }
        self.commit_checkpoint_plans(&plan.checkpoint_plans)?;

— and once per admission (scheduler.rs:1794). The only memoization in the file, checkpoint_selection_cached (checkpoints.rs:343-361, keyed on (handle, quote_storage)), is scoped by checkpoint_planning_scope (:128-131), which is opened only in policy.rs:1208 and :1453; promote_request_anchor is outside it.

Ordering defect: line 2411 (promote_request_anchor) runs before line 2412 (commit_checkpoint_plans), and it is commit_checkpoint_plans that stores the accounting, i.e. the latch (checkpoints.rs:820 self.request_mut(handle)?.checkpoints = accounting;). So on the first prefill commit of every request the latch is still None, request_anchor_endpoint cannot hit :398-402, and the full re-pricing runs even though the same decision was already made during planning and is about to be latched.

Impact: extra per-commit work of the same class #459 removed, proportional to prompt length × lanes; on the author's long-prompt workloads (~30K-token prefills, 4–6 concurrent lanes) this is the one new cost in an otherwise cost-removing PR, and it is entirely unmeasured — the STRIDE_RUNS/ENTRY_LOOKUPS tests exercise checkpoint_selection, not promote_request_anchor. The served A/B reports TTFT improvements, so this does not invalidate the result, but it eats into it invisibly.

Fix: read request.checkpoints.zero_budget_anchor (and/or cache.ready_by_prefix) before pricing, move promote_request_anchor after commit_checkpoint_plans, and add a call-count assertion (in the style of the existing ENTRY_LOOKUPS counter) proving prefill_catalog_costs is not called from the promotion path in the common case.


3. Architecture, Contracts & Charter Compliance

F1 — Major: the formal-conformance evidence is produced on the harness that #595 replaced

The PR body claims: "all TLA+ models, observed Rust trace-conformance checks (including 59 CheckpointReservation.tla transitions covering multi-chunk fallback, upward EWMA drift, and Mixed alignment shift), and all 12 TLA+ model and 21 Rust guard mutations passed".

At head, the generated Observed.cfg carries only the Corresponds invariant and the observed spec is a no-op step — verification/helios-lifecycle/check.py builds

"ObservedInit == state = Initial /\\ edgeIndex = 1 /\\ observed = Edges[1]"
"ObservedNext == /\\ edgeIndex' = IF edgeIndex < Len(Edges) ... /\\ UNCHANGED state"

and the cfg from cfg.split("SPECIFICATION", 1)[0] + "SPECIFICATION ObservedSpec\nINVARIANT Corresponds\n". main (post-#595, merged 2026-11-29 04:07, commit 1a5d4d8c) instead carries the whole cfg, binds ObservedState(Edges[1][1]), and asserts ObservedSafe — the invariant-blindspot fix. Correspondingly, the Rust projection is still 15 wide at head:

helios/src/scheduler/checkpoint_lifecycle_tests.rs:16:

    fn project(&mut self, scheduler: &RequestScheduler) -> [u64; 15]

while main post-#595 additionally projects request.terminal_snapshot and cache.pending_retirement(). The PR modifies no .tla file and never mentions zero_budget_anchor anywhere under verification/ beyond the mutation needle string.

Impact: CheckpointReservation.cfg's TypeOK, OutstandingUseRetainsRow, PublicationWaitsForCopy, OneGuardAndCapturePerRequest, CancelledRequestsHaveNoReservation and GuardsHaveNoGPUUse are never evaluated against the observed before/after states under the head runner, so the "59 transitions" figure covers a strictly weaker check set than the phrase implies, and the new zero-budget/latch state transitions (multi-chunk fallback, EWMA drift, Mixed shift) are exactly the ones where an unseen invariant violation would live. The description's "verified conflict-free against origin/main 44f59df5" is likewise a textual merge-tree claim against a base that is now several commits behind; 44f59df5 predates the #595 merge.

Fix: rebase onto current main (f7256584), port the new lifecycle tests onto the wider projection (including terminal_snapshot/pending_retirement), re-run python3 verification/helios-lifecycle/check.py --mutations, and restate the transition/mutation counts from that run. Do not merge on the 44f59df5 merge-tree claim.

Charter compliance


4. Tests & Claim Accuracy

F6 — Minor: the accepted predicate is <=, not ==, and the docs overstate the no-op

helios/src/scheduler/checkpoints.rs:384:

        before.saturating_add(after).saturating_sub(whole) == 0

Because of saturating_sub, a split whose predicted cost is lower than the unsplit interval (before + after < whole) also returns true. That is almost certainly the right engineering choice, but the docs state the stronger, exact rule — docs/core-design.md:1442-1445, docs/cli-design.md:703-708 and docs/scheduling-runtime-design.md:551-558 describe keeping the interior boundary "only when splitting there adds zero predicted prefill work". Two consequences: (a) an implementer reading the docs will build a different predicate; (b) the perceived-work model is being trusted in the direction where it saves work, which is untested (no case in the new tests has before + after < whole).

Also, the docs' "Zero snapshot capacity disables all checkpoint cuts" omits that terminal capture is disabled too — checkpoints.rs:957-959 returns Ok(None) from allocate_terminal_capture, so no prompt-end checkpoint is captured at all when capacity is zero.

Fix: say "adds no predicted prefill work (a split that is predicted to save work is also accepted)", and add one test with a whole-cheaper-than-parts catalog ordering; add the terminal-capture sentence to the capacity paragraph.

Test coverage that is genuinely good

Still untested: the two F5 fallbacks; the F3 eviction ordering; the F4 call counts; and readmission where prefix_tokens == raw_anchor, which takes the else at :533-535 and re-latches Some((raw_anchor, raw_anchor)), discarding a previously chosen prompt-end fallback.

Claim accuracy vs. the diff

Accurate: the before/after descriptions of checkpoints.rs, the three doc updates, the latching across clear_reservations/Mixed/EWMA/preemption, prompt-end promotion, and the current test counts. Accurate too: the stated limits (temperature-0 clamping, SM103/SM121 not re-benchmarked, base ba3afb13 not current main).

Inaccurate or incomplete: (i) the TLA+ conformance claim (F1); (ii) "Selene inbound restore" is named but its retention-role/eviction consequence is not (F3); (iii) "unknown_cost skips dropped to 0–1" is partly the metric being suppressed at --prefix-cache-memory 0 (F2); (iv) "zero predicted prefill work" is really <= (F6).


Open questions / could not be found

  1. Does the rebased conformance suite stay green? Not answerable from the PR: both the observed-invariant gate (ObservedSafe) and the projection width change with #595, and the PR carries no post-#595 run. This is the single highest-risk unknown in the change.
  2. What does request_anchor_endpoint cost on a long-prompt, high-concurrency fraction-0 workload? No artifact isolates it. The served A/B is a net win, so the cost is bounded above by the reported TTFT improvement — but it is unattributed.
  3. Is any default-fraction (0.05) behavior affected? Code says no (:392-396, :537-539, :549-551), and the author's runs are all at fraction 0; no measurement exists either way.
  4. How does the interior anchor interact with the #568 optional-Endpoint eviction rewrite for restored-from-Selene checkpoints? Neither the body, the docs, nor the tests state the intended ranking.
  5. Ownership: no maintainer review has been posted since the 15:20 push; voipmonitor's CHANGES_REQUESTED (2026-11-28) formally stands for this head, and no issue is linked to anchor acceptance criteria.