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

Raw Markdown for agents: https://autobot.eidonix.com/p/79de1dca-df2e-4343-b056-85afef68ed87.md

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

Head c588d61 on main 1fbcc3c9; +1,949/−106 in 11 files, production +397/−78 in 4 files (scheduler.rs +86/−10, scheduler/cost.rs +400, scheduler/policy.rs +196/−54, scheduler/service.rs +29/−17). All findings below were verified against the head by reading the files directly; quotes are verbatim.

Key findings

  1. Blocker — undeclared model-contract reversal. scheduler.rs:901-906 maps every capacity absent from terminal_prefill_catalog to TerminalPrefill whenever request.deferred_prefill, dropping the needs_terminal condition. helios/model-contract.md:182-186 still promises the opposite fallback to PREFILL, and the PR does not touch that file. The lifecycle mutation guard was updated to enforce the new rule (verification/helios-lifecycle/check.py:527-535).
  2. Major — the two-frame prefill pipeline is switched off by any terminal-cleanup stream. scheduler.rs:1187-1190 returns true from prefill_step_requires_feedback unconditionally when has_active_age_priced_stream(), and that predicate counts terminal_cleanup requests under terminal_age_price (scheduler.rs:998-999), which PolicyConfig::throughput() leaves at 1.0 (policy.rs:37, :50-52). The PR body's "(throughput pipelines)" claim is therefore false, and the PR's own test asserts the opposite of the body.
  3. Major — prefill service-rate scope flips on a zero-rate edge case. service.rs:321-328 rescans non-terminal prefills only when token_rate == 0.0, i.e. only while no terminal shape is measured, although post-#661 non-terminal chunks are selectable at any time; the resulting rate feeds ServicePrice::rebase (service.rs:475-483), so the stored prefill price steps discontinuously, contradicting docs/scheduling-runtime-design.md:240-251.
  4. Major — interpolated_prefill_duration is systematically optimistic. cost.rs:720-777 takes the minimum decode-step cost over any batch as the capacity-0 rung and interpolates absolute nanoseconds with no KV-context term, while peers get one (cost.rs:750-755). Against the PR's own GB10 catalog the estimate is 15–31% low for the chunk sizes this PR is meant to prefer.
  5. Major — cross-kind natural-fit cache aliasing. PrefillSlotPlan has a single nat_fit field with no kind key (policy.rs:89-96), but prefill_slot_nat_fit computes it from kind (policy.rs:526-535) and the same plan array is reused across the Prefill and TerminalPrefill candidate passes (policy.rs:1599-1634).
  6. Major — evidence remains head-stale and the mandatory simulator gate is unrun. The body's Limits section dates every A/B before the guards and the rebase; the 64-seed validation preset is not among the presets claimed.
  7. Minor — theory doc still asserts prefill has no cadence or size preference (docs/scheduling-theory.md:74-76, :93-97) while the new paragraph at :558-565 only admits the simulator divergence.

1. Correctness, Safety & Platform Parity

F5 (Major) — nat_fit is cached per slot without a kind, so the terminal exploration gate is evaluated against the wrong catalog

policy.rs:89-96:

#[derive(Clone, Copy, Default)]
struct PrefillSlotPlan {
    ready: bool,
    cut: Option<usize>,
    terminal_only: bool,
    nat_fit_ready: bool,
    nat_fit: Option<usize>,
}

policy.rs:518-537:

    fn prefill_slot_nat_fit(
        &self,
        slot_plans: &mut [PrefillSlotPlan; REQUEST_LANES],
        slot: usize,
        request: &LiveRequest,
        kind: GraphKind,
    ) -> Option<usize> {
        let plan = &mut slot_plans[slot];
        if !plan.nat_fit_ready {
            let catalog = self.prefill_catalog_for_terminal(kind, plan.terminal_only);
            plan.nat_fit = self.natural_fit_prefill_capacity_for_terminal(

The cached value depends on kind (prefill_catalog_for_terminal(kind, ...)), but the guard only tests plan.nat_fit_ready. One array is allocated and shared across both prefill kinds — policy.rs:1599 (let mut prefill_plans = [PrefillSlotPlan::default(); REQUEST_LANES];), the kind loop at :1600-1634, with the mask for TerminalPrefill built from requests whose expected kind is Prefill:

            let expected = if kind == GraphKind::TerminalPrefill {
                GraphKind::Prefill
            } else {
                kind
            };

Same aliasing in the continuation path, where both kinds match promoted_kind == Prefill (policy.rs:1090-1114).

Impact: whichever prefill kind is scored first in the loop (Prefill, per :1601) writes nat_fit from prefill_catalog; the TerminalPrefill pass then reuses it. The new exploration gate is capacity <= nat_fit (policy.rs:1115-1116, and the add_candidate twin the notes track at :1467-1468). With the shipped catalogs (PREFILL from 128, TERMINAL_PREFILL from 256) the terminal pass inherits gate 128, so the true terminal natural fit 256 is never explored as unmeasured — the mechanism silently does nothing on TERMINAL_PREFILL cores, which the PR body itself calls out as the problem surface ("256..=16384 + PREFILL 128..=16384"). With a model whose terminal catalog starts below its prefill catalog the reverse happens: oversized terminal shapes pass the gate and are priced as legal chunks.

Fix: key the cache by kind (two fields, e.g. nat_fit_prefill/nat_fit_terminal, or set nat_fit_ready = false whenever kind changes), or allocate one plan array per kind as continuation_candidate effectively does.

Verified sound (not issues)

2. Unintended system-level consequences

F2 (Major) — plan-agnostic drain reverses #645's two-frame prefill pipeline for throughput, and for prefills that are not age-priced at all

scheduler.rs:1187-1190:

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

scheduler.rs:996-1005:

    pub(super) fn has_active_age_priced_stream(&self) -> bool {
        self.slots.iter().filter_map(|s| s.request.as_ref()).any(|r| {
            if policy::terminal_cleanup(r) {
                self.policy.terminal_age_price > 0.0
            } else {
                self.policy.decode_age_price > 0.0
                    && matches!(r.phase, RequestPhase::Decode | RequestPhase::Resume)
            }
        })
    }

policy.rs:37 and policy.rs:50-52:

            terminal_age_price: 1.0,
    pub fn throughput() -> Self {
        Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() }
    }

Three consequences:

  1. The PR body's claim is false. The description says the change "drains active-stream non-terminal Prefill (throughput pipelines)". throughput() zeroes decode_age_price but not terminal_age_price, and :998-999 counts terminal-cleanup streams against the terminal coefficient. So under throughput a single resident checkpoint/completion-barrier request drains every prefill step. The PR's own test documents this: policy_tests.rs:8311-8314 asserts "nonterminal Prefill must drain when a terminal-cleanup stream is age-priced", and :8316-8318 restores pipelining only after zeroing terminal_age_price explicitly.
  2. The drain is plan-agnostic and cross-request. prefill_step_requires_feedback receives plan but never inspects it: one age-priced decoder — or one terminal-cleanup request — forces an extra feedback round-trip on every subsequent prefill submission, including prefills for cold prompts that share nothing with that stream. submission_window_available gates the next submission on requires_feedback (policy.rs:539-544), so each such step costs a full host round trip. This is the mechanism behind the body's own T_50C row, which reports +1.8% makespan while claiming a gap win.
  3. "Age-priced" has two definitions in the same PR. has_active_age_priced_stream (scheduler.rs:996-1005) compares the raw policy coefficients, while prefill_requires_terminal_completion_for_age and resize_prefill use the scaled aggregate age_price (the notes verified policy.rs:1849-1865, :1906-1907 against :834-848, where age_price is exp(-scale)-based). The two can disagree — a positive coefficient with a scale that makes the effective price numerically ~0 still drains.

Impact: a throughput-policy user with one checkpointing request loses the two-frame pipeline merged the day before in #645 (e85019b9), with no flag and no opt-out, and pays a drain per cold-prompt chunk. #661's stated purpose is to reduce decoder stalls, so a hard regression on the throughput path is the opposite of the intent.

Fix: make the predicate plan-aware — require that at least one masked, non-terminal request in this plan is itself age-priced (and gate terminal-cleanup streams on whether they share the plan), or add an explicit prefill_pipelining policy field so throughput() keeps the #645 pipeline. Then correct the PR description.

F3 (Major) — the non-terminal prefill rescan fires only at token_rate == 0.0, so the priced feasible set changes without the plan changing

service.rs:321-328:

            token_rate = token_rate.max(scan_prefill(terminal_only));
            if token_rate == 0.0
                && terminal_only
                && self.has_active_age_priced_stream()
                && !self.prefill_must_complete_terminally_from(request, start, cut)
            {
                token_rate = token_rate.max(scan_prefill(false));
            }

scan_prefill(skip_nonterminal) (service.rs:298-320) keeps only the kinds it is told to keep; skip_nonterminal = terminal_only means the first pass skips GraphKind::Prefill entirely. The fallback pass — the only one that prices non-terminal chunks — is reachable only while no terminal shape for this request yields a duration.

That price is not cosmetic: service.rs:475-483 rebases the stored price from it, and the doc contract it implements is docs/scheduling-runtime-design.md:240-251:

"Individually feasible prefill service rates price each request from the prefill catalog and operation it can execute (PREFILL, TERMINAL_PREFILL, or SCORED_PREFILL), excluding MIXED durations …"

Impact: terminal_only is a property of (request, cut, age_price) — the rate is a property of the feasible set, and after #661 the feasible set includes Prefill (policy.rs:1110-1141, :1462-1492). But the rate only reflects that when zero terminal shapes are measured. As soon as one TerminalPrefill capacity gets a GPU measurement — or as the last age-priced stream leaves and has_active_age_priced_stream() flips false — the computed rate jumps from the mixed-kind maximum to the terminal-only maximum or vice versa. ServicePrice::rebase(previous, rate) rescales the stored price by that ratio, so an unrelated event (a graph measurement landing, or another request finishing) rescales this request's prefill priority mid-prompt. The existing test only covers the token_rate == 0.0 branch (policy_tests.rs:8240-8243, "measured Prefill(2048) must provide fallback token_rate when TerminalPrefill is unmeasured"), so the discontinuity is untested.

Fix: when terminal_only && has_active_age_priced_stream() && !prefill_must_complete_terminally_from(...), always scan_prefill(false) — the zero-rate guard should exist only to avoid a full rescan when the terminal scan already covered the feasible set (i.e. !terminal_only). Add a test that measures one terminal shape and asserts the rate equals the non-terminal-inclusive maximum.

F4 (Major) — the interpolated estimate is optimistic, and the bias is largest exactly where the PR steers traffic

cost.rs:695-786. The relevant rungs:

            if matches!(
                key.kind,
                GraphKind::Decode | GraphKind::Speculative | GraphKind::Resume
            ) {
                decode_floor = Some(decode_floor.map_or(estimate.nanos, |f| f.min(estimate.nanos)));
                continue;
            }
            if key.batch != 1 || key.tokens == capacity {
                continue;
            }
        let (c_hi, _, t_hi) = hi?;
        let (c_lo, t_lo) = match lo {
            Some((c, _, t)) => (c, t),
            None => (0, decode_floor?.min(t_hi)),
        };
        let span = (c_hi - c_lo) as u128;
        let offset = (capacity - c_lo) as u128;
        let interp = u128::from(t_lo) + (u128::from(t_hi - t_lo) * offset) / span;

Three concrete defects:

  1. The floor is taken before the batch filter. The Decode | Speculative | Resume branch (:720-725) continues before if key.batch != 1 (:727), so an entry measured at any batch — including a large-batch decode that is cheap per step only because it wastes rows — sets the floor, and the loop takes the minimum over all such entries.
  2. The floor becomes the capacity-0 rung with no KV-context term. Peers get context pricing: pred.predict(key.tokens, start_position) plus with_borrowed_context_slope (:750-755). The floor rung (:777) reuses a raw decode nanos with no such term. Interpolating absolute nanoseconds from a decode step to a prefill peer assumes both graphs share the same fixed intercept, which they do not (peers fit theta0 + theta1*u per PrefillPredictor).
  3. No per-token normalization and no freshness check. Interpolation is between two peers' absolute times, so the result is exact only if the constant term matches at both capacities — it does not for widely separated peers (128 vs 16384). Unlike the borrowed-slope/stale-key path, interpolated_prefill_duration accepts arbitrarily old measurements (estimate.nanos != 0 is the only test at :717), so one old large-prefill measurement keeps every smaller shape "measured" indefinitely for ValueRate competition.

Quantified against the PR's own GB10 catalog (policy_tests.rs:7488-7505 prefill table; :7507-7518 decode, batch 1 = 28 ms), interpolating from the decode floor to Prefill(16384) = 1302 ms:

capacity estimate measured error
128 38.0 ms 45 ms −15.7%
256 47.9 ms 65 ms −26.3%
512 67.8 ms 98 ms −30.8%
1024 107.6 ms 150 ms −28.2%
4096 346.5 ms 380 ms −8.8%

The new unit test encodes the same arithmetic as ground truth — cost.rs test: let expected_4k = 18_000_000 + (1_302_000_000 - 18_000_000) / 4; (18 ms floor, 1302 ms peer) — so the test pins the optimistic formula rather than catching it.

Impact: this value is the ValueRate denominator for unmeasured candidates and it gates them by capacity <= nat_fit (policy.rs:1115-1116). Understating the smallest chunk's cost by ~30% means the exploration rule prefers the smallest unmeasured chunk by ~30% beyond what measured cost justifies: more chunks per prompt, therefore more drain barriers per prompt (F2) and more decoder stalls per prompt, at the same time the PR claims to reduce them. The body's own +1.8% makespan is consistent with this.

Fix: interpolate per-token time (or add the peers' fitted theta0) instead of absolute nanos; do not use an arbitrary decode step as the c = 0 rung unless it shares the fitted intercept with the peers — or require lo to be a measured prefill peer and return None otherwise; apply the same start_position context term to the floor rung; and enforce estimate_ttl-style freshness on candidates. Re-anchor the unit test to the measured table instead of the closed-form formula.

3. Architecture, contracts & charter compliance

F6 (Blocker) — the deferred_prefill kind resolution contradicts the published model contract, and the mutation guard now enforces the contradiction

scheduler.rs:895-910:

        let window = self.terminal_prefill_window();
        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
            };
        }

needs_terminal is computed and then ignored on that branch. Before this PR the guard additionally required needs_terminal, so a non-terminal-catalog capacity with a deferred request still ran as Prefill unless it was at a completion boundary.

The contract it overrides — helios/model-contract.md:182-186:

"Helios derives the tail-protection window from the prepared catalog as the largest PREFILL capacity absent from the TERMINAL_PREFILL catalog; those smaller PREFILL graphs execute complete continuation state. When a model declares no TERMINAL_PREFILL graphs, or omits a capacity from the terminal catalog, Helios falls back to PREFILL with no contract version change."

helios/model-contract.md is not in the changed-file list.

Impact: for any model that omits capacities from the terminal catalog, a request holding deferred prefill state can no longer use the smallest complete-state PREFILL graph. On the shipped catalog (PREFILL from 128, TERMINAL_PREFILL from 256) the minimum chunk quantum during deferred prefill doubles to 256 and every mid-prompt chunk pays full terminal-state rebuild cost instead of the cheaper continuation path — the opposite of "smaller prefill chunks". This is a captured-graph selection contract per the charter's "captured-graph op contracts … requires owner approval" rule, and the PR declares neither the change nor a version bump.

Enshrined in the mutation guard: verification/helios-lifecycle/check.py:527-535 changed the expected source for the "deferred prefill small cut bypass" mutation from the old if request.deferred_prefill && needs_terminal { to the new if request.deferred_prefill {, so the lifecycle check now protects the new rule and will not flag a regression against the documented fallback.

Fix: restore needs_terminal in the condition (or, if the widening is intended, state it as a contract change: update helios/model-contract.md:182-186, bump the contract version, get owner sign-off, and describe the reach in the PR body — the description only alludes to it as "excludes non-terminal-catalog shapes under deferred_prefill"), and update the mutation guard to assert the intended rule plus a regression case for the documented fallback.

F1 (Blocker) — the evidence does not describe the mergeable head, and one behavioural claim is false

PR body, Limits:

"SM120 A/B ran on fdb10bb5/82f68ea8 before resize_prefill/Discovery guards and 1fbcc3c9 rebase; template tests & kani unrun."

Every headline row in the body's Result table (the post-#663 mixed-c32 p99 −29.0% / >250 ms −78.9%, the T_50C peak-gap −21.6%, the 215 → 78 row, the 4x GB10 >1s stall 24 → 0) therefore predates the guards and the rebase onto 1fbcc3c9. Only the archive-tree claim (5bb2aff2, tree 74625efe6837 == c588d610) ties the head to any verification, and it is an author claim with no readable CI run.

Second claim, PR body "Chunking & drain":

"drains active-stream non-terminal Prefill (throughput pipelines)"

False per F2 (policy.rs:37, :50-52; scheduler.rs:998-999, :1187-1190).

Third, the gate: docs/design-review.md:195-208 requires "the screening and 64-seed validation catalog". The body claims learning.py (not opened) smoke+screen, whose presets use TRAINING_SEEDS = range(16) (scripts/scheduling_sim/learning_analysis.py:13); the held-out 64 seeds HELDOUT_SEEDS = range(10_000, 10_064) (learning_analysis.py:12) are only used by --preset validate. And the simulator's Graph carries only prefill_capacity/decode_capacity/width (scripts/scheduling_sim/model.py:24-36 (not opened)) — no TERMINAL_PREFILL splitting, no two-frame pipelining — so it cannot model either mechanism this PR changes even if run.

Impact: charter #210 requires served-workload evidence for a performance PR; the performance story here is on code that no longer exists, on a mechanism the simulator cannot represent. The throughput claim is a factual error about behaviour this PR introduces.

Fix: re-run the served A/B on c588d610 and report it; correct the throughput sentence (or make it true, per F2); run --preset validate or state explicitly that the simulator cannot model the changed mechanisms and add the capability first.

F7 (Minor) — the theory doc still contradicts the new behaviour; it only admits the simulator divergence

docs/scheduling-theory.md:93-96:

"All pure prefill, pure decode, and available mixed graphs compete on this score. No duration ceiling, prefill size preference, or breadth-before-depth rule precedes it."

docs/scheduling-theory.md:74-76: "Prefill has no externally visible per-chunk cadence."

The new paragraph at :558-565 concedes that the simulator's initial_discovery = "native" bootstraps unmeasured prefill shapes "without TERMINAL_PREFILL splitting or two-frame pipelining, whereas native Helios restricts solo (age_price == 0) cold discovery to natural fit and prices smaller unmeasured prefill capacities via GPU-measured interpolation" — but the earlier statements, which are the ones a reader uses for the contract, are unchanged. helios/README.md:285-287 and :426-431 now match the new behaviour, so the residual defect is theory-only.

Fix: amend :74-76, :93-97 and :119-120 to state the age-priced size preference and the drain cadence, in the same terms as the :558-565 paragraph, and note the service.rs feasible-set scope next to docs/scheduling-runtime-design.md:247-251.

4. Tests & claim accuracy

Open questions

  1. Is the deferred_prefill → TerminalPrefill widening (F6) intentional? Nothing in the PR body declares a model-contract change, and the contract file is untouched — if it is intentional the dossier's item A6 and the contract need to be reconciled by the author, not by a reviewer.
  2. Is the terminal_age_price = 1.0 survival in throughput() (F2) a deliberate decision to keep checkpoint barriers synchronous, or an oversight from #645? Either way the PR body's claim needs correcting.
  3. Is the potentially-optimistic interpolation (F4) load-bearing for the reported win, or would requiring a measured lo peer (no decode floor) still reproduce it? This is the cheapest experiment to settle the finding.
  4. Does any served A/B exist for c588d610 itself? None is reported and no CI run is readable for that commit.

What I could not verify

No CI result is readable for c588d610; the only verification tying the head to a result is the author's local archive claim (5bb2aff2, tree 74625efe6837). The Autobot Changes-Requested review targets 29f2b5b, pushed before the head, so its findings are not evidence about c588d610. The 15.3 s GB10 TTFT figure in the #538/#550 history comes from #550's description, not from a run I could inspect. kani and template tests are admittedly unrun.