Skip to content

helios/scheduler: explore smaller prefill chunks under active age-priced streams - #661

Merged
lukealonso merged 2 commits into
NVIDIA:mainfrom
FujitsuPolycom:fix/helios-prefill-cadence-exploration
Dec 2, 2026
Merged

lukealonso merged 2 commits into
NVIDIA:mainfrom
FujitsuPolycom:fix/helios-prefill-cadence-exploration

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

With --scheduler-policy balanced (decode_age_price = 0.1), Helios interleaves prefill and decode without mixed graphs. On TERMINAL_PREFILL cores (256..=16384 alongside PREFILL 128..=16384), cold prompts stall active decoders: unmeasured smaller Prefill shapes are skipped, prompt tails at or below max_terminal force a single TerminalPrefill, non-terminal Prefill steps fill both dispatch frames, splitting a single-graph prompt resets first_output_wait_ns, and deferred TerminalPrefill completions at an interior cut credit first_output_value only for the final stub tokens.

What

+236 net non-test Rust production LOC (+376/-140 across 4 files; 15 files total, +2,778/-186 atop 1fbcc3c9; zero new CLI flags, unsafe, hardcoded capacities, or ABI changes; signed model cores unchanged):

  • Interpolated discovery (cost.rs, policy.rs): Adds ActionCosts::interpolated_prefill_duration (uses a measured sibling at the same capacity if present, else linearly interpolates between the nearest smaller measured peer or fastest decode floor and the nearest larger measured peer; keeps ScoredPrefill isolated). When age_price > 0.0, prefill_candidate_ns scores unmeasured capacities up to natural fit in add_prefill_candidate and continuation_candidate, tagging winners as PlanOrigin::Discovery.
  • Chunking, wait clock, interior-cut credit, and draining (scheduler.rs, policy.rs, service.rs): Unblocks non-terminal Prefill below max_terminal under active age-priced streams, restricts deferred_prefill and resize_prefill to TERMINAL_PREFILL, caps age-priced resize_prefill growth at candidate.capacity, caches terminal_prefill_window, aligns service_rates via prefill_must_complete_terminally_from, retains first_output_wait_ns (preserves_first_output_wait) across capture-free non-terminal Prefill on single-graph prompts, credits (end - prefix_tokens) / initial_prefill in lane_value_for_tokens_within for deferred TerminalPrefill steps landing at an interior checkpoint cut, and drains non-terminal Prefill steps via prefill_step_requires_feedback. PolicyConfig::throughput() (decode_age_price = 0.0) keeps two-frame Prefill pipelining across active decode and resume streams, draining only when a finishing terminal_cleanup stream is resident (terminal_age_price > 0.0).
  • Simulator, formal checks, and documentation: Models initial_discovery = "interpolated" in scripts/scheduling_sim, updates verification/helios-lifecycle/check.py mutations, adds unit and simulator tests, and updates runtime, theory, and README documentation.

Result

  • 64-seed simulator validation (scripts/scheduling_sim/learning.py --preset validate --reference ttl, 15,872 runs): retained-refresh (alpha = 0.002, initial_discovery = "interpolated") ACCEPTED (35/35 vs ttl at 1.0100x; 35/35 vs native with -17.5% to -27.0% p99 TTFT on prefill-16-decoders-*; 0 diffs across 2,112 solo/zero-age pairs; 6/6 recovery checks passed; calibration passed; 0/64 resets).
  • SM120 TP4 flare run A/B (3d868f84 / tree c1d6858b vs main 1fbcc3c9, 4x RTX PRO 6000, DeepSeek-V4.1-Flash, --scheduler-policy balanced, 0 server errors, 100% clean responses):
Workload (repeats) >250 ms Stalls Burst Gap p99 User tok/s Out ∥ TTFT p50 ∥ SLO
mixed-c32 (2) 538 -> 365 (-32.2%) 261.5 -> 254.7 ms 66.0 -> 67.8 1,277 -> 1,258 ∥ 1,423 -> 1,479 ms ∥ 92.0 -> 89.5%
long-context-mixed (1) 863 -> 503 (-41.7%) 263.7 -> 256.4 ms 73.7 -> 77.1 661.3 -> 670.5 ∥ 1,476 -> 1,503 ms ∥ 94.8 -> 89.3%
cold-heavy-mix [1] (1) 2,988 -> 2,732 (-8.6%) 298.4 -> 278.2 ms 52.2 -> 51.8 534.8 -> 545.6 ∥ 1,922 -> 1,713 ms ∥ 89.0 -> 81.6%

Workloads come from FujitsuPolycom/tokbench (v0.4.0, closed-loop client, --seed 42 --temperature 0.0). SLO passes when a request achieves at least 15 tok/s per-user decode speed and meets its class TTFT target (<= 2 s interactive, <= 3 s agentic and long-decode, <= 10 s / 30 s / 45 s heavy prefill): mixed-c32 runs 32 concurrent clients (10 interactive chat at 0.7K–2.2K tokens, 12 multi-turn coding agents at 3.5K–8K tokens sharing a 2K prefix, 4 cold prefills at 10K–22K tokens, and 6 long-decode streams generating 480–850 tokens); long-context-mixed runs 20 clients (6 interactive at 1K–3K, 8 multi-turn agents at 12K–24K, and 6 cold prefills at 32K–128K tokens); cold-heavy-mix (-c 32) splits 32 clients evenly between multi-turn agents (4.5K–10K) and cold prefills (150K–250K).

Across two mixed-c32 repeats, medians were output 1,273 -> 1,254 tok/s (-1.5%), stalled decode time 11.4% -> 6.7% (-41.6%), SLO 91.1% -> 89.4% (long_decode 93.8%, agentic_multiturn 87.2% -> 90.6%), and prefix cache hit rate 47.3% -> 48.6%. In a cold-burst micro-probe (4 active decoders plus staggered 14K, 32K, and 64K cold prefills, n=2), TPOT moved 7.12 -> 6.70 ms, p95 gap 14.4 -> 14.1 ms, mean max gap 229.3 -> 243.8 ms, peak gap 277.4 -> 433.7 ms (trial 0: 218.7 ms), and makespan 2.81 -> 2.91 s. [1] In cold-heavy-mix, 4 -> 7 heavy-prefill requests hit client-side 45 s drain cutoffs under KV saturation (0 server errors). Opt-out: --scheduler-policy throughput.

Evidence

  • Archive checks (3d868f84 / tree c1d6858b): cargo check --locked --release (RUSTFLAGS="-D warnings") and cargo test --locked --release passed across all 7 crates (3,590 passed, 0 failed; flare-cli run with --test-threads=1); verification/helios-lifecycle/check.py --jobs 16 --mutations passed (13/13 TLA+ mutations, 8/8 observed traces / 594,065 transitions plus DispatchRing SlotReuseSafe, 26/26 Rust mutations); pytest 839/839 passed; uvx ruff==0.12.8 check reported 0 errors; 64-seed learning.py result carries over via unchanged scripts/scheduling_sim/*, cost.rs, scheduler.rs, service.rs, and utility.rs.
  • SM120 flare run flags: --gpus 0,1,2,3 --scheduler-policy balanced --max-concurrency 32 --mtp-draft-tokens 7 --mtp-adaptive-verification --mtp-max-verification-token-budget 128 --mtp-adaptive-verification-alpha 1.0 --embedding-table-cache-size 84GiB --kv-cache-limit memory --prefix-cache-memory 0.
  • Limits: cargo-kani is not installed on the build host; GB10 was not re-measured on 3d868f84; long-context-mixed and cold-heavy-mix ran single repeats (n=1).

Discord: Dooner

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. labels Dec 1, 2026
@FujitsuPolycom
FujitsuPolycom force-pushed the fix/helios-prefill-cadence-exploration branch from fdb10bb to 29f2b5b Compare December 1, 2026 22:40
@FujitsuPolycom
FujitsuPolycom marked this pull request as ready for review December 1, 2026 22:42
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 661.
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 the triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. label Dec 1, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core Rust scheduling changes are clean, memory-safe, and model-agnostic, but this default-on balanced-policy performance change fails two merge gates: the mandatory 64-seed simulator timing gate is unrun (no head-commit A/B or CI on 29f2b5b), and the PR's throughput pipelining claim contradicts the code.

  • Blockers: 1 · Should fix: 2 · Subtract/Simplify: 4 · Nits: 2
Walkthrough
  • cost.rs (:695-786, :1280-1577): Adds ActionCosts::interpolated_prefill_duration, estimating unmeasured Prefill/TerminalPrefill/ScoredPrefill capacities from a measured same-capacity sibling or linear interpolation between a measured smaller peer (or fastest measured Decode/Speculative/Resume floor) and a strictly larger peer, clamping non-monotonic timings; 3 isolated unit tests.
  • scheduler.rs (:657, 803, 838, 842-861, 896-902, 957-1015, 1180-1183): Caches terminal_prefill_window; widens resolve_prefill_kind_from so deferred_prefill excludes every capacity absent from terminal_prefill_catalog; adds prefill_must_complete_terminally_from, has_active_age_priced_stream, prefill_requires_terminal_completion_for_age; drains non-terminal Prefill steps when an active age-priced stream exists.
  • policy.rs (:79-86, 350-456, 970-1031, 1330-1381, 1694-1799): Replaces effective_prefill_catalog with prefill_catalog_for_terminal; hoists per-slot (cut, terminal_only, nat_fit) into PrefillSlotPlan; prices unmeasured pure-prefill candidates <= nat_fit via interpolation under age_price > 0.0 (still recorded as TimingOrigin::Discovery); resize_prefill uses the terminal catalog under deferred_prefill and caps capacity under age_price > 0.0 && !terminal_only.
  • service.rs (:201-231): Adds a token_rate == 0.0 fallback scanning non-terminal Prefill capacities when an age-priced stream is active and !prefill_must_complete_terminally_from(...).
  • Tests/docs: 7 isolated scheduler tests, synthetic GB10 workload/test, updated check.py mutation source string, runtime-design/README documentation.
Merge Risk: Medium · up to 29f2b5b
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings

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.

FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 2, 2026
…ced streams

Why

To keep decode cadence responsive without mixed prefill-decode graphs, Helios
interleaves smaller prepared prefill chunks with normal decode steps under the
default balanced policy (PolicyConfig::decode_age_price = 0.1 value/ms^2,
specified in docs/scheduling-theory.md and docs/scheduling-runtime-design.md).
On prepared cores whose TERMINAL_PREFILL catalog covers capacities above the
smallest chunk (for example, 256..=16384 alongside PREFILL 128..=16384), long
cold prompts contending with active decoding streams still cause multi-second
decode stalls for three reasons:

1. Cold-discovery lockout: prompts up to max_terminal measure TerminalPrefill(c)
   while leaving smaller non-terminal Prefill(c) unmeasured; add_candidate and
   continuation_candidate skip unmeasured capacities other than natural_fit, and
   funded refresh only revisits measured keys.
2. Monolithic-tail lockout: prefill_requires_terminal_completion_from excludes
   non-terminal Prefill whenever remaining tokens fit within max_terminal,
   forcing any remaining tail up to max_terminal into one TerminalPrefill step.
3. Two-frame prefill pipelining: prefill_step_requires_feedback lets consecutive
   non-terminal Prefill steps fill both transport frames ahead of active
   age-priced decoders and updated output ages.

Pricing unmeasured smaller prefill capacities from already-measured GPU
durations, allowing non-terminal Prefill chunks below max_terminal while active
age-priced streams exist, and requiring feedback between non-terminal chunks
lets ValueRate choose latency-bounded chunks by default under balanced without
new CLI flags, hardcoded capacities, duration ceilings, or per-model branches.

What

Net non-test production change: +319 LOC (+397/-78) across 4 Rust scheduler
files (11 files total, +1,949/-106; zero new CLI/config flags, zero unsafe,
zero hardcoded capacities, zero model-name branches, zero Protobuf or ABI
changes):

- Interpolated GPU-measured prefill estimates and discovery origin
  (helios/src/scheduler/cost.rs, policy.rs): added
  ActionCosts::interpolated_prefill_duration, deriving positive durations
  strictly from measured GPU timings (same-capacity sibling first, else linear
  interpolation between nearest smaller peer or fastest Decode/Speculative/Resume
  floor and nearest strictly larger peer, with order-independent same-kind
  precedence and ScoredPrefill isolation). When age_price > 0.0, unmeasured
  pure-prefill capacities <= nat_fit compete by ValueRate in add_candidate and
  continuation_candidate (excluding oversized padded shapes > nat_fit). In
  select_plan() and phase_plan(), unmeasured interpolated winners return
  PlanOrigin::Discovery directly (preventing displacement by stale refresh
  probes and preventing unmeasured interpolated durations from entering
  PlanOrigin::AcceptanceStart), drain on first run as TimingOrigin::Discovery,
  and record real GPU timings. Solo prefill (age_price == 0.0), service_rates,
  and checkpoint planning are unchanged.
- Chunkable non-terminal Prefill, resize capping, and hot-path caching
  (helios/src/scheduler.rs, policy.rs, service.rs): tightened
  resolve_prefill_kind_from so deferred_prefill never selects non-terminal-
  catalog shapes when needs_terminal is false; updated resize_prefill to select
  from terminal_prefill_catalog whenever request.deferred_prefill is active and
  cap age-priced non-terminal prefill growth at candidate.capacity; added
  prefill_must_complete_terminally_from and
  prefill_requires_terminal_completion_for_age; cached terminal_prefill_window
  and hoisted per-slot prefill planning state across capacities/continuations;
  kept the token_rate == 0.0 non-terminal Prefill fallback in service_rates.
- Active-stream feedback barrier (helios/src/scheduler.rs):
  prefill_step_requires_feedback drains between non-terminal Prefill steps when
  an active Decode/Resume (decode_age_price > 0.0) or terminal-cleanup
  (terminal_age_price > 0.0) stream exists, preserving two-frame pipelining for
  solo prefill and --scheduler-policy throughput (decode_age_price = 0.0).
- Added a GB10 simulator workload (scripts/scheduling_sim/workloads.py), unit
  and mutation-coverage regression tests, updated the deferred-prefill source
  mutation pattern in verification/helios-lifecycle/check.py, and reconciled
  present-state documentation (docs/scheduling-runtime-design.md,
  docs/scheduling-theory.md, helios/README.md). Existing signed cores load and
  serve unchanged.

Result

Live zero-re-export flare run A/B measurements with stock --scheduler-policy
balanced (0.1) and --scheduler-policy throughput (0.0) (zero new CLI flags,
DeepSeek-V4.1-Flash signed cores, zero errors, zero non-finite logprobs):

- 4x RTX PRO 6000 (SM120 TP4, signed core gb202-tp4-202612010626, flare run
  --gpus 0,1,2,3 --max-concurrency 32 --mtp-draft-tokens 7
  --mtp-adaptive-verification --mtp-max-verification-token-budget 128
  --mtp-adaptive-verification-alpha 1.0 --scheduler-policy balanced
  --embedding-table-storage disk --embedding-table-cache-size 84GiB
  --embedding-table-workers 1 --embedding-table-resident-scales
  --kv-cache-limit memory --prefix-cache-memory 0):
  - Standalone pre-NVIDIA#663 (5d53040 vs fdb10bb): on 4 active decoders + staggered
    14K+32K+64K prefills (T_50C, n=2), peak decode gap drops 331.9 -> 260.3 ms
    (-21.6%), mean max gap drops 279.7 -> 246.1 ms (-12.0%), and mean TPOT drops
    6.10 -> 5.55 ms (-9.0%) for +1.8% makespan (3.164 -> 3.221 s). On tokbench
    mixed-c32 (FujitsuPolycom/tokbench d6b74524, C=32, seed 42, temperature 0.0,
    warmup 15s + measure 60s + drain 30s, n=1), >250 ms stalls drop 215 -> 78
    (-63.7%), gap p99 drops 237.2 -> 188.6 ms (-20.5%), and per-user p50 rises
    93.9 -> 99.2 tok/s (+5.7%) for -2.0% output (1,072.8 -> 1,050.8 tok/s). Solo
    27.5K TTFT stays within +0.7% (540.7 -> 544.2 ms, n=1); solo C=1 short (464
    tok, n=2) Trial 0 matches base (58.91 vs 58.58 ms; Trial 1 189.2 ms jitter).
  - Post-NVIDIA#663 stacked SM120 A/B (a3c80e1 base vs NVIDIA#663 vs NVIDIA#660+NVIDIA#661+NVIDIA#663,
    mixed-c32, n=1): standalone NVIDIA#663 raises mixed-c32 gap p99 from 227.3 to
    286.0 ms and >250 ms stalls from 206 to 431; stacking NVIDIA#661 eliminates that
    regression, cutting gap p99 by -29.0% (286.0 -> 203.1 ms, -10.6% below
    pre-NVIDIA#663 base) and >250 ms stalls by -78.9% vs NVIDIA#663 (431 -> 91, -55.8% below
    pre-NVIDIA#663 base) while sustaining 97.8% SLO and 1,354.9 tok/s output.
- 4x DGX Spark GB10 (SM121 TP4, signed core gb10-tp4-202612010243, pre-NVIDIA#656
  571a447, n=3 trials, 12 decoders + 3x19.5K prompts): >1 s decode stalls drop
  24 -> 0 (-100%), p99 ITL drops 1,670 -> 713 ms (-57.3%), max burst gap drops
  1,699 -> 725 ms (-57.4%), trading +2.8% heavy TTFT p50 and -1.3% decode output.
- 4x RTX PRO 6000 throughput control (pre-NVIDIA#656 571a447, --scheduler-policy
  throughput, n=2 across 3 workloads): prefill launches are bit-identical
  (28/24/19) and makespan stays within +0.3% (3.64 vs 3.65 s).
- Host planning & calibrated simulation: 25-bucket dense-catalog plan() is
  4.70x-8.65x faster than base 571a447 (55.8-196.0 us mean). All 21 existing
  workloads remain bit-identical under Python UtilityScheduler.

Evidence

Verified on a clean git archive of this commit atop 1fbcc3c (post-NVIDIA#663 main)
via release cargo check (-D warnings) and cargo test (helios --features server
and --features runtime-core,server, flare, flare-cli, and heliopause), pytest
(core boundary and scheduling suites), ruff 0.12.8 lint, throttled
scripts/scheduling_sim/learning.py smoke and screen presets (known, ttl,
retained-refresh), and TLA+ lifecycle models, Rust trace conformance, and full
source/model mutation testing (verification/helios-lifecycle/check.py
--mutations). Standalone SM120 hardware A/B ran on direct pre-NVIDIA#663 predecessor
fdb10bb (atop 5d53040) and stacked post-NVIDIA#663 SM120 A/B ran on 82f68ea8
(NVIDIA#660+NVIDIA#661+NVIDIA#663 atop a3c80e1), both prior to the resize_prefill
deferred_prefill guard, select_plan() PlanOrigin::Discovery guard, doc sync,
and rebase onto 1fbcc3c.

Limitations: live flare run A/B benchmarks were not re-executed on this exact
rebased SHA atop 1fbcc3c; gated Hugging Face chat-template tests require
FLARE_TEST_TEMPLATE_DIR with gated repo credentials; cargo-kani was not run
because completion-vector and StateView validators are unchanged.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
@FujitsuPolycom
FujitsuPolycom force-pushed the fix/helios-prefill-cadence-exploration branch from 29f2b5b to c588d61 Compare December 2, 2026 00:57
FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 2, 2026
…l swap

Why

Under concurrent mixed prefill and decode load (multiple long cold prompts
competing alongside active decoders), prefill valuation in
helios/src/scheduler/policy.rs and scripts/scheduling_sim/utility.py has two
structural defects:

1. Scalar min_i(rem_i) collapse: clamping the decode-batch coalescing horizon
   and expected speculative output across active decoders to min_i(rem_i)
   collapses coalescing credit whenever one active decoder nears completion.
2. Multi-chunk prefill lockstep: ServicePrice::observe credits each
   intermediate prefill chunk, dropping the executing prompt's normalized
   price below untouched peers so long prompts advance in lockstep instead of
   completing sequentially and freeing KV pages.

Averaging bounded per-decoder remaining budgets across active decoders prevents
single-stream collapse without inflating credit past the cohort's remaining
output. Recording planned normalized-entitlement swaps among competing
multi-chunk prefills at submission, projecting queued swaps across depth-2
pipelines, and applying the exchange only at validated completion conserves
aggregate prefill entitlement relative to active decoders while preserving
completion-only accounting and rejection safety.

What

- Helios scheduler (helios/src/scheduler.rs, helios/src/scheduler/policy.rs,
  helios/src/scheduler/service.rs, helios/src/scheduler/utility.rs; +263/-39,
  +224 net non-test Rust production LOC; zero CLI, config, decode, ABI, unsafe,
  or lock changes):
  - Replaced scalar min_i(rem_i) in coalescing_prefill_log_bonus with the
    cohort mean across all active decoders for both speculative expected output
    and the coalescing horizon (bounded by coalescing_horizon_tokens and each
    prefiller's post-prefill output budget).
  - Added ServicePrice::{log_normalized_share, swap_normalized_share},
    best_prefill_chunk, stack-allocated heavy_prefill_donors (zero heap Vec
    allocations), projected_services, and Submission::prefill_share_swap.
  - Multi-chunk pairing activates only when active non-terminal decoders exist
    (excluding retiring Snapshot requests), token_fairness > 0,
    decode_age_price > 0 (inactive under --scheduler-policy throughput), and at
    least two non-terminal, non-prompt_logprobs prefills exceed
    prefill_chunk_size (including deferred TerminalPrefill chunks). Single-chunk
    prefills (remaining <= prefill_chunk_size) are excluded even when the
    highest-throughput chunk c_max is smaller than prefill_chunk_size.
  - Submission records any non-self (recipient, donor) handle pair computed
    from projected prices without mutating stored prices. Depth-2 projection
    (projected_services) applies pending swaps before projecting queued frames.
    observe_service executes swap_normalized_share only after
    observed_duration_ns returns Some, verifying non-error status, positive
    useful_tokens on the recipient, and matching live request handles.
- Python scheduling simulator (scripts/scheduling_sim/utility.py; +105/-7):
  mirrored cohort-mean coalescing and weighted-conserving multi-chunk share
  exchange (ranking and swapping log_price to conserve aggregate sum q_i across
  unequal weights, gated on reference is not None, age_price > 0,
  rate_history == "service", and remaining_prefill > max_prefill_cap, using
  log-space urgency to avoid overflow on tiny durations, and validating
  duration_ms and committed rows before mutating prices or clearing donors).
- Documentation and tests (+127/-35 docs; +784/-0 Rust tests; +245/-0 Python
  tests): placed canonical specification and linear-aging preemption limits in
  docs/scheduling-utility.md, reconciled docs/scheduling-runtime-design.md,
  docs/scheduling-theory.md, and helios/README.md, and added unit tests
  covering packed/unpacked speculative cohort-mean, zero-fairness/throughput
  opt-out, prompt_logprobs exclusion, single-chunk exclusion below
  prefill_chunk_size, arrival-wait aging and tie-breakers, completion-only
  depth-2 pipelining, error/zero-timing invariance, Mixed prefill swaps, and
  weighted Python conservation.

Result

Measured incrementally atop post-NVIDIA#663 main (1fbcc3c):
- All 21 standard simulator workloads in scripts/scheduling_sim/workloads.py
  under both standard and mixed catalogs and both balanced and throughput
  policies show zero regressions (0/21 changed).
- --scheduler-policy throughput (decode_age_price == 0) is byte-for-byte
  unchanged by share swaps across all tested workloads.
- Under balanced policy on concurrent multi-chunk workloads alongside active
  decoders (standard catalog): 2 decoders + 2x16k shifts heavy TTFTs from
  [593.1, 678.4] ms to [383.9, 857.2] ms (first -35.3%, mean 320.1 -> 312.5 ms,
  max_output_gap_ms unchanged at 217.3 ms, output_tok_s -1.9%, decode_age_area
  +6.2%); 4 decoders + 4x16k shifts heavy TTFTs from [1436.0..1637.3] ms to
  [788.0, 970.6, 1968.6, 2200.6] ms (first -45.1%, mean 773.5 -> 744.7 ms,
  max_output_gap_ms 213.0 -> 226.6 ms, output_tok_s -2.4%, decode_age_area
  +7.9%). On mixed catalog: 2 decoders + 2x16k shifts mean TTFT -17.2% (first
  -36.9%, gap unchanged 145.0 ms, out -1.8%); 4 decoders + 4x16k shifts mean
  TTFT -21.1% (first -57.4%, gap unchanged 114.7 ms, out -1.5%). Live
  SM120/SM121 flare run GPU A/B is pending before upstream review.

Evidence

Verified on clean git archive (tree d0c622a) atop 1fbcc3c:
- Merge-tree: 0 conflicts vs upstream/main (1fbcc3c), NVIDIA#660 (9709d49),
  NVIDIA#661 (c588d61), NVIDIA#665 (c5b3923), and composed main + NVIDIA#660 + NVIDIA#665.
- Rust builds & tests: RUSTFLAGS="-D warnings" cargo check --locked --release
  across helios, flare, flare-cli, and heliopause passed with 0 warnings;
  helios --features server --lib 1,284 passed; helios --features
  runtime-core,server --lib 1,796 passed (excl. 6 FLARE_TEST_TEMPLATE_DIR
  tests); flare --lib 246 passed; flare-cli 245 passed (0 failed).
- Python & simulator: pytest (test_core_boundary.py + test_scheduling*.py) 838
  passed; ruff==0.12.8 0 issues; full 21-workload sweep under balanced and
  throughput (standard + mixed catalogs).
- Formal & mutations: 10/10 standalone Java TLC configs, 8/8 observed Rust
  TLA+ traces (594,065 transitions, 0 errors), 12/12 aux tests, 26/26 check.py
  Rust lifecycle mutations + 13/13 TLA+ model mutations + 1/1 DispatchRing
  SlotReuseSafe observed-edge check KILLED (0 survivors), plus 13/13 reachable
  custom Rust PR mutations and 12/12 custom Python PR mutations KILLED.
- Limits: live SM120/SM121 flare run GPU A/B is pending; learning.py --preset
  validate and cargo-kani were not run because their covered code is unchanged.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
@flare-autobot flare-autobot added triage:validation Proposed implementation needs acceptance evidence; no claim that a reported defect is fixed. and removed triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Head c588d61 rebases cleanly onto main (1fbcc3c9) and the core scheduling changes are memory-safe, single-threaded, and model-agnostic, but the Round 1 verification blocker is still open (no 64-seed simulator timing gate, no served A/B or CI on c588d61) and RequestScheduler::service_rates still misprices feasible non-terminal Prefill rates whenever any TerminalPrefill shape is measured.

  • Blockers: 1 · Should fix: 2 · Subtract/Simplify: 4 · Nits: 3
Walkthrough
  • helios/src/scheduler/cost.rs (:695-786, :1279-1577): Adds ActionCosts::interpolated_prefill_duration to estimate unmeasured Prefill/TerminalPrefill/ScoredPrefill capacities from a measured same-capacity sibling (Prefill ↔ TerminalPrefill; ScoredPrefill isolated) or linear interpolation between a smaller measured peer (or fastest measured Decode/Speculative/Resume floor) and a strictly larger measured peer, with safe u128 arithmetic and non-monotonic clamping; adds 3 isolated unit tests.
  • helios/src/scheduler.rs (:662, 757, 808, 843, 847-866, 901-907, 964-1022, 1187-1190): Caches terminal_prefill_window on catalog updates; tightens resolve_prefill_kind_from so request.deferred_prefill excludes capacities absent from terminal_prefill_catalog even when !needs_terminal; adds prefill_must_complete_terminally_from, has_active_age_priced_stream, and prefill_requires_terminal_completion_for_age; drains non-terminal Prefill steps in prefill_step_requires_feedback while an active age-priced stream exists.
  • helios/src/scheduler/policy.rs (:89-96, 371-379, 414-439, 501-537, 1081-1142, 1443-1494, 1599, 1784-1792, 1813-1815, 1863-1865, 1906-1920, 2052, 2071-2081): Replaces effective_prefill_catalog with prefill_catalog_for_terminal; hoists per-slot prefill state into PrefillSlotPlan; enables interpolated ValueRate scoring for unmeasured pure-prefill capacities <= nat_fit under age_price > 0.0 while classifying them as PlanOrigin::Discovery in select_plan() and phase_plan(); keeps resize_prefill inside terminal_prefill_catalog under deferred_prefill and caps age-priced resizes at candidate.capacity.
  • helios/src/scheduler/service.rs (:297-328): Adds a token_rate == 0.0 fallback rescanning non-terminal Prefill capacities when terminal_only && has_active_age_priced_stream() && !prefill_must_complete_terminally_from(...).
  • Tests, simulator workload, lifecycle check & docs (policy_tests.rs, scripts/scheduling_sim/workloads.py, tests/test_scheduling_utility.py, verification/helios-lifecycle/check.py, docs/scheduling-runtime-design.md, docs/scheduling-theory.md, helios/README.md): Adds 9 isolated Rust scheduler tests (GB10 storm, continuation/add-candidate oversized-sibling guards, resize_prefill caps, deferred_prefill exclusion, service_rates fallback, has_active_age_priced_stream branches, Discovery origin preservation), a synthetic GB10 simulator workload/test, updated check.py:527-535 mutation target, and updated runtime/README/theory docs.
Merge Risk: Medium · up to c588d61
  • Default-on hot-path behavior change: Activates implicitly under the shipped balanced policy (decode_age_price = 0.1, helios/src/scheduler/policy.rs:35), unlocking smaller unmeasured pure-prefill chunks via GPU-interpolated one-shot discovery and draining non-terminal Prefill steps whenever an active age-priced stream is present (narrowing Overhaul Helios prefill scheduling, cost modeling, and two-frame pipelining #645's two-frame prefill pipelining on the same cold-discovery surface where Restrict cold pure-prefill discovery to natural-fit graph capacities #538 → Restore prefix checkpoints on prefill catalogs without terminal prefill #550 previously caused a GB10 regression).
  • Sound safety & concurrency invariants: RequestScheduler remains single-threaded with zero unsafe, no new CLI flags/ABI/graph-op changes, sound u128 interpolation clamping (cost.rs:779-785), and a sound deferred_prefill safety guard (scheduler.rs:901-907) preventing non-terminal-catalog full-state Prefill graphs from running over skipped continuation state.
  • Residual pricing & validation risk: Under service.rs:321-328, measuring any covering TerminalPrefill suppresses faster feasible non-terminal Prefill rates in service_rates, distorting ServicePrice share accounting during active-stream chunking; and all headline SM120/GB10 benchmarks predate the new resize_prefill/Discovery guards and the 1fbcc3c9 rebase.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings

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.

FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 2, 2026
Why

In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded output-token horizon (`coalescing_horizon_tokens`, default
64.0). Previously, `coalescing_prefill_log_bonus` reduced all active
decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon. Under heterogeneous mixed serving, any single active
decoder within one token of its output limit (`rem = 1`) collapsed both the
speculative per-round expected output (`mean_out`) and the coalescing
horizon to 1 token for the entire cohort, eliminating over 98% of the
coalescing incentive even when all other active decoders had large remaining
budgets.

Averaging per-decoder clamped budgets across the active cohort preserves
accurate continuation value when individual requests approach completion
while still shrinking smoothly as the cohort as a whole approaches its
output limit.

What

- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus` (+11/-10
  lines, +1 net Rust production LOC; function visibility unchanged):
  - Replace the scalar minimum `peer_budget` with a bounded per-decoder
    remaining-budget array (`decoder_rems`), where each `rem` is an active
    decoder's remaining output tokens.
  - Compute speculative per-round expected output (`mean_out`) by clamping
    `expected_at(width)` (speculative expected accepted tokens per round,
    evaluated at `eff_width` in the packed branch and `width` in the
    unpacked branch) to each active decoder's `rem` and averaging across
    `decoder_rems[..decoder_count]`.
  - Compute each prefiller's coalescing `horizon` by clamping each active
    decoder's `rem` to `min(coalescing_horizon_tokens, post_prefill)`
    (where `post_prefill` is the prefiller's remaining output budget after
    its first generated token) and averaging across
    `decoder_rems[..decoder_count]`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python LOC): replace
  `peer_budget = min(v.output_budget for v in decoders)` in the coalescing
  horizon calculation with the cohort mean across active decoders, matching
  Helios and the existing cohort-mean `mean_out` in `best_decode_rate`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
  specification to reflect cohort-averaged per-decoder clamping.
- In `helios/src/scheduler/policy_tests.rs` and
  `tests/test_scheduling_utility.py`: add unit tests covering pure Decode,
  packed and full-width Speculative cohorts with a near-EOS (`rem = 1`)
  decoder alongside a long decoder, single-decoder equivalence, and
  zero-decoder / single-token-prefill no-op invariants.

Result

- Single-decoder cohorts and homogeneous-budget cohorts produce identical
  values to the prior minimum formula.
- Mixed cohorts with one near-EOS decoder (`rem = 1`) and one long decoder
  (`rem = 100`) retain a 32.5-token coalescing horizon instead of collapsing
  to 1 token.
- Measured on `DeepSeek-V4.1-Flash` (`tokbench v0.3.0`, seed 42, temp 0,
  base `1fbcc3c990b5`) on 4x NVIDIA RTX PRO 6000 Blackwell (SM120, TP4):
  - Solo `long-context-mixed` (1-rep): +1.8% output (655.4 -> 667.3 tok/s),
    stalled >250ms 28.1% -> 26.3%, -4.0% TTFT p50 (1,510 -> 1,449 ms),
    +2.8 pp SLO (89.8% -> 92.6%).
  - Solo `mixed-c32` (2-rep medians): -0.4% output (1,281.7 -> 1,276.8
    tok/s), TTFT p50 1,425.3 -> 1,390.2 ms (-2.5%), stalled >250ms 11.29%
    -> 11.49%, SLO 93.0% -> 91.1%.
  - Solo `cold-heavy-mix` (1-rep): -3.7% output (541.8 -> 521.8 tok/s),
    -9.0 pp SLO (88.1% -> 79.1%). Default-ON trade-off: keeping coalescing
    active near EOS pulls competing 150K-250K cold prefills ahead of
    decoders without chunk shrinking, raising `agentic_multiturn` TTFT p99
    from 3,323 to 5,144 ms.
  - Combined stack atop open PRs NVIDIA#660, NVIDIA#661, and NVIDIA#665 (attributed to that
    composed stack):
    - `mixed-c32` (2-rep medians): +1.4% output (1,374.6 -> 1,394.2 tok/s),
      overall TTFT p50 1,001.0 -> 921.8 ms (-7.9%), stalled >250ms 4.82% ->
      4.34% (-10.0% rel; spread [3.45%, 5.23%] vs [4.77%, 4.88%]), SLO
      96.5% -> 97.1% (+0.6 pp). Trial-2 (1-trial rep): 233 -> 120 stalls,
      Gap p99 230.2 -> 183.0 ms, `agentic_multiturn` TTFT p50 845 -> 681 ms
      vs `heavy_prefill` 3,239 -> 7,551 ms.
    - `long-context-mixed` (1-rep): output 707.8 -> 692.1 tok/s (-2.2%),
      stalled >250ms 6.0% -> 4.0% (141 -> 94 stalls), SLO 94.1% -> 92.9%.
    - `cold-heavy-mix` (1-rep): output 579.1 -> 574.0 tok/s (-0.9%), stalls
      567 -> 672, cache hit 48.1% -> 52.8% (+4.7 pp).
- Measured on 4x NVIDIA DGX Spark GB10 (SM121, TP4, RoCEv2, signed core
  `gb10-tp4-202612010547`, combined stack atop NVIDIA#660+NVIDIA#661+NVIDIA#665):
  - `mixed-c8` (2-rep medians): output 128.4 -> 129.4 tok/s (+0.8%), TTFT
    p50 1,181 -> 1,118 ms (-5.3%), stalled >250ms 41.8% -> 38.0%, SLO 79.0%
    -> 81.7% (+2.7 pp).
  - `agentic-coding` C=8 (1-rep): output 137.1 -> 135.0 tok/s (-1.5%), TTFT
    p50 1,024 -> 877 ms (-14.4%), Gap p99 1,354 -> 725 ms (-46.5%), >1s
    stalls 35 -> 12 (-65.7%), stalled >250ms 45.4% -> 34.5%, SLO 81.8% ->
    85.7% (+3.9 pp), cache hit 74.6% -> 76.4%.

Evidence

Verified on clean `git archive` of tree `40596880cc64`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
  `eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server`),
  `flare`, `flare-cli` and `helios` tests -> 0 warnings.
- `cargo test --locked --release`: `helios --features server --lib` (1,283
  passed, 15 ignored), `helios --features runtime-core,server --lib` (1,795
  passed, 47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli`
  (245 passed, 3 ignored).
- Python (`pytest`): 853 passed across `tests/preparation/test_core_boundary.py`,
  `tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`.
- Scheduling simulator (`scripts/scheduling_sim`, 21 workloads x {std, mixed}
  x {balanced, throughput}): 84/84 identical traces vs `1fbcc3c9`, 0
  regressions.
- Cohort-mean mutation checks: reverting packed `mean_out`, Rust `horizon`,
  and Python `utility.py` `horizon` back to `.min()` fails tests (3/3
  reachable sites killed; the `!saw_packed` fallback branch in `policy.rs`
  is structurally unreachable because `ActionCosts::duration(Speculative, b, w)`
  queries `packed = b * w != 0` which `packed_round_shapes()` always yields).
- Formal lifecycle verification (`verification/helios-lifecycle/check.py`):
  10/10 TLA+ configs, 8/8 observed Rust traces (594,065 edges) + negative
  `DispatchRing SlotReuseSafe` check, 12/12 aux tests, 13/13 TLA+ model
  mutations, and 26/26 Rust lifecycle mutations killed.
- `git merge-tree --write-tree`: clean against `1fbcc3c9`, NVIDIA#660 (`9709d496`),
  NVIDIA#661 (`c588d610`), and NVIDIA#665 (`c5b39236`).
- Hardware binaries were built from unpushed local build trees `df9a8ebd`
  (solo) and `dbbf65df` (stack) whose `helios/src/scheduler/policy.rs` is
  byte-identical to this commit. SM120 `flare run` flags:
  `--scheduler-policy balanced --max-concurrency 32 --mtp-draft-tokens 7
  --mtp-adaptive-verification --mtp-max-verification-token-budget 128
  --mtp-adaptive-verification-alpha 1.0 --embedding-table-cache-size 84GiB
  --kv-cache-limit memory --prefix-cache-memory 0`. External client harness
  (`tokbench`): `python3 -m tokbench run --url http://127.0.0.1:8002
  --scenario <mixed-c32|long-context-mixed|cold-heavy-mix> -c <32|20|32>
  --warmup <15|15|20> --duration <75|90|120> --drain <20|30|45>
  --repeats <2|1|1> --seed 42 --temperature 0`. Standalone GB10, other GPUs,
  and other model recipes were not benchmarked.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
@FujitsuPolycom
FujitsuPolycom force-pushed the fix/helios-prefill-cadence-exploration branch from c588d61 to 3d868f8 Compare December 2, 2026 13:18
@FujitsuPolycom

FujitsuPolycom commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the PR branch to 3d868f84 (tree c1d6858b atop main 1fbcc3c9) and updated the PR description accordingly. Thank you for the Round 2 review — each point is addressed below:

Blocker 1 — 64-seed simulator timing gate, head SM120 A/B, and CI

  • Simulator model and 64-seed validation (scripts/scheduling_sim/learning_policy.py, learning.py, tests/test_scheduling_learning_policy.py, tests/test_scheduling_learning_experiments.py): Modeled interpolated unmeasured pure-prefill discovery under initial_discovery = "interpolated" (_natural_fit_prefill_capacity, _interpolated_prefill_duration), keeping behavior identical to native when age_price == 0 or no active decoding stream is resident. scripts/scheduling_sim/learning.py --preset validate --reference ttl (64 held-out seeds 10,000..10,064, 15,872 runs) PASSED / ACCEPTED (retained-refresh, alpha = 0.002, interpolated): 35/35 vs ttl (1.0100x), 35/35 vs native (-17.5% to -27.0% p99 TTFT on prefill-16-decoders-*), 0 diffs across 2,112 solo/zero-age pairs, 6/6 recovery, calibration PASS, and 0/64 resets.
  • Clean SM120 TP4 flare run A/B on 3d868f84 (c1d6858b) vs main (1fbcc3c9): Measured on 4x RTX PRO 6000 (DeepSeek-V4.1-Flash, --scheduler-policy balanced, 0 server errors) using closed-loop scenarios from FujitsuPolycom/tokbench v0.4.0 (--seed 42 --temperature 0; SLO: per-user decode >= 15 tok/s plus class TTFT target <= 2s interactive, <= 3s agentic/long-decode, <= 10s/30s/45s heavy prefill):
    • mixed-c32 (C=32: 10 interactive 0.7–2.2K, 12 multi-turn agentic 3.5–8K with 2K shared prefix, 4 cold 10–22K prefills, 6 long-decode 480–850 out; 15s/75s/20s, n=2): >250ms stalls 538 -> 365 (-32.2%; 2-rep median stalled time 11.39% -> 6.65%, -41.6%), burst gap p99 261.5 -> 254.7 ms, per-user 66.0 -> 67.8 tok/s, output 1,273.0 -> 1,254.4 tok/s med (-1.5%; rep 1,277.3 -> 1,258.2), TTFT p50 1,423 -> 1,479 ms, SLO 91.1% -> 89.4% med (agentic_multiturn 87.2% -> 90.6%, long_decode 93.8% -> 93.8%; rep 92.0% -> 89.5%), prefix cache 47.3% -> 48.6% (361/0 -> 352/0).
    • long-context-mixed (C=20: 6 interactive 1–3K, 8 multi-turn 12–24K, 6 cold 32–128K prefills; 15s/90s/30s, n=1): output 661.3 -> 670.5 tok/s (+1.4%), >250ms stalls 863 -> 503 (-41.7%; 27.4% -> 16.4%), burst gap p99 263.7 -> 256.4 ms, TTFT p50 1,476 -> 1,503 ms, SLO 94.8% -> 89.3% (269/0 -> 272/0).
    • cold-heavy-mix (-c 32 50/50 split: multi-turn 4.5–10K + cold 150–250K prefills; 20s/120s/45s, n=1, 0 server errors; 4 -> 7 client-side 45s drain cutoffs on 150K–250K prompts at KV saturation): output 534.8 -> 545.6 tok/s (+2.0%), TTFT p50 1,922 -> 1,713 ms (-10.9%), >250ms stalls 2,988 -> 2,732 (-8.6%; 62.9% -> 56.3%), burst gap p99 298.4 -> 278.2 ms, SLO 89.0% -> 81.6% (250/4 -> 249/7).
    • Cold burst probe (4 decoders + staggered 14K/32K/64K prefills, n=2): TPOT 7.12 -> 6.70 ms, p95 gap 14.4 -> 14.1 ms, mean max gap 229.3 -> 243.8 ms, peak gap 277.4 -> 433.7 ms (trial 0: 218.7 ms), makespan 2.813 -> 2.906 s.
  • Archive verification on c1d6858b & CI: cargo check --locked --release (-D warnings) and cargo test --locked --release passed across 7/7 crates (3,590 passed, 0 failed, 98 ignored; flare-cli run with --test-threads=1); verification/helios-lifecycle/check.py --jobs 16 --mutations passed (13/13 TLA+, 8/8 trace models / 594,065 edges + DispatchRing SlotReuseSafe, 26/26 Rust mutations); pytest 839/839 passed; uvx ruff==0.12.8 check 0 errors. GitHub Actions CI is triggered on 3d868f84. Remaining limits: cargo-kani was not installed on the build host, long-context-mixed and cold-heavy-mix are n=1, and GB10 was not re-measured on 3d868f84.

Should Fix

  1. service_rates single-pass feasible set (helios/src/scheduler/service.rs): Removed scan_prefill and the token_rate == 0.0 rescan; service_rates now selects terminal_only in a single pass using prefill_must_complete_terminally_from when has_active_age_priced_stream() is true, matching selection. Added unit test service_rates_prefers_faster_feasible_prefill_over_slower_measured_terminal_under_active_decoders confirming a slower measured TerminalPrefill no longer hides a faster measured feasible non-terminal Prefill.
  2. PolicyConfig::throughput() drain condition: Updated the PR body to state that throughput (decode_age_price = 0.0) pipelines non-terminal Prefill across decode and resume streams and drains only when a finishing terminal_cleanup stream is resident (terminal_age_price > 0.0).

Subtract / Simplify

  1. Consolidated interpolated-exploration logic (helios/src/scheduler/policy.rs): Extracted the shared candidate duration estimation into prefill_candidate_ns, called from both add_prefill_candidate and continuation_candidate (both hold (kind, capacity) fixed across the active-slot loop, where the last_interp memo remains sound and allocation-free).
  2. Unified PlanOrigin::Discovery predicate (helios/src/scheduler/policy.rs): Extracted is_unmeasured_candidate and called it from both select_plan() and phase_plan().
  3. Deduplicated peer-ranking check (helios/src/scheduler/cost.rs): Shared directional closer and target selection in ActionCosts::interpolated_prefill_duration.
  4. Hoisted cost.rs unit-test helpers: Promoted make_test_graph, make_test_step, and make_test_timing to module-local #[cfg(test)] helpers shared by the interpolated_prefill_duration tests.

Nits

  1. Added the parenthetical pointer from steady-state objective selection in docs/scheduling-theory.md to scheduling-runtime-design.md.
  2. Trimmed the duplicate exploration-limit restatement in docs/scheduling-runtime-design.md to a cross-reference.
  3. Delegated prefill_catalog(kind) directly to prefill_catalog_for_terminal(kind, kind == GraphKind::TerminalPrefill) in helios/src/scheduler/policy.rs.

Additional balanced single-graph fixes validated on 3d868f84 (policy.rs, policy_tests.rs, docs/scheduling-runtime-design.md)

Two additional bugs exposed by SM120 multi-chunk single-graph testing (both leaving scripts/scheduling_sim/*, cost.rs, scheduler.rs, service.rs, and utility.rs untouched, preserving the 64-seed learning.py --preset validate result) are fixed and tested on 3d868f84:

  1. preserves_first_output_wait (policy.rs): Retains first_output_wait_ns across capture-free non-terminal Prefill steps when decode_age_price > 0.0 and the request's uncached prompt at admission fits in one eligible prefill graph (fits_single_prefill_from(request, request.admission_reused_tokens as usize)), covered by first_output_wait_preserved_across_age_priced_non_terminal_prefill_chunks.
  2. Reconciled-cut first_output_value credit in lane_value_for_tokens_within (policy.rs): When a deferred TerminalPrefill completes at an interior estimated_checkpoint_cut < prompt_tokens (!first_output, r.deferred_prefill, single-prefill-eligible from admission), credits first_output_value over end.saturating_sub(r.prefix_tokens as usize) / initial_prefill so interior checkpoint tails do not lose wait credit after non-terminal intermediate chunks, keeping token work proportional to the chunk's tokens. Covered by deferred_terminal_prefill_at_checkpoint_cut_credits_reconciled_segment_wait.

Please take another look at 3d868f84.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

Head 3d868f8 resolves every Round 2 blocker and should-fix item cleanly, and direct verification of the core scheduler changes confirms sound state transitions, memory safety, and contract compliance with no new regressions. Confirm GitHub Actions CI is green on 3d868f8 before merging.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • helios/src/scheduler/cost.rs (:688-776, :1269-1499): Adds ActionCosts::interpolated_prefill_duration (same-capacity Prefill/TerminalPrefill sibling lookup, else u128 linear interpolation between measured smaller peer or fastest measured decode/speculative/resume floor and strictly larger peer, clamping non-monotonic timings and isolating ScoredPrefill), plus 3 isolated unit tests.
  • helios/src/scheduler.rs (:662, 757, 808, 843, 847-866, 901-907, 964-1022, 1187-1190): Caches terminal_prefill_window across catalog updates; tightens resolve_prefill_kind_from so request.deferred_prefill excludes non-terminal-catalog Prefill shapes even when !needs_terminal; adds prefill_must_complete_terminally_from, has_active_age_priced_stream, and prefill_requires_terminal_completion_for_age; drains non-terminal Prefill steps in prefill_step_requires_feedback while an age-priced stream is active.
  • helios/src/scheduler/policy.rs (:89-96, 371-374, 409-548, 875-895, 1066-1121, 1388-1458, 1537-1575, 1722-1853, 1985-2006): Consolidates prefill candidate generation into add_prefill_candidate and prefill_candidate_ns with per-slot PrefillSlotPlan; prices unmeasured pure-prefill candidates <= nat_fit via interpolation under age_price > 0.0 while preserving PlanOrigin::Discovery via is_unmeasured_candidate; caps age-priced resize_prefill growth at candidate.capacity and restricts deferred_prefill resizes to terminal_prefill_catalog; retains first_output_wait_ns across capture-free non-terminal chunks on single-graph prompts (preserves_first_output_wait); credits reconciled segment wait (end - prefix_tokens) / initial_prefill in lane_value_for_tokens_within for deferred TerminalPrefill steps landing on interior checkpoint cuts.
  • helios/src/scheduler/service.rs (:297-319): Computes terminal_only once per prefill request using prefill_must_complete_terminally_from when has_active_age_priced_stream() is true, aligning service_rates feasible capacities with candidate selection.
  • scripts/scheduling_sim/{learning.py,learning_policy.py,workloads.py} & tests/test_scheduling_*.py: Models initial_discovery = "interpolated" in the simulator (_natural_fit_prefill_capacity, _interpolated_prefill_duration, bootstrap accounting matching native when age_price == 0 or solo), adds the synthetic GB10 prefill-storm workload, and adds isolated Python unit/CLI tests.
  • helios/src/scheduler/policy_tests.rs, verification/helios-lifecycle/check.py, docs/{scheduling-runtime-design.md,scheduling-theory.md}, helios/README.md: Adds isolated Rust unit/policy tests covering all new paths, updates the check.py:527-535 mutation target, and updates runtime, theory, and README documentation.
Merge Risk: Medium · up to 3d868f8
  • Default-on balanced hot-path behavior change: Activates implicitly under --scheduler-policy balanced (decode_age_price = 0.1), allowing unmeasured pure-prefill capacities <= nat_fit to compete via GPU-interpolated durations (helios/src/scheduler/cost.rs:695-776, policy.rs:531-542), unblocking non-terminal Prefill chunks below max_terminal, and draining non-terminal Prefill steps whenever an active age-priced stream is resident (helios/src/scheduler.rs:1187-1190).
  • Measured workload trade-offs & benchmark limits: On SM120 TP4 (3d868f8 vs main 1fbcc3c9), >250 ms decode stalls drop substantially (-32.2% on mixed-c32, -41.7% on long-context-mixed, -8.6% on cold-heavy-mix), but overall SLO dips across all three mixes (91.1% -> 89.4%, 94.8% -> 89.3%, 89.0% -> 81.6%, with 4 -> 7 client-side 45 s drain cutoffs under KV saturation on cold-heavy-mix), the two heavier mixes are n=1, and GB10 was not re-measured on 3d868f8.
  • Clean concurrency, safety, and artifact compatibility: Single-threaded scheduler logic, zero unsafe, zero new CLI flags/ABI/graph ops, sound deferred_prefill state guard (helios/src/scheduler.rs:901-907), overflow-safe u128 interpolation with non-monotonic clamping (cost.rs:769-775), and verified lifecycle mutations (verification/helios-lifecycle/check.py:527-535).
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings

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

Copy link
Copy Markdown
Collaborator

Review of 3d868f84c5118b40a9ee6112f1d551ecef3d32c4: the overall design is model-agnostic, cleanly layered, and keeps the deferred_prefill, Discovery, and service_rates invariants intact. There is one numerical bug in interpolated_prefill_duration that should be fixed, along with a few validation points before merging default-on under --scheduler-policy balanced.

1. Should fix: GraphKind::Resume poisons decode_floor in helios/src/scheduler/cost.rs

In ActionCosts::interpolated_prefill_duration:

if matches!(
    key.kind,
    GraphKind::Decode | GraphKind::Speculative | GraphKind::Resume
) {
    decode_floor = Some(decode_floor.map_or(estimate.nanos, |f| f.min(estimate.nanos)));
    continue;
}

Per docs/core-design.md, GraphKind::Resume runs only vocabulary projection and sampling from a checkpoint's saved final hidden vector—it does not run a transformer forward pass or read model layer weights. On GPU, Resume typically completes in sub-millisecond to ~1 ms time, whereas a full forward pass (Decode / Speculative / Prefill) has a ~18–30 ms weight-read floor.

Taking the minimum across Decode | Speculative | Resume collapses decode_floor to LM-head latency as soon as any prefix-cached request executes Resume (which happens immediately in mixed-c32 at ~48% prefix cache hit rate and in multi-turn agent workloads). For example, on SM120 (Prefill(16384) = 225 ms), a ~0.5 ms floor estimates an unmeasured Prefill(128) at ~2.2 ms instead of ~19.6 ms—nearly an order of magnitude too optimistic—making tiny unmeasured buckets win cold discovery too aggressively. This also contradicts the function's doc comment ("the fastest measured decode step as a forward-pass floor") and diverges from scripts/scheduling_sim/learning_policy.py, which has no Resume graph.

Please restrict decode_floor to GraphKind::Decode | GraphKind::Speculative.

2. SM120 SLO trade-off and remaining verification

  • SM120 TP4 SLO dip: While >250 ms decode stalls drop substantially (-32.2% on mixed-c32, -41.7% on long-context-mixed, -8.6% on cold-heavy-mix), overall SLO pass rates decrease across all three tokbench workloads (91.1% -> 89.4%, 94.8% -> 89.3%, and 89.0% -> 81.6% with client-side 45 s drain cutoffs rising 4 -> 7), and the cold-burst micro-probe peak gap worsens (277.4 -> 433.7 ms, mean max 229.3 -> 243.8 ms). Re-measuring SM120 after removing GraphKind::Resume from decode_floor is worthwhile since all three mixes exercise prefix-cache Resume heavily.
  • GB10 head measurement: GB10 (where 16K prefill takes ~1.3 s and motivates breaking up monolithic prefills) was not re-measured on 3d868f84.
  • Native serving CI missing: Only Helios lifecycle (lifecycle, kani) and Python CPU tests (pytest) reported on 3d868f84. Please ensure .github/workflows/native-serving.yml (Linux and Windows cargo test --locked --release, including the FLARE_TEST_TEMPLATE_DIR chat-template tests) runs green before merge.

3. Verified parts and minor notes

  • Core scheduler invariants look sound: The deferred_prefill guard in resolve_prefill_kind_from and resize_prefill, the capacity >= limit early exit in prefill_must_complete_terminally_from, the single-pass service_rates alignment, u128 interpolation clamping and ScoredPrefill isolation in cost.rs, PrefillSlotPlan/last_interp memoization, and is_unmeasured_candidate (PlanOrigin::Discovery + queue drain) all check out.
  • Wait-clock additions: preserves_first_output_wait and the reconciled interior-cut first_output_value credit in lane_value_for_tokens_within are cleanly scoped to single-graph-at-admission prompts (fits_single_prefill_from(r, r.admission_reused_tokens)). Note that these two additions are not modeled in scripts/scheduling_sim, so the 64-seed learning.py validation covers the interpolated discovery rule rather than those wait-clock changes.
  • Rebase note: Expect minor textual overlap with open PR helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction #660 in docs/scheduling-runtime-design.md, helios/README.md, and verification/helios-lifecycle/check.py.

FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 2, 2026
Why

In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded cohort-mean output horizon (`coalescing_horizon_tokens`,
default 64.0). Previously, `coalescing_prefill_log_bonus` reduced all
active decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon (while already averaging per-decoder expected output
`mean_out` across active decoders in `best_decode_rate`). Under
heterogeneous mixed serving, any single active decoder within one token of
its output limit (`rem = 1`) collapsed both Rust's speculative per-round
expected output (`mean_out`) and both implementations' coalescing `horizon`
to 1 token for the entire cohort, eliminating over 98% of the coalescing
incentive even when all other active decoders had large remaining budgets.

Averaging per-decoder clamped budgets across the active cohort repairs the
Rust-to-simulator `mean_out` parity gap and extends cohort averaging to the
coalescing `horizon`, preserving continuation value when individual requests
approach completion while still shrinking smoothly as the cohort approaches
its output limit.

What

- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus`
  (+16/-18 lines, -2 net Rust production LOC; visibility unchanged):
  - Replace the scalar minimum `peer_budget` with a bounded per-decoder
    remaining-budget array (`decoder_rems`), where each `rem` is an active
    decoder's remaining output tokens clamped by KV sequence headroom
    (`max_sequence_tokens - scheduled_consumed`).
  - Extract local helper `mean_capped(rems: &[usize], cap: f64) -> f64`,
    hoist `expected_at(eff_width)` and `expected_at(width as f64)` out of
    the per-decoder loop, and delete provably dead `.max(1.0)` clamps and
    the unreachable `if horizon > 0.0` branch while keeping the
    `per_token.is_finite() && per_token > 0.0` guard.
  - Compute speculative per-round expected output (`mean_out`, parity with
    `utility.py`) and each prefiller's coalescing `horizon` (clamped to
    `min(coalescing_horizon_tokens, post_prefill)`, where `post_prefill` is
    the prefiller's remaining output budget after its first generated token)
    via `mean_capped`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python production
  LOC): replace `peer_budget = min(v.output_budget for v in decoders)` in
  the coalescing horizon calculation with the cohort mean across active
  decoders, matching Helios and `best_decode_rate`'s existing cohort-mean
  `mean_out`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
  specification to describe the bounded cohort-mean decode horizon and
  per-decoder clamped cohort averaging.
- In `helios/src/scheduler/policy_tests.rs` and
  `tests/test_scheduling_utility.py`: add unit tests covering `[1, 100]`
  and `n=3` `[1, 20, 100]` heterogeneous cohorts, Rust-specific KV-headroom
  clamping, packed and unpacked speculative cohorts (reusing
  `super::rounds::forecast_tokens`), single-decoder equivalence, zero-bonus
  invariants, and an end-to-end `scripts/scheduling_sim` heterogeneous-budget
  test (`max_new_tokens < 64`) under `balanced` (`age_price = 0.1`).

Result

- Single-decoder and homogeneous-budget cohorts produce identical values to
  the prior minimum formula; a `[1, 100]` cohort retains a 32.5-token
  horizon instead of collapsing to 1 token.
- End-to-end `scripts/scheduling_sim` (`catalog()`, `balanced`,
  `age_price = 0.1`, cohort-mean vs prior `min(rem, ph)` horizon):
  - Non-speculative (`short0` `max_new_tokens=8` + 3 long decoders + 4
    queued 4K prefills): makespan 7,779.0 -> 7,734.0 ms (-45.0 ms), mean
    prefill TTFT 266.8 -> 201.0 ms (-24.6%), max prefill TTFT 373.0 ->
    327.0 ms (-12.3%), max output gap 226.0 -> 182.0 ms (-19.5%).
  - Speculative (`short0` `max_new_tokens=32` + 3 long decoders + 5 queued
    4K prefills): makespan 1,912.0 -> 1,878.0 ms (-34.0 ms), mean prefill
    TTFT 293.6 -> 266.4 ms (-9.3%), max prefill TTFT 468.0 -> 432.0 ms
    (-7.7%), max output gap 278.0 -> 212.0 ms (-23.7%).
- Measured on `DeepSeek-V4.1-Flash` (`FujitsuPolycom/tokbench`, seed 42,
  temp 0, base `1fbcc3c990b5`) on 4x RTX PRO 6000 Blackwell (SM120, TP4)
  and 4x DGX Spark GB10 (SM121, TP4, `gb10-tp4-202612010547`):
  - Solo on `1fbcc3c9`: `long-context-mixed` (1-rep) +1.8% output (655.4 ->
    667.3 tok/s), stalls 28.1% -> 26.3%, SLO 89.8% -> 92.6%; `mixed-c32`
    (2-rep) output 1,281.7 -> 1,276.8 tok/s, TTFT p50 1,425 -> 1,390 ms,
    stalls 11.29% -> 11.49%, SLO 93.0% -> 91.1%; `cold-heavy-mix` (1-rep)
    regresses output 541.8 -> 521.8 tok/s (-3.7%) and SLO 88.1% -> 79.1%
    (-9.0 pp, `agentic_multiturn` TTFT p99 3,323 -> 5,144 ms) because
    keeping coalescing active near EOS pulls 150K-250K cold prefills ahead
    of decoders without `NVIDIA#661` chunk shrinking.
  - Atop `NVIDIA#661` (`3d868f84`, primary stall reduction from `NVIDIA#661`):
    `mixed-c32` (2-rep med) output 1,254 -> 1,261 tok/s, stalls 6.65% ->
    5.95%, TTFT p50 1,479 -> 1,439 ms, SLO 89.4% -> 90.5%;
    `long-context-mixed` (1-rep) stalls 16.4% -> 9.8% while SLO dropped
    89.3% -> 82.1% (-7.2 pp); `cold-heavy-mix` (1-rep) output 545.6 ->
    547.8 tok/s, stalls 56.3% -> 55.7%, SLO 81.6% -> 79.8%.
  - Composed 4-PR stack (`NVIDIA#660 + NVIDIA#661 + NVIDIA#665`, where prefix-cache hit-rate
    gains come from `NVIDIA#665` and primary stall cuts from `NVIDIA#661`): SM120
    `mixed-c32` (2-rep) output 1,374.6 -> 1,394.2 tok/s (+1.4%), stalls
    4.82% -> 4.34%, TTFT p50 1,001 -> 922 ms (-7.9%), SLO 96.5% -> 97.1%;
    GB10 `mixed-c8` (2-rep) stalls 41.8% -> 38.0%, TTFT p50 1,181 -> 1,118
    ms, SLO 79.0% -> 81.7%; GB10 `agentic-coding` C=8 (1-rep) stalls 45.4%
    -> 34.5%, TTFT p50 1,024 -> 877 ms, SLO 81.8% -> 85.7%.

Evidence

Verified on clean `git archive` of tree `fe2b8739991e`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
  `eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server --tests`),
  `flare`, `flare-cli` -> 0 warnings.
- `cargo test --locked --release`: `eos` (12 passed), `selene --features
  test-support` (553 passed), `selene-manager --features test-support`
  (426 passed, 1 ignored), `helios --features server --lib` (1,283 passed,
  15 ignored), `helios --features runtime-core,server --lib` (1,795 passed,
  47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli` (245
  passed, 3 ignored).
- Python: `ruff==0.12.8` passed on modified Python files; `pytest` passed
  (854 passed across `tests/preparation/test_core_boundary.py`,
  `tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`,
  including `test_coalescing_heterogeneous_budget_end_to_end_balanced`).
- Fault mutation checks (scratch copies): reverting `scripts/scheduling_sim/
  utility.py` `horizon` to `min(ph, min(output_budget))` failed both
  `test_coalescing_heterogeneous_budget_end_to_end_balanced` and
  `test_coalescing_horizon_averages_active_decoder_budgets`; reverting
  `helios/src/scheduler/policy.rs::mean_capped` to `.min()` failed both
  Rust coalescing unit tests (`2/2` killed).
- `git merge-tree --write-tree`: clean (`rc=0`) against `main` (`4cc6f2fd`),
  `2acc3f3a`, `NVIDIA#660` (`9709d496`), `NVIDIA#661` (`3d868f84`), and `NVIDIA#665`
  (`c5b39236`).
- Hardware binaries were built from earlier equivalent trees `df9a8ebd`
  (solo), `38130855` (on `NVIDIA#661`), and `dbbf65df` (stack) before the
  semantics-preserving `mean_capped` / hoist refactor; final rebase onto
  `main` after `NVIDIA#661` lands and CI/A/B confirmation on the rebased head
  remain pending. Standalone GB10, other GPUs, and other recipes were not
  benchmarked.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
FujitsuPolycom and others added 2 commits December 2, 2026 12:00
…ced streams

Why:
Under `--scheduler-policy balanced` (`decode_age_price = 0.1`), Helios
interleaves prefill chunks with decode without mixed graphs. On
`TERMINAL_PREFILL` cores (`256..=16384` alongside `PREFILL` `128..=16384`),
cold prompts stall active decoders: unmeasured smaller `Prefill` shapes are
skipped, tails `<= max_terminal` run as a single `TerminalPrefill`, and
non-terminal `Prefill` fills both submission frames. Splitting a prompt whose
uncached suffix at admission fits in one eligible prefill graph also resets
`first_output_wait_ns` on every non-terminal `Prefill` chunk, and when the
completing `TerminalPrefill` chunk lands on an interior checkpoint cut before
`prompt_tokens`, pricing `first_output_value` only on that stub's tokens
undervalues completion of the deferred segment.

What:
Changes 4 non-test Rust production files (`+236` net LOC, `+376/-140` atop
`1fbcc3c9`, `15` files total `+2,778/-186`, no CLI flags, no `unsafe`, no
hardcoded capacities, and no ABI changes):

- Discovery (`helios/src/scheduler/cost.rs`, `policy.rs`): Adds
  `interpolated_prefill_duration` (same-capacity sibling, else linear
  interpolation between the nearest smaller peer or decode floor and nearest
  larger peer; `ScoredPrefill` remains isolated). Under `age_price > 0.0`,
  `prefill_candidate_ns` prices unmeasured shapes `<= nat_fit` in
  `add_prefill_candidate` and `continuation_candidate`; unmeasured winners
  return `PlanOrigin::Discovery`.
- Chunking, service rates, wait clock, reconciled cut credit, and drain
  (`helios/src/scheduler.rs`, `policy.rs`, `service.rs`): Permits legal
  non-terminal `Prefill` chunks below `max_terminal` while active age-priced
  streams exist, restricts `deferred_prefill` and `resize_prefill` to
  `TERMINAL_PREFILL` capacities, caps age-priced `resize_prefill` growth at
  `candidate.capacity`, caches `terminal_prefill_window`, aligns
  `service_rates` via `prefill_must_complete_terminally_from`, preserves
  `first_output_wait_ns` in `preserves_first_output_wait` across non-terminal
  `Prefill` chunks without a checkpoint capture when the admission prompt fits
  in one eligible prefill graph, credits `first_output_value` across the
  reconciled segment `(end - prefix_tokens) / initial_prefill` in
  `lane_value_for_tokens_within` when a deferred `TerminalPrefill` chunk on
  such a prompt lands on `estimated_checkpoint_cut` before `prompt_tokens`
  (leaving token-work credit proportional to chunk tokens), and drains
  non-terminal `Prefill` in `prefill_step_requires_feedback`.
  `PolicyConfig::throughput()` (`decode_age_price = 0.0`,
  `terminal_age_price = 1.0`) keeps solo and decoder-concurrent prefills
  pipelined and drains only when `terminal_cleanup` is active.
- Simulator, formal checks, tests, and docs: Models `interpolated` discovery
  in `scripts/scheduling_sim/`, updates `verification/helios-lifecycle/check.py`,
  adds scheduler unit tests in `helios/src/scheduler/policy_tests.rs`, and
  syncs `docs/scheduling-runtime-design.md`, `docs/scheduling-theory.md`, and
  `helios/README.md`. Existing signed model cores load unchanged.

Result:
On the 64-seed timing validation catalog (`scripts/scheduling_sim/learning.py
--preset validate --reference ttl`, `15,872` runs), `retained-refresh`
(`alpha=0.002`, `interpolated`) is ACCEPTED (`35/35` vs `ttl` geomean
`1.0100x`; `35/35` vs `native`, `-17.5%` to `-27.0%` p99 TTFT on
`prefill-16-decoders-*`; `0` diffs across `2,112` solo/zero-age pairs; `6/6`
recovery; calibration PASS; `0/64` resets).

On SM120 TP4 `flare run` (`4x NVIDIA RTX PRO 6000 Blackwell Workstation
Edition`, `DeepSeek-V4.1-Flash` core `gb202-tp4-202612010626`, `--scheduler-policy
balanced`, `--max-concurrency 32`, `0` server errors, `100.0%` clean) against
base `1fbcc3c9`:
- `mixed-c32` (`C=32`, `n=2`): `>250ms` stalls `538 -> 365` (`-32.2%`, 2-rep
  median stalled time `11.39% -> 6.65%`), burst gap p99 `261.5 -> 254.7 ms`,
  per-user decode `66.0 -> 67.8 tok/s`, 2-rep median output `1,273.0 -> 1,254.4
  tok/s` (`-1.5%`), TTFT p50 `1,423 -> 1,479 ms`, 2-rep median SLO `91.05% ->
  89.40%` (`long_decode` `93.8% -> 93.8%`, `agentic_multiturn` `87.2% -> 90.6%`),
  cache hit `47.3% -> 48.6%`.
- `long-context-mixed` (`C=20`, `n=1`): `>250ms` stalls `863 -> 503` (`-41.7%`,
  stalled time `27.4% -> 16.4%`), output `661.3 -> 670.5 tok/s` (`+1.4%`),
  per-user decode `73.7 -> 77.1 tok/s` (`p10 54.5 -> 59.9`), TTFT p50 `1,476 ->
  1,503 ms`, burst gap p99 `263.7 -> 256.4 ms`, SLO `94.8% -> 89.3%`.
- `cold-heavy-mix` (`C=32`, `n=1`): output `534.8 -> 545.6 tok/s` (`+2.0%`),
  TTFT p50 `1,922 -> 1,713 ms` (`-10.9%`), TTFT p99 `81,032 -> 80,986 ms`,
  burst gap p99 `298.4 -> 278.2 ms` (`-6.8%`), `>250ms` stalls `2,988 -> 2,732`
  (`62.9% -> 56.3%`), SLO `89.0% -> 81.6%`.
- `T_50C` (`n=2`, 4 decoders + staggered cold `14K/32K/64K` prefills): mean
  TPOT `7.12 -> 6.70 ms`, p95 gap `14.4 -> 14.1 ms`, peak gap `277.4 -> 433.7
  ms` (`t0 218.7 ms`, `t1 433.7 ms`), mean max gap `229.3 -> 243.8 ms`,
  makespan `2.813 -> 2.906 s`.
Users prioritizing peak batch fill over decode smoothness can select
`--scheduler-policy throughput`.

Evidence:
Verified on exact tree `c1d6858bc71bb3b877da986d69960f56974df8b5` atop
`1fbcc3c990b5ee603de74587e119e9fa55771f3d` from clean `git archive` extracts:
- `cargo check --locked --release` (`RUSTFLAGS="-D warnings"`): 7/7 crates
  PASS (`0` warnings: `eos`, `selene --features test-support`, `selene-manager
  --features test-support`, `helios --features runtime-core,server`, `flare`,
  `flare-cli`, `heliopause`).
- `cargo test --locked --release`: 7/7 crates PASS (`3,590` passed, `0` failed,
  `98` ignored; `flare-cli` run with `--test-threads=1` to avoid Linux
  concurrent fork/exec `ETXTBSY`).
- `python3 verification/helios-lifecycle/check.py --jobs 16 --mutations`: PASS
  (all TLA+ configs, `13/13` TLA+ mutations, `8/8` observed Rust trace models /
  `594,065` transitions + negative `DispatchRing SlotReuseSafe`, `26/26` Rust
  source mutations).
- Python and lint: `pytest tests/preparation/test_core_boundary.py
  tests/test_scheduling*.py` `839/839` passed; `ruff==0.12.8 check` `0` errors.
- 64-seed `learning.py --preset validate` carries over unchanged with
  byte-identical `scripts/scheduling_sim/`, `cost.rs`, `scheduler.rs`,
  `service.rs`, and `utility.rs`.
- Limitations: `cargo-kani` is not installed on the build host; GB10 hardware
  was not re-measured on this tree; `long-context-mixed` and `cold-heavy-mix`
  are single-repeat runs (`n=1`).

Discord: Dooner

Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Why

`ActionCosts::interpolated_prefill_duration` in `helios/src/scheduler/cost.rs`
included `GraphKind::Resume` when computing `decode_floor`, the zero-token
forward-pass floor used to linearly interpolate unmeasured pure-prefill
capacities when no smaller prefill peer has been measured. Because
`GraphKind::Resume` runs only vocabulary projection and sampling from a
checkpoint's saved final hidden vector rather than a full transformer forward
pass, its GPU duration (~0.5-1 ms) is an order of magnitude below full-model
weight-read latency (~18-30 ms). Once any prefix-cached request ran `Resume`,
`decode_floor` collapsed to LM-head latency, severely underestimating
unmeasured small prefill buckets and biasing cold discovery toward tiny chunks.

What

- `helios/src/scheduler/cost.rs`: narrowed `decode_floor` matching in
  `ActionCosts::interpolated_prefill_duration` from
  `GraphKind::Decode | GraphKind::Speculative | GraphKind::Resume` to
  `GraphKind::Decode | GraphKind::Speculative`, aligning Rust with the
  forward-pass floor contract and `scripts/scheduling_sim/learning_policy.py`.
- `helios/src/scheduler/cost.rs`: added unit test
  `interpolated_prefill_duration_excludes_resume_from_decode_floor` covering
  `Resume`-only (returns `None`), `Decode` + faster `Resume`, and `Speculative`
  + faster `Resume`.

Result

- Observed in CPU unit tests: with `Prefill(16384) = 225 ms` and `Resume = 0.5 ms`,
  `interpolated_prefill_duration(Prefill, 128)` returns `None` until a full
  forward-pass decode graph is measured, and interpolates from the `Decode`
  (18 ms) or `Speculative` (15 ms) floor thereafter instead of `Resume`.
- Expected in live serving: workloads with prefix-cache `Resume` hits retain
  realistic forward-pass duration estimates during cold prefill discovery
  rather than over-selecting tiny unmeasured prefill capacities.

Evidence

- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target --lib scheduler::`: 445 passed, 0 failed, 4 ignored.
- `RUSTFLAGS="-D warnings" cargo check --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --tests --target-dir flare-cli/target`: passed with 0 warnings.
- `.venv/bin/python -m pytest tests/test_scheduling_sim.py tests/test_scheduling_utility.py tests/test_scheduling_learning_policy.py tests/test_scheduling_learning_experiments.py tests/preparation/test_core_boundary.py -q`: 510 passed.
- `python3 verification/helios-lifecycle/check.py --tlc-jar /home/luke/.cache/flare-formal/tla2tools-1.7.4.jar --target-dir flare-cli/target --jobs 16 --mutations`: passed all TLA+ models, 8 observed Rust trace models (621,390 transitions), and all Rust and TLA+ mutation checks.
- Limitations: live GPU serving benchmarks were not re-run in this environment; in the sandboxed full-crate `helios` run (1,814 passed), 13 `engram` `io_uring` tests failed under sandbox seccomp (`ENOSYS`) and 6 chat-template tests failed without `FLARE_TEST_TEMPLATE_DIR`.

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
@lukealonso
lukealonso force-pushed the fix/helios-prefill-cadence-exploration branch from 3d868f8 to b68e579 Compare December 2, 2026 20:14
@lukealonso
lukealonso merged commit ef38cb9 into NVIDIA:main Dec 2, 2026
lukealonso pushed a commit that referenced this pull request Dec 2, 2026
Why

In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded cohort-mean output horizon (`coalescing_horizon_tokens`,
default 64.0). Previously, `coalescing_prefill_log_bonus` reduced all
active decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon (while already averaging per-decoder expected output
`mean_out` across active decoders in `best_decode_rate`). Under
heterogeneous mixed serving, any single active decoder within one token of
its output limit (`rem = 1`) collapsed both Rust's speculative per-round
expected output (`mean_out`) and both implementations' coalescing `horizon`
to 1 token for the entire cohort, eliminating over 98% of the coalescing
incentive even when all other active decoders had large remaining budgets.

Averaging per-decoder clamped budgets across the active cohort repairs the
Rust-to-simulator `mean_out` parity gap and extends cohort averaging to the
coalescing `horizon`, preserving continuation value when individual requests
approach completion while still shrinking smoothly as the cohort approaches
its output limit.

What

- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus`
  (+16/-18 lines, -2 net Rust production LOC; visibility unchanged):
  - Replace the scalar minimum `peer_budget` with a bounded per-decoder
    remaining-budget array (`decoder_rems`), where each `rem` is an active
    decoder's remaining output tokens clamped by KV sequence headroom
    (`max_sequence_tokens - scheduled_consumed`).
  - Extract local helper `mean_capped(rems: &[usize], cap: f64) -> f64`,
    hoist `expected_at(eff_width)` and `expected_at(width as f64)` out of
    the per-decoder loop, and delete provably dead `.max(1.0)` clamps and
    the unreachable `if horizon > 0.0` branch while keeping the
    `per_token.is_finite() && per_token > 0.0` guard.
  - Compute speculative per-round expected output (`mean_out`, parity with
    `utility.py`) and each prefiller's coalescing `horizon` (clamped to
    `min(coalescing_horizon_tokens, post_prefill)`, where `post_prefill` is
    the prefiller's remaining output budget after its first generated token)
    via `mean_capped`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python production
  LOC): replace `peer_budget = min(v.output_budget for v in decoders)` in
  the coalescing horizon calculation with the cohort mean across active
  decoders, matching Helios and `best_decode_rate`'s existing cohort-mean
  `mean_out`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
  specification to describe the bounded cohort-mean decode horizon and
  per-decoder clamped cohort averaging.
- In `helios/src/scheduler/policy_tests.rs` and
  `tests/test_scheduling_utility.py`: add unit tests covering `[1, 100]`
  and `n=3` `[1, 20, 100]` heterogeneous cohorts, Rust-specific KV-headroom
  clamping, packed and unpacked speculative cohorts (reusing
  `super::rounds::forecast_tokens`), single-decoder equivalence, zero-bonus
  invariants, and an end-to-end `scripts/scheduling_sim` heterogeneous-budget
  test (`max_new_tokens < 64`) under `balanced` (`age_price = 0.1`).

Result

- Single-decoder and homogeneous-budget cohorts produce identical values to
  the prior minimum formula; a `[1, 100]` cohort retains a 32.5-token
  horizon instead of collapsing to 1 token.
- End-to-end `scripts/scheduling_sim` (`catalog()`, `balanced`,
  `age_price = 0.1`, cohort-mean vs prior `min(rem, ph)` horizon):
  - Non-speculative (`short0` `max_new_tokens=8` + 3 long decoders + 4
    queued 4K prefills): makespan 7,779.0 -> 7,734.0 ms (-45.0 ms), mean
    prefill TTFT 266.8 -> 201.0 ms (-24.6%), max prefill TTFT 373.0 ->
    327.0 ms (-12.3%), max output gap 226.0 -> 182.0 ms (-19.5%).
  - Speculative (`short0` `max_new_tokens=32` + 3 long decoders + 5 queued
    4K prefills): makespan 1,912.0 -> 1,878.0 ms (-34.0 ms), mean prefill
    TTFT 293.6 -> 266.4 ms (-9.3%), max prefill TTFT 468.0 -> 432.0 ms
    (-7.7%), max output gap 278.0 -> 212.0 ms (-23.7%).
- Measured on `DeepSeek-V4.1-Flash` (`FujitsuPolycom/tokbench`, seed 42,
  temp 0, base `1fbcc3c990b5`) on 4x RTX PRO 6000 Blackwell (SM120, TP4)
  and 4x DGX Spark GB10 (SM121, TP4, `gb10-tp4-202612010547`):
  - Solo on `1fbcc3c9`: `long-context-mixed` (1-rep) +1.8% output (655.4 ->
    667.3 tok/s), stalls 28.1% -> 26.3%, SLO 89.8% -> 92.6%; `mixed-c32`
    (2-rep) output 1,281.7 -> 1,276.8 tok/s, TTFT p50 1,425 -> 1,390 ms,
    stalls 11.29% -> 11.49%, SLO 93.0% -> 91.1%; `cold-heavy-mix` (1-rep)
    regresses output 541.8 -> 521.8 tok/s (-3.7%) and SLO 88.1% -> 79.1%
    (-9.0 pp, `agentic_multiturn` TTFT p99 3,323 -> 5,144 ms) because
    keeping coalescing active near EOS pulls 150K-250K cold prefills ahead
    of decoders without `#661` chunk shrinking.
  - Atop `#661` (`3d868f84`, primary stall reduction from `#661`):
    `mixed-c32` (2-rep med) output 1,254 -> 1,261 tok/s, stalls 6.65% ->
    5.95%, TTFT p50 1,479 -> 1,439 ms, SLO 89.4% -> 90.5%;
    `long-context-mixed` (1-rep) stalls 16.4% -> 9.8% while SLO dropped
    89.3% -> 82.1% (-7.2 pp); `cold-heavy-mix` (1-rep) output 545.6 ->
    547.8 tok/s, stalls 56.3% -> 55.7%, SLO 81.6% -> 79.8%.
  - Composed 4-PR stack (`#660 + #661 + #665`, where prefix-cache hit-rate
    gains come from `#665` and primary stall cuts from `#661`): SM120
    `mixed-c32` (2-rep) output 1,374.6 -> 1,394.2 tok/s (+1.4%), stalls
    4.82% -> 4.34%, TTFT p50 1,001 -> 922 ms (-7.9%), SLO 96.5% -> 97.1%;
    GB10 `mixed-c8` (2-rep) stalls 41.8% -> 38.0%, TTFT p50 1,181 -> 1,118
    ms, SLO 79.0% -> 81.7%; GB10 `agentic-coding` C=8 (1-rep) stalls 45.4%
    -> 34.5%, TTFT p50 1,024 -> 877 ms, SLO 81.8% -> 85.7%.

Evidence

Verified on clean `git archive` of tree `fe2b8739991e`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
  `eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server --tests`),
  `flare`, `flare-cli` -> 0 warnings.
- `cargo test --locked --release`: `eos` (12 passed), `selene --features
  test-support` (553 passed), `selene-manager --features test-support`
  (426 passed, 1 ignored), `helios --features server --lib` (1,283 passed,
  15 ignored), `helios --features runtime-core,server --lib` (1,795 passed,
  47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli` (245
  passed, 3 ignored).
- Python: `ruff==0.12.8` passed on modified Python files; `pytest` passed
  (854 passed across `tests/preparation/test_core_boundary.py`,
  `tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`,
  including `test_coalescing_heterogeneous_budget_end_to_end_balanced`).
- Fault mutation checks (scratch copies): reverting `scripts/scheduling_sim/
  utility.py` `horizon` to `min(ph, min(output_budget))` failed both
  `test_coalescing_heterogeneous_budget_end_to_end_balanced` and
  `test_coalescing_horizon_averages_active_decoder_budgets`; reverting
  `helios/src/scheduler/policy.rs::mean_capped` to `.min()` failed both
  Rust coalescing unit tests (`2/2` killed).
- `git merge-tree --write-tree`: clean (`rc=0`) against `main` (`4cc6f2fd`),
  `2acc3f3a`, `#660` (`9709d496`), `#661` (`3d868f84`), and `#665`
  (`c5b39236`).
- Hardware binaries were built from earlier equivalent trees `df9a8ebd`
  (solo), `38130855` (on `#661`), and `dbbf65df` (stack) before the
  semantics-preserving `mean_capped` / hoist refactor; final rebase onto
  `main` after `#661` lands and CI/A/B confirmation on the rebased head
  remain pending. Standalone GB10, other GPUs, and other recipes were not
  benchmarked.

Discord: Dooner

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. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:validation Proposed implementation needs acceptance evidence; no claim that a reported defect is fixed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants