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

Raw Markdown for agents: https://autobot.eidonix.com/p/6c958f55-2fec-461f-a503-316c0a4cd16b.md

#1 [high] PR #663 correctness lens — primary findings with citations

  1. BLOCKER-ish: docs/scheduling-theory.md:850-853 unchanged, states the exact invariant the PR inverts: "First-token waiting has no independent age penalty: prompt work competes by its useful progress and token-service price." New credit is gated on PolicyConfig::decode_age_price (policy.rs:35 = 0.1 in Default; :51 = 0.0 in throughput()), and balanced is the documented default (docs/cli-design.md:683; flare-cli/src/cli.rs:546, :861). So a shipped default behavior change with the contradicting contract doc left stale.

  2. MAJOR: observability gap. helios/src/server/metrics/scheduler.rs:55-70 RequestDetail exposes last_progress_ns (:61) and last_output_ns (:62) but the new clock first_output_wait_ns (policy.rs:59) is never published (runtime.rs:1231-1240 populates the detail). Operators cannot see or verify the new default-affecting clock.

  3. MAJOR: existing regression assertions weakened. tests/test_scheduling_utility.py:388-395 replaced coal_ttft < base_ttft*0.85, end_ms < base*0.95, sub <= base_sub//2 with absolute coal_ttft <= 600.0 / coal_sub <= 2; and low_coal_sub < low_base_sub -> == 0. helios/src/scheduler/policy_tests.rs:6843-6862 replaced the simultaneous-burst relative comparison with sim_coal_sub == 0 only (no TTFT/makespan assertion for the simultaneous case). PR description calls this only "updated the burst-coalescing isolation tests".

  4. MINOR: simulator mirror does not implement the two novel mechanisms. scripts/scheduling_sim/utility.py:251-259 uses now_ms - view.last_service_ms (no first_output_wait_ns, no anchor-cut preservation, no readmission clamp) and multiplies by view.weight (:257) which Rust has no analogue for (policy.rs:750-751). So the 21/21 trace-identity and "zero regressions" simulator claims cover only the credit term, not the anchor/readmission behavior, which is Rust-unit-test-only.

  5. MINOR: ignition/direct/policy.py:114-126 Accounting is documented as "Helios's RequestAccounting" and LaneValue (:129-142) as "Mirrors utility.rs LaneValue", but neither gained first_output_wait_ns / first_output_value. Partly excused by docs/scheduling-runtime-design.md:15-19 ("reproduces the selection ... only for decode rounds").

  6. MINOR (claim accuracy): docs/scheduling-utility.md:290-294 says b_served * T_dec is the incumbent decode round's measured duration "minimizing T_dec / b_served"; the implementation (service.rs:150-182, esp. :168-173) selects the catalog graph minimizing per-delivery time across Decode/Speculative AND mixed shapes, which need not be the round the scheduler actually runs. best_decode.1^2 * best_decode.0 = b*T (arithmetic correct).

  7. NO issue found (say so): hot path — preserve_first_output_wait (scheduler.rs:2681-2702) is guarded by cheap predicates including request.checkpoint_capture.is_some_and(...) before the O(catalog) fits_single_prefill_from (policy.rs:442-464), so the scan is normally short-circuited. delivery_references_and_decode_batch (service.rs:69-183) adds only two float comparisons per slot in the existing single pass; no new allocations, no new locks, arithmetic stays f64 in the single-threaded &mut self scheduler. set_first_output_wait (policy.rs:271-281) mirrors set_arrival's guard, and runtime.rs:1574-1577 calls it right after set_arrival, so its error conditions cannot fire on that path.

#3 [high] Research summary

Reviewed PR #663 through the correctness/contracts/system-consequences lens, opening the full diff plus every changed production file and its direct callers (policy.rs, utility.rs, service.rs, scheduler.rs, server/runtime.rs), the mirrored simulator and ignition scheduler, the metrics surface, and the affected tests.

Verdict: the implementation is mechanically careful and the hot-path cost is genuinely small — the new anchor-cut predicate short-circuits cheap checks before its O(catalog) scan, the decode-batch return value rides the existing single pass with no new allocations or locks, and throughput-policy inertness is structural. I found no race, panic, or unbounded-growth hazard.

The real issues are contract and evidence shaped. Most serious: the PR inverts an explicit documented invariant — docs/scheduling-theory.md:850-853 still says "First-token waiting has no independent age penalty" — while changing a shipped default (decode_age_price = 0.1 under balanced, the documented and CLI default), with no knob and no way for an operator to observe the new clock (the new first_output_wait_ns is absent from RequestDetail, unlike last_output_ns). Second: two existing regression tests were converted from relative guarantees to absolute ceilings, which the description mentions only as "updated the burst-coalescing isolation tests". Third: the Python "mirror" implements the credit term but not the anchor-cut preservation or readmission clamp — the two most novel mechanisms — and additionally multiplies by a request weight Rust has no analogue for, so the trace-identity claims do not cover the behaviour that motivates the PR.

Findings, quotes, severities, and concrete fixes are in the scratchpad (entries 1 and 2).

#4 [high] PR #663 — verbatim quotes for each finding

Verbatim quotes for the report (all read directly this session).

F1 Contract inversion. docs/scheduling-theory.md:847-853 (unchanged by this PR): "The ongoing policy uses separate intrinsic output value, token fairness, delivery fairness, and decode-age coefficients. Their concrete defaults and units are specified in the native design. First-token waiting has no independent age penalty: prompt work competes by its useful progress and token-service price. A burst earns its accepted token volume and one delivery. The delivery reference accounts for feasible batching; changing a rate normalizer preserves marginal service prices across phases." helios/src/scheduler/policy.rs:29-35: "impl Default for PolicyConfig / fn default() -> Self / Self { / output_token_value: 64.0, / token_fairness: 16.0, / delivery_fairness: 4.0, / decode_age_price: 0.1," policy.rs:50-52: "pub fn throughput() -> Self { / Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() } / }" docs/cli-design.md:683-685: "flare run --scheduler-policy balanced is the default and balances token / throughput with output cadence. For throughput-oriented serving, use / flare run model.safetensors --gpus 0,1,2,3 --scheduler-policy throughput." flare-cli/src/cli.rs:859-861: "#[arg(long, value_name = "MODE", default_value = "balanced", / value_parser = ["balanced", "throughput"], help_heading = "Serving options")] / pub scheduler_policy: String," and cli.rs:546 scheduler_policy: "balanced".into(), New credit gate, policy.rs:729-733: "} else if r.consumed_tokens < r.prompt_tokens as u64 / && r.max_new_tokens > 0 / && self.policy.decode_age_price > 0.0 / && incumbent_decode_batch_ms > 0.0 / {"

F2 Observability. helios/src/server/metrics/scheduler.rs:55 struct RequestDetail, :61 "pub last_progress_ns: u64,", :62 "pub last_output_ns: Option," — no first_output_wait_ns. Populated at helios/src/server/runtime.rs:1231-1240: "Some(RequestDetail { / handle: live.handle, / phase: live.phase, / consumed: live.consumed_tokens, / prompt: live.prompt_tokens, / generated: live.generated_tokens, / last_progress_ns: accounting.last_progress_ns, / last_output_ns: accounting.last_output_ns, / published_deliveries: accounting.published_deliveries, / })" New field declared policy.rs:59 "pub first_output_wait_ns: u64,".

F3 Weakened assertions. tests/test_scheduling_utility.py hunk "@@ -361,30 +361,67 @@" removes: "- assert coal_ttft < base_ttft * 0.85, f"expected >=15% max TTFT reduction: {coal_ttft} vs {base_ttft}"" "- assert coal.trace[-1]["end_ms"] < base.trace[-1]["end_ms"] * 0.95" "- assert coal_sub <= base_sub // 2, f"coal_sub={coal_sub}, base_sub={base_sub}"" "- assert low_coal_sub < low_base_sub, f"low_coal_sub={low_coal_sub}, low_base_sub={low_base_sub}"" adds: "+ assert coal_ttft <= 600.0, f"expected coalesced balanced max TTFT <= 600ms, got {coal_ttft}"" "+ assert coal_sub <= 2, f"expected <=2 sub-batch rounds, got {coal_sub}"" "+ assert low_coal_sub == 0, f"expected 0 low-acceptance sub-batch rounds, got {low_coal_sub}"" Rust twin, helios/src/scheduler/policy_tests.rs hunk "@@ -6826,14 +6840,23 @@" adds: "// On simultaneous arrivals, default balanced policy keeps zero sub-batch fragmentation. / let (sim_coal_sub, sim_coal_full, _) = / run_burst(PolicyConfig::default().coalescing_horizon_tokens, false); / assert_eq!(sim_coal_sub, 0, "expected zero sub-batch fragmentation on simultaneous burst"); / assert!(sim_coal_full >= 120, "expected full B=4 decode rounds, got {sim_coal_full}");" — no TTFT/makespan assertion for the simultaneous case, which was the original test's whole point.

F4 Simulator not a mirror. scripts/scheduling_sim/utility.py:251-259: "if self.config.age_price > 0 and incumbent_decode_batch_ms > 0: / for view in views: / if view.remaining_prefill > 0 and view.output_budget > 0: / age_ms = now_ms - view.last_service_ms / if age_ms > 0: / self._first_output_value[view.name] = ( / unit * self.config.age_price * view.weight / * incumbent_decode_batch_ms * age_ms / )" Rust, policy.rs:745-751: "let age_ms = self / .now_ns / .saturating_add(window_ns) / .saturating_sub(wait_start) as f64 / / 1e6; / values[slot].first_output_value = / self.policy.decode_age_price * incumbent_decode_batch_ms * age_ms;" Python has no first_output_wait_ns, no anchor preservation, no readmission clamp, and an extra view.weight Rust lacks.

F5 Ignition mirror drift. ignition/direct/policy.py:115-120: '"""Helios's RequestAccounting and ServiceAccounting for one request; times are scheduler nanoseconds.""" ... arrival_ns: int = 0 ... last_progress_ns: int = 0 ... last_output_ns: int | None = None' (no first_output_wait_ns); :130-138 '"""Mirrors utility.rs LaneValue; values share one scaling factor within a decision."""' (no first_output_value). Partly excused by docs/scheduling-runtime-design.md:15-19: "The diagnostic ignition debug-serve --direct path has its own Python / scheduler in ignition/direct/. It reproduces the selection specified here / only for decode rounds".

F6 (revised, higher value) b_servedT_dec can be a MIXED graph, not a decode round. service.rs:150-160 inside the Decode/Speculative iteration also calls consider() for every mixed_catalog shape: "if matches!(kind, GraphKind::Decode | GraphKind::Speculative) { / for &(batch, width, prefill) in &self.mixed_catalog { / if let Some(ns) = self / .costs / .shape_duration(GraphKind::Mixed, batch, width, prefill) / .filter(|ns| ns > 0) / { / consider(ns, batch, mask); / } / } / }" then service.rs:168-173 promotes it: "if matches!(kind, GraphKind::Decode | GraphKind::Speculative) / && (per_delivery_ms < best_decode.0 / || (per_delivery_ms == best_decode.0 && served > best_decode.1)) / { / best_decode = (per_delivery_ms, served); / }" and :177-179 "let incumbent_decode_batch_ms = if best_decode.0.is_finite() { / best_decode.1 * best_decode.1 * best_decode.0". A Mixed graph's duration includes prefill work, so the credit's "decode round" duration can be inflated. Docs say otherwise: docs/scheduling-runtime-design.md:271-273 "Here b_served * T_dec is the fastest incumbent Decode or Speculative / round's work-time in stream-milliseconds"; docs/scheduling-utility.md:290-293 "T_dec is the measured duration in milliseconds of the decode or speculative graph minimizing T_dec / b_served". Reachability: mixed graphs exist for Qwen3.8 (docs/scheduling-runtime-design.md:27-29 "Ignition captures mixed graphs only when given --mixed-prefill, and only for recipes that declare mixed capture; the Qwen3.8 Flash recipe ... is the one that does"). Arithmetic bbper_delivery == b*T is correct; the reference selection is the issue. Fix: skip mixed shapes for best_decode (guard the mixed loop with kind != GraphKind::Mixed-style exclusion, i.e. only feed best_decode from the pure decode/speculative consider calls), or rename/redocument the term as "fastest incumbent serving round".

Also F6b ceiling check: even the pure-catalog part selects the graph minimizing T/b over the whole catalog rather than the round actually in flight (service.rs:110-122 best[] per slot), so "incumbent" is a slight misnomer; low severity, docs already say "batch-feasible".

No-issue / verified-sound list and residual concerns are in entry 2.

#2 [medium] PR #663 — secondary notes: gating, anchor predicate, coalescing stacking