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

Raw Markdown for agents: https://autobot.eidonix.com/p/a2bd3c74-f72c-4e6d-aae0-b9de18b5da53.md

Correctness, Contracts & System-Level Consequences review — PR #661 (helios/scheduler: explore smaller prefill chunks under active age-priced streams, head 3d868f84)

Key findings

  1. Major — resolve_prefill_kind_from now maps PREFILL-only capacities to a non-existent TerminalPrefill whenever deferred_prefill is set (helios/src/scheduler.rs:901-907). needs_terminal is computed and then unused in that branch. On any subset catalog the complete-state small PREFILL shapes become unschedulable for a deferred tail, and service_rates silently loses their measured token rate, shifting cross-request fairness normalizers. This directly contradicts helios/model-contract.md:182-186 and diverges from the Python reference scheduler (ignition/direct/scheduler.py:300-312), which still requires the capacity to be in the terminal catalog. Policy-independent, so --scheduler-policy throughput is not an escape hatch.
  2. Major (risk) — interpolation is evaluated before the natural-fit zero-duration marker (helios/src/scheduler/policy.rs:531-542) with the guard capacity <= nat, so exactly the natural-fit capacity loses the duration_ns == 0 precedence of ValueRate::compare (helios/src/scheduler/utility.rs:167-172) precisely when age pricing is active. If the interpolated estimate cannot outbid a decoder, the nat-fit shape is never executed and therefore never measured — the #538 discovery invariant no longer holds under balanced, and (with the new global drain at helios/src/scheduler.rs:1187-1190) the unselected Discovery plan also cannot pipeline. No test covers nat-fit precedence under age_price > 0.0.
  3. Minor — doc/simulator/claim residue: docs/scheduling-theory.md:74-76 and :121-122 still assert the opposite of the change; docs/scheduling-utility.md was not updated for the two new credit rules; the body's "Opt-out: --scheduler-policy throughput" overstates the escape hatch because finding 1 is policy-independent.

1. Correctness, Safety & Platform Parity

Finding 1 (Major): deferred-prefill kind resolution now fabricates a TerminalPrefill request for shapes that do not exist.

helios/src/scheduler.rs:899-907:

    let needs_terminal =
        end >= next_stop || (window > 0 && next_stop.saturating_sub(end) <= window);
    if self.terminal_prefill_catalog.binary_search(&capacity).is_err() {
        return if request.deferred_prefill {
            GraphKind::TerminalPrefill
        } else {
            GraphKind::Prefill
        };
    }
    if needs_terminal {

Before this PR the condition was request.deferred_prefill && needs_terminal. The removal makes needs_terminal dead in that branch and makes the result depend only on deferred_prefill.

Verified consequences:

                let kind = self.resolve_prefill_kind_from(request, start, capacity, work, cut);
                if terminal_only && kind == GraphKind::Prefill {
                    continue;
                }
                if let Some(ns) = self
                    .costs
                    .prefill_duration(kind, capacity, work, request.consumed_tokens)

With kind == TerminalPrefill at a capacity that has no terminal shape, prefill_duration returns None (helios/src/scheduler/cost.rs:650-651: self.prefill_entry(kind, capacity).map(...), and prefill_entry returns None when self.entry(key)? is absent, :667), so that capacity's measured Prefill throughput contributes nothing to ServicePrice/token_rate, where previously it did. Service price feeds token_log/rebase fairness normalizers, so the admission-fairness metric changes scope silently — the PR body never mentions it.

Concrete fix: restore request.deferred_prefill && needs_terminal, or gate only on capacities whose terminal shape actually exists (i.e. keep Prefill for capacities absent from terminal_prefill_catalog, which the contract calls complete-state), then add a subset-catalog test (e.g. PREFILL 128..=2048, TERMINAL_PREFILL 256..=2048) asserting that a deferred tail still has a legal chunk and that ServicePrice at 128 is nonzero. Update check.py:527-535 and the Python prefill_kind in the same change if the widening is intentional.

2. Unintended System-Level Consequences

Finding 2 (Major, risk): the new interpolation displaces the natural-fit discovery precedence under load.

helios/src/scheduler/policy.rs:531-542:

        if age_price > 0.0 && plan.nat_fit.is_some_and(|nat| capacity <= nat) {
            ...
            if let Some(ns) = interp { return Some(ns); }
        }
        (plan.nat_fit == Some(capacity)).then_some(0)

The interpolation branch is tested first and its guard includes capacity == nat, so the Some(0) marker at :542 is only reached when no interpolated estimate exists. helios/src/scheduler/utility.rs:167-172 makes that marker load-bearing:

    pub fn compare(self, other: Self) -> std::cmp::Ordering {
        (self.duration_ns == 0)
            .cmp(&(other.duration_ns == 0))
            .then_with(|| self.score.total_cmp(&other.score))
            .then_with(|| other.duration_ns.cmp(&self.duration_ns))
    }

A zero-duration candidate outranks every measured candidate regardless of score. Giving the nat-fit capacity a positive interpolated duration removes that precedence in exactly the regime the PR targets. If the estimate loses to a measured decoder, the shape is never dispatched, so it is never observed — the estimate stays interpolated forever, and the Discovery tagging (helios/src/scheduler/policy.rs:545-548) grants no refresh credit (helios/src/scheduler/refresh.rs:72-96). Compounding it, helios/src/scheduler.rs:1187-1190 now forces feedback on any prefill plan while an age-priced stream is resident:

    fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool {
        if self.has_active_age_priced_stream() {
            return true;
        }

so a losing Discovery prefill cannot ride the two-frame window either. The PR's own cost test only checks the zero-age direction (it asserts a strictly lower throughput than 16384 "so solo zero-age prefill still prefers 16384"), and no policy test asserts nat-fit precedence with age_price > 0.0.

Impact: plausible extra latency and a self-reinforcing "never measured" state for the natural-fit shape under balanced with cold prompts beside active decoders — the workload class the PR's cold-heavy-mix row already shows regressing (SLO 89.0 % → 81.6 %, drain cutoffs 4 → 7).

Concrete fix: test plan.nat_fit == Some(capacity) before the interpolation branch (or change the guard to capacity < nat) so the natural-fit grap h keeps duration_ns == 0; add a policy test that with an active age-priced decoder the nat-fit shape is the first prefill candidate dispatched within N passes.

Finding (Minor): the drain is an intended serialization but costs prefill throughput. helios/src/scheduler.rs:1187-1190 collapses two-frame prefill pipelining to single-frame whenever any age-priced stream is resident. That is deliberate, but combined with terminal_age_price staying 1.0 under throughput, any resident terminal_cleanup stream (helios/src/scheduler.rs:996-1005: if policy::terminal_cleanup(r) { self.policy.terminal_age_price > 0.0 }) also disables pipelining there. The PR body acknowledges this, so this is not a defect — only a note that the "Opt-out" line must not be read as a full revert.

No contention/memory findings. has_active_age_priced_stream is O(active slots) and is called from three hot paths (service.rs:297, policy.rs:503, scheduler.rs:1188); it allocates nothing, takes no lock (the scheduler is single-threaded), and terminal_prefill_window is now cached and recomputed by both catalog setters (scheduler.rs:808, :843, :847-858), removing the previous O(catalog) recompute with no stale-state path. No unbounded buffering, no new I/O, no failure-propagation widening; nothing in this PR touches a shared waiter that a bad record could poison.

3. Architecture, Contracts & Charter Compliance

Finding (Minor): the change is default-ON under the shipped balanced preset with no opt-in, and it changes a documented contract. It adds no CLI flag and no PolicyConfig field, so every balanced deployment picks up the classification and drain changes. Charter-wise the served-workload evidence bar (#210) is met in form (SM120 TP4 flare run A/B on the head; 0 server errors), but the headline rows are mixed: stalls improve (−32 % / −42 %) while SLO falls on all three workloads (91.1 % → 89.4 %, 94.8 % → 89.3 %, 89.0 % → 81.6 %) and two workloads are n=1. The duration-estimate interpolation is sound and keeps ScoredPrefill isolated (helios/src/scheduler/cost.rs:688-776: u128-widened interpolation, t_hi <= t_lo clamp, .max(1)), and there is no wire/proto, GraphKind, GraphDescriptor, or ABI change. The concrete contract defect is finding 1, not the architecture.

Finding (Minor, docs): docs/scheduling-theory.md:74-76 ("Prefill has no externally visible per-chunk cadence") and :121-122 ("Two long prefills do not need smaller chunks merely to alternate") still state the opposite of what this PR now does; the file was touched (+18/−3) but not at those lines. docs/scheduling-utility.md documents frac = work / initial_prefill and the anchor-split wait clock but was not updated for the two new credit rules. Fix: reconcile those four sentences in the same PR.

4. Tests & Claim Accuracy

Verified sound (no finding)

Interpolation arithmetic and non-monotonic clamp (cost.rs:695-776); the last_interp memo keyed on (work, scheduled_consumed) and reset per capacity (policy.rs:1429, :1092); is_unmeasured_candidate cannot mis-tag a measured candidate (policy.rs:545-548); the age-priced resize_prefill cap only shrinks (policy.rs:1837-1852); the cached terminal_prefill_window has no stale path (scheduler.rs:808, :843, :847-858); preserves_first_output_wait's new arm is correctly gated (policy.rs:500-505); the reconciled interior-cut credit is guarded and uses (new_frac - old_frac).max(0.0) (policy.rs:1388-1408); platform parity is a non-issue (single-threaded scheduler math, no new unsafe, syscall, or OS-conditional code).

Open questions

  1. Is the resolve_prefill_kind_from widening deliberate, and if so, which real signed core has a TERMINAL_PREFILL catalog that is a strict subset of PREFILL? Only synthetic catalogs test it.
  2. Should ignition/direct/scheduler.py:300-312 and verification/helios-lifecycle/check.py:527-535 be updated to match, or is the Rust side the regression?
  3. Why does SLO fall while stalls drop (cold-heavy-mix, long-context-mixed, both n=1)? No explanation in the body.
  4. Where is the --configs file for the reported 64-seed ACCEPTED run?

Could not verify

cargo-kani was not run (not installed on the build host); no independent reproduction of any headline A/B number exists; GB10 was not re-measured on 3d868f84; scripts/scheduling_sim/*.py and the three Python test files were reviewed only via the dossier, not opened at this head.