#1 [high] Lens verdict: diff is lean; 4 concrete simplifications
PR #681 (helios/src/scheduler/policy.rs +1 net production LOC, scripts/scheduling_sim/utility.py +2/-6, docs +5/-2, 2 new Rust tests, 1 new Python test).
Verdict: production diff is genuinely small and already removes code (the unreachable peer_budget == usize::MAX arm at old policy.rs:567 and the let mut peer_budget accumulator). No new flags, config keys, fallbacks, or speculative generality. Python side is a net deletion. Suggestions below are the only worthwhile ones; nothing here justifies blocking on its own except, maybe, A.
FINDING A (high) — three copies of the same cohort-mean expression; collapse to one helper. helios/src/scheduler/policy.rs:627:
let mean_out = decoder_rems[..decoder_count].iter().map(|&rem| expected_at(eff_width).min(rem as f64).max(1.0)).sum::<f64>() / decoder_count as f64;
helios/src/scheduler/policy.rs:636 (identical shape, width as f64):
let mean_out = decoder_rems[..decoder_count].iter().map(|&rem| expected_at(width as f64).min(rem as f64).max(1.0)).sum::<f64>() / decoder_count as f64;
helios/src/scheduler/policy.rs:668-672:
let horizon = decoder_rems[..decoder_count]
.iter()
.map(|&rem| (rem as f64).min(ph))
.sum::<f64>()
/ decoder_count as f64;
All three are mean_i f(rem_i). Add one module-level helper next to the other free fns (e.g. near rounds.rs:991 forecast_tokens or in policy.rs above the impl):
fn cohort_mean(rems: &[usize], f: impl Fn(f64) -> f64) -> f64 {
rems.iter().map(|&rem| f(rem as f64)).sum::<f64>() / rems.len() as f64
}
then let mean_out = cohort_mean(&decoder_rems[..decoder_count], |rem| expected_at(eff_width).min(rem)); and let horizon = cohort_mean(&decoder_rems[..decoder_count], |rem| rem.min(ph));.
Also: :627 and :636 are the only two lines in the file (1969 lines) longer than 150 chars (search ^.{150,}$) and break the neighbouring wrapping style. Extracting the helper fixes that too. Simulator already factors this implicitly (utility.py:215-219 has one mean_out sum used by both call sites).
FINDING B (medium) — .max(1.0) is a no-op and should be deleted, not carried into the shared helper.
expected_at(policy.rs:586-598) returns1.0wheneff_width <= 1.0 || mean_curve.is_empty(), else1.0 + Σ curve[..]where every curve entry is a probability in [0,1] raised to a positive exponent → E >= 1.0.- Every recorded decoder has
rem >= 1(policy.rs:550if rem > 0). Somin(E, rem) >= 1.0always and.max(1.0)on :627/:636 can never bind. It appears 2× decoder_count times per planning call. Remove both.max(1.0)calls rather than preserving them in the helper. (Same argument made the oldexpected_at(eff).min(peer_budget).max(1.0)vacuous, so this is dead code the PR relocated rather than introduced.)
FINDING C (medium) — the if horizon > 0.0 guard at policy.rs:673 is unreachable; delete it and unindent the body.
policy.rs:667-682:
let ph = self.policy.coalescing_horizon_tokens.min(post_prefill as f64);
let horizon = ...
if horizon > 0.0 {
// Amortize ...
let per_token = (best_surplus_per_horizon * horizon) / initial_prefill as f64;
if per_token.is_finite() && per_token > 0.0 {
bonus_log[slot] = per_token.ln();
}
}
coalescing_horizon_tokens > 0.0 (early return :527), post_prefill >= 1 (:561 guard post_prefill > 0), each rem >= 1 (:550) ⇒ ph > 0 and mean_i min(rem_i, ph) > 0 for decoder_count >= 1 (:567 guard). The guard is dead; the existing per_token.is_finite() && per_token > 0.0 inner guard already covers the degenerate cases. Removing it drops one nesting level from the whole amortization block (which also lets the comment block at :674-676 sit at natural indent).
FINDING D (medium) — the new test re-implements production interpolation instead of using the existing helper. helios/src/scheduler/policy_tests.rs:7002-7011:
let expected_at = |eff_width: f64| -> f64 {
let drafts = eff_width - 1.0;
let full = (drafts.floor() as usize).min(curve.len());
let frac = (drafts - full as f64).clamp(0.0, 1.0);
let mut sum = 1.0 + curve[..full].iter().sum::<f64>();
if full < curve.len() {
sum += frac * curve[full];
}
sum
};
This is a hand copy of policy.rs:586-598. Every width queried in this test is integral (8.0, 6.0, 4.0 — packed_per_lane 16/2, 12/2, 12/3), where the interpolation collapses to 1.0 + Σ curve[..w-1], i.e. exactly super::rounds::forecast_tokens(&curve, w) (rounds.rs:991-993), which this test file already uses at policy_tests.rs:7152. Replace the closure with |w: usize| super::rounds::forecast_tokens(&curve, w) and delete 10 lines, so the test cannot drift from production arithmetic.
FINDING E (low, optional) — parallel arrays where the neighbouring code uses tuples. policy.rs:530-533:
let mut decoder_slots = [0usize; REQUEST_LANES];
let mut decoder_rems = [0usize; REQUEST_LANES];
let mut decoder_count = 0usize;
let mut prefillers = [(0usize, 0usize, 0usize); REQUEST_LANES];
Two 512-byte parallel arrays (decoder_slots, decoder_rems) written together at :551-553 and read together, while the prefill cohort two lines below uses one tuple array. A single [(0usize, 0usize); REQUEST_LANES] of (slot, rem) matches the local convention and removes one buffer plus one index write. Only worth doing if A is taken anyway.
NOT SUGGESTED (checked and rejected):
- No new config knob/flag/wrapper:
coalescing_horizon_tokensis pre-existing (#645); #681 adds no off-switch, which the other lenses can argue about but is not a subtraction item. - scripts/scheduling_sim/utility.py:232-236 is a net -4 lines (deletes
peer_budget), no duplication introduced;phmirrors Rust. - The three inline
GraphDescriptorliterals in the new test (policy_tests.rs:6941, 6956, 6973) fully spell out 14 fields each, but that is the established style in this file (see :4139, :4280, :4500) — no builder exists to reuse, so not a convention violation. add_active_decoder(policy_tests.rs:6877-6885) near-duplicates the inlineadd_decoderclosure at :6698-6713, but that one carries test-specific acceptance seeding; extracting it is unrelated cleanup.coalescing_bonus(policy_tests.rs:6866-6875) mutates policy to isolate the term; the neighbouring burst test (:6794-6845) does the same withrun_burst(0.0, ..), so it follows convention.- Docs edit is a 1-clause rewrite, not expansion.
#3 [high] Research summary
Reviewed PR #681 through the Subtraction/Simplicity/Conventions lens by reading the full diff, coalescing_prefill_log_bonus at the head (helios/src/scheduler/policy.rs:525-684), the simulator block (scripts/scheduling_sim/utility.py:203-244), the new tests, AGENTS.md, and the neighbouring helpers (rounds.rs:991 forecast_tokens, speculative_curve).
Verdict: the diff is already lean. It removes more than it adds in structure — the old let mut peer_budget accumulator and the unreachable peer_budget == usize::MAX return arm are gone, the Python side is a net −4 lines, and the PR introduces no new flag, config key, wrapper, fallback branch, or abstraction. Nothing in AGENTS.md:188-193 ("no speculative compatibility, fallback layers, or configuration switches") is violated.
Four worthwhile simplifications, all on lines this PR touches:
- A (main item): the cohort mean is written out three times (
policy.rs:627,:636,:668-672) asΣ f(rem_i)/n. Collapse into one small helper. Two of those lines are also the only >150-char lines in the 1,969-line file, breaking the wrapping style used two lines below at:668. - B: the
.max(1.0)on:627/:636is provably non-binding (expected_atreturns ≥ 1.0 at:586-598; every recordedrem ≥ 1at:550) — delete it instead of carrying it into the helper. - C:
if horizon > 0.0at:673is unreachable given the:527,:550,:561,:567guards; deleting it unindents the amortization block. - D: the new test at
policy_tests.rs:7002-7011hand-copies production'sexpected_atinterpolation; every width it queries is integral, so the existingsuper::rounds::forecast_tokens(already used in this test file at:7152) replaces it in one line.
Also checked and explicitly not flagged: the verbose inline GraphDescriptor literals (established style in this file), add_active_decoder/coalescing_bonus helpers (near-duplicates exist but carry test-specific setup), the ph local in the simulator, and the docs clause rewrite. Details with verbatim quotes and replacement code are in the scratchpad.
#4 [high] Report-ready findings list (ordered), with replacement code
DELIVERABLE (report should be sparing: state plainly that the diff is lean, then these 4-5 items).
VERDICT PARAGRAPH: PR #681 is already lean. It removes more structure than it adds: the old let mut peer_budget accumulator and the unreachable peer_budget == usize::MAX return arm are deleted, scripts/scheduling_sim/utility.py is net −4 lines, and the PR adds no flag, config key, wrapper, fallback branch, or abstraction — compliant with AGENTS.md:188-193 ("Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement"). The remaining opportunities are local collapses on lines the PR already edits.
[A] MEDIUM-HIGH. One cohort-mean helper instead of three copies.
- policy.rs:627 (verbatim):
let mean_out = decoder_rems[..decoder_count].iter().map(|&rem| expected_at(eff_width).min(rem as f64).max(1.0)).sum::<f64>() / decoder_count as f64; - policy.rs:636 (verbatim):
let mean_out = decoder_rems[..decoder_count].iter().map(|&rem| expected_at(width as f64).min(rem as f64).max(1.0)).sum::<f64>() / decoder_count as f64; - policy.rs:668-672 (verbatim):
let horizon = decoder_rems[..decoder_count]
.iter()
.map(|&rem| (rem as f64).min(ph))
.sum::<f64>()
/ decoder_count as f64;
- Replace all three with one free fn (place beside policy.rs's other free helpers, cf. rounds.rs:991
forecast_tokens):
fn cohort_mean(rems: &[usize], f: impl Fn(f64) -> f64) -> f64 {
rems.iter().map(|&rem| f(rem as f64)).sum::<f64>() / rems.len() as f64
}
call sites: let mean_out = cohort_mean(&decoder_rems[..decoder_count], |rem| expected_at(eff_width).min(rem)); and let horizon = cohort_mean(&decoder_rems[..decoder_count], |rem| rem.min(ph));
- Extra justification: :627 and :636 are the ONLY lines over 150 chars in the 1,969-line file (verified with
^.{150,}$), while :668-672 immediately below wraps properly. The simulator already factors this (utility.py:215-219 computes onemean_outsum reused by all graph shapes).
[B] MEDIUM. Delete .max(1.0) on :627 and :636 (twice each per planning call).
Proof it never binds: expected_at (policy.rs:586-598) returns 1.0 for eff_width <= 1.0 || mean_curve.is_empty(), otherwise 1.0 + Σ mean_curve[..] where mean_curve entries are probabilities in [0,1] raised to a positive exponent (rounds.rs:625-627), so E ≥ 1.0; and every recorded decoder has rem >= 1 (policy.rs:550 if rem > 0). Therefore min(E, rem) >= 1.0 always. Do not carry .max(1.0) into the helper; it is dead code the PR relocated (the old expected_at(..).min(peer_budget).max(1.0) was equally vacuous).
[C] MEDIUM. Delete the unreachable if horizon > 0.0 guard at policy.rs:673 and unindent its body (policy.rs:667-682 verbatim):
let ph = self.policy.coalescing_horizon_tokens.min(post_prefill as f64);
let horizon = decoder_rems[..decoder_count]
.iter()
.map(|&rem| (rem as f64).min(ph))
.sum::<f64>()
/ decoder_count as f64;
if horizon > 0.0 {
// Amortize the unlocked coalescing surplus uniformly across the prefiller's
// uncached prompt tokens so total credit sums to 1x regardless of chunking
// and chunk sizing stays smooth under active decode waiting age.
let per_token = (best_surplus_per_horizon * horizon) / initial_prefill as f64;
if per_token.is_finite() && per_token > 0.0 {
bonus_log[slot] = per_token.ln();
}
}
Guards upstream make horizon > 0.0 always true: coalescing_horizon_tokens > 0.0 (:527), post_prefill > 0 (:561) so ph > 0, rem > 0 (:550), decoder_count >= 1 (:567). The inner per_token.is_finite() && per_token > 0.0 already covers degenerate values. Removing the dead branch drops one nesting level from the whole amortization block and lets the 3-line comment sit at natural indent.
[D] MEDIUM. New test re-implements production interpolation. policy_tests.rs:7002-7011 verbatim:
let expected_at = |eff_width: f64| -> f64 {
let drafts = eff_width - 1.0;
let full = (drafts.floor() as usize).min(curve.len());
let frac = (drafts - full as f64).clamp(0.0, 1.0);
let mut sum = 1.0 + curve[..full].iter().sum::<f64>();
if full < curve.len() {
sum += frac * curve[full];
}
sum
};
This is a hand copy of policy.rs:586-598. Every width queried here is integral (8.0, 6.0, 4.0 = packed_per_lane 16/2, 12/2, 12/3), where it collapses to 1.0 + Σ curve[..w-1] — exactly super::rounds::forecast_tokens(&curve, w) (rounds.rs:991-993), already used in this test file at policy_tests.rs:7152. Replace with let expected_at = |w: usize| super::rounds::forecast_tokens(&curve, w); (call sites at :7012, :7044-7045 take integer literals already) and delete 10 lines; the test then cannot drift from production arithmetic.
[E] LOW/OPTIONAL. policy.rs:530-533 verbatim:
let mut decoder_slots = [0usize; REQUEST_LANES];
let mut decoder_rems = [0usize; REQUEST_LANES];
let mut decoder_count = 0usize;
let mut prefillers = [(0usize, 0usize, 0usize); REQUEST_LANES];
Two parallel 512-byte arrays written together at :551-553 and read together, while the prefill cohort two lines below uses a single tuple array. Collapse to let mut decoders = [(0usize, 0usize); REQUEST_LANES]; of (slot, rem) to match the local convention; only worth doing together with [A].
EXPLICITLY NOT FLAGGED (so the report does not pad): the verbose inline GraphDescriptor literals at policy_tests.rs:6941/6956/6973 (established style: :4139, :4280, :4500; no builder exists); add_active_decoder (:6877-6885) near-duplicating the closure at :6698-6713 (that one carries test-specific acceptance seeding); coalescing_bonus (:6866-6875) policy mutation (same technique as run_burst(0.0, ..) at :6794-6845); the simulator's ph local and net-negative diff (utility.py:232-236); the 1-clause docs rewrite (docs/scheduling-runtime-design.md:222-235). The missing operator knob / default-on reach argument belongs to the other lenses, not this one.
#2 [medium] Citations verified for #681 simplicity review
Verified at PR head (e15b836):
- policy.rs:525-684 =
coalescing_prefill_log_bonus; :527 early return oncoalescing_horizon_tokens <= 0.0; :548-554 decoderremcomputation withif rem > 0; :556-564 prefiller withpost_prefill > 0; :567 guarddecoder_count == 0 || prefiller_count == 0(PR deleted the old unreachablepeer_budget == usize::MAXarm); :586-598expected_atclosure; :599-645best_decode_rate; :646-665 surplus loop; :666-682 amortization. expected_atis the only place the acceptance curve is interpolated in this function; identical copy in policy_tests.rs:7002-7011 (PR-added).rounds.rs:991-993pub(super) fn forecast_tokens(powered: &[f64], width: usize) -> f64 { f64::from(width != 0) + powered[..width.saturating_sub(1)].iter().sum::<f64>() }— equals the integer-width case ofexpected_at; used by tests at policy_tests.rs:7152 and by production at policy.rs:870, :910.search_code ^.{150,}$over policy.rs returns only :627, :636 (PR-added) and :1596; the first two are the PR's long single-line closures, unlike the multi-line wrapping used at :668-672 and :1093-1097.- REPO AGENTS.md:188-193 "Reject unsupported abstractions and churn… Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement." — PR complies; and "Refactoring must directly support the requested behavior" is why A–E are scoped to lines this PR touches.
- Python: utility.py:203-244 coalescing block; :215-219 already a cohort mean over
decoders(untouched); :232-236 new horizon block; :168-169incumbent_decode_batch_msis the only other placedecodersis summed. tests/test_scheduling_utility.py:506-526 new test. - docs/scheduling-runtime-design.md:222-235 rewritten clause; :713 config table row unchanged (still "64").