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

Raw Markdown for agents: https://autobot.eidonix.com/p/c5800baa-2070-420c-8820-3924270bc5ab.md

#1 [high] Research summary

Correctness, Contracts & System-Level Consequences — PR #644

I read the full diff plus head code for utility.rs, service.rs, policy.rs, rounds.rs, speculation.rs, scheduler.rs (completion path), policy_tests.rs, scripts/scheduling_sim/utility.py, helios/README.md and docs/scheduling-runtime-design.md.

The arithmetic is sound. I re-derived σ_i = (K−b)T/b against service.rs:59-161, the excluded-only age cancellation in decode_within (utility.rs:101-119) against the common −T/2·Σc subtraction in ValueRate::new (utility.rs:142-152, summed at policy.rs:493), and the rewritten exact-Bellman identity (utility.rs:338-383). With σ=0, s=1, preceding=0 the score reduces to v/T + g + c·A. No arithmetic contradiction with the PR text, no ABI/proto/core-format file touched, no new allocation on the plan hot path beyond pre-existing per-round Vecs. The calibration data path is correct too: per-row row_realized ascending depths, prev_realized seeded at 1.0 and advanced outside the skip branch, and the inheritance loop prefers local over global at each shallower depth as documented.

Findings (all verified at head):

  1. Blocker/Major — contract docs left contradictory, in the exact sentence another open PR fixes. helios/README.md:446-450 still reads "scaled by a request-local aged per-depth verification calibration ratio … clamped to [0, 2]", while rounds.rs:13 is CALIBRATION_FACTOR_MAX: f64 = 4.0 and the priced quantity is now a cumulative product of per-step factors. The PR edits only the calibration section of docs/scheduling-runtime-design.md. Fix: update this sentence in the same PR.

  2. Major — delivery accounting is still documented as one-delivery-per-burst. docs/scheduling-runtime-design.md:527-538 still says "replaces that interval's delivery update with one served delivery" and "initializes a missing delivery history to one delivery over its measured frame duration"; at head it is price.observe(duration_ms, duration_ms, 1.0, …) (service.rs:47-52) and ServicePrice::initial(1.0) (service.rs:424). The diff hunk starts at line ~110, so this section is untouched. Fix: amend §"Completion initially records zero deliveries".

  3. Major — the finish change is under-described and reprices terminal retirement under --scheduler-policy throughput too. utility.rs:121-130 now charges the full horizon and completion_ms is used only by a debug_assert; PolicyConfig::throughput() (policy.rs:49) zeroes only delivery_fairness/decode_age_price and leaves terminal_age_price = 1.0 (policy.rs:36). PR text says only "updated LaneValue::finish". Fix: state the semantic change and confirm the intent for the throughput policy.

  4. Major — global default change with no opt-in, and two config knobs silently change dimension. The age/delivery half runs for every core shape and both policies (only calibration is gpu_confidence()-gated, rounds.rs:472-474); delivery_fairness/decode_age_price keep their names and defaults (policy.rs:33-34) while measuring a dimensionless served share instead of a burst rate. Anyone who tuned them via configure_policy/CLI gets the same numbers with different units. Charter: "Be explicit… no magic defaults".

  5. Major — undocumented derivations. CALIBRATION_FACTOR_MAX = 4.0 (rounds.rs:13), the flat 0.5 prior vec![DepthCalibration::new(0.5); token_capacity - 1] (rounds.rs:337), and the round weight clamp(sum_w / count as f64, 0.0, 1.0) (rounds.rs:701-706, divisor is the lane count, so a depth whose survival-weighted samples average w learns α ≈ w/weight — depth 3 at w≈0.15 learns ~7× slower than depth 0) are all unjustified in code or docs. This is the identical gap #632 was twice asked to close.

  6. Minor — the unweighted estimator is now test-only, and the existing bleed test no longer exercises the production path. rounds.rs:353-356 gates observe_calibration behind #[cfg(test)]; policy_tests.rs:5420,5436 still call it (weight 1.0), so gpu_confidence_calibration_is_per_request_and_resists_cross_workload_bleed validates a path production never runs.

  7. Minor — the documented tie-break rarely fires. service.rs:107 prefers a larger served batch only on exact float equality (cost == best[slot].0); with distinct measured durations the "breaking ties toward larger served batch" rule is effectively inert.

  8. Evidence gaps (charter #210). No same-core main baseline for the headline 76.11 tok/s (compared to throughput on the same new core); greedy_code 70.30→75.98 is on a different core; the DFly2 "+24.2%" compares against forced P=6, not main. The simulator does not model GPU-confidence calibration, so the 786 pytest results cover only the age/delivery half, and the fairness tests use hand-set synthetic costs. B=4 uncontended and K>4 oversubscribed — the exact regimes the retention-fairness change targets — are acknowledged as unbenchmarked.

  9. For the adjudicator: issue #152 (open, filed a month earlier) is the prior field report of this defect, names the same two knobs, and its maintainer triage asked for inter-token/cadence evidence that this PR does not supply. #632 (open) is a competing fix in the same file for the same symptom, and #645 (same author, one minute later) reuses policy.rs/service.rs/LaneValue with the old burst-rate z_ss variable — whichever lands second must be re-derived. No cross-reference exists in the PR body for #152, #632, or #645.

#2 [high] Docs left contradictory: helios/README.md calibration clamp [0,2] vs 4.0

FINDING (Major): helios/README.md:446-450 is NOT touched by PR #644 and still documents the superseded model:

"stored per-depth forecasts are scaled by a request-local aged per-depth verification calibration ratio (seeded scale-invariantly with prior weight 2 from a once-per-round population prior capped at weight 64, 128-token half-life, request EWMA cap 32, clamped to [0, 2])"

Head reality:

So README says per-depth ratio clamped 2.0; code does per-step factors clamped 4.0 multiplied cumulatively across 0..=depth. Note #632 (open, competing) DOES update helios/README.md (+3/-2) for exactly this sentence; #644 omits it.

Fix: update this sentence in #644 (per-step conditional factors, cumulative product, clamp 4.0, unobserved-deeper inheritance).

Also: docs/scheduling-runtime-design.md sections still describing the old model and untouched by the diff (gradient g/z at :203-210, sigma_i = K*T/min(batch_capacity,K) at :233-246, terminal H-t savings at :378-383, one-delivery accounting at :527-538, delivery_fairness "value/ms" at :645). New model lives in docs/scheduling-utility.md:28-41,60-68,212-231,252-257,276-298.

#3 [high] docs/scheduling-runtime-design.md:527-538 still says one delivery per burst

FINDING (Major): docs/scheduling-runtime-design.md:527-538 verbatim at head:

"Completion initially records zero deliveries. The first successful visible publication for the same fence replaces that interval's delivery update with one served delivery; subsequent tokens in the burst do not change the count. ... A first published burst initializes a missing delivery history to one delivery over its measured frame duration."

Code at head contradicts it:

The diff's hunk for this file starts around line 110, so §"Completion initially records zero deliveries" was never revised. Fix: amend it to describe served-time share (delivered = duration_ms, normalizer 1, init share 1.0) as docs/scheduling-utility.md:87-105 now does.