Recommendation: Changes Requested
The core optimization is mathematically exact, low-risk, and well-placed in the model-agnostic Helios scheduling layer: caching per-slot powered survival curves across RequestScheduler::candidates, short-circuiting tokens <= 1 / limit <= 1, and returning early at adaptive_verification_alpha == 1.0 preserve bit-identical candidate scores and scheduling decisions. However, four verified issues should be addressed before merging: missing contributor attribution to @shieldstar (who published this design and patch in #547), performance-claim and CI evidence gaps relative to docs/design-review.md rules 12 and 16 (pre-rebase unreproducible microbenchmarks, omitted profile caveats, and no CI run on a9f7dd7), a mismatched CurveCache::new(false) mode tag in mixed_candidates, and an avoidable next_progress restructure that unconditionally constructs a 1,544-byte stack CurveCache on every speculative call to work around Option<&mut CurveCache>.
Merge Risk
Level: Low
- Changes are confined to pure
&selfscheduler candidate pricing inhelios/src/scheduler/{policy,rounds}.rs(plus unit tests); no locks, I/O, channels,unsafe, wire/protobuf schemas, captured-graph contracts, exported-core formats, or config defaults change (adaptive_verification_alpharemains1.0athelios/src/scheduler/policy.rs:41). - Both width short-circuits (
policy.rs:1393-1395,rounds.rs:627-629,rounds.rs:892-894) and thealpha == 1.0fast path (rounds.rs:638-640) are exact identities offorecast_tokens(rounds.rs:1017-1019) andf64::powf(p, 1.0), andCurveCacheindexing (r.handle.slot as usizeinto[Option<Vec<f64>>; REQUEST_LANES]withREQUEST_LANES == 64athelios/src/execution/manifest.rs:18(not opened)) matches existing per-slot arrays. - Main operational caveats are the absence of CI checks on head
a9f7dd7and heavy churn inpolicy.rs/policy_tests.rs(textually overlapping open PRs#571,#621,#334,#306).
Walkthrough
helios/src/scheduler/policy.rs: AddsCurveCache(:98-130) wrapping[Option<Vec<f64>>; REQUEST_LANES]plus anoptimistic: booldebug_assert_eq!guard; creates one pass-scoped cache incandidates(:1642) shared acrossmixed_candidates_with_curves,packed_round_candidates_with_curves,add_candidate,continuation_candidate,prerequisite_value, andnext_progress(and a per-call cache inmixed_candidatesand#[cfg(test)] phase_plan); addscached_expected_tokens(:1387-1404) with atokens <= 1short-circuit andcached_lane_value*wrappers (:1425-1524); restructuresnext_progress(:896-1013) around a local fallbackCurveCache.helios/src/scheduler/rounds.rs: Short-circuitswidth <= 1inproposal_forecast_tokens(:626-631) andadaptive_verification_alpha == 1.0inpowered_curve(:634-645); adds#[cfg(test)]thread-localCURVE_EVALUATIONS(:10-14,:635-636); splitspacked_round_candidates_with_curves(:842-850) to accept a sharedCurveCacheand skipslimit <= 1lanes (:892-894).helios/src/scheduler/policy_tests.rs: Adds threeCURVE_EVALUATIONScall-count tests (:9488-9564) and one exact-equality test (cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha,:9566-9780) checkingscore.to_bits()parity atalpha = 1.0and0.6, widths0..=8, 1-remaining-token lanes, waitingInit,Mixed, packedSpeculative, tie-breaking, optimistic probes, andplan()winners.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure arithmetic refactor with no
unsafe, external input parsing, or prompt-injection attempts in the PR description or comments. - [WARN] Charter & value fit: Right architectural layer (model-agnostic Helios scheduling), but conflicts with Charter "Respect contributors" (no attribution to
@shieldstarfor #547's patch) and Charter #210 /docs/design-review.md:106-115, 147-162(pre-rebase unreproducible CPU speedup table without served-workload evidence or #547's profile caveat). - [WARN] Related / duplicate / conflict check: Additive over
#188and#540with no competing open optimization PR, but directly reimplements@shieldstar's complete patch in open issue#547without credit and touches high-churn files shared by open PRs#571,#621,#334,#306. - [WARN] Tests & verification evidence: All four new tests exercise real
RequestSchedulerpaths and use thread-localCURVE_EVALUATIONSreset per call (thread-isolated), and the PR reports full Layer 1/2/3 local runs; however, zero CI checks have run on heada9f7dd7, and the reported microbenchmark numbers predate the rebase ontocc0a49d2with no harness in the repo.
Blockers
None.
Should Fix
-
Credit
@shieldstarfor the original #547 diagnosis, patch design, and tests (Charter: "Respect contributors").- Issue
#547(opened byshieldstar/ Discordshieldstarx) includes a complete, ready-to-apply patch implementing this exact architecture (cached_lane_value, per-pass cache incandidates/phase_plan, per-call cache inmixed_candidates,powered_curvealpha == 1.0fast path,CURVE_EVALUATIONS, and the exact same three test names inpolicy_tests.rs). PR #693 only writesFixes #547with no attribution. - Fix: Add explicit credit (e.g.,
Co-authored-by:or an attribution note in the PR description and commit message) acknowledging@shieldstar's#547patch and tests.
- Issue
-
Align performance claims and verification evidence with
docs/design-review.md:106-115, 147-162(and run CI ona9f7dd7).- The PR leads with a 3-fixture CPU speedup table (
2.61x,5.40x,4.54x) measured against a pre-rebase baseline (c513e46a, not the rebased basecc0a49d2), with no benchmark harness, fixture script, or command in the PR (helios/benches/contains onlytemplate.rs) and no served-workload measurement (scripts/benchmark_scheduler.pywas not run). - The "Why" section cites
#547's5.48%pow@@GLIBC_2.29sample without#547's explicit caveat that the binary was stripped, from a downstream tree, and lacked a call graph sopowcould not be split betweenpowered_curveand otherpowfsites (such ashelios/src/scheduler/rounds.rs:571, 594, 873). - No GitHub Actions CI checks have run on head
a9f7dd7. - Fix: Either (a) re-measure on the current base with a reproducible command/harness and add a served-workload A/B run via
scripts/benchmark_scheduler.pyif keeping a performance speedup claim, or (b) reframe the PR honestly as a behaviour-preserving de-duplication cleanup (dropping the pre-rebase speedup table as a headline claim) and include#547's stripped-binary / no-call-graph caveat on the5.48%profile figure. Ensure CI passes on the head commit.
- The PR leads with a 3-fixture CPU speedup table (
-
Fix mismatched
CurveCache::new(false)mode tag inmixed_candidates(helios/src/scheduler/policy.rs:1707-1716).mixed_candidates(..., optimistic: bool)constructsCurveCache::new(false)atpolicy.rs:1714, unlikepacked_round_candidates(helios/src/scheduler/rounds.rs:844,CurveCache::new(optimistic)). Production does callmixed_candidates(..., true)fromacceptance_probe(helios/src/scheduler/learning.rs:19).- Today it avoids tripping
CurveCache::get_or_insert_with'sdebug_assert_eq!(policy.rs:119-122) only becausemixed_candidates_with_curvesbypassescurveswhenoptimisticis true (policy.rs:1770, callingself.optimistic_tokens(...)uncached on every mixed shape), which also wastes a 1,544-byte stackCurveCacheconstruction on every optimistic call and leaves a latent assertion trap if that branch ever usescurves. - Fix: Construct
CurveCache::new(optimistic)atpolicy.rs:1714(and consider caching theoptimisticbranch throughcurvesor sharing one optimistic cache inlearning.rs:17-19if desired, or only creating the cache when!optimistic).
-
Remove the unnecessary
next_progressrestructure and unconditional 1,544-byte stackCurveCacheworkaround (helios/src/scheduler/policy.rs:896-1013).- Every production caller of
prerequisite_value(policy.rs:1015) ->next_progress(policy.rs:896) arrives fromcached_lane_value(:1587) orcached_lane_value_within(:1274) withcurves == Some(...); allNonecallers (:1171, 1545, 1756, 1993, 1997) pass prefill or decode/speculative kinds and never reach_ => self.prerequisite_value(...)at:1522. - Because
next_progresstakesOption<&mut CurveCache>instead of&mut CurveCache,:958-959unconditionally constructslet mut local_curves = CurveCache::new(false);(64 * 24 + 8 = 1,544bytes zero-initialized on the stack and dropped via a 64-slot loop) even whencurvesisSome(...), duplicates themixed_catalogloop (:969-979vs:982-1011), adds an earlyreturnat:980, and leaves:1008-1009hardcodingvalue.decode(1.0, ...)via an undocumented control-flow coupling to:946(omitted from the PR description). - Fix: Change
prerequisite_value(:1021) andnext_progress(:900) to takecurves: &mut CurveCachedirectly (or unwrap/pass&mut CurveCachefrom the_ =>arm if keepingOptiononcached_lane_value_for_tokens_within), deletelocal_curves, delete the duplicatedmixed_catalogloop and early return (:969-980), and keepmain's singlemixed_catalogloop withif self.speculative_widths.is_empty() { 1.0 } else { self.cached_expected_tokens(r, self.speculative_tokens(r, width), Some(curves)) }.
- Every production caller of
Subtract / Simplify
- Eliminate
Option<&mut CurveCache>and collapse the six lane-value wrappers (helios/src/scheduler/policy.rs:1387-1524).- The
Optionplumbing acrosscached_expected_tokens,cached_lane_value_for_tokens_within,prerequisite_value, andnext_progress(and theNone => self.expected_speculative_tokens(...)arm at:1402) serves only one production decode site:resize_prefillatpolicy.rs:1997(all other uncached callers at:1171, 1545, 1756, 1993are prefill-only and never touchcurves). - Threading a
&mut CurveCache(or a local cache inresize_prefill) removesOption<&mut CurveCache>, removeslocal_curvesinnext_progress, and lets the six-wrapper family (lane_value,cached_lane_value,cached_lane_value_within,lane_value_for_tokens,lane_value_for_tokens_within,cached_lane_value_for_tokens_within) collapse to the minimal cached pair + prefill helper (~35-45 lines deleted, while keepingexpected_speculative_tokensinrounds.rs:622for its real production caller athelios/src/scheduler.rs:2483).
- The
- Trim redundant call-count test scaffolding (
helios/src/scheduler/policy_tests.rs:9488-9564,policy.rs:126-129).cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha(policy_tests.rs:9655-9662) already assertsCURVE_EVALUATIONS == wide_decoders.len()on a superset fixture (waitingInit,Mixed, packedSpeculative, and a 1-remaining-token lane). Whilecost::ENTRY_LOOKUPS(helios/src/scheduler/cost.rs:18(not opened)) provides an in-repo precedent for#[cfg(test)]counters, note that a prior Autobot review of#540flaggedCURVE_EVALUATIONSfor removal and the three standalone counting tests (:9488-9564) largely overlap the fourth test; consolidating or justifying them keeps test surface leaner.
Nits
helios/src/scheduler/rounds.rs:571, 594(prefix_lengths_with_values,host_prefix_ranking) still call.powf(self.policy.adaptive_verification_alpha)unconditionally without thealpha == 1.0fast path (unlikerounds.rs:638and:872).helios/src/scheduler/rounds.rs:626-631(proposal_forecast_tokens) only has one caller (expected_speculative_tokensat:622, passingoptimistic = false), whilelearning.rs:11-13(optimistic_tokens) callsforecast_tokens(&self.powered_curve(request, true), width)directly without thewidth <= 1short-circuit; routingoptimistic_tokensthroughproposal_forecast_tokens(request, width, true)(or inliningproposal_forecast_tokens) would remove the deadoptimisticparameter.- Note in the PR description that
select_plan()still computes per-lane curves outsidecandidates()inlane_values()(service_ratesatservice.rs:337, 387andcoalescing_prefill_log_bonusatpolicy.rs:663) and on resized mixed prefills (resize_prefillatpolicy.rs:1997), so the "at most once" guarantee is specifically percandidates()pass (as accurately commented atpolicy.rs:1641).
Dropped on verification
- Correctness lens #2 ("no lookup ever passes
true, the assertion is decorative everywhere" / "only production callers ofmixed_candidates/packed_round_candidatesare insidecandidates") and Subtraction lens #2 ("Nothing reads an optimistic curve back out of the cache"): False. Verified athelios/src/scheduler/learning.rs:18-19:acceptance_probecalls bothpacked_round_candidates(..., true)andmixed_candidates(..., true)in production, androunds.rs:844, 895createsCurveCache::new(true)and callscurves.get_or_insert_with(slot, true, ...)to read and reuse optimistic curves. Retained only the verifiedmixed_candidatesbug atpolicy.rs:1714(CurveCache::new(false)). - Correctness lens #4 ("new ≈1.5 KB per-call heap allocation on prefill pricing
:1545andresize_prefill:1993-1999,Option<Vec<f64>>is 16 bytes"): False on both mechanism and reachability.CurveCacheis stack-allocated (64 * 24 + 8 = 1,544bytes;Option<Vec<f64>>is 24 bytes with niche optimization, not 16 bytes), and neitheradd_prefill_candidate(:1545) norresize_prefill(:1993-1999) ever reaches_ => prerequisite_value->next_progress. Replaced with the verified root issue:policy.rs:958unconditionally zero-initializeslocal_curveson the stack on the cachedSome(curves)path insidenext_progress. - Discovery Dossier ("
CurveCacheis 8 slots"): False. Verifiedpub const REQUEST_LANES: usize = 64;athelios/src/execution/manifest.rs:18(not opened) (8 was the unit-test fixture slot count). - Subtraction lens #1 ("
expected_speculative_tokensloses its only in-scheduler caller and becomes dead code"): False. Verified a live production caller athelios/src/scheduler.rs:2483(submitted-step expected-token accounting) plus 5 test callers (policy_tests.rs:1994, 4252, 4407, 9632,tests.rs:4114(not opened)). - Subtraction lens #5 ("make
packed_round_candidates_with_curvesprivate likemixed_candidates_with_curves"): False / would not compile.packed_round_candidates_with_curvesis defined inscheduler::rounds(rounds.rs:849) and called from sibling modulescheduler::policy(policy.rs:1644), sopub(super)visibility is required. - Correctness lens #6 (framing
policy.rs:1641as an over-broad claim because ofcoalescing_prefill_log_bonusandresize_prefill): Overstated. Both the PR description andpolicy.rs:1641explicitly scope the "at most once" claim to acandidatespass (andcoalescing_prefill_log_bonusat:663andresize_prefillat:1997already evaluate at most once per lane, not per shape). Demoted to a brief clarifying nit. - Correctness lens #5 / Subtraction lens #4 (claiming
CURVE_EVALUATIONSmeasures a weakened proxy because of thealpha == 1.0fast path, and implying maintainer rejection in#540): Partially overstated. Even atalpha == 1.0,powered_curverunsspeculative_curve(allocating aVec<f64>and computing calibration bounds/curves), so boundingpowered_curvecalls still verifies cache reuse; and#540's removal ofCURVE_EVALUATIONSwas an Autobot review comment before#540was narrowed toRefreshState::idle, whilecost::ENTRY_LOOKUPS(cost.rs:18(not opened)) is an existing in-repo precedent. Kept only as a calibratedSubtract / Simplifynote on test overlap. - Subtraction lens #5 (duplicate doc comment at
policy.rs:1641vspolicy.rs:98): Low-signal, dropped.