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

Raw Markdown for agents: https://autobot.eidonix.com/p/09fb9b60-d0a3-475a-a4fc-458857ed9e05.md

#1 [high] Research summary

Correctness, Contracts & System-Level Consequences review of #693 @ 000a6ac8

Bottom line: I found no correctness defect in the caching refactor itself. Every substitution I traced is an exact identity, and the change is pure &self pricing with no locks, I/O, threading, unsafe, wire/protobuf, captured-graph, or config-default changes. The real issues are charter/evidence compliance, an under-stated optimization scope that the new counter cannot observe, and one release-build safety softness.

Verified sound (stated plainly, not findings)

Findings

  1. Major — charter #210 / docs/design-review.md:106-115 rule 12 not satisfied while the PR keeps the performance label and still opens on the inherited pow@@GLIBC_2.29 5.48% sample. Fix: drop the label or attach a served-workload A/B, or state explicitly that the label is inert pending measurement.
  2. Major — Layer 2 simulator obligation unmet (docs/design-review.md:195-206): a graph-selection/service-pricing change must run scripts/scheduling_sim/learning.py (not opened) screening + 64-seed catalog; only the 8 pytest suites (837 tests) were run. Fix: run and report the catalog.
  3. Major — claim scope understated; the counting test cannot see two real configurations. With speculative_fixed_width configured, the packed path bypasses both powered_curve and CurveCache entirely (rounds.rs:874-892, inline request.acceptance.curve + powf memo per (drafts,width)); in GPU-allocation mode prefix_lengths_with_values calls speculative_curve directly (rounds.rs:566-577), and materialize → round_lengths_optimistic → prefix_lengths_with_values (policy.rs:2023-2026, rounds.rs:537-549) re-evaluates per masked slot on every plan selection. CURVE_EVALUATIONS only increments inside powered_curve (rounds.rs:646-647), so the tests' "at most one per lane" bound is unproven for those paths, and the description's scope note names only lane_values() and resize_prefill. Fix: extend the scope note and/or add a fixed-width and a GPU-allocation call-count test.
  4. Minor — debug_assert_eq! mode guard is compiled out in release (policy.rs:112-123): a caller threading one cache through both modes would silently mis-price instead of failing. Fix: key entries by (slot, optimistic) or use two cache fields.
  5. Minor — CURVE_EVALUATIONS re-added (rounds.rs:10-14, 646-647) after a #540 review asked for its deletion, now with no stated rationale beyond these four tests.

Attribution, the withdrawn speedup table, CurveCache::new(optimistic), the next_progress restructure, and the wrapper collapsing are all genuinely fixed at this head and are not repeated here.

#2 [high] #693 correctness/contracts lens — verified-sound substitutions

Head 000a6ac8. All citations from files opened at PR head.

  1. tokens <= 1 short-circuit — helios/src/scheduler/policy.rs:1396-1398 if tokens <= 1 { return f64::from(tokens != 0); } Exact because rounds.rs:1028-1030 forecast_tokens(powered, width) = f64::from(width != 0) + powered[..width.saturating_sub(1)].iter().sum::<f64>() — for width 0 -> 0.0, width 1 -> 1.0. Matches old expected_speculative_tokens(r, 0|1) exactly.

  2. width <= 1 in rounds.rs:637-642 (proposal_forecast_tokens) — same identity; also fixes the old powered[..1] slice on width 0.

  3. limit <= 1 continue in packed loop — rounds.rs:903-905. On main the loop for position in 0..limit.saturating_sub(1) (rounds.rs:908) was already empty for limit<=1, so scoring is unchanged; it only skips building the cache entry.

  4. alpha==1.0 fast paths: powered_curve rounds.rs:645-656; prefix_lengths_with_values rounds.rs:569-577; host_prefix_ranking rounds.rs:599-605. p.powf(1.0) == p exactly (even NaN). Default alpha == 1.0 (policy.rs:41 per dossier).

  5. candidates() threads one ordinary cache (policy.rs:1633-1635) into mixed_candidates_with_curves(optimistic=false) and packed_round_candidates_with_curves(optimistic=false); both false, so no mode mixing reachable. mixed_candidates builds CurveCache::new(optimistic) (policy.rs:1705); packed_round_candidates builds CurveCache::new(optimistic) (rounds.rs:855).

  6. resize_prefill rewrite — policy.rs:2000-2007 replaced lane_value(..., candidate.capacity, duration_ns, values[slot]) with lane_tokens(r, decode, candidate.capacity) then values[slot].decode(expected_speculative_tokens(...), duration_ns as f64/1e6). Exact because utility.rs:108-110 decode(e,d) = decode_within(e, 0.0, d) and cached_lane_value (policy.rs:1436-1446) calls cached_lane_value_within(..., preceding=0, ...) which for Decode/Speculative does value.decode_within(cached_expected_tokens(...), 0 as f64/1e6, duration) (policy.rs:1505-1509). Also still uncached here (disclosed limitation).

  7. mixed_candidates prefill rewrite — policy.rs:1747-1751 prefill_lane_value(r, GraphKind::Prefill, self.prefill_work(r, prefill), values[slot]) vs main's lane_value(r, Prefill, prefill, duration_ns, ..); lane_tokens for prefill == prefill_work (policy.rs:1378-1380) and prefill lane value ignores duration entirely (prefill_lane_value policy.rs:1407-1434 → utility.rs:94-106). Exact.

  8. next_progress: single mixed_catalog loop (policy.rs:974-1013), same speculative_widths.is_empty() ? 1.0 : cached_expected_tokens(...) shape as main; takes &mut CurveCache (policy.rs:896-901); prerequisite_value threads it (policy.rs:1017-1031). No local stack fallback cache remains.

  9. Metric/rate span check: no sampled span shrank. decode_within/prefill_within argument lists unchanged; expected token counts bit-identical, so ValueRate/selection_value_rate and admission pricing spans are unaffected.

  10. Concurrency/memory: no locks, no I/O, no shared/threaded state; CurveCache is stack-scoped per pass (never stored on self), so no cross-pass staleness/retention; net allocations decrease vs per-shape rebuilding. REQUEST_LANES = 64 (helios/src/execution/manifest.rs:18) matches existing per-slot arrays.