Skip to content

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

Merged
lukealonso merged 1 commit into
mainfrom
helios-adaptive-verification-and-excluded-fairness
Nov 30, 2026
Merged

lukealonso merged 1 commit into
mainfrom
helios-adaptive-verification-and-excluded-fairness

Conversation

@lukealonso

Copy link
Copy Markdown
Collaborator

Why

Two independent biases in Helios's scheduler caused adaptive speculative verification to under-select deeper, higher-throughput verification depths under the default balanced policy:

  1. Cumulative depth calibration drift (helios/src/scheduler/rounds.rs): DepthCalibration and RequestCalibration calibrated cumulative prefix survival ratios independently per depth, defaulting unobserved deeper depths to 1.0. When shallow shapes ran, deeper depths could not inherit the observed step-level calibration factor, causing mis-calibrated depth rankings (for example, collapsing to shallow W=1/P=3 shapes when raw drafter confidence diverged from realized acceptance).
  2. Duration penalty on unskipped served rounds (helios/src/scheduler/utility.rs, service.rs, policy.rs, scripts/scheduling_sim/utility.py): Previously, linear waiting-age cost $c_i(A_i T + T^2 / 2)$ was charged to served decoders as well as excluded ones (yielding continuation reference $\sigma_i = \mu / p_i > 0$ even when $p_i = 1$), and delivery fairness priced raw burst frequency $1 / T$ (delivered = 1, maximum_rate = 1 / T_min). On longer-round hardware such as 4× DGX Spark (~35 ms/round), these two terms imposed a strong bias against deeper, higher-tok/s speculative rounds even when every active decoder was served and zero requests were excluded. Under the scheduler's fairness principle, hardware should only trade throughput for shorter round duration in service of protecting actual excluded or underserved active requests—never to protect unarrived future requests.

What Changed

  • Per-step conditional speculative calibration (helios/src/scheduler/rounds.rs, docs/scheduling-runtime-design.md):
    • Replaced cumulative-ratio DepthCalibration / RequestCalibration updates with survival-weighted per-step conditional updates (CALIBRATION_FACTOR_MAX = 4.0, sample weight $w_d = \text{prev_realized}$, conditional realized $\text{realized}_d / w_d$ vs raw per-step GPU confidence step_c_d).
    • Pricing now multiplies each depth's stored cumulative prefix mean by the cumulative product of per-step calibration factors across 0..=depth.
    • Unobserved deeper depths inherit the deepest observed shallower depth's calibration factor (preferring request-local over global at each shallower depth) instead of defaulting to 1.0.
  • Excluded-only waiting age with exact Bellman continuation (helios/src/scheduler/utility.rs, service.rs, policy.rs, scripts/scheduling_sim/utility.py, docs/scheduling-utility.md):
    • Before: Every active decoder paid $c_i(A_i T + T^2 / 2)$ during a round, giving $\sigma_i = \mu / p_i = K T_f / b_f$.
    • After: Only excluded delivery-bearing streams $j \in \mathcal{D} \setminus S(a)$ incur waiting cost; served streams make active progress with zero waiting cost and reset $A_i' = 0$. The exact reference continuation solves to $\sigma_i = \mathbb{E}\pi[T \cdot \mathbf{1}{i \notin S}] / p_i = (K - b_f) T_f / b_f$ (DeliveryReference::excluded_wait_ms).
    • Added LaneValue::decode_within(expected, preceding_ms, horizon_ms) (and updated LaneValue::finish) so served lanes cancel their $-c_i T / 2$ term in ValueRate::new while keeping fixed-graph cohort selection (best_cohort, best_two_stage_cohort, packed-round DP) strictly additive and modeling prerequisite wait over [0, preceding_ms] exactly in two-stage sequences.
  • Served-share delivery fairness (service.rs, utility.rs, policy.rs, scripts/scheduling_sim/utility.py, docs/scheduling-utility.md):
    • Before: Delivery accounting recorded delivered = 1.0 against maximum_rate = 1 / T_min, producing a delivery / T score term that taxed longer high-tok/s rounds even when no stream was skipped.
    • After: Delivery accounting tracks served wall-time share $s_i \in (0, 1]$ (maximum_rate = 1.0, delivered = duration_ms on visible publication, 0.0 when excluded, initialized from the batch-feasible served share $b_f / K$). In candidate scoring, a served decoder earns delivery_price_i * service_ms, which divides by $T$ to a duration-independent constant $+g_i / s_i$, prioritizing skipped or underserved requests without taxing deeper speculation when all decoders are served.
  • Compatibility: No Protobuf, core-format, or CUDA-graph ABI changes; existing exported cores load and serve unchanged.

Claimed Benefit and Result

  • No request-count special case: Whenever every active decoder is served and $\sigma_i = 0$ (solo B = 1, uncontended full B = 4 decode, or a decoder taking its turn alongside a waiting prefiller), neither delivery fairness nor waiting age introduces any $T$-dependent bias against higher-tok/s speculation. Prefill chunks still shrink when decoders wait, and oversubscribed decode batches ($K > b$) still trade duration against excluded-peer wait and prioritize skipped lanes.
  • Measured on 4× DGX Spark TP4 DeepSeek-V4.1-Flash serving (max_tokens = 256, 5-prompt suite):
    • On gb10-tp4-202611301553, default --scheduler-policy balanced achieves 76.11 tok/s 5-prompt mean (peaking at 80.89 tok/s on greedy_code with off/r = 4.80), matching --scheduler-policy throughput (76.43 tok/s, 0.4% difference, within T = 1 sampling noise).
    • Isolated scheduler comparison on existing DSpark core gb10-tp4-202611301141: greedy_code under balanced rose from 70.30 tok/s (off/r = 2.04) to 75.98 tok/s (off/r = 3.17), and 5-prompt mean rose from 72.46 to 74.15 tok/s.
    • On DFly2 (gb10-tp4-202611301002, --scheduler-policy throughput), per-step conditional calibration eliminated the W=1/P=3 collapse (ctx16k_T1: 70.94 vs 57.12 tok/s forced P=6, +24.2%; ctx4k_T1: 62.57 vs 54.59 tok/s, +14.6%).

Supporting Evidence and Limitations

  • Rust crate tests (cargo test --locked --release):
    • eos: 2 passed, 0 failed
    • selene (--features test-support): 548 passed, 0 failed
    • selene-manager (--features test-support): passed
    • helios (--features runtime-core,server, scheduler::): 400 passed, 0 failed, including new unit tests balanced_unexcluded_decoders_maximize_throughput_without_delivery_or_age_penalty, oversubscribed_decoders_incur_excluded_wait_and_protect_skipped_lanes, and the excluded-only continuation identity in utility.rs.
    • flare and flare-cli: 201 passed, 0 failed (actual_load_core_leases_managed_local_entries_and_releases_on_failure passed standalone).
  • Scheduling simulator (pytest tests/test_scheduling*.py -q): 786 passed, 0 failed, including the updated excluded-only reference Poisson equation test (test_age_continuation_satisfies_the_reference_poisson_equation), test_unexcluded_decoders_pick_peak_throughput_speculation_depth (B = 1 and B = 4), test_short_prompt_startup_and_subsequent_decode_gaps, and test_common_workloads_complete_or_make_progress_to_the_horizon.
  • TLA+ lifecycle models and Rust trace conformance (python3 verification/helios-lifecycle/check.py --tlc-jar /home/luke/.cache/flare-formal/tla2tools-1.7.4.jar --target-dir flare-cli/target): All 8 models passed with 0 TLC errors:
    • Lifecycle.tla: 1,342 observed Rust transitions
    • RankProtocol.tla: 1,291 observed Rust transitions
    • DispatchRing.tla: 7,940 observed Rust transitions
    • OffloadTransfer.tla: 8,490 observed Rust transitions
    • CacheOwnership.tla: 195,492 observed Rust transitions
    • Speculation.tla: 13,566 observed Rust transitions
    • ResponseLifecycle.tla: 365,508 observed Rust transitions
    • CheckpointReservation.tla: 68 observed Rust transitions
  • Limitations / unrun checks:
    • cargo-kani is not installed locally (covered by CI's Kani job; Kani-covered completion-vector and StateView validators were not modified).
    • Live GPU multi-concurrency (B = 4 uncontended and K > 4 oversubscribed) serving benchmarks were not run in this pass; those regimes are verified by the Rust unit tests and 786 simulator tests.

Discord: lukealonso

…ng/delivery fairness

Why:
Two independent scheduler biases caused adaptive speculative verification
to under-select deeper, higher-throughput verification depths under the
default `balanced` policy:
1. Per-depth cumulative calibration in `rounds.rs` defaulted unobserved
   deeper depths to unity while calibrating shallow depths, letting raw
   drafter overconfidence persist at unobserved depths and mis-estimating
   deeper cumulative survival when shallow shapes ran.
2. In `utility.rs`, `service.rs`, `policy.rs`, and `scripts/scheduling_sim/utility.py`,
   linear decode-age waiting cost `c_i * (A_i * T + T^2 / 2)` was charged
   to served decoders as well as excluded decoders (giving continuation
   reference `sigma_i = mu / p_i > 0` even when `p_i = 1`), and delivery
   fairness priced raw burst frequency `1 / T` (`delivered = 1`,
   `maximum_rate = 1 / T_min`). On longer-round hardware such as 4x DGX
   Spark (~35 ms/round), this penalized higher-`tok/s` speculative depths
   even when every active decoder was served and zero requests were
   excluded, violating the principle that hardware should only trade
   throughput for latency to protect an actual excluded/underserved request.

What changed:
- **Per-step conditional calibration (`helios/src/scheduler/rounds.rs`,
  `docs/scheduling-runtime-design.md`):** Switched `DepthCalibration` and
  `RequestCalibration` from cumulative ratios to survival-weighted per-step
  conditional ratios (`CALIBRATION_FACTOR_MAX = 4.0`, weight `w_d =
  prev_realized`), multiplied cumulatively across `0..=depth` during
  pricing. Unobserved deeper depths inherit the deepest observed shallower
  depth's factor instead of defaulting to `1.0`.
- **Excluded-only waiting age (`helios/src/scheduler/utility.rs`,
  `service.rs`, `policy.rs`, `scripts/scheduling_sim/utility.py`,
  `docs/scheduling-utility.md`):** Charged linear waiting age only to
  excluded delivery-bearing streams (`j in D \ S(a)`), yielding the exact
  Bellman continuation reference `sigma_i = E[T * 1_{i not in S}] / p_i =
  (K - b_f) * T_f / b_f` (`DeliveryReference::excluded_wait_ms`). Added
  `LaneValue::decode_within(expected, preceding_ms, horizon_ms)` (and
  updated `LaneValue::finish`) so served lanes cancel their `-c_i * T / 2`
  term while preserving additive cohort selection and exact two-stage
  prerequisite waiting over `[0, preceding_ms]`.
- **Served-share delivery fairness (`service.rs`, `utility.rs`, `policy.rs`,
  `scripts/scheduling_sim/utility.py`, `docs/scheduling-utility.md`):**
  Replaced burst-frequency delivery service (`delivered = 1`,
  `maximum_rate = 1 / T_min`) with served wall-time share `s_i in (0, 1]`
  (`delivered = duration_ms` on visible publication, `0` when excluded,
  `maximum_rate = 1.0`, initialized at `served_share = b_f / K`). Served
  decoders earn `+delivery_price_i * service_ms`, which divides by `T` to
  a duration-independent constant `+g_i / s_i`, protecting skipped
  requests without taxing deeper speculation on unskipped rounds.
- **No core format, Protobuf, or model-specific changes:** Existing cores
  load and serve unchanged.

Claimed benefit and result:
- Eliminates artificial depth throttling under `balanced` whenever all
  active decoders are served (solo `B = 1`, uncontended full `B = 4`, or
  a decoder taking its turn alongside a waiting prefiller) while preserving
  prefill chunk shrinking when decoders wait and duration/priority
  protection for excluded decoders when oversubscribed (`K > b`).
- Live 4x DGX Spark TP4 DeepSeek-V4.1-Flash serving (`max_tokens=256`,
  5-prompt suite):
  - On `gb10-tp4-202611301553`, default `balanced` achieves **76.11 tok/s**
    mean (peaking at **80.89 tok/s** on `greedy_code` with `off/r = 4.80`),
    matching `throughput` (**76.43 tok/s**, 0.4% difference, within `T=1`
    sampling variance).
  - On `gb10-tp4-202611301141`, default `balanced` on `greedy_code` rose
    from 70.30 tok/s (`off/r = 2.04`) to 75.98 tok/s (`off/r = 3.17`), and
    on DFly2 (`gb10-tp4-202611301002`), per-step calibration cured the
    `W=1`/`P=3` collapse (`ctx16k_T1`: 70.94 vs 57.12 tok/s forced `P=6`,
    +24.2%).

Supporting evidence and limitations:
- Rust crate tests (`cargo test --locked --release`): `eos` (2/2),
  `selene` (548/548), `selene-manager`, `helios` scheduler suite (400/400,
  including `balanced_unexcluded_decoders_maximize_throughput_without_delivery_or_age_penalty`
  and `oversubscribed_decoders_incur_excluded_wait_and_protect_skipped_lanes`),
  `flare`, and `flare-cli` (201/201).
- Scheduling simulator (`pytest tests/test_scheduling*.py -q`): **786/786**
  passed, including the updated excluded-only Poisson equation check and
  unexcluded `B = 1` / `B = 4` peak-throughput depth test.
- TLA+ lifecycle models and Rust trace conformance (`python3
  verification/helios-lifecycle/check.py --tlc-jar
  /home/luke/.cache/flare-formal/tla2tools-1.7.4.jar --target-dir
  flare-cli/target`): all 8 models passed with 0 TLC errors (`Lifecycle`
  1,342, `RankProtocol` 1,291, `DispatchRing` 7,940, `OffloadTransfer`
  8,490, `CacheOwnership` 195,492, `Speculation` 13,566,
  `ResponseLifecycle` 365,508, `CheckpointReservation` 68 observed
  transitions).
- Limitations / unrun checks: `cargo-kani` is not installed locally (covered
  by CI; completion-vector and `StateView` validators were not modified).
  Live GPU multi-concurrency (`B = 4` and `K > 4`) serving benchmarks were
  not run in this pass (covered by unit and 786 simulator tests).

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 644.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 30, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core calibration, Bellman continuation, and served-share fairness math check out across Rust and the simulator, but next_progress leaves a +age_price * T / 2 bias uncanceled, stale docs contradict the new model, and multi-concurrency validation is incomplete.

  • Blockers: 0 · Should fix: 3 · Subtract/Simplify: 3 · Nits: 2
Walkthrough
  • helios/src/scheduler/rounds.rs: Replaces cumulative-ratio calibration with survival-weighted per-step conditional calibration (CALIBRATION_FACTOR_MAX = 4.0, flat 0.5 prior, clamp(sum_w / count, 0, 1)), inherits the deepest observed shallower factor, and multiplies per-step factors across 0..=depth.
  • helios/src/scheduler/utility.rs: Adds LaneValue::decode_within(expected, preceding_ms, horizon_ms) so served decoders cancel -age_price * T / 2, updates LaneValue::finish to cancel waiting over the full horizon, and expands the Bellman continuation test with an excluded lane.
  • helios/src/scheduler/service.rs: Replaces scalar delivery intervals with DeliveryReference { excluded_wait_ms, served_share }, and switches delivery accounting from burst count to served wall-time share.
  • helios/src/scheduler/policy.rs: Threads DeliveryReference into lane valuation and passes preceding_ns through two-stage lookahead in continuation_candidate.
  • Python simulator and tests mirror excluded-only waiting and served-share delivery accounting, adding coverage for calibration inheritance, depth selection, oversubscribed fairness, and the excluded-only Poisson equation.
  • Docs in docs/scheduling-utility.md and docs/scheduling-runtime-design.md:113-152 describe served-share fairness, excluded-only waiting, and per-step calibration.
Merge Risk: Medium · up to 2b15114
  • Global default-policy blast radius: Excluded-only waiting and served-share fairness apply unconditionally to --scheduler-policy balanced; LaneValue::finish also affects throughput.
  • Hardware validation gap: Live GPU coverage is B=1; B=4, K>4, and inter-token/delivery-gap behavior are verified only in CPU/simulator tests. CALIBRATION_FACTOR_MAX = 4.0 warrants attention given prior C=1..32 regressions in helios/scheduler: scale GPU prefix calibration ceiling per step across depth #632.
  • No concurrency, ABI, or hot-path hazards: Changes are pure f64 arithmetic on the single-threaded planning/completion path, with no Protobuf, core-format, CUDA-graph, lock, or hot-path allocation changes. Sibling PR Overhaul Helios prefill scheduling, cost modeling, and two-frame pipelining #645 overlaps 7 files and will need rebasing/re-derivation.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
Should Fix (3)
  1. Uncanceled +age_price * T / 2 bias in helios/src/scheduler/policy.rs:501. next_progress uses ValueRate::new(ns, work, 0.0) while LaneValue::decode now adds + age_price * service_ms * (age_ms + service_ms / 2.0). For delivery-bearing multistage requests, dividing by T leaves an uncanceled bonus that rewards slower graphs producing the same tokens. Change to ValueRate::new(ns, work, value.age_price) and add a test that faster decode/resume shapes win when value.age_price > 0.
  2. Reconcile superseded docs. docs/scheduling-runtime-design.md:200-210, 233-247, 338-339, 378-383, 527-538, 645 and helios/README.md:446-450, 470-476 still describe delivery-rate counting, old sigma_i, terminal waiting over [T, H], and [0, 2] calibration. Update them, preferably with concise statements and pointers to docs/scheduling-utility.md.
  3. Clarify multi-concurrency validation and link DeepSeek V4.1 Flash TP3 on GB10: with four requests, the balanced policy verifies most rounds at width one; throughput is 8% faster on prose #152. Add DeepSeek V4.1 Flash TP3 on GB10: with four requests, the balanced policy verifies most rounds at width one; throughput is 8% faster on prose #152/helios/scheduler: scale GPU prefix calibration ceiling per step across depth #632/Overhaul Helios prefill scheduling, cost modeling, and two-frame pipelining #645 references, state that the DFly2 gb10-tp4-202611301002 comparison is against forced P=6 rather than main, and if possible run a B=4 main-vs-PR balanced check covering throughput plus inter-token/delivery gaps.
Subtract / Simplify (3)
  1. Delete dead completion_ms from LaneValue::finish and unused first_ms. completion_ms is used only by a debug_assert!, and policy.rs:723 computes first_ms solely to pass it. Change finish(&self, horizon_ms: f64) -> f64 and simplify callers.
  2. Deduplicate calibration inheritance. Forecast::prior_calibration_factor and #[cfg(test)] Forecasts::calibration_factor duplicate the descending (0..depth).rev() search. Extract a shared helper taking Option<&[RequestCalibration]>.
  3. Deduplicate cumulative calibration-factor multiplication. speculative_curve and observe_packed_forecasts independently accumulate the same product. Extract a zero-allocation iterator helper on Forecast so pricing and learning cannot diverge.
Nits (2)
  • helios/src/scheduler/rounds.rs:13: Add a one-line rationale for CALIBRATION_FACTOR_MAX = 4.0 (bounding per-step upscaling when proxy confidence is ~0.25 vs realized ~1.0, with cumulative multiplication handling multi-step compounding).
  • helios/src/scheduler/policy.rs:956-963: Decode | Speculative and Resume now share identical decode_within(..., preceding_ns / 1e6, horizon_ns / 1e6) calls and can be merged into one match arm.
Dropped on verification (10)
  • helios/scheduler: scale GPU prefix calibration ceiling per step across depth #632 still open/undecided: Stale; original-el8 closed it on 2026-11-30 18:02 in favor of fix(helios): per-step speculative calibration and excluded-only waiting/delivery fairness #644.
  • LaneValue::finish charges the full horizon: Sign-inversion misread; it cancels the waiting penalty and is documented, including for throughput. Only the dead completion_ms argument was kept.
  • delivery_references fallback bias at startup: False; unmeasured graphs produce delivery_rate = None, and the fallback applies only to multistage-blocked streams.
  • Inert cost == best[slot].0 tie-break: Low-signal; exact ties occur in linear/power-of-two models and tests, and an epsilon would add an arbitrary magic constant.
  • delivery_fairness / decode_age_price dimension change: Inaccurate; both retain their physical units and equilibrium magnitude, and a legacy-bias flag would violate the charter.
  • Flat 0.5 prior and clamp(sum_w / count, 0, 1) underived: 0.5 is the exact per-step equivalent of the prior 0.5^(d+1) cumulative prior, and dividing by count is the correct mean survival weight.
  • No single-core before/after exists: Overbroad; the PR reports an isolated same-core balanced A/B on gb10-tp4-202611301141 (72.46 -> 74.15 mean, 70.30 -> 75.98 greedy_code).
  • #[cfg(test)] observe_calibration no longer tests production code: Misleading; it is a one-line wrapper around observe_calibration_weighted(..., 1.0), while the bleed test drives complete_packed_round_with_survival end-to-end.
  • Drop service.rs:64-69 fallback / merge catalog scans; add observe_delivery: Dropping the fallback breaks the documented b = 1 reference; service_rates and delivery_references have distinct scopes; a wrapper expands API surface.
  • utility.py dataclass style: (cost, -served) is concise, idiomatic Python.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso
lukealonso merged commit 3e57bdc into main Nov 30, 2026
3 checks passed
@original-el8

Copy link
Copy Markdown
Collaborator

Tested #644 (+ #643) live on 4x DGX Spark (DeepSeek-V4.1-Flash TP4 roceshard-csf-v3, --scheduler-policy balanced, --mtp-adaptive-verification-alpha 1.0, --embedding-table-cache-size 22GiB) and closed #632 in favor of #644 + local-inference-lab/hyperflare-recipes#111:

  • 8K sustained decode (3 repeated 25s passes): C=1 71.1 tok/s (72.4 warmed), C=4 160.4 tok/s (164.1 pass 3), C=16 319.1 tok/s (329.5 pass 3), C=32 488.3 tok/s (490.2 / 493.6 / 481.0 tok/s).
  • Single-stream coding: 109.1 tok/s mean (120.6 tok/s max) across 3 x 5 coding runs; 48k-token PS4 Tetris reached 143.1 tok/s in the HTML/JS answer phase (6.59 offered / 5.09 accepted drafts/round, 162.3 tok/s 5s peak) even before re-exporting the core with hyperflare-recipes#111.

One small edge case worth noting in helios/src/scheduler/rounds.rs: Forecast::prior_calibration_factor inherits the deepest observed shallower step's local_factor (up to CALIBRATION_FACTOR_MAX = 4.0) for each unobserved deeper step, so cumulative_factor multiplies that factor once per unobserved step (up to 4^k across k unobserved steps after shallow rounds) rather than shrinking unobserved marginal steps toward 1.0 or the global prior.

lukealonso added a commit that referenced this pull request Nov 30, 2026
…tep ring2)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
lukealonso added a commit that referenced this pull request Nov 30, 2026
…tep ring2) (#643)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
lukealonso added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Nov 30, 2026
…obabilities (#111)

Why:
`_complete_block` in `hyperflare_recipes/components/vocabulary_sampling.py`
previously reported the sequential rejection-sampling product
`prod_{k <= s} min(p_k / q_k, 1)` as `completion_speculative_survival`.
Under Sun et al. block verification, prefix length >= s + 1 is accepted
whenever at least one independent test k in s..(limit - 2) succeeds with
hazard `h_k`, so the sequential product is only a strict lower bound that
under-reports survival at deeper depths (20-30 percentage points low at
depths 2..5). Because Helios uses `completion_speculative_survival` as
its Rao-Blackwellized realized target for adaptive verification
calibration, this bias systematically underestimated deeper-depth
acceptance.

What changed:
- In `hyperflare_recipes/components/vocabulary_sampling.py`
  (`_complete_block`): stored each clamped step hazard `h_k` in FP32 and
  computed the exact conditional survival probability
  `S_s = 1 - prod_{k=s}^{limit - 2} (1 - h_k)` via the backward FP32
  recurrence `S_s = min(S_{s+1} + h_s * (1 - S_{s+1}), 1.0)`, preserving
  monotonicity and avoiding cancellation near 0.
- Added Monte Carlo validation test
  `test_block_verification_survival_matches_monte_carlo_acceptance` in
  `tests/components/test_vocabulary_completion_abi.py` verifying that
  reported `survivals` match empirical acceptance across 4,096 Philox
  seeds within tight statistical tolerance.

Claimed benefit and result:
Eliminates the systematic downward bias in Rao-Blackwellized realized
survival reported to Helios under block verification, allowing adaptive
verification calibration to match actual realized acceptance at deeper
draft depths. Combined with the companion Helios scheduler PR
(`NVIDIA/hyperflare-inference#644`) and SM121 b12x kernel PRs
(`local-inference-lab/flashinfer#192`, `#193`), 4x DGX Spark TP4
DeepSeek-V4.1-Flash serving reached 76.11 tok/s mean (80.89 tok/s peak
on `greedy_code`) under default `balanced` policy.

Supporting evidence and limitations:
- `TRITON_INTERPRET=1 pytest tests/components/test_vocabulary_completion_abi.py -q`:
  all tests passed (verified exact Monte Carlo survival match).
- Full 4x DGX Spark TP4 export (`gb10-tp4-202611301553`) and 5-prompt
  live serving verified on SM121.
- Limitations: non-block (sequential) speculative verification paths were
  unchanged and already report exact sequential survival.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=6fcc
lukealonso added a commit that referenced this pull request Nov 30, 2026
…lining

Why

Four coupled scheduling defects degraded Helios prefill throughput,
simultaneous-burst batching, and long-context chunk selection:

1. Under-batched decode coalescing: Helios executes pure prefill at batch 1
   with prompt-token value 1.0 against output-token value 64.0 and did not
   price the multi-step K -> K + m decode-batch throughput surplus unlocked
   when queued prefills finish and join an active decode cohort. On
   simultaneous bursts, the scheduler launched premature sub-batch decode
   rounds and split prefill work into smaller chunks instead of coalescing
   waiting prompts into full decode batches.
2. Fill- and KV-context-blind prefill timing estimates (#485): ActionCosts
   keyed a single 9-sample rolling median purely on static graph capacity,
   ignoring live token count and KV history depth. Short masked tails
   poisoned full-chunk medians on large graphs, and deep KV-attention
   slowdown on larger chunks caused selection to drift down onto stale
   shallow-context smaller capacities.
3. Serialized nonterminal prefill chunks: plan_requires_feedback and the
   executor submission guards required completion feedback for every graph
   outside Decode and Speculative, draining the two-frame pipeline between
   consecutive nonterminal GraphKind::Prefill chunks even when no token is
   sampled and no checkpoint capture or prompt end is reached.
4. Mixed-graph and terminal-prefill catalog mismatches: Mixed decode rate
   and optimistic continuation paths bypassed powered_curve / forecast_tokens
   and lacked a !prefill guard, while unmeasured TerminalPrefill discovery
   looked up prefill_catalog instead of terminal_prefill_catalog.

What Changed

- Decode-batch coalescing continuation value (helios/src/scheduler/policy.rs,
  scripts/scheduling_sim/utility.py, docs/scheduling-runtime-design.md,
  helios/README.md): Added PolicyConfig::coalescing_horizon_tokens (default
  64.0, validated nonnegative). When active decoders are under-batched
  relative to the measured decode/speculative catalog and queued prefills
  can enter decode (max_new_tokens > 1, not prompt_logprobs), each prefiller
  receives an intrinsic output_token_value * ((K + m) / m) * (1 - R_K / R_{K+m})
  surplus over min(coalescing_horizon_tokens, post_prefill, peer_budget),
  amortized uniformly across its uncached prompt tokens so total credit sums
  to 1x regardless of chunking and chunk sizing stays smooth under active
  decoder waiting age. Checked in burst_four, burst_eight, burst_eight_8k,
  burst_four_low, and burst_eight_low in scripts/scheduling_sim/workloads.py.
- Stratified fill/context prefill cost model and O(1) affine checkpoint
  stride (helios/src/scheduler/cost.rs, helios/src/scheduler/checkpoints.rs,
  helios/src/scheduler/policy.rs, helios/src/scheduler/service.rs): Replaced
  single-median prefill estimates with PrefillCostModel (6 strata crossing
  u <= 0.5 / u > 0.5 with start_position < 4096 / 4096..32768 / >= 32768,
  each keeping a 9-sample rolling median shared via Ring9) and exact 3-param
  relative-error-weighted NNLS fitting theta_0 + theta_1*u + theta_2*u*(pos/4096).
  Narrow-fill upward extrapolation applies a bounded 4x constant-throughput
  floor on the base term before adding theta_2*h, preventing partial fills
  from discounting full-chunk costs or locking out large capacities after TTL
  reset. Smaller capacities without deep-context observations borrow the
  per-token context slope theta_2 / peer_capacity from the largest fresh
  strictly larger peer of the same kind. Extended checkpoints::interval_prefill_ns
  with an O(1) closed-form arithmetic-series stride over full-chunk affine
  segments so long agentic prompts retain bounded cost evaluation under
  non-constant predictors.
- Two-frame nonterminal GraphKind::Prefill pipelining (helios/src/execution/manifest.rs,
  helios/src/scheduler.rs, helios/src/scheduler/policy.rs, helios/src/model.rs,
  helios/src/execution/{transport,threaded,parallel}.rs,
  helios/src/execution/threaded/protocol.rs, verification/helios-lifecycle/check.py):
  Single-sourced GraphKind::pipelines(self) for Decode | Speculative | Prefill,
  added prefill_cursor / _from planning helpers and prefill_step_requires_feedback,
  allowed nonterminal non-capture Prefill steps to queue two deep while
  draining at prompt end, checkpoint cuts, deferred-prefill limits, grammar
  constraints, stale/probe costs, or terminal/scored prefill, and guarded
  ConsumedTokens / SnapshotConsumedTokens reuse.
- Mixed-graph curve and terminal-catalog fixes (helios/src/scheduler/learning.rs,
  helios/src/scheduler/service.rs, helios/src/scheduler/policy.rs): Wired
  powered_curve + forecast_tokens with !prefill guards into Mixed rate and
  optimistic continuation paths, routed unmeasured prefill discovery and
  resize_prefill through effective_prefill_catalog, and removed unreachable
  is_prefill() branches in add_candidate and continuation_candidate.
- Compatibility: No Protobuf, core-format, or CUDA-graph ABI changes;
  existing exported cores load and serve unchanged.

Claimed Benefit and Result

- Live SM120 flare run A/B vs origin/main (3e57bdc, including #644):
  - nvidia/Qwen3.8-27B-NVFP4@gb202-tp1-202610281501 (1x RTX PRO 6000
    Blackwell, balanced policy, unique uncached prompts):
    - Simultaneous B=8 burst (8 x ~2,430-token prompts, 2,048 output tokens):
      aggregate throughput rose from 398.6 to 497.6 tok/s (+24.8%), max TTFT
      fell from 3,070.3 to 2,776.8 ms (-9.6%), prefill launches fell from 24
      to 16 (-33%), and speculative rounds fell from 113 to 71 (-37%).
    - Simultaneous B=4 burst (4 x ~2,430-token prompts, 1,024 output tokens):
      aggregate throughput rose from 305.8 to 316.5 tok/s (+3.5%), max TTFT
      fell from 1,903.5 to 1,855.3 ms (-2.5%), prefill launches fell from 11
      to 8.
    - Consecutive ~130k uncached prompts (#485): Run 0 improved 30,622.6 ->
      29,510.2 ms (-3.6%, 57 -> 52 launches), Run 1 improved 30,349.9 ->
      28,982.5 ms (-4.5%, 59 -> 40 launches), Run 2 29,209.2 -> 29,082.8 ms
      (-0.4%, 38 vs 39 launches).
  - nvidia/Qwen3.8-Flash-Next-FP4-Local@gb202-tp2-202610270419 (2x SM120):
    B=4 burst 252.9 -> 262.7 tok/s (+3.9%), B=8 burst 353.1 -> 354.9 tok/s
    (max TTFT 2,063.0 -> 2,017.6 ms), 77k uncached prompts 4,492.5 ->
    4,488.1 ms; clean SIGTERM drain (rc=0) on both arms.
  - deepseek-ai/DeepSeek-V4.1-Flash-1017@gb202-tp4-202611281955 (4x SM120):
    3 consecutive ~158k uncached prompts stayed flat at 20 prefill launches
    with ~13 ms lower TTFT per run (3,524.0 -> 3,510.8 ms, 3,497.3 ->
    3,484.2 ms, 3,494.0 -> 3,487.5 ms); clean SIGTERM drain (rc=0).
- Synthetic scheduling simulator (scripts/scheduling_sim, balanced policy):
  - burst_eight (8 x 4,096): makespan 2,188 -> 2,060 ms (-5.9%), max TTFT
    876 -> 706 ms (-19.4%), sub-batch rounds 16 -> 8.
  - burst_eight_8k (8 x 8,192): makespan 2,746 -> 2,648 ms (-3.6%), max TTFT
    1,448 -> 1,314 ms (-9.3%), sub-batch rounds 18 -> 12.
  - burst_eight_low (8 x 4,096, zero draft acceptance): max TTFT 611 ->
    559 ms (-8.5%), sub-batch rounds 6 -> 2.

Supporting Evidence and Limitations

- Rust crate suites (cargo test --locked --release):
  - eos: 2 passed, 0 failed.
  - selene (--features test-support): 548 passed, 0 failed.
  - selene-manager (--features test-support): passed.
  - helios (--features runtime-core,server): 1,751 passed (406/406
    scheduler:: tests including bounded post-TTL extrapolation, peer
    context-slope borrowing, O(1) affine checkpoint stride on 150k/999-
    boundary prompts, burst coalescing, and two-frame prefill pipelining);
    6 chat-template tests require FLARE_TEST_TEMPLATE_DIR from a gated HF
    repo and did not run locally.
  - flare: 237 passed, 0 failed.
  - flare-cli: passed; release build succeeded with 0 warnings.
- Python suites (pytest tests/cli tests/test_scheduling*.py -q): 961 passed.
- 64-seed timing-learning validation (scripts/scheduling_sim/learning.py
  --preset validate --reference ttl across all 62 scenarios, seeds
  10000..10063, Helios production retained-refresh alpha=0.002): accepted
  retained-refresh:funded:cumulative:alpha=0.002 with 35/35 core gates,
  6/6 recovery gates, calibration passed, 0/64 stationary resets, geomean
  core throughput ratio 1.0093, worst core p99 decode-gap ratio 1.0101.
- TLA+ lifecycle verification (verification/helios-lifecycle/check.py with
  tla2tools-1.7.4.jar): all 8 models and Rust trace conformance passed
  (and check.py --mutations detected all injected mutations).
- Limitations: cargo-kani is not installed locally (covered by CI; Kani-
  covered completion-vector and StateView validators were not modified).
  Live GPU measurements cover SM120 TP1/TP2/TP4; SM103/SM121 and TP16
  Kimi K3.1 were not re-measured on hardware in this pass.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
lukealonso added a commit that referenced this pull request Nov 30, 2026
…lining (#645)

Why

Four coupled scheduling defects degraded Helios prefill throughput,
simultaneous-burst batching, and long-context chunk selection:

1. Under-batched decode coalescing: Helios executes pure prefill at batch 1
   with prompt-token value 1.0 against output-token value 64.0 and did not
   price the multi-step K -> K + m decode-batch throughput surplus unlocked
   when queued prefills finish and join an active decode cohort. On
   simultaneous bursts, the scheduler launched premature sub-batch decode
   rounds and split prefill work into smaller chunks instead of coalescing
   waiting prompts into full decode batches.
2. Fill- and KV-context-blind prefill timing estimates (#485): ActionCosts
   keyed a single 9-sample rolling median purely on static graph capacity,
   ignoring live token count and KV history depth. Short masked tails
   poisoned full-chunk medians on large graphs, and deep KV-attention
   slowdown on larger chunks caused selection to drift down onto stale
   shallow-context smaller capacities.
3. Serialized nonterminal prefill chunks: plan_requires_feedback and the
   executor submission guards required completion feedback for every graph
   outside Decode and Speculative, draining the two-frame pipeline between
   consecutive nonterminal GraphKind::Prefill chunks even when no token is
   sampled and no checkpoint capture or prompt end is reached.
4. Mixed-graph and terminal-prefill catalog mismatches: Mixed decode rate
   and optimistic continuation paths bypassed powered_curve / forecast_tokens
   and lacked a !prefill guard, while unmeasured TerminalPrefill discovery
   looked up prefill_catalog instead of terminal_prefill_catalog.

What Changed

- Decode-batch coalescing continuation value (helios/src/scheduler/policy.rs,
  scripts/scheduling_sim/utility.py, docs/scheduling-runtime-design.md,
  helios/README.md): Added PolicyConfig::coalescing_horizon_tokens (default
  64.0, validated nonnegative). When active decoders are under-batched
  relative to the measured decode/speculative catalog and queued prefills
  can enter decode (max_new_tokens > 1, not prompt_logprobs), each prefiller
  receives an intrinsic output_token_value * ((K + m) / m) * (1 - R_K / R_{K+m})
  surplus over min(coalescing_horizon_tokens, post_prefill, peer_budget),
  amortized uniformly across its uncached prompt tokens so total credit sums
  to 1x regardless of chunking and chunk sizing stays smooth under active
  decoder waiting age. Checked in burst_four, burst_eight, burst_eight_8k,
  burst_four_low, and burst_eight_low in scripts/scheduling_sim/workloads.py.
- Stratified fill/context prefill cost model and O(1) affine checkpoint
  stride (helios/src/scheduler/cost.rs, helios/src/scheduler/checkpoints.rs,
  helios/src/scheduler/policy.rs, helios/src/scheduler/service.rs): Replaced
  single-median prefill estimates with PrefillCostModel (6 strata crossing
  u <= 0.5 / u > 0.5 with start_position < 4096 / 4096..32768 / >= 32768,
  each keeping a 9-sample rolling median shared via Ring9) and exact 3-param
  relative-error-weighted NNLS fitting theta_0 + theta_1*u + theta_2*u*(pos/4096).
  Narrow-fill upward extrapolation applies a bounded 4x constant-throughput
  floor on the base term before adding theta_2*h, preventing partial fills
  from discounting full-chunk costs or locking out large capacities after TTL
  reset. Smaller capacities without deep-context observations borrow the
  per-token context slope theta_2 / peer_capacity from the largest fresh
  strictly larger peer of the same kind. Extended checkpoints::interval_prefill_ns
  with an O(1) closed-form arithmetic-series stride over full-chunk affine
  segments so long agentic prompts retain bounded cost evaluation under
  non-constant predictors.
- Two-frame nonterminal GraphKind::Prefill pipelining (helios/src/execution/manifest.rs,
  helios/src/scheduler.rs, helios/src/scheduler/policy.rs, helios/src/model.rs,
  helios/src/execution/{transport,threaded,parallel}.rs,
  helios/src/execution/threaded/protocol.rs, verification/helios-lifecycle/check.py):
  Single-sourced GraphKind::pipelines(self) for Decode | Speculative | Prefill,
  added prefill_cursor / _from planning helpers and prefill_step_requires_feedback,
  allowed nonterminal non-capture Prefill steps to queue two deep while
  draining at prompt end, checkpoint cuts, deferred-prefill limits, grammar
  constraints, stale/probe costs, or terminal/scored prefill, and guarded
  ConsumedTokens / SnapshotConsumedTokens reuse.
- Mixed-graph curve and terminal-catalog fixes (helios/src/scheduler/learning.rs,
  helios/src/scheduler/service.rs, helios/src/scheduler/policy.rs): Wired
  powered_curve + forecast_tokens with !prefill guards into Mixed rate and
  optimistic continuation paths, routed unmeasured prefill discovery and
  resize_prefill through effective_prefill_catalog, and removed unreachable
  is_prefill() branches in add_candidate and continuation_candidate.
- Compatibility: No Protobuf, core-format, or CUDA-graph ABI changes;
  existing exported cores load and serve unchanged.

Claimed Benefit and Result

- Live SM120 flare run A/B vs origin/main (3e57bdc, including #644):
  - nvidia/Qwen3.8-27B-NVFP4@gb202-tp1-202610281501 (1x RTX PRO 6000
    Blackwell, balanced policy, unique uncached prompts):
    - Simultaneous B=8 burst (8 x ~2,430-token prompts, 2,048 output tokens):
      aggregate throughput rose from 398.6 to 497.6 tok/s (+24.8%), max TTFT
      fell from 3,070.3 to 2,776.8 ms (-9.6%), prefill launches fell from 24
      to 16 (-33%), and speculative rounds fell from 113 to 71 (-37%).
    - Simultaneous B=4 burst (4 x ~2,430-token prompts, 1,024 output tokens):
      aggregate throughput rose from 305.8 to 316.5 tok/s (+3.5%), max TTFT
      fell from 1,903.5 to 1,855.3 ms (-2.5%), prefill launches fell from 11
      to 8.
    - Consecutive ~130k uncached prompts (#485): Run 0 improved 30,622.6 ->
      29,510.2 ms (-3.6%, 57 -> 52 launches), Run 1 improved 30,349.9 ->
      28,982.5 ms (-4.5%, 59 -> 40 launches), Run 2 29,209.2 -> 29,082.8 ms
      (-0.4%, 38 vs 39 launches).
  - nvidia/Qwen3.8-Flash-Next-FP4-Local@gb202-tp2-202610270419 (2x SM120):
    B=4 burst 252.9 -> 262.7 tok/s (+3.9%), B=8 burst 353.1 -> 354.9 tok/s
    (max TTFT 2,063.0 -> 2,017.6 ms), 77k uncached prompts 4,492.5 ->
    4,488.1 ms; clean SIGTERM drain (rc=0) on both arms.
  - deepseek-ai/DeepSeek-V4.1-Flash-1017@gb202-tp4-202611281955 (4x SM120):
    3 consecutive ~158k uncached prompts stayed flat at 20 prefill launches
    with ~13 ms lower TTFT per run (3,524.0 -> 3,510.8 ms, 3,497.3 ->
    3,484.2 ms, 3,494.0 -> 3,487.5 ms); clean SIGTERM drain (rc=0).
- Synthetic scheduling simulator (scripts/scheduling_sim, balanced policy):
  - burst_eight (8 x 4,096): makespan 2,188 -> 2,060 ms (-5.9%), max TTFT
    876 -> 706 ms (-19.4%), sub-batch rounds 16 -> 8.
  - burst_eight_8k (8 x 8,192): makespan 2,746 -> 2,648 ms (-3.6%), max TTFT
    1,448 -> 1,314 ms (-9.3%), sub-batch rounds 18 -> 12.
  - burst_eight_low (8 x 4,096, zero draft acceptance): max TTFT 611 ->
    559 ms (-8.5%), sub-batch rounds 6 -> 2.

Supporting Evidence and Limitations

- Rust crate suites (cargo test --locked --release):
  - eos: 2 passed, 0 failed.
  - selene (--features test-support): 548 passed, 0 failed.
  - selene-manager (--features test-support): passed.
  - helios (--features runtime-core,server): 1,751 passed (406/406
    scheduler:: tests including bounded post-TTL extrapolation, peer
    context-slope borrowing, O(1) affine checkpoint stride on 150k/999-
    boundary prompts, burst coalescing, and two-frame prefill pipelining);
    6 chat-template tests require FLARE_TEST_TEMPLATE_DIR from a gated HF
    repo and did not run locally.
  - flare: 237 passed, 0 failed.
  - flare-cli: passed; release build succeeded with 0 warnings.
- Python suites (pytest tests/cli tests/test_scheduling*.py -q): 961 passed.
- 64-seed timing-learning validation (scripts/scheduling_sim/learning.py
  --preset validate --reference ttl across all 62 scenarios, seeds
  10000..10063, Helios production retained-refresh alpha=0.002): accepted
  retained-refresh:funded:cumulative:alpha=0.002 with 35/35 core gates,
  6/6 recovery gates, calibration passed, 0/64 stationary resets, geomean
  core throughput ratio 1.0093, worst core p99 decode-gap ratio 1.0101.
- TLA+ lifecycle verification (verification/helios-lifecycle/check.py with
  tla2tools-1.7.4.jar): all 8 models and Rust trace conformance passed
  (and check.py --mutations detected all injected mutations).
- Limitations: cargo-kani is not installed locally (covered by CI; Kani-
  covered completion-vector and StateView validators were not modified).
  Live GPU measurements cover SM120 TP1/TP2/TP4; SM103/SM121 and TP16
  Kimi K3.1 were not re-measured on hardware in this pass.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b

Signed-off-by: Luke Alonso <lalonso@gmail.com>
FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Nov 30, 2026
Why:
Adaptive speculative verification scores each joint prefix-survival
probability p as p^alpha using a single static adaptive_verification_alpha
across all decode batch sizes. Lower values (alpha < 1.0) favor longer
verification prefixes, while higher values (alpha > 1.0) favor shorter
prefixes. Because verification step latency grows steeply with active decode
concurrency, a single static exponent tuned for low concurrency (C = 1..8)
over-offers deep drafts at higher concurrency (C >= 12), inflating per-round
latency, whereas raising a static exponent globally reduces low-concurrency
speculative depth. Linearly interpolating the effective exponent with active
decode concurrency lets operators balance low- and high-concurrency
verification width independently at serving time using existing signed cores,
without re-exporting cores or changing captured graph contracts.

What:
- Helios scheduler (helios/src/scheduler.rs, policy.rs, rounds.rs,
  policy_tests.rs): Adds opt-in adaptive_verification_alpha_high (default
  None), adaptive_verification_alpha_low_concurrency (default 8), and
  adaptive_verification_alpha_high_concurrency (default 12) to PolicyConfig,
  plus PolicyConfig::effective_adaptive_verification_alpha(active_decodes)
  and RequestScheduler::active_decode_concurrency() /
  effective_adaptive_verification_alpha(). When alpha_high is unset, or when
  fixed-width verification is configured, the effective exponent returns
  adaptive_verification_alpha unchanged. When set under adaptive
  verification, the exponent interpolates linearly across live
  RequestPhase::Decode slots between low and high concurrency thresholds,
  clamped to [min(low, high), max(low, high)] with finiteness guards.
  Per-step speculative calibration (NVIDIA#644), excluded-only waiting age and
  served-share delivery fairness (NVIDIA#644), decode-batch coalescing through
  powered_curve (NVIDIA#645), stratified prefill cost modeling (NVIDIA#645), and
  two-frame nonterminal prefill pipelining (NVIDIA#645) are preserved.
  configure_policy validates positive finite alphas and 1 <= low < high.
- Server config and CLI (helios/src/server/config.rs, flare-cli/src/cli.rs,
  flare-cli/src/main.rs): Adds --mtp-adaptive-verification-alpha-high,
  --mtp-adaptive-verification-alpha-low-concurrency, and
  --mtp-adaptive-verification-alpha-high-concurrency to ServingOptions,
  validates them early before GPU initialization and in Bootstrap::load
  (rejecting thresholds without alpha_high, non-positive/non-finite alphas,
  and low >= high), forwards them to peer ranks via rank_options(), and
  emits bootstrap JSON keys only when set.
- Scheduling simulator and docs (scripts/scheduling_sim/{__main__,
  learning_policy,model,scheduler,utility}.py,
  tests/test_scheduling_utility.py, docs/cli-design.md,
  docs/scheduling-runtime-design.md): Applies effective concurrency-aware
  alpha consistently across expected_output, candidates, UtilityConfig,
  UtilityScheduler (including decode-batch coalescing), LearningScheduler
  (_actions and _cohort_actions), and simulator CLI flags with matching
  validation; adds regression coverage verifying LearningScheduler matches
  UtilityScheduler under concurrency-aware alpha; updates CLI and
  scheduling-runtime docs as present-state specification.
- Compatibility: No core format, Protobuf schema, captured graph contract,
  or model-specific changes; existing signed cores load and serve without
  re-export.

Result:
Enables opt-in runtime tuning of speculative verification prefix length
across active decode concurrency with zero behavioral change when
--mtp-adaptive-verification-alpha-high is omitted. In the deterministic
scheduling simulator using the 28-shape multi-width catalog and survival
curve from helios/src/scheduler/policy_tests.rs (256 output tokens per
request, seed 0), ramping alpha from 1.0 to 1.5 across C = 8..12 leaves
C = 1, 4, and 8 bit-for-bit identical to constant alpha = 1.0 (mean width
8.00 at C = 1 and C = 4; 4.55 at C = 8) while tightening mean verification
width from 4.47 to 2.14 at C = 12 (p95 step 13.60 -> 9.80 ms, -27.9%; max
output gap 20.90 -> 10.45 ms, -50.0%; output rate 2,163.1 -> 2,040.6 tok/s,
-5.7%) and from 4.40 to 2.14 at C = 16 (p95 step 16.90 -> 11.60 ms, -31.4%;
max output gap 40.80 -> 20.34 ms, -50.1%; output rate 2,360.9 -> 2,301.0
tok/s, -2.5%).

Evidence:
Verified on a clean git archive of this commit atop e85019b:
conflict-free git merge-tree against e85019b; all 8 TLA+ lifecycle
models and Rust trace conformance via verification/helios-lifecycle/check.py;
release cargo test for helios (--features server and --features
runtime-core,server), flare, and flare-cli; cargo check for heliopause;
pytest for tests/preparation/test_core_boundary.py and
tests/test_scheduling*.py (including LearningScheduler parity);
scripts.scheduling_sim scenario checks; and ruff 0.12.8 on touched Python
lines.
Limitation: Controlled equivalent-baseline target-hardware flare run A/B
serving benchmarks on this post-NVIDIA#644/NVIDIA#645 commit have not been run yet and
are required before upstream readiness.

Design-Signed-Off-By: Antigravity (gemini-4-neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduling Request scheduling, fairness, batching, and speculative-width selection. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants