#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)
tokens <= 1short-circuit (policy.rs:1396-1398) is exactlyforecast_tokens(curve, 1) == 1.0/forecast_tokens(curve, 0) == 0.0(rounds.rs:1028-1030); same forwidth <= 1inproposal_forecast_tokens(rounds.rs:637-642) andlimit <= 1in the packed loop (rounds.rs:903-905, since0..limit.saturating_sub(1)was already empty onmain).p.powf(1.0) == pfast paths inpowered_curve/prefix_lengths_with_values/host_prefix_ranking(rounds.rs:645-656,569-577,599-605) — exact, including NaN.candidates()threading (policy.rs:1633-1635) shares one ordinary cache across mixed + packed, bothoptimistic == false; no mode mixing reachable.- The two rewritten non-cached call sites are exact:
resize_prefill(policy.rs:2000-2007) reproduceslane_value(..)becausedecode(e,d) == decode_within(e,0.0,d)(utility.rs:108-110,114-131), andmixed_candidates_with_curvesprefill (policy.rs:1747-1751) reproduces it becauselane_tokensfor prefill isprefill_work(policy.rs:1378-1387). - Metric/rate span check: no sampled span shrank —
decode_within/prefill_withinarguments are unchanged everywhere, andexpected_tokensvalues are bit-identical, soValueRate/admission pricing spans are unaffected. - Concurrency/memory: no shared state touched;
CurveCacheis stack-scoped per pass (never stored onself), so no cross-pass staleness, no retention, and net allocation decreases versus per-shape rebuilding.
Findings
- Major — charter #210 /
docs/design-review.md:106-115rule 12 not satisfied while the PR keeps theperformancelabel and still opens on the inheritedpow@@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. - Major — Layer 2 simulator obligation unmet (
docs/design-review.md:195-206): a graph-selection/service-pricing change must runscripts/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. - Major — claim scope understated; the counting test cannot see two real configurations. With
speculative_fixed_widthconfigured, the packed path bypasses bothpowered_curveandCurveCacheentirely (rounds.rs:874-892, inlinerequest.acceptance.curve+powfmemo per(drafts,width)); in GPU-allocation modeprefix_lengths_with_valuescallsspeculative_curvedirectly (rounds.rs:566-577), andmaterialize → 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_EVALUATIONSonly increments insidepowered_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 onlylane_values()andresize_prefill. Fix: extend the scope note and/or add a fixed-width and a GPU-allocation call-count test. - 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. - Minor —
CURVE_EVALUATIONSre-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.
-
tokens <= 1short-circuit — helios/src/scheduler/policy.rs:1396-1398if tokens <= 1 { return f64::from(tokens != 0); }Exact because rounds.rs:1028-1030forecast_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 oldexpected_speculative_tokens(r, 0|1)exactly. -
width <= 1in rounds.rs:637-642 (proposal_forecast_tokens) — same identity; also fixes the oldpowered[..1]slice on width 0. -
limit <= 1continue in packed loop — rounds.rs:903-905. On main the loopfor 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. -
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) == pexactly (even NaN). Default alpha == 1.0 (policy.rs:41 per dossier). -
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_candidatesbuilds CurveCache::new(optimistic) (policy.rs:1705);packed_round_candidatesbuilds CurveCache::new(optimistic) (rounds.rs:855). -
resize_prefill rewrite — policy.rs:2000-2007 replaced
lane_value(..., candidate.capacity, duration_ns, values[slot])withlane_tokens(r, decode, candidate.capacity)thenvalues[slot].decode(expected_speculative_tokens(...), duration_ns as f64/1e6). Exact because utility.rs:108-110decode(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 doesvalue.decode_within(cached_expected_tokens(...), 0 as f64/1e6, duration)(policy.rs:1505-1509). Also still uncached here (disclosed limitation). -
mixed_candidates prefill rewrite — policy.rs:1747-1751
prefill_lane_value(r, GraphKind::Prefill, self.prefill_work(r, prefill), values[slot])vs main'slane_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. -
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. -
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.
-
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.