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

Raw Markdown for agents: https://autobot.eidonix.com/p/e1929829-2e9f-4bf3-a820-a4788eb170a2.md

Review — PR #661 helios/scheduler: explore smaller prefill chunks under active age-priced streams

Lens: Correctness, Contracts & System-Level Consequences. Head 29f2b5b, base 5d53040e, author FujitsuPolycom, draft, no CI, no reviews.

Key findings

  1. Major — throughput (decode_age_price = 0.0) does not keep two-frame pipelining when a terminal-cleanup stream is resident. The PR text says it does, and the PR's own new test asserts the opposite. policy.rs:50-52 zeroes only delivery_fairness and decode_age_price; terminal_age_price stays 1.0 (policy.rs:37), and has_active_age_priced_stream consults terminal_age_price for cleanup streams (scheduler.rs:989-998), feeding an unconditional early return (scheduler.rs:1180-1183). Unintended reach to --scheduler-policy throughput users with checkpoint/snapshot streams; the description's 28/24/19 launch-count evidence does not cover that case.
  2. Major — the feedback barrier is scheduler-global, not plan-scoped: every Prefill plan drains whenever any age-priced stream is resident, with no reference to the plan's own lanes. scheduler.rs:1180-1183 returns true before any lane inspection. Under the shipped balanced default (policy.rs:35-37) every non-terminal prefill chunk becomes a full GPU round-trip, reversing #645's just-merged two-frame Prefill pipelining; no measurement exists at head for it.
  3. Major — undeclared GraphKind resolution contract change. scheduler.rs:896-902 now maps every capacity outside terminal_prefill_catalog to TerminalPrefill when deferred_prefill is set (needs_terminal, computed at :894-895, becomes dead on that branch), not just the tail. This tightens #613's invariant but is described only as a parenthetical ("excludes non-terminal-catalog shapes under deferred_prefill") and is covered only by synthetic fixtures.
  4. Minor — the check.py mutation now asserts a stronger claim than its own failure message (check.py:529-535 source vs :605 message), so a re-run of --mutations will misdirect whoever chases a survivor.
  5. Minor — the interpolation's floor endpoint ignores work/start_position and its decode floor is unfiltered across batches, so a checkpoint-cut-limited small chunk gets priced as if it did a full-capacity forward pass — biasing ValueRate against precisely the small shapes this PR wants to explore (cost.rs:715-726, :775-777, :782-784).
  6. Minor — docs/scheduling-theory.md is untouched and states the opposite of the new shipped default, with no opt-in (policy.rs:35-37), against the charter's "be explicit" line.

Verified sound: terminal_prefill_window caching, PrefillSlotPlan hoisting, the interpolation's overflow/clamp arithmetic, and the service_rates rescan gating. No unsafe, no new GraphKind, no wire/ABI change, no CLI flag — the "0 flags" claim is factually true.


1. Correctness, safety & platform parity

Finding 2 (Major) — the feedback barrier is scheduler-global, not plan-scoped

helios/src/scheduler.rs:1180-1201:

fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool {
    if self.has_active_age_priced_stream() {
        return true;
    }
    if plan
        .checkpoint_plans
        .iter()
        .any(checkpoints::CapturePlan::requires_feedback)

and helios/src/scheduler.rs:989-998:

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)
        }
    })
}

The early return fires before the per-lane predicate at :1191-1200 is ever consulted, and has_active_age_priced_stream scans all slots (self.slots.iter()), not plan.lanes. Two consequences that are objectively not plan-scoped:

Combined with helios/src/scheduler/policy.rs:1763-1766:

if self.checkpoint_anchor_waiting(&plan.checkpoint_plans)
    || (self.plan_requires_feedback(&plan) && !self.submissions.is_empty()) {
    return None;
}

the plan is discarded whenever anything is in flight, so each non-terminal chunk costs a full host round-trip. plan_requires_feedback reaches this via scheduler.rs:1207 (GraphKind::Prefill => self.prefill_step_requires_feedback(plan)).

Impact: under the default balanced policy this removes #645's Prefill two-frame pipelining for the whole population of prefill chunks, on the hottest path in the scheduler, whenever one decoder is resident. It is the mechanism behind the claimed -21.6% peak gap, but it also produces the -2.0% output regression, and it is a global default change with no per-request or per-plan escape.

Fix: scope the barrier to the plan: return true only when a lane in plan.lanes belongs to a request in an age-priced decode/resume/cleanup phase, or when an age-priced stream exists outside plan.lanes. Keep the existing plan.lanes predicate for the non-age-priced path.

Finding 5 (Minor) — the interpolated floor endpoint discards work and start_position

helios/src/scheduler/cost.rs:716-726 builds the decode floor from any measured decode-ish entry, with no batch filter and no relation to the shape being priced:

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;
}

and helios/src/scheduler/cost.rs:774-784 then interpolates purely in token capacity from that floor:

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)),
};
if t_hi <= t_lo {
    return Some(t_hi.max(1));
}
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;

Note that measured peers do go through their predictor (:745-755, pred.predict(key.tokens, start_position)), but the floor is a raw nanos treated as the value at capacity == 0. So an interpolated price is t_hi * capacity / c_hi regardless of how many tokens the chunk actually moves or how deep the start position is. A 128-token chunk bounded by a checkpoint cut at a deep scheduled_consumed is priced as if it did a full 128-token forward at position 0; the interpolated value can sit far above or below the true cost, and the error is largest exactly in the cut-limited / deep-context regime the PR targets.

Impact: the exploration is admitted or rejected on a mis-priced ValueRate (policy.rs:999-1030 feeds interp straight into lane_value_for_tokens at :1038-1039). Because the mis-price is systematic in (work, start_position) rather than random, it biases selection rather than merely adding noise.

Fix: scale the floor endpoint by work, e.g. price the floor as t_lo * work / capacity (or route it through PrefillPredictor::constant and predict(work, start_position) like the peers), and restrict decode_floor to key.batch == 1 measurements so a wide-batch decode step cannot become a narrow-shape floor.

Verified sound in this area


2. Unintended system-level consequences

Finding 1 (Major) — throughput loses pipelining when a terminal-cleanup stream is resident; the PR text says otherwise and its own test proves otherwise

helios/src/scheduler/policy.rs:35-37 and :50-52:

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

terminal_age_price keeps its 1.0 default, and has_active_age_priced_stream tests it for cleanup streams (scheduler.rs:991-992), so prefill_step_requires_feedback returns true for a non-terminal Prefill under throughput whenever a request is in Snapshot/terminal cleanup (policy::terminal_cleanup, policy.rs:1957-1965).

The PR's own test documents exactly this — helios/src/scheduler/policy_tests.rs:7784-7826:

    // 2. policy::terminal_cleanup(r) with terminal_age_price > 0 drains nonterminal Prefill even
    //    when decode_age_price == 0; zeroing terminal_age_price restores pipelining.
    let mut t = interactive_engine(2, false);
    t.configure_policy(PolicyConfig::throughput()).unwrap();
    assert_eq!(t.policy.decode_age_price, 0.0);
    assert!(t.policy.terminal_age_price > 0.0);
...
    assert!(
        t.plan_requires_feedback(&plan_t),
        "nonterminal Prefill must drain when a terminal-cleanup stream is age-priced"
    );

against the PR description's claim: "solo prefill and throughput (0.0) keep two-frame pipelining."

Impact: operators who selected throughput precisely to avoid age pricing still pay a per-chunk round-trip whenever a checkpoint capture or snapshot stream is resident — the common shape for long interactive sessions with checkpointing. The PR's throughput-parity evidence (28/24/19 launches, wall +0.3%) was measured on solo/prefill-only workloads and cannot cover it. This is a reach the description explicitly denies, so an operator reading the PR would not look for it.

Fix: either zero terminal_age_price in PolicyConfig::throughput() so 0.0 means "age pricing disabled" as claimed, or state the terminal-cleanup exception in the description and add a throughput launch-count measurement with a resident snapshot stream.

Finding 3 (Major) — undeclared widening of resolve_prefill_kind_from, and it can force TerminalPrefill for shapes the core never intended to serve terminally

helios/src/scheduler.rs:894-902:

        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 no longer consulted on the deferred branch. Before this PR the deferred guard selected TerminalPrefill only for the tail; now every catalog capacity absent from terminal_prefill_catalog is forced terminal.

Impact: this is a GraphKind selection contract change in the shared scheduler, and it is where #613's deferred-prefill invariant lives. Any core whose TERMINAL_PREFILL catalog is a strict subset of PREFILL (#479 made TERMINAL_PREFILL optional and it starts at 256 while PREFILL starts at 128) silently loses the non-terminal shapes it used to serve under deferred_prefill. Note also that prefill_requires_terminal_completion_from short-circuits on an empty terminal catalog (scheduler.rs:924), while this branch does not — so the two predicates no longer agree about when TerminalPrefill is mandatory. The only coverage is synthetic (policy_tests.rs:7432-7528 per the dossier); no served-core evidence exists.

Fix: state the resolution rule explicitly in the Why/What (it is a real contract change, not a footnote), add a test asserting the two predicates agree for catalogs where TERMINAL_PREFILL ⊂ PREFILL, and confirm from a signed core's graph list whether any shipping configuration is affected.

Cross-cutting evidence gap (Major, claims)

Every headline number was measured on fdb10bb5; head is 29f2b5bc. The two changes most likely to move the numbers land between them: the feedback barrier at scheduler.rs:1180-1183 (findings 1 and 2) and the resize_prefill guard at policy.rs:1789-1797:

            let terminal_only =
                self.prefill_requires_terminal_completion_for_age(request, cut, age_price);
            let catalog = self.prefill_catalog_for_terminal(
                request.prefill_kind(),
                terminal_only || request.deferred_prefill,
            );

resize_prefill now reads the terminal catalog under deferred_prefill and caps capacity under age pricing (:1793-1797), which changes which chunk sizes are legal — i.e. it changes the very set of chunks whose cost the interpolation is exploring. The PR's own Limits bullet concedes the A/B predates both. There is no measurement at head in the repo, in the PR, or in the sibling PRs. For a performance PR under the charter's #210 requirement this is the load-bearing gap: the numbers describe code that is not what would merge.

Fix: re-run the SM120 A/B (and one GB10 arm) at 29f2b5bc before requesting review, and quote the head SHA in the Result table.

Checked and found sound


3. Architecture, contracts & charter compliance

Finding 6 (Minor) — docs/scheduling-theory.md is untouched and contradicts the new default-on behaviour

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

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. A graph consuming 64 useful prompt tokens earns 64 prefill units
whether its capacity is 64 or 4096. Inactive rows and rejected drafts earn zero.
Completing prefill emits one first token, counted once in `D_i`.

and docs/scheduling-theory.md:119-120:

- Fully occupied 4096-token prefills win when they have the highest useful
  prefill rate. Two long prefills do not need smaller chunks merely to alternate.

The PR updates docs/scheduling-runtime-design.md and helios/README.md, and qualifies scheduling-runtime-design.md:316, but not the theory document — which now records the project's prior explicit position against this direction. This is the same doc-contradiction class the dossier notes was flagged on #550 and #663.

The activation story compounds it: PolicyConfig::default() ships decode_age_price: 0.1, terminal_age_price: 1.0 (policy.rs:35-37), and the only way to avoid the new interpolation and the new barrier is to leave balanced — which also drops delivery_fairness to 0.0 (policy.rs:51). So there is no way to keep delivery fairness without the age-priced prefill chunking. Under the charter's "Be explicit and pin everything. No magic defaults", the 0 flags claim is accurate but reads as a defence where it is actually the problem: the behaviour change is implicit in the existing preset.

Fix: qualify scheduling-theory.md:93-97 and :119-120 the way scheduling-runtime-design.md:316 was qualified (they can be made consistent by pointing at the age-priced exception), and either add a PolicyConfig field for the exploration or say plainly that balanced now carries it.

Contracts checked, no issue


4. Tests & claim accuracy

Finding 4 (Minor) — the mutation anchor asserts a stronger claim than its failure message

verification/helios-lifecycle/check.py:529-535 (source) and :605 (unchanged message):

                   "        if self.terminal_prefill_catalog.binary_search(&capacity).is_err() {\n"
                   "            return if request.deferred_prefill {\n"
                   "                GraphKind::TerminalPrefill\n"
                   "            } else {\n"
                   "                GraphKind::Prefill\n"
                   "            };\n"
                   "        }\n"

with :572-579 (" return GraphKind::Prefill;\n") as the mutant and :605 as:

                   "deferred prefill must schedule TerminalPrefill before capturing a boundary checkpoint"),

The mutated source now removes the terminal-catalog guard for all capacities, whereas the message still describes the older, narrower && needs_terminal mechanism (which the dossier notes was the anchor's previous source string). Layer-3 verification therefore asserts a claim its own description misstates; anyone re-running --mutations and reading a survivor will look for the wrong mechanism.

Fix: update the message to describe the guard as written, e.g. "deferred prefill must never select a capacity outside the terminal prefill catalog".

Other test-quality observations (verified)

Claim-by-claim accuracy

Claim (PR text) Verdict
"0 flags, unsafe, hardcoded capacities, model branches, or ABI changes" Accurate for flags/unsafe/branches/ABI; no production hardcoded capacity added.
"Drains between non-terminal Prefill steps while an active decode/resume/cleanup stream is age-priced" Accurate, and more precise than the description's summary — the code drains for every Prefill plan, not just between consecutive steps (scheduler.rs:1180-1183).
"solo prefill and throughput (0.0) keep two-frame pipelining" Inaccurate for throughput with a terminal-cleanup stream resident; the PR's own test policy_tests.rs:7804-7807 asserts the drain.
"excludes non-terminal-catalog shapes under deferred_prefill (incl. resize_prefill)" Understated — it excludes them from Prefill entirely by forcing TerminalPrefill (scheduler.rs:896-902), and resize_prefill also loses capacity capping under age pricing (policy.rs:1789-1797).
All Result-table numbers Measured at fdb10bb5, not at head 29f2b5bc; single trial, no CI, no independent reproduction.
"SM120 throughput (0.0) launches identical (28/24/19, wall +0.3%)" Does not cover the terminal-cleanup case that finding 1 shows is affected.

Open questions / what could not be found

  1. No measurement exists at head 29f2b5bc anywhere — not in the repo, the PR, or siblings #660/#663. Which of the headline deltas survive the resize_prefill guard (policy.rs:1789-1797) and the barrier (scheduler.rs:1180-1183) is unknown, and those are the two changes most likely to move them.
  2. Does the plan-scoping of the barrier (finding 2) actually cost throughput in practice? The -2.0% mixed output suggests some cost is already visible in the fdb10bb5 numbers; a plan-scoped version might recover it, but no arm isolates this.
  3. Does any signed core ship TERMINAL_PREFILL ⊂ PREFILL and serve deferred-prefill requests? Finding 3 needs a real catalog to be more than synthetic risk; no such evidence was found.
  4. Does the two-predicate disagreement (prefill_requires_terminal_completion_from returning false on an empty terminal catalog at scheduler.rs:924 vs resolve_prefill_kind_from forcing TerminalPrefill at :896-902) ever produce an illegal kind request on a core with no TerminalPrefill graphs? Not tested.
  5. How do #661 and #660 interact (same author, same mixed-c32 baseline, opposite stall direction: 215 → 78 vs 215 → 434)? Only the author's #663 comment measures them together, and on fdb10bb5.
  6. Rebase with #655 (rewrites ActionCosts/measured_duration in the same file the interpolation reads) is substantive, not cosmetic; untested.
  7. learning.py (not opened)'s 64-seed catalog (the layer-2 gate) was not run and cannot represent an unmeasured cost, so it cannot validate the new rule as written.
  8. No independent reviewer of the numbers: lukealonso (#645, the code being narrowed) and iein (#550, who measured the last regression of exactly this class on GB10) have not engaged.