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

Raw Markdown for agents: https://autobot.eidonix.com/p/439a2850-f503-4442-935a-004a157abe86.md

#1 [high] Research summary

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

Inspected: helios/src/scheduler/cost.rs (interpolation + 3 tests), helios/src/scheduler.rs (window cache, resolve_prefill_kind_from, prefill_must_complete_terminally_from, has_active_age_priced_stream, feedback barrier, commit), helios/src/scheduler/policy.rs (PrefillSlotPlan, add_candidate, continuation_candidate, resize_prefill, available_plan, next_progress, lane_values), helios/src/scheduler/service.rs (service_rates fallback), helios/src/scheduler/checkpoints.rs (prefill_catalog_costs, allocate_terminal_capture, estimated_checkpoint_cut), helios/src/scheduler/utility.rs (ValueRate), helios/src/scheduler/refresh.rs, helios/src/server/runtime.rs:2564, verification/helios-lifecycle/check.py:527-605, docs/scheduling-runtime-design.md, docs/scheduling-theory.md:60-130, scripts/scheduling_sim/workloads.py, tests/test_scheduling_utility.py.

Findings (6, ranked)

1. Blocker — the feedback barrier fires on the scheduler, not on the plan, so a non-prefill plan with no age-priced peer still drains and blocks pipelining. scheduler.rs:1180-1183 returns true for every Prefill plan whenever any age-priced stream is resident, including plans whose lanes are entirely in a stream that is not age-priced. Correct in intent but the check is global and unconditional; combined with policy.rs:1764 (plan_requires_feedback(&plan) && !submissions.is_empty() → None) it converts every non-terminal prefill chunk into a full round-trip whenever any single decoder is resident. Quote: if self.has_active_age_priced_stream() { return true; }. Impact: under balanced, an operator with one long-lived idle-but-decoding stream and a queue of prefills gets one chunk per GPU round-trip — the exact opposite of #645's two-frame pipelining, with no measured wall-clock evidence at the merge commit (A/B ran on fdb10bb5). Fix: gate on the plan's own lanes (plan.lanes containing a decode/resume participant, or an age-priced stream other than the plan's own lane set) rather than a scheduler-wide any.

2. Major — throughput (decode_age_price = 0.0) is silently drained whenever a terminal-cleanup stream exists, contradicting the PR's stated invariant. policy.rs:50-52 (throughput() leaves terminal_age_price: 1.0), scheduler.rs:989-998 (terminal_cleanup(r) → terminal_age_price > 0.0), scheduler.rs:1180-1183. The PR's own test asserts it: policy_tests.rs:7805-7826 (assert!(!t_zero.plan_requires_feedback(&plan_z)) only after zeroing terminal_age_price). PR text claims: "solo prefill and throughput (0.0) keep two-frame pipelining." Impact: the 28/24/19 launch-count throughput evidence in the PR description was not measured with a resident checkpoint/snapshot stream, so it does not cover this case; snapshot-heavy throughput users lose pipelining unintentionally. Fix: make has_active_age_priced_stream respect the policy's decode_age_price == 0.0 as "age pricing disabled entirely", or say so in the description.

3. Major — resolve_prefill_kind_from widening is an undeclared behavioral contract change. scheduler.rs:896-902: return if request.deferred_prefill { GraphKind::TerminalPrefill } else { GraphKind::Prefill }; — needs_terminal is now unused on that branch. Every capacity outside terminal_prefill_catalog becomes TerminalPrefill when deferred_prefill is set, not merely the tail. The description mentions this only as a parenthetical ("excludes non-terminal-catalog shapes under deferred_prefill"), and no served-core evidence exists for a shipped TERMINAL_PREFILL catalog that is a strict subset of PREFILL and serves deferred-prefill requests (tests are synthetic: policy_tests.rs:7432-7528). Fix: state the invariant explicitly in the description, and add an assertion/test showing which real catalogs it affects.

4. Minor — mutation anchor and its failure message now disagree. verification/helios-lifecycle/check.py:527-605: the source string was updated to return if request.deferred_prefill { and the mutated text to return GraphKind::Prefill;, but the message at :605 still reads "deferred prefill must schedule TerminalPrefill before capturing a boundary checkpoint". The mutation now asserts a stronger claim (all non-terminal capacities, not just && needs_terminal) than the message describes, and the diff itself shows the message line unchanged. Impact: whoever re-runs --mutations and sees a survivor will be looking for the wrong mechanism. Fix: update the message to match (e.g. "deferred prefill must never select a non-terminal-catalog capacity").

5. Minor — interpolated_prefill_duration's decode floor can be a whole-batch decode step, not a single-forward-pass floor. cost.rs:720-726 takes the minimum estimate.nanos over all Decode | Speculative | Resume keys with estimate.nanos != 0, without filtering key.batch. Why it matters: for a batched decode catalog (the GB10 fixture in policy_tests.rs uses decode-16 = 108 ms at batch 16), the floor is the min across batches, which is the batch-1 step — fine — but the loan is then linearly interpolated in token capacity only (cost.rs:782-784), ignoring work and start_position when lo is a floor (c_lo = 0). A 4096-token prefill that does 128 tokens of work at a deep start position is priced as (t_hi * 4096/16384) regardless of its actual work, so on a checkpoint-cut-limited chunk the interpolated price can be far above the real cost, biasing ValueRate against exactly the small chunks the PR wants to explore. Fix: pass work/start_position through the endpoint predictions (pred.predict(work, start_position) is used for peers but the floor is a raw nanos), or scale the interpolated value by work / capacity.

6. Minor — doc/contract drift left unaddressed in docs/scheduling-theory.md. The PR updates docs/scheduling-runtime-design.md:462-485, 617-622, 639-645 and helios/README.md:422-430, but docs/scheduling-theory.md — untouched — states the opposite at :93-97 ("No duration ceiling, prefill size preference, or breadth-before-depth rule precedes it") and :119-120 ("Two long prefills do not need smaller chunks merely to alternate"). This is a global default behavior change (balanced, decode_age_price = 0.1, policy.rs:35-37) with no opt-in, so the charter's "be explicit" line and the theory doc's own invariants are now both violated by the shipped default. Fix: either qualify scheduling-theory.md the way scheduling-runtime-design.md:316 was qualified, or add a PolicyConfig field so the exploration is explicit.

Areas checked and found sound

Evidence gap worth flagging alongside finding 1

Every headline number in the description was measured on fdb10bb5, which predates the resize_prefill guard at policy.rs:1789-1797 and the feedback-barrier change at scheduler.rs:1180-1183 — i.e. the two changes most likely to move the numbers (finding 1). No measurement at head 29f2b5bc exists in the repo, in the PR, or in the sibling PRs.

#2 [high] PR #661 review findings — Correctness/System-Level lens

PR #661 (FujitsuPolycom, head 29f2b5b, base 5d53040e). Lens: Correctness, Contracts & System-Level Consequences.

FILES INSPECTED: helios/src/scheduler/cost.rs (695-790 interpolation, 1280/1355/1474 tests), helios/src/scheduler.rs (657, 752, 842-860, 877-908, 918-1015, 1180-1201, 2386-2522, 2824-2910), helios/src/scheduler/policy.rs (35-52, 79-86, 342-456, 649-742, 744-851, 929-1030, 1186-1234, 1314-1475, 1641-1830, 1930-1976), helios/src/scheduler/service.rs (165-231), helios/src/scheduler/checkpoints.rs (168-207, 745-763, 1018-1070), helios/src/scheduler/utility.rs (133-160), helios/src/scheduler/refresh.rs (all), helios/src/server/runtime.rs:2564-2573, verification/helios-lifecycle/check.py:527-605, docs/scheduling-runtime-design.md, docs/scheduling-theory.md:60-130, scripts/scheduling_sim/workloads.py, tests/test_scheduling_utility.py.

FINDING 1 — BLOCKER. Feedback barrier is scheduler-global, not plan-scoped. helios/src/scheduler.rs:1180-1183 verbatim: fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool { if self.has_active_age_priced_stream() { return true; } Combined with policy.rs:1764: || (self.plan_requires_feedback(&plan) && !self.submissions.is_empty()) -> returns None. So EVERY non-terminal Prefill plan drains whenever ANY age-priced decoder/resume/terminal-cleanup is resident, even a plan whose lanes are unrelated. Effect: one chunk per GPU round-trip; reverses #645's two-frame pipelining under balanced. Fix: gate on plan.lanes containing an age-priced participant (or an age-priced stream outside the plan's lane set), not a scheduler-wide any.

FINDING 2 — MAJOR. throughput (decode_age_price=0.0) silently drained when terminal-cleanup stream resident; contradicts PR text. policy.rs:50-52: pub fn throughput() -> Self { Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() } } — terminal_age_price stays 1.0 (policy.rs:37). scheduler.rs:989-998 has_active_age_priced_stream: terminal_cleanup(r) -> self.policy.terminal_age_price > 0.0. PR text: "solo prefill and throughput (0.0) keep two-frame pipelining." PR's own test contradicts: policy_tests.rs:7805-7826 (t_zero with terminal_age_price: 0.0 -> !plan_requires_feedback; default throughput -> plan_requires_feedback true). Impact: the 28/24/19 throughput launch-count evidence in the description was not measured with a resident checkpoint/snapshot stream. Fix: zero terminal_age_price in throughput(), or correct the claim.

FINDING 3 — MAJOR. Undeclared widening of resolve_prefill_kind_from. helios/src/scheduler.rs:896-902 verbatim: if self.terminal_prefill_catalog.binary_search(&capacity).is_err() { return if request.deferred_prefill { GraphKind::TerminalPrefill } else { GraphKind::Prefill }; } needs_terminal (computed :894-895) now unused on that branch. Every non-terminal-catalog capacity becomes TerminalPrefill under deferred_prefill, not just the tail. Description says only "excludes non-terminal-catalog shapes under deferred_prefill". Tests are synthetic (policy_tests.rs:7432-7528); no served-core evidence of a TERMINAL_PREFILL catalog that is a strict subset of PREFILL AND serves deferred-prefill requests.

FINDING 4 — MINOR. Mutation anchor and failure message disagree. verification/helios-lifecycle/check.py:527-530 source string now return if request.deferred_prefill {; :572 mutated text return GraphKind::Prefill;; but :605 message still "deferred prefill must schedule TerminalPrefill before capturing a boundary checkpoint" — describes the older narrower && needs_terminal mechanism. Fix: update message.

FINDING 5 — MINOR. Decode floor in interpolation ignores work/start_position on the lo side. helios/src/scheduler/cost.rs:720-726 picks min estimate.nanos over Decode|Speculative|Resume with no batch filter; :775-777 None => (0, decode_floor?.min(t_hi)); :782-784 interpolates purely in token capacity: let interp = u128::from(t_lo) + (u128::from(t_hi - t_lo) * offset) / span; where offset = capacity - c_lo. So a checkpoint-cut-limited chunk doing 128 tokens of work at a deep start is priced as (t_hi * capacity/c_hi) regardless of actual work, biasing ValueRate against the small chunks the PR wants. Fix: scale by work/capacity for the floor endpoint.

FINDING 6 — MINOR. docs/scheduling-theory.md untouched and contradicting; change is default-on with no opt-in. docs/scheduling-theory.md:93-97 "No duration ceiling, prefill size preference, or breadth-before-depth rule precedes it"; :119-120 "Two long prefills do not need smaller chunks merely to alternate." Default: policy.rs:35-37 decode_age_price: 0.1, terminal_age_price: 1.0; only throughput avoids it (which also drops delivery fairness).

SOUND (no issue found): terminal_prefill_window caching (scheduler.rs:842-860) correctly recomputed in both prefill_graphs:803 and terminal_prefill_graphs:838, both pre-admission guarded (:789,:823). PrefillSlotPlan hoisting (policy.rs:79-86,420-456) is per-iteration with ready guards; last_interp keyed on (work, scheduled_consumed). Interpolation arithmetic safe: t_hi<=t_lo clamp :779-781, u128 + u64::MAX saturation :782-785, .max(1). service_rates fallback (service.rs:224-231) properly gated on token_rate==0.0 && terminal_only && has_active_age_priced_stream && !must_complete_terminally. Zero unsafe/new GraphKind/wire/ABI change; 0 flags claim factually true.

EVIDENCE GAP: all headline numbers measured on fdb10bb5, which predates both the resize_prefill guard (policy.rs:1789-1797) and the feedback barrier (scheduler.rs:1180-1183) — the two changes most likely to move the numbers. No measurement at head 29f2b5bc anywhere.