PR #644: fix(helios): per-step speculative calibration and excluded-only waiting/delivery fairness

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/3b495ce1-30a7-468c-acba-30d1a4f01173

Opened by a workflow run, Nov 30, 2026 12:56 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: lukealonso (COLLABORATOR, one of the charter's named priority contributors; 26 merged PRs in 180 days, 229 commits to helios/src, 384 to docs; Discord lukealonso) Motivation: Under the default balanced policy Helios picks shallow speculative verification depths (W=1/P=3) instead of deeper, higher-tok/s ones, because the waiting-age and delivery-fairness prices charge served decoders and tax longer rounds. This PR changes that accounting plus the depth-calibration estimator so that when nobody is excluded the scheduler maximises throughput. Scale: +649 / −230 lines in 10 files Proposal:


The PR bundles three coupled scheduler changes (per-step conditional speculative calibration in helios/src/scheduler/rounds.rs; excluded-only waiting age with sigma_i = (K−b)·T/b; served-share delivery fairness with s_i ∈ (0,1]), mirrored in scripts/scheduling_sim/utility.py and documented only in docs/scheduling-utility.md. I verified at head that the arithmetic supports the central claim: with sigma_i = 0, s_i = 1 and preceding = 0, the served-lane +c_i·T/2 term exactly cancels ValueRate::new's common −T/2·Σc, so the score reduces to v_i/T + g_i + c_i·A_i and no T-dependent bias remains; cohort selection stays additive and the excluded-only derivation matches the docs. I found no arithmetic contradiction with the description.

What the description omits, in order of decision weight: #632 is an open competing fix by original-el8 for the same under-selection defect in the same file (it scales the ceiling 2.0·1.75^depth; #644 redefines the calibrated quantity and raises the flat clamp to 4.0), and it already updates helios/README.md:446-450, which #644 leaves stating the old [0,2] contract. #645, by the same author, opened one minute after #644, shares 7 files, adds LaneValue::prefill_finish next to #644's decode_within, and still prices the old delivery-rate variable z_ss that #644 redefines. #152 (open since 2026-10-30, triage:design-review) is the month-old user report of exactly this defect (416 width-1 vs 165 width-6 rounds under balanced), and its maintainer triage asked for inter-token cadence evidence that #644 does not supply. Reach is wider than the framing: only the calibration half is gpu_confidence()-gated; the age/delivery and LaneValue::finish changes hit every core shape and both policies (throughput leaves terminal_age_price = 1, and finish now ignores completion_ms and charges the full horizon). Evidence gaps: no same-core main baseline (76.11 balanced vs 76.43 throughput on the new core; the only before/after is another core, 72.46→74.15; the DFly2 "+24.2%" is against a forced P=6), no derivation for the 4.0 clamp, the clamp(sum_w/count,0,1) round weight or the new flat 0.5 prior, and the B=4 / K>4 regimes the new unit tests assert are unmeasured on hardware. Six sections of docs/scheduling-runtime-design.md still describe the old model, so the two design docs now disagree.

Process: open, ready for review, CI green on 2b15114, no labels, no reviews, no comments, no Autobot pass — the review has effectively not started, and neither voipmonitor (#515/#522 author of the estimator being replaced) nor original-el8 (#632) has engaged.

Full report · Notes

Value Proposition

Value Proposition — PR #644 "per-step speculative calibration and excluded-only waiting/delivery fairness"

Charter alignment. The change is confined to Helios scheduling — no model branches, no new flags, no Protobuf/core-format/CUDA-graph ABI change (10 files: scheduler, docs, tests). It targets a reproducible, filed performance defect (#152: default balanced choosing 416 width-1 rounds vs 165 width-6 at B=4 on 3× DGX Spark), which fits "measured performance issue" and the named DGX Spark target. Two frictions: CALIBRATION_FACTOR_MAX = 4.0, the clamp(sum_w/count, 0, 1) round weight and the new flat 0.5 prior are undocumented derivations ("no magic defaults"); and delivery_fairness/decode_age_price keep their names and defaults while measuring different quantities, silently reinterpreting tuned configs — while LaneValue::finish charging the full horizon also reprices --scheduler-policy throughput (terminal_age_price = 1.0).

Novelty & status. Not obsolete — nothing on main fixes this; #515/#522 introduced the estimator. Not fully superseded: #632 (open) attacks the same W=1/P=3 collapse in the same rounds.rs, but only the calibration half, with two outstanding "Changes Requested" for missing derivation and default-α regressions. #645 (same author, one minute later) overlaps 7 files and still prices the old delivery-rate variable. The change is genuinely additive, though two of its three parts are contested or colliding.

Value vs maintenance cost. Beneficiaries are real: every flare run user on default balanced, plus #152's reporter (uncredited, unlinked). The evidence is the weak leg. The headline 76.11 tok/s compares balanced to throughput on a new core; the only before/after pair is on a different core (mean 72.46→74.15, greedy_code 70.30→75.98); DFly2 "+24.2%" compares against forced P=6, not main. That misses charter #210 and #152's triage ask for inter-token/cadence gaps. The B=4 and K>4 regimes the PR rests on are hardware-unmeasured. helios/README.md still says the clamp is [0, 2] and six sections of docs/scheduling-runtime-design.md still document the old model.

Verdict: Worth it with changes. Conditions: same-core main A/B plus the cadence data #152 requested; derivation for 4.0, the round weight and the 0.5 prior; rename or gate the reused pricing fields and state the throughput effect; fix the stale docs; and resolve supersession/order with #632 and #645 before merge.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, bug, performance, area:scheduling

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +bug, +performance, +area:scheduling

Subtraction and simplicity

Subtraction/Simplicity review of PR #644 (head 2b15114). The diff is structurally lean — no new flags, knobs, feature gates, fallback layers or ABI files — so the findings are about duplication inside the new code.

  1. (high) The "inherit deepest observed shallower depth" walk exists twice in helios/src/scheduler/rounds.rs: production Forecast::prior_calibration_factor (290-305) and #[cfg(test)] Forecasts::calibration_factor (364-375), differing only in the request-local step. Tests assert the test-only copy (policy_tests.rs:5257-5518), so they can drift. Extract one free fn taking Option<&[RequestCalibration]>.

  2. (high) The cumulative-product prefix loop is duplicated: speculative_curve (rounds.rs:451-455, pricing) and observe_packed_forecasts (rounds.rs:627-637, observation) both do cumulative_factor *= forecast.calibration_factor(...). One calibrated_prefix_means helper serves both — important because this PR's defect is pricing disagreeing with observation.

  3. (high, pure subtraction) LaneValue::finish's completion_ms (utility.rs:121-130) now appears only in a debug_assert; three production callers (policy.rs:606, 741, 872) and policy_tests.rs:3554 still thread it, and policy.rs:723's first_ms exists only to feed it. Drop the parameter.

  4. (medium) service.rs scans the delivery catalogs twice per plan — service_rates (165-286) computes a delivery_rate whose magnitude survives only as the (count-1)/r seed at :66, while delivery_references (100-158) re-walks the catalogs for the same quantity; the rate is otherwise bound as Some(_) and discarded (:313, :411). Keep one scan or reduce to a presence flag.

  5. (medium) The maximum rate is now the literal 1.0 at all three delivery observe sites (service.rs:47-52, 315, 420) and in tests; ServicePrice::observe's maximum_rate is vestigial on that path. Add observe_delivery or split observe.

  6. (high, conventions) Docs left self-contradictory: docs/scheduling-runtime-design.md:203-210, 233-247 still state the old sigma_i = K*T/min(batch_capacity,k)/g/z model while docs/scheduling-utility.md:230-239, 251-254 states the new one; helios/README.md:446-450 still says "clamped to [0, 2]" vs CALIBRATION_FACTOR_MAX = 4.0 (rounds.rs:13). Replace with a pointer rather than a second derivation.

Already lean: vec![DepthCalibration::new(0.5); …] (rounds.rs:337) simplifies seeding; observed replaces a heuristic; decode (utility.rs:95-97) is a warranted wrapper; DeliveryReference is a documented struct, not over-modelling.

Open: whether (count-1)/r is a deliberate pre-measurement reference (no derivation given); which doc is normative; merge order vs #632 (also edits rounds.rs + runtime-design doc and patches helios/README.md) and #645 (same LaneValue, old z_ss), since #645 still prices the delivery-rate variable #644 redefines.

Full report · Notes

Correctness and contracts

PR #644's pricing arithmetic is sound — I re-derived the excluded-only Bellman identity, the −c·T/2 cancellation between LaneValue::decode_within and ValueRate::new, and the served-share delivery term against head code. No ABI/proto/core-format contract is touched, and no new hot-path cost, lock, allocation, or platform-parity gap exists. The problems are documentation contracts, an under-described semantic change, knob redefinition, and evidence.

Top findings:

  1. Major — helios/README.md:446-450 still says the calibration ratio is "clamped to [0, 2]" and per-depth; head is CALIBRATION_FACTOR_MAX = 4.0 (rounds.rs:13) and a cumulative per-step product (rounds.rs:661). Competing #632 does fix this sentence; #644 omits it.
  2. Major — docs/scheduling-runtime-design.md:527-538 still says one served delivery per burst and init "one delivery over its measured frame duration"; head records delivered = duration_ms with normalizer 1.0 (service.rs:47-52) and initial(1.0) (service.rs:424). Sections :203-210, :233-247, :378-383, :645 are also stale.
  3. Major — LaneValue::finish now charges the full horizon and completion_ms is used only by a debug_assert (utility.rs:121-130), so terminal retirement is repriced at policy.rs:741 (stage-one finish charged the whole two-stage horizon). throughput keeps terminal_age_price = 1.0 (policy.rs:36,49), so --scheduler-policy throughput is repriced too — the PR body only says "updated".
  4. Major — delivery_fairness (4.0) and decode_age_price (0.1) keep names and defaults while changing dimension (burst rate 1/T → dimensionless served share); the age/delivery half is not GPU-confidence-gated (rounds.rs:471-474) so it changes default balanced for every core shape with no opt-in.
  5. Major — CALIBRATION_FACTOR_MAX = 4.0, the flat 0.5 prior (rounds.rs:337) and round_w = clamp(sum_w/count) (rounds.rs:701) are underived; #632 was twice asked to close the same gap.
  6. Minor — the pre-measurement delivery default assumes b = 1 ((K−1)/r, service.rs:66), so sigma > 0 at startup even when all decoders fit one batch, contradicting the PR's "sigma = 0 when all served" claim.
  7. Major evidence — no same-core main baseline; the only before/after is on a different core, DFly2 compares against forced P=6, and #152's requested cadence data is absent.
  8. Minor — observe_calibration is now #[cfg(test)]-only (rounds.rs:352-356) yet policy_tests.rs:5420,5436 still exercise it, so the bleed test validates a non-production path.

Open: same-core main baseline and cadence data; derivations; merge order vs #632/#645; whether the throughput-policy finish repricing is intended.

Full report · Notes

Final review

Recommendation: Changes Requested

The core mathematical design in PR #644 is sound: the survival-weighted per-step conditional calibration in rounds.rs, the exact excluded-only Bellman continuation $\sigma_i = (K - b_f) T_f / b_f$ (including heterogeneous multi-family wall-time shares), and served-share delivery fairness all check out algebraically and align cleanly across Rust and the Python simulator with zero ABI changes. However, deep inspection surfaced one real mathematical bug introduced in next_progress (helios/src/scheduler/policy.rs:501), where ValueRate::new(ns, work, 0.0) leaves the new +age_price * T / 2 term uncanceled for delivery-bearing multistage requests, alongside six superseded passages in docs/scheduling-runtime-design.md and two in helios/README.md that now directly contradict docs/scheduling-utility.md and the code. Fixing policy.rs:501, reconciling the stale docs, and removing the dead completion_ms parameter from LaneValue::finish will make this ready to merge (with #645 rebased/re-derived afterward).

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Uncanceled +age_price * T / 2 duration bias in next_progress for delivery-bearing multistage requests (helios/src/scheduler/policy.rs:501).

    • LaneValue::decode (helios/src/scheduler/utility.rs:95-119) now adds + self.age_price * service_ms * (self.age_ms + service_ms / 2.0) to cancel the - decode_age_price * duration_ms / 2.0 subtraction in ValueRate::new.
    • However, next_progress (helios/src/scheduler/policy.rs:501) still constructs ValueRate::new(ns, work, 0.0) when scoring Resume, Decode, Speculative, and Mixed shapes at lines 547, 556, and 587. For any delivery-bearing request with value.age_price > 0 (e.g., a request in Restore or non-terminal Snapshot with consumed_tokens == prompt_tokens, evaluated via prerequisite_value and continuation_candidate's fill()), dividing by T leaves an uncanceled + value.age_price * T / 2 bonus that rewards slower graphs over faster ones producing the same tokens.
    • Fix: Change helios/src/scheduler/policy.rs:501 from ValueRate::new(ns, work, 0.0) to ValueRate::new(ns, work, value.age_price) (for prefill requests value.age_price is 0.0, so prefill scoring is unaffected, while delivery-bearing requests cancel the + c * T / 2 term cleanly). Add a unit test in policy_tests.rs verifying that next_progress prefers a faster decode/resume shape over a strictly slower equal-token shape when value.age_price > 0.
  2. Reconcile superseded scheduler equations in docs/scheduling-runtime-design.md and helios/README.md.

    • docs/scheduling-runtime-design.md still documents the pre-PR model in six places that now contradict docs/scheduling-utility.md and the implementation:
      • docs/scheduling-runtime-design.md:200-210: still describes "one delivery regardless of its token count", "delivery rate z", and "output delivery: g/z".
      • docs/scheduling-runtime-design.md:233-247: still gives the old sigma_i = K*T/min(batch_capacity,k) and the old score formula "- T/2 * sum over active decoders of c_i" without excluded-only cancellation.
      • docs/scheduling-runtime-design.md:338-339 and :378-383: still state that terminal rows in a two-stage sequence stop accumulating age at time T and save waiting over [T, H] (now zero waiting over the full horizon H, matching docs/scheduling-utility.md:296-305).
      • docs/scheduling-runtime-design.md:527-538: still says visible publication records "one served delivery" and initializes a missing delivery history "to one delivery over its measured frame duration" (now delivered = duration_ms, normalizer 1.0, initial share 1.0 at helios/src/scheduler/service.rs:47-52, 424).
      • docs/scheduling-runtime-design.md:645: still calls delivery_fairness the "Delivery-rate log-utility coefficient, value/ms" instead of served delivery-share.
    • helios/README.md is untouched and still states the superseded model in two places:
      • helios/README.md:446-450: still describes a "per-depth verification calibration ratio (... clamped to [0, 2])" instead of per-step conditional factors multiplied cumulatively, clamped to [0, 4], with unobserved deeper inheritance.
      • helios/README.md:470-476: still says a delivery is credited "once per completion regardless of token count" and initialized "from its reference delivery interval" instead of served wall-time share initialized from batch-feasible served share.
    • Fix: Update helios/README.md:446-450, 470-476 and update docs/scheduling-runtime-design.md (preferring concise statements + pointers to docs/scheduling-utility.md over duplicating full derivations so the two docs cannot drift again).
  3. Add or clarify multi-concurrency (B=4 / K>4) validation and reference #152 in the PR description.

    • Open issue #152 reports this exact balanced width-1 collapse at B=4 and its triage asked for matched inter-token/delivery-gap evidence alongside throughput; meanwhile #632 showed that raising calibration ceilings can regress C=4..32 moderate-acceptance workloads on real hardware.
    • Fix: Link #152 (and #632/#645) in the PR description, clarify that the DFly2 gb10-tp4-202611301002 comparison is against forced P=6 (not main), and if a 4× DGX Spark host is available before merge, run a quick B=4 main-vs-PR balanced check (throughput + inter-token/delivery gaps) to confirm no multi-concurrency over-allocation regression from CALIBRATION_FACTOR_MAX = 4.0.

Subtract / Simplify

  1. Delete dead completion_ms parameter from LaneValue::finish and unused first_ms local (helios/src/scheduler/utility.rs:121-130, helios/src/scheduler/policy.rs:606, 723, 741, 872).

    • After switching terminal retirement to excluded-only waiting over the full horizon, completion_ms is used solely in debug_assert!(horizon_ms == 0.0 || completion_ms <= horizon_ms) at utility.rs:122 and is completely dead in release builds. let first_ms = duration_ns as f64 / 1e6; at policy.rs:723 exists only to pass it.
    • Fix: Change the signature to pub fn finish(&self, horizon_ms: f64) -> f64, delete first_ms at policy.rs:723, and simplify all callers (policy.rs:606, 741, 872, policy_tests.rs:3554, utility.rs:365).
  2. Deduplicate the descending calibration inheritance walk (helios/src/scheduler/rounds.rs:290-305 vs :364-375).

    • Forecast::prior_calibration_factor and #[cfg(test)] Forecasts::calibration_factor duplicate the same descending (0..depth).rev() search, differing only in whether self.calibration is checked alongside global.
    • Fix: Extract a single helper fn inherited_calibration_factor(local: Option<&[RequestCalibration]>, global: &[DepthCalibration], depth: usize) -> f64 called with Some(&self.calibration) in production and None in the #[cfg(test)] accessor, preventing drift between test assertions and production pricing.
  3. Deduplicate the cumulative calibration-factor product loop (helios/src/scheduler/rounds.rs:451-455 vs :627-637).

    • Both speculative_curve (pricing) and observe_packed_forecasts (learning/surplus) independently accumulate cumulative_factor *= forecast.calibration_factor(depth, &self.forecasts.calibration).
    • Fix: Extract a zero-allocation iterator helper on Forecast (e.g., fn cumulative_calibration_factors<'a>(&'a self, global: &'a [DepthCalibration], limit: usize) -> impl Iterator<Item = f64> + 'a) used by both sites so pricing and learning cannot diverge without adding a Vec allocation to speculative_curve.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (80%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.