Skip to content

helios: avoid splitting prefill on zero-budget checkpoint anchors - #582

Merged
lukealonso merged 3 commits into
NVIDIA:mainfrom
FujitsuPolycom:perf/helios-zero-budget-anchor-split
Nov 29, 2026
Merged

lukealonso merged 3 commits into
NVIDIA:mainfrom
FujitsuPolycom:perf/helios-zero-budget-anchor-split

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

A conversation message boundary can fall inside a prompt where cutting prefill requires an extra padded graph launch, even when snapshot storage capacity is zero or scheduler_checkpoint_extra_work_fraction is zero. Avoiding that extra prefill launch requires evaluating split cost from one consistent catalog snapshot, latching the resulting anchor endpoint across multi-chunk prefill progress, Mixed prefill alignment shifts, EWMA timing updates, and preemption readmission, and resolving a single anchor endpoint for reuse promotion and Selene inbound restore.

What changed

  • helios/src/scheduler/checkpoints.rs and helios/src/scheduler.rs:
    • Before: Helios always kept the last eligible message boundary as the anchor regardless of snapshot capacity or zero-fraction prefill split cost, evaluated optional cuts even at zero extra-work fraction, and did not short-circuit zero snapshot capacity before catalog pricing or terminal capture allocation.
    • After: Helios returns immediately with no cuts or terminal allocations when snapshot capacity is zero. When scheduler_checkpoint_extra_work_fraction is zero, Helios prices whole, before, and after intervals from the same prefill_catalog_costs snapshot, keeps an interior message boundary as the anchor only when splitting there adds zero predicted prefill work, falls back to prompt_tokens otherwise (including when prefill costs are unknown), latches (raw_anchor, prompt_tokens, chosen) on CheckpointAccounting across remaining chunks and clear_reservations() (invalidated if park() grows prompt_tokens), filters stale baseline_interval entries in request_anchor_endpoint to end == request.prompt_tokens, skips optional-cut pricing and work_budget skip increments, and resolves/latches a single consistent anchor endpoint across partial prefix hits, full-prompt GPU cache hits, promote_request_anchor (gated on consumed_tokens >= prompt_tokens for O(1) Resume/Decode steps), and Selene inbound restore.
  • Compatibility: Existing signed cores, Protobuf wire contracts, nonzero extra-work fractions, and optional Endpoint eviction rules are unchanged.
  • docs/cli-design.md, docs/core-design.md, and docs/scheduling-runtime-design.md: Document zero-capacity cut suppression and zero-fraction interior-anchor split pricing, including unknown-cost fallback to the prompt-end anchor.

Claimed benefit and observed results

  • Zero-budget serving avoids extra padded prefill launches on unaligned interior message boundaries while preserving single-anchor checkpoint capture and prefix reuse across single-chunk, multi-chunk, Mixed-prefill, and preempted requests, without duplicate Anchor publications or spurious work_budget skip counts.
  • Exact-SHA live 4× RTX PRO 6000 SM120 flare run A/B (ba3afb13 vs 69bf2cf2):
    • Signed DeepSeek-V4.1-Flash TP4 (gb202-tp4-202611281642, --scheduler-checkpoint-extra-work-fraction 0, plain local /dev/nvme1n1p1 ext4) across interleaved --scheduler-policy balanced (2 passes, --prefix-cache-memory 8GiB), --scheduler-policy throughput (8GiB), and --prefix-cache-memory 0 (balanced) runs on multi-turn chat prompts with interior message boundaries:
      • short_2turn (4 req): flare_graph_launches_total{kind="prefill"} dropped 8 -> 4 (-50%) on every pass; TTFT p50 dropped -18.9% to -19.4% (82.2 -> 66.2 ms, 79.7 -> 64.6 ms, 80.7 -> 65.4 ms, 80.2 -> 64.7 ms).
      • long_12k_2turn (2 req, ~61K tok): prefill launches dropped 6 -> 4 (-33%) on every pass; long_20k_2turn (1 req, ~51K tok): 5 -> 4 (-20%).
      • Concurrent mixed_load (4 active decode streams + 2 staggered ~30K-token 2-turn cold prefills): prefill launches dropped 16 -> 10 (-37.5%), prefill TTFT p50 dropped -15.1% to -23.8% (2918.1 -> 2466.6 ms, 2949.8 -> 2503.0 ms, 2839.5 -> 2163.8 ms), and mixed wall time dropped -4.4% to -5.7%.
      • Across all runs, flare_message_checkpoints_total dropped to 0, flare_prompt_checkpoints_total absorbed all terminal anchors, unknown_cost skips dropped to 0–1, and all containers exited cleanly (exit=0).

Supporting evidence and limitations

  • Current PR head 754f873a94f5461110c8ff2a8fa12f8677b79f29 merged with origin/main e80b1f2f7da2221f7301bcd50f4bee3977b2b3e2 (all commits DCO-signed).
  • Unit, lifecycle, and TLA+ mutation verification (754f873a):
    • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler::: 403 passed, 4 ignored, 0 failed.
    • python3 verification/helios-lifecycle/check.py --mutations --jobs 8: all TLA+ models, all 8 observed Rust trace-conformance suites (including 68 CheckpointReservation.tla transitions covering multi-chunk fallback, upward EWMA drift, Mixed alignment shift, and deferred prefill), and all TLA+ and Rust guard mutations passed (Detected Rust mutation: dropped multi-chunk zero-budget fallback).
    • pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py tests/test_scheduling_learning_policy.py tests/test_scheduling_learning_experiments.py tests/test_scheduling_sim.py: 312 passed.
  • Exact-SHA live 4-GPU verification (69bf2cf2 vs ba3afb13): clean git archive release binaries (flare_base_ba3a sha256 72c61a47759f9fe6f377ad2a16ba2d0847643f26e59211522fc5bbe849ecccc8, flare_pr582_69bf sha256 bfd1a5a7bcc34470978d5b2bd5d8ae5547c2bd7a21f33592cd5626b0f8146825) on ai01 (4x RTX PRO 6000 Blackwell SM120). Live GPU serving was not re-run after the 754f873a scheduler review follow-ups.
  • Limits: Flare clamps temperature=0 to the core's general sampling defaults, so live validation confirmed exact prompt-token counts, valid finish reasons, and coherent completions rather than greedy token-string equality. Live GPU serving was verified on 4× SM120 TP4 (DeepSeek-V4.1-Flash); SM103/SM121 were not re-benchmarked on this revision.

Discord: Dooner

@voipmonitor voipmonitor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review & Live 4× SM120 Test Report (commit a3c64835)

Verdict: Request changes (2 blocker correctness bugs) — the motivation is solid, TLA+ conformance checks pass, and live 4× SM120 serving confirms the intended reduction in prefill splits at --scheduler-checkpoint-extra-work-fraction 0, but two bugs in checkpoints.rs cause duplicate RetentionRole::Anchor captures on normal multi-chunk workloads.

Automated & Live 4× SM120 Test Results

  • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler:: — 390 passed, 0 failed.
  • python3 verification/helios-lifecycle/check.py (all 8 TLA+ models + mutation checks) — PASSED.
  • Live 4× SM120 (DeepSeek-V4.1-Flash TP4, --scheduler-checkpoint-extra-work-fraction 0, identical origin/main base):
    • Short 2-turn chat (242 tok): prefill_steps dropped 2 → 1 (anchor_captures = 1).
    • Multi-chunk 2-turn (12,212–12,232 tok, 5 runs): prefill_steps dropped 3 → 2 across all 5 runs, though flare_checkpoint_skips_total{reason="work_budget"} still incremented 1..3 per request at fraction == 0.0 (confirming Major #5 below).
    • 64K cold NIAH (71,429 tok): 59,453 tok/s, needle_ok = True.

Findings

  1. [Blocker] Duplicate RetentionRole::Anchor capture on normal upward GPU EWMA timing drift (helios/src/scheduler/checkpoints.rs:364-388, 466-505):
    checkpoint_selection_uncached latches accounting.initial_prefill_ns once at start = 0 and passes it as known_whole into anchor_split_is_zero_cost, comparing before(live_catalog) + after(live_catalog) against whole(old_latched_ewma).
    • Reproducer: prompt = 1024, message_boundaries = [512], prefill_catalog = [512] (512_000 ns), fraction = 0.0. Chunk 1 (0..512) sees zero split cost, keeps 512 as Anchor, runs on GPU with tiny normal jitter (515_000 ns → EWMA 512_300 ns), and publishes 512 as Anchor. At Chunk 2 (start = 512), raw_anchor > start is false, so execution enters the else if branch: before(512_300) + after(512_300) - known_whole(1_024_000) = 600 != 0, flipping to anchor = 1024 and capturing a second RetentionRole::Anchor at 1024.
    • (Why the PR's unit test missed this: complete_test_step passed dur_ns = 1_000 vs 512_000, pushing EWMA downward so saturating_sub clamped to 0 — which symmetrically causes the inverse bug where downward EWMA drift falsely classifies genuinely costly splits as zero-cost.)
  2. [Blocker] Duplicate RetentionRole::Anchor capture when Mixed prefill shifts chunk alignment (checkpoints.rs:466-505):
    • Reproducer (zero EWMA drift): prefill_catalog = [128, 512] (150k, 400k), mixed = [(2, 1, 256)], prompt = 1024, raw_anchor = 768, fraction = 0.0. At start = 0, 0..768..1024 is costly → fallback 1024. Chunk 1 executes Mixed(256) (0..256). At start = 256, 256..768..1024 (512 + 256) is zero-cost → selects & publishes 768 as Anchor (anchor_fallback_from = None). At start = 768, the else if branch re-prices from baseline_start = 0, sees 0..768..1024 is costly, and publishes a second Anchor at 1024.
    • Fix for Blockers #1 & #2: Always price whole, before, and after from the same catalog snapshot (do not pass stale known_whole), and latch an explicit (raw_anchor, chosen_anchor) decision on CheckpointAccounting (preserved across clear_reservations()) instead of reconstructing fallback backwards from baseline_start.
  3. [Major] is_request_anchor_endpoint hardcodes start = 0 and checks raw_anchor before limits.snapshots == 0 (checkpoints.rs:390-420, scheduler.rs:1794):
    On a partial prefix hit (baseline_start = 88, raw_anchor = 600, prompt = 1024, prefill_catalog = [128, 512]), checkpoint_selection_uncached prices from 88 and selects 600 (zero cost), while is_request_anchor_endpoint(req, 1024) prices from 0 and also returns true for 1024, allowing promote_request_anchor / inbound restore to promote both. Check limits.snapshots == 0 first and price from baseline_start when baseline_start < raw_anchor.
  4. [Major] clear_reservations() wipes anchor_fallback_from (checkpoints.rs:48-52, scheduler.rs:1726):
    admit_planned_with_checkpoint_accounting preserves CheckpointAccounting across preemption/readmission and calls clear_reservations(). Preserve the latched zero-budget anchor decision across clear_reservations() just like baseline_interval and initial_prefill_ns.
  5. [Major] O(N) wasted prefill pricing & spurious checkpoint_skip_work_budget stats at fraction == 0.0 (checkpoints.rs:538-650):
    When fraction == 0.0 and anchor falls back to prompt_tokens, raw_anchor and all earlier message boundaries enter candidates and run 2 * N interval_prefill_ns walks every step even though available == 0 can never fund optional cuts. Return early after pushing the Anchor cut when fraction == 0.0.
  6. [Minor]
    • Move if self.limits.snapshots == 0 before prefill_catalog_costs and short-circuit allocate_terminal_capture when snapshots == 0.
    • Update the stale follow-on sentences in docs/core-design.md:1448-1449 and docs/scheduling-runtime-design.md:567-569 so they agree with the fraction == 0.0 unknown-cost fallback rule.
    • Add regression unit tests for upward EWMA drift, Mixed-prefill alignment shift, partial prefix hit < raw_anchor, and preemption/readmission, and replace the brittle 13-line string literal mutation in verification/helios-lifecycle/check.py:325-343.

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 582.
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.

A conversation message boundary can fall inside a prompt where cutting
prefill requires an extra padded graph launch, even when snapshot storage
capacity is zero or `scheduler_checkpoint_extra_work_fraction` is zero.
Avoiding that extra prefill launch requires evaluating split cost from one
consistent catalog snapshot, latching the resulting anchor endpoint across
multi-chunk prefill progress, `Mixed` prefill alignment shifts, EWMA timing
updates, and preemption readmission, and resolving a single anchor endpoint
for reuse promotion and Selene inbound restore.

- `helios/src/scheduler/checkpoints.rs` and `helios/src/scheduler.rs`:
  - Before: Helios always kept the last eligible message boundary as the
    anchor regardless of snapshot capacity or zero-fraction prefill split
    cost, evaluated optional cuts even at zero extra-work fraction, and did
    not short-circuit zero snapshot capacity before catalog pricing or
    terminal capture allocation.
  - After: Helios returns immediately with no cuts or terminal allocations
    when snapshot capacity is zero. When
    `scheduler_checkpoint_extra_work_fraction` is zero, Helios prices
    `whole`, `before`, and `after` intervals from the same
    `prefill_catalog_costs` snapshot, keeps an interior message boundary as
    the anchor only when splitting there adds zero predicted prefill work,
    falls back to `prompt_tokens` otherwise (including when prefill costs
    are unknown), latches `(raw_anchor, chosen_anchor)` on
    `CheckpointAccounting` across remaining chunks and
    `clear_reservations()`, skips optional-cut pricing and `work_budget`
    skip increments, and resolves a single consistent anchor endpoint across
    partial prefix hits, `promote_request_anchor`, and Selene inbound
    restore.
- Compatibility: Existing signed cores, Protobuf wire contracts, nonzero
  extra-work fractions, and optional `Endpoint` eviction rules are
  unchanged.
- `docs/cli-design.md`, `docs/core-design.md`, and
  `docs/scheduling-runtime-design.md`: Document zero-capacity cut
  suppression and zero-fraction interior-anchor split pricing, including
  unknown-cost fallback to the prompt-end anchor.

Zero-budget serving avoids extra padded prefill launches on unaligned
interior message boundaries while preserving single-anchor checkpoint
capture and prefix reuse across single-chunk, multi-chunk, `Mixed`-prefill,
and preempted requests, without duplicate `Anchor` publications or spurious
`work_budget` skip counts. On prior PR revision `a3c64835` atop `167f22c8`
(`DeepSeek-V4.1-Flash` TP4 on 4x SM120 with
`--scheduler-checkpoint-extra-work-fraction 0`), reviewer live serving
observed `prefill_steps` drop `2 -> 1` on 242-token 2-turn chat and `3 -> 2`
across five 12,212-12,232-token 2-turn runs (`59,453 tok/s`,
`needle_ok = True` on 71,429-token 64K cold NIAH); live signed-core serving
has not been re-run on this revision.

- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler::`:
  394 passed, 4 ignored, 0 failed (0 warnings in touched files).
- `python3 verification/helios-lifecycle/check.py --mutations`: all TLA+
  models, observed Rust trace-conformance checks (including 59
  `CheckpointReservation.tla` transitions covering multi-chunk fallback,
  upward EWMA drift, and `Mixed` alignment shift), and all 12 TLA+ model and
  19 Rust guard mutations passed (`Detected Rust mutation: dropped
  multi-chunk zero-budget fallback`).
- `pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py tests/test_scheduling_learning_policy.py tests/test_scheduling_learning_experiments.py tests/test_scheduling_sim.py`:
  312 passed.
- Broad `helios --lib` reproduces only environment-gated and base-existing
  failures (`FLARE_TEST_TEMPLATE_DIR` unset, WSL2 8 MiB `RLIMIT_MEMLOCK` on
  two parallel `engram::reader` tests, and pre-existing
  `model::tests::packed_combined_budget_keeps_width_one_batches_without_a_useful_packed_shape`).
- Limitations: Live `flare run` GPU serving and isolated latency benchmarks
  were not re-executed on this post-review revision.

Discord: Dooner

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

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The problem is real and in the right layer, and live 4× SM120 testing confirmed the expected prefill-launch reduction, but this head has two verified correctness blockers that emit duplicate RetentionRole::Anchor captures on ordinary multi-chunk workloads.

  • Blockers: 2
  • Should fix: 4
  • Subtractive suggestions: 1
  • Nits: 3

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.

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. 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 29, 2026
@FujitsuPolycom
FujitsuPolycom force-pushed the perf/helios-zero-budget-anchor-split branch from a3c6483 to 69bf2cf Compare November 29, 2026 15:20
@FujitsuPolycom

Copy link
Copy Markdown
Contributor Author

Updated branch to 69bf2cf (clean rebase on �a3afb13, verified conflict-free against main 44f59df, full scheduler:: 394 passed + �erification/helios-lifecycle/check.py --mutations 12 TLA+ & 21 Rust guard mutations passed) and added exact-SHA live 4× RTX PRO 6000 SM120 lare run A/B evidence (�a3afb13 vs 69bf2cf on signed DeepSeek-V4.1-Flash TP4 with --scheduler-checkpoint-extra-work-fraction 0):

  • short_2turn: prefill launches 8 -> 4 (-50%), TTFT p50 -18.9% to -19.4% across �alanced, hroughput, and --prefix-cache-memory 0.
  • long_12k_2turn / long_20k_2turn: prefill launches 6 -> 4 / 5 -> 4.
  • Concurrent mixed_load (4 active decodes + 2 staggered ~30K 2-turn cold prefills): prefill launches 16 -> 10 (-37.5%), prefill TTFT p50 -15.1% to -23.8%, mixed wall -4.4% to -5.7%, with lare_message_checkpoints_total == 0 and clean exit=0.

@voipmonitor voipmonitor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified updated commit 69bf2cf2 — every Round 1 blocker/major/minor finding is cleanly resolved (same-snapshot split pricing, latched zero_budget_anchor: Option<(usize, usize)> preserved across chunks & clear_reservations(), unified single-anchor request_anchor_endpoint across partial prefix hits/promote_request_anchor/Selene restore, zero-fraction optional candidate pricing skip, snapshots == 0 early exits, and updated docs/mutations).

Verification (69bf2cf2)

  • Clean merge vs origin/main (44f59df5): Zero conflicts.
  • Rust scheduler tests: cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler:: — 394 passed, 0 failed, 4 ignored (0 warnings in touched files).
  • Formal verification (verification/helios-lifecycle/check.py --mutations): All exhaustive TLA+ models, observed-edge conformance suites (including 59 observed Rust transitions against CheckpointReservation.tla covering upward EWMA drift & Mixed alignment shift), and all TLA+ & Rust mutations PASS.
  • Live 4× RTX PRO 6000 Blackwell (SM120) flare run check (69bf2cf2 --release binary, DS4.1-Flash TP4 signed core, RAM Engram, --prefix-cache-memory 64G --scheduler-checkpoint-extra-work-fraction 0):
    • Greedy 17 * 23: 391 (prompt=43, prefill_launches=1, anchor=1, 0 prefill budget skips).
    • Short 2-turn chat (prompt=95): prefill_launches=1 (down from 2), anchor=1; identical repeat cached=95/95 (restore_launches=1, prefill_launches=0).
    • Multi-chunk 2-turn chat (prompt=12,051): prefill_launches=2 (down from 3), anchor=1.
    • 64K Cold NIAH (prompt=66,367): dt=1.184s (56.1k tok/s wall), needle_ok=True (VORTEX-6982-SAPPHIRE), prefill_launches=9, anchor=1.

Ready to merge.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

All Round 1 correctness blockers, major issues, and minor items are cleanly resolved in 69bf2cf with targeted regression tests and exact-SHA 4× SM120 flare run A/B evidence (-20% to -50% prefill launches, -15.1% to -23.8% prefill TTFT p50 on multi-turn zero-budget workloads), and priority contributor @voipmonitor has independently verified and approved this head. No correctness, safety, or default-path regressions remain; ensure CI (or a quick rebase onto main f7256584) runs main's post-1a5d4d8c check.py --mutations harness on the merged commit.

  • Blockers: 0 · Should fix: 2 · Subtract/Simplify: 3 · Nits: 1
Walkthrough
  • helios/src/scheduler/checkpoints.rs: Short-circuits limits.snapshots == 0 before catalog pricing (:482-484) and terminal capture allocation (:957-959); adds same-catalog split-cost check anchor_split_is_zero_cost (:363-385), latches (raw_anchor, chosen) in CheckpointAccounting::zero_budget_anchor (:28, preserved across clear_reservations() at :48-51, written at :526, 534, read at :529-532, 711-717), returns early after the Anchor cut when checkpoint_extra_work_fraction == 0.0 (:549-551), resolves a single anchor endpoint in request_anchor_endpoint / is_request_anchor_endpoint (:387-463) for promote_request_anchor (:788-811), and adds regression tests covering zero capacity, multi-chunk fallback, upward/downward EWMA drift, Mixed prefill alignment shifts, partial prefix hits, preemption readmission, and zero-fraction skip counters (:2364-3501).
  • helios/src/scheduler.rs: Routes Selene inbound-restore role classification (:1792-1808) through self.is_request_anchor_endpoint(request, inbound.consumed_tokens) so prompt-end restores match the resolved zero-budget anchor.
  • helios/src/scheduler/checkpoint_lifecycle_tests.rs: Adds CheckpointReservation.tla trace-conformance tests for multi-chunk zero-budget fallback with cancellation points (:278-411) and upward EWMA drift + Mixed(256) alignment shifts (:414-692).
  • verification/helios-lifecycle/check.py: Adds a single-line Rust mutation guard (:325-330) asserting multi-chunk zero-budget anchor fallback is retained.
  • docs/cli-design.md, docs/core-design.md, docs/scheduling-runtime-design.md: Document zero-capacity cut suppression and zero-fraction interior-anchor split pricing, including unknown-cost fallback to the prompt-end anchor.
Merge Risk: Low · up to 69bf2cf
  • Production behavior changes are strictly gated behind self.limits.snapshots == 0 or self.policy.checkpoint_extra_work_fraction == 0.0 (helios/src/scheduler/checkpoints.rs:388-396, 482-484, 510-511, 549-551, 957-959); the default 0.05 scheduling and optional-Endpoint eviction paths are unchanged.
  • No wire contracts, captured-graph contracts, config knobs, concurrency primitives, or per-model branches are introduced; all 7 modified files merge cleanly against current main (f7256584).
  • The only residual runtime cost on the zero-budget path is minor CPU/allocation overhead in promote_request_anchor on decode steps of full-prompt cache hits (where zero_budget_anchor remains None), which does not affect correctness or undo the measured TTFT gains.
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

The core fix is in the right layer and addresses a real zero-budget / zero-capacity prefill-splitting defect, but 69bf2cf2 needs a rebase and a couple of targeted fixes before merge:

Blockers

  1. Stale zero_budget_anchor causes a spurious interior prefill split after real preemption/readmission (helios/src/scheduler/checkpoints.rs:398-402, 526-536, 709-717)

    • CheckpointAccounting::zero_budget_anchor stores (raw_anchor, chosen) and is preserved across clear_reservations(), matching only on latched_raw == raw_anchor.
    • In production serving, preempt_newest only preempts requests in RequestPhase::Decode (helios/src/scheduler.rs:1459-1477), and park() extends incoming.prompt.tokens with all generated tokens (helios/src/server/runtime.rs:2106-2121) while keeping message_boundaries (and thus raw_anchor) unchanged.
    • Reproducer: A growable request with prompt_tokens = 1024, message_boundaries = [200], checkpoint_extra_work_fraction = 0.0, and prefill_catalog = [128, 512, 1024] latches zero_budget_anchor = Some((200, 1024)). It decodes 100 tokens (prompt_tokens becomes 1124) and is preempted. If its 1124/1024 checkpoints are absent or evicted while an earlier prefix checkpoint at 512 remains resident, readmission starts at start = 512 (> raw_anchor = 200). checkpoint_selection_uncached hits latched_raw == raw_anchor, selects anchor = 1024, and because 1024 > 512, pushes Cut { endpoint: 1024, role: Anchor } — splitting 512..1124 (one Prefill(1024) launch) at the obsolete pre-preemption prompt end 1024 into Prefill(512) + Snapshot + Prefill(128) under a zero extra-work budget.
    • Subcases (e1)/(e2) in checkpoints.rs missed this because they readmitted the original 1024-token RequestSpec without appending generated tokens.
    • Fix: Key the latch on (raw_anchor, prompt_tokens) (e.g., latched_raw == raw_anchor && latched_prompt == request.prompt_tokens) so a grown post-decode prompt never turns an old prompt-end fallback into an interior cut, and add a readmission test with extended prompt_tokens.
  2. Rebase onto main (#613 / 0c25e88f) and re-run verification

    • helios/src/scheduler/checkpoints.rs currently conflicts with origin/main in allocate_terminal_capture (and overlaps plan_checkpoints) where #613 (0c25e88f) added request.deferred_prefill guards.
    • verification/helios-lifecycle/check.py --mutations was run on ba3afb13, before both 1a5d4d8c (ObservedState/ObservedSafe full-.cfg edge validation) and 0c25e88f (16-integer CheckpointReservation.tla projection with deferred state). Please re-run check.py --mutations and the scheduler:: suite after rebasing onto main, and update the commit message (Design-Signed-Off-By digest on main is now 2e5b, and the commit body still says live serving was not re-run on this revision).

Should fix

  1. Per-decode-step heap allocation and 3× interval_prefill_ns in promote_request_anchor on full-prompt cache hits (helios/src/scheduler/checkpoints.rs:387-458, 788-811, helios/src/scheduler.rs:2463)

    • A full-prompt GPU cache hit goes through Restore -> Decode without ever running checkpoint_selection_uncached, so request.checkpoints.zero_budget_anchor stays None for the entire request lifetime.
    • Because commit() calls promote_request_anchor on every lane of every step, every decode step of every full-prompt fallback cache hit (where ready_by_prefix(raw_anchor) is None) heap-allocates prefill_catalog_costs(request) and runs interval_prefill_ns three times synchronously in commit().
    • promote_request_anchor already takes &mut self; latching the resolved (raw_anchor, prompt_tokens, chosen) onto request.checkpoints.zero_budget_anchor on first resolution makes this O(1) per request.
  2. Fragile parent_tokens reconstruction in request_anchor_endpoint can fail to refresh demand_epoch on a cached fallback anchor (helios/src/scheduler/checkpoints.rs:415-434)

    • On a full-prompt GPU cache hit where ready_by_prefix(raw_anchor) was already confirmed None at line 419, reconstructing price_start from request.prefix's current cache parent can flip anchor_split_is_zero_cost to true (e.g., 1024-token fallback anchor for raw_anchor = 640 whose cache parent happens to be a 128-token system-prompt checkpoint on [128, 512], where 128..640..1024 = 512 + 384 is zero-cost). request_anchor_endpoint then returns Some(640) — which is known not to exist in cache — so promote_request_anchor becomes a no-op and never refreshes demand_epoch on the resident 1024 checkpoint.

Minor

  • Dead fallback branch in plan_checkpoints (helios/src/scheduler/checkpoints.rs:703-720): anchor is only read by reserve_guard (cut.endpoint < anchor). At fraction == 0.0, cuts never contains a cut with endpoint < anchor, and at nonzero fractions zero_budget_anchor is cleared to None, so the zero_budget_anchor lookup in map_or_else has no effect.
  • Skip-counter claim vs allocate_terminal_capture: The PR description states "without ... spurious work_budget skip counts" at fraction == 0.0, which holds for prefill selection, while allocate_terminal_capture still increments checkpoint_skip_work_budget (or checkpoint_skip_unknown_cost) on request completion when limits.snapshots > 0 and fraction == 0.0.
  • Wrapping nit: docs/scheduling-runtime-design.md line 567 is unwrapped (130+ chars).

voipmonitor added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Nov 29, 2026
Resolved trivial conflicts with NVIDIA#613 (combine limits.snapshots == 0 and
request.deferred_prefill guard in allocate_terminal_capture) and NVIDIA#614
(preserve NVIDIA#582 checkpoint mutation check before build_test_binary /
run_observed_checks in verification/helios-lifecycle/check.py).

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=2e5b
voipmonitor added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Nov 29, 2026
…anchor refresh)

Address all review items from @lukealonso on NVIDIA#582:
- Key CheckpointAccounting::zero_budget_anchor on (raw_anchor, prompt_tokens,
  chosen) so a growable request preempted after decode (extending
  prompt_tokens via park()) never turns an obsolete pre-preemption prompt-end
  fallback into a spurious interior prefill cut upon readmission.
- Keep separate limits.snapshots == 0 and request.deferred_prefill checks in
  allocate_terminal_capture so NVIDIA#613's mutation test remains intact.
- Latch zero_budget_anchor inside promote_request_anchor on first resolution
  so full-prompt GPU cache hits run O(1) on subsequent Resume/Decode steps
  without per-step catalog allocation or interval_prefill_ns calls.
- Remove fragile parent_tokens reconstruction in request_anchor_endpoint:
  on a full-prompt GPU cache hit where raw_anchor is absent, keep
  prompt_tokens immediately when request.prefix is already RetentionRole::Anchor
  (guaranteeing demand_epoch refresh even with a system-prompt parent),
  otherwise price from 0.
- Remove the dead zero_budget_anchor fallback branch in plan_checkpoints,
  wrap docs/scheduling-runtime-design.md line 573, update check.py's mutation
  target, and add targeted regression tests for grown-prompt readmission,
  full-prompt Anchor demand_epoch refresh with a system-prompt parent, and
  zero STRIDE_RUNS on latched Resume/Decode steps.

Verified on origin/main (2147cd4, incl. NVIDIA#613 + NVIDIA#614):
- cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler:: -> 403 passed, 0 failed, 4 ignored
- python3 verification/helios-lifecycle/check.py --mutations --jobs 8 -> all TLA+ models, all 8 observed-edge suites (68 CheckpointReservation transitions on 16-int deferred model), and all TLA+/Rust mutations passed.

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=2e5b
@voipmonitor

Copy link
Copy Markdown
Collaborator

@lukealonso Thanks for the thorough catch — addressed every item in cc144c7c (atop merge commit 9c2cf418 with origin/main 2147cd4c, including #613 and #614):

Addressed Findings

  1. [Blocker] Grown-prompt preemption/readmission latch: Keyed CheckpointAccounting::zero_budget_anchor on (raw_anchor, prompt_tokens, chosen) (latched_raw == raw_anchor && latched_prompt == request.prompt_tokens) so a post-decode grown prompt readmitted at start > raw_anchor never splits at an obsolete pre-preemption prompt end. Added zero_fraction_grown_prompt_readmission_does_not_split_at_stale_prompt_end reproducing your exact 1024 -> 1124 / raw_anchor = 200 / prefix = 512 scenario.
  2. [Blocker] Merged with main (#613 + #614) & re-verified: Preserved #613's request.deferred_prefill guard as a separate if after self.limits.snapshots == 0 in allocate_terminal_capture (keeping #613's mutation intact), integrated #614's build_test_binary/run_observed_checks, updated check.py's mutation target string, and signed with design-review=2e5b.
  3. [Should fix] O(1) promote_request_anchor on full-prompt cache hits: promote_request_anchor now latches (raw_anchor, prompt_tokens, anchor) onto request.checkpoints.zero_budget_anchor on first resolution, eliminating per-step prefill_catalog_costs allocations and 3× interval_prefill_ns calls across subsequent Resume/Decode steps (verified with STRIDE_RUNS == 0).
  4. [Should fix] Removed fragile parent_tokens reconstruction in request_anchor_endpoint: On full-prompt GPU cache hits where ready_by_prefix(raw_anchor) is None, if request.prefix is already RetentionRole::Anchor we immediately return Some(request.prompt_tokens) (guaranteeing demand_epoch refresh even with a 128-token system-prompt parent); otherwise we price from 0. Added zero_fraction_full_prompt_cache_hit_refreshes_anchor_with_system_parent_and_latches.
  5. [Minors]:
    • Removed the dead zero_budget_anchor fallback branch in plan_checkpoints.
    • Wrapped docs/scheduling-runtime-design.md line 573 cleanly.
    • Note on skip counters: zero-fraction eliminates spurious optional prefill work_budget skips (0 during prefill selection), while allocate_terminal_capture still records a terminal decode work_budget skip when limits.snapshots > 0 && fraction == 0.0.

Verification (cc144c7c on origin/main 2147cd4c)

  • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler::: 403 passed, 0 failed, 4 ignored (0 warnings in touched files).
  • python3 verification/helios-lifecycle/check.py --mutations --jobs 8: PASS — all 9 exhaustive TLA+ models + Speculation16.cfg, all 8 observed-edge suites with full ObservedState/ObservedSafe invariants (68 observed Rust transitions against #613's 16-int CheckpointReservation.tla), and all TLA+ & Rust mutations (including both #613's deferred prefill terminal capture bypass and #582's dropped multi-chunk zero-budget fallback).
  • Live 4× RTX PRO 6000 Blackwell (SM120) flare run (--scheduler-checkpoint-extra-work-fraction 0, DS4.1-Flash TP4 signed core): confirmed prefill_launches 2 -> 1 (2-turn), 3 -> 2 (12K 2-turn), 95/95 repeat cache hit, Greedy 391, and 64K Cold NIAH PASS (56.1k tok/s).

@lukealonso

Copy link
Copy Markdown
Collaborator

Everything from the previous round was addressed cleanly, except cc144c7c introduces one new bug on grown-prompt preemption readmission (plus a missing DCO trailer):

Blocker

  1. promote_request_anchor fabricates a duplicate RetentionRole::Anchor at the mid-generation preemption point (1124) on grown-prompt readmission (helios/src/scheduler/checkpoints.rs:404-409, 787-797)
    • In request_anchor_endpoint, baseline_start reads request.checkpoints.baseline_interval without checking that baseline_end == request.prompt_tokens. After park() extends prompt_tokens (1024 -> 1124), baseline_interval still holds the pre-preemption Some((0, 1024)) (baseline_start = 0 < raw_anchor = 200).
    • Trace (this reproduces directly inside the new zero_fraction_grown_prompt_readmission_does_not_split_at_stale_prompt_end test):
      1. Readmitted request has prompt_tokens = 1124, raw_anchor = 200, consumed_tokens = prefix_tokens = 512 (or 1024, the normal case where the original Anchor is still resident), baseline_interval = Some((0, 1024)), zero_budget_anchor = Some((200, 1024, 1024)).
      2. Before Restore commits, checkpoint_cut(readmitted) returns None (1024 != 1124, raw_anchor <= start).
      3. When Restore commits, promote_request_anchor calls request_anchor_endpoint, which misses the old latch, takes baseline_start = 0 < 200, prices 0..200..1124 as costly, and returns Some(1124). Because consumed_tokens >= 200, promote_request_anchor latches zero_budget_anchor = Some((200, 1124, 1124)) onto the request.
      4. On the subsequent Prefill (512..1124 or 1024..1124), checkpoint_selection_uncached hits the newly fabricated (200, 1124, 1124) latch, flipping checkpoint_cut from None to Some(1124) and arming/publishing a duplicate RetentionRole::Anchor at the mid-generation preemption point 1124 (and again at 1224, 1324, … on every preemption cycle).
    • The new test missed this because it checked checkpoint_cut == None before Restore committed and stopped after scheduler.plan() without committing the Prefill step or checking checkpoint_cut / checkpoint_capture after Restore.
    • Fix:
      1. In request_anchor_endpoint, ignore a stale baseline_interval whose end != request.prompt_tokens:
        let baseline_start = request
            .checkpoints
            .baseline_interval
            .filter(|&(_, end)| end == request.prompt_tokens)
            .map_or(request.admission_reused_tokens as usize, |(start, _)| start);
      2. In promote_request_anchor, only latch zero_budget_anchor once prefill is already complete (request.consumed_tokens >= prompt_tokens as u64), so it caches full-prompt cache hits for Resume/Decode without fabricating a latch ahead of checkpoint_selection_uncached on requests that still have prefill work.
      3. Extend zero_fraction_grown_prompt_readmission_does_not_split_at_stale_prompt_end to assert checkpoint_cut == None after Restore commits and checkpoint_capture.is_none() when the Prefill(1024) step commits (and cover the prefix = 1024 case as well if convenient).

Minor / Merge Hygiene

  • Missing DCO Signed-off-by: trailers: 9c2cf418 and cc144c7c omit Signed-off-by: (mergeStateStatus is currently BLOCKED). Please also refresh the PR description to reflect the (raw_anchor, prompt_tokens, chosen) latch and updated verification commit.
  • Test coverage nit: In zero_fraction_full_prompt_cache_hit_refreshes_anchor_with_system_parent_and_latches, anchor_1024 is already RetentionRole::Anchor, so STRIDE_RUNS would already be 0 via the early RetentionRole::Anchor check even without latching; adding a STRIDE_RUNS == 0 assertion on a full-prompt Endpoint cache hit (after Restore promotes/latches it) would directly exercise the pricing-bypass path as well.

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=2e5b
Signed-off-by: Martin Vit <martin@voipmonitor.org>
…stale baseline guard)

Address all review findings from @lukealonso on NVIDIA#582 (Rounds 1 & 2):
- Key `CheckpointAccounting::zero_budget_anchor` on `(raw_anchor, prompt_tokens, chosen)`
  so a growable request preempted after decode (extending `prompt_tokens` via `park()`)
  never turns an obsolete pre-preemption prompt-end fallback into a spurious interior
  prefill cut upon readmission.
- Filter stale `baseline_interval` in `request_anchor_endpoint` so it is only reused
  when `end == request.prompt_tokens`, preventing grown-prompt readmission from
  fabricating a stale anchor endpoint on `Restore`.
- In `promote_request_anchor`, gate latching on `request.consumed_tokens >= prompt_tokens`
  (preventing premature latching before prefill completes) while preserving O(1)
  latched `Resume`/`Decode` steps without per-step catalog allocation or
  `interval_prefill_ns` calls.
- Remove fragile `parent_tokens` reconstruction in `request_anchor_endpoint`: on a
  full-prompt GPU cache hit where `raw_anchor` is absent, keep `prompt_tokens`
  immediately when `request.prefix` is already `RetentionRole::Anchor` (guaranteeing
  `demand_epoch` refresh even with a system-prompt parent), otherwise price from `0`.
- Keep separate `limits.snapshots == 0` and `request.deferred_prefill` checks in
  `allocate_terminal_capture` so NVIDIA#613's mutation test remains intact.
- Remove the dead `zero_budget_anchor` fallback branch in `plan_checkpoints`, wrap
  `docs/scheduling-runtime-design.md` line 573, update `check.py`'s mutation target,
  and add regression tests covering:
  - grown-prompt readmission (`prefix=512` and `prefix=1024`) verifying `checkpoint_cut`
    stays `None` across `Restore`, `checkpoint_capture.is_none()`,
    `checkpoint_anchor_captures == 0`, and `ready_by_prefix(1124).is_none()`;
  - full-prompt `Anchor` `demand_epoch` refresh with a system-prompt parent and zero
    `STRIDE_RUNS` on latched `Resume`/`Decode` steps;
  - full-prompt `Endpoint` (`raw_anchor == 512`) latching in `promote_request_anchor`
    (`STRIDE_RUNS > 0` on `Restore`, `0` on `Resume`/`Decode`).

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=2e5b
Signed-off-by: Martin Vit <martin@voipmonitor.org>
@voipmonitor
voipmonitor force-pushed the perf/helios-zero-budget-anchor-split branch from cc144c7 to 754f873 Compare November 29, 2026 20:25
@voipmonitor

Copy link
Copy Markdown
Collaborator

@lukealonso Thanks for catching those two! All items from your latest review are addressed in 754f873a (merged with origin/main e80b1f2f, all commits DCO-signed):

  1. Stale baseline_interval + premature latch on grown-prompt Restore:
    • request_anchor_endpoint now filters baseline_interval with .filter(|&(_, end)| end == request.prompt_tokens) so an obsolete pre-preemption interval (0..1024) is ignored after park() grows prompt_tokens (1124).
    • promote_request_anchor now gates latching zero_budget_anchor on request.consumed_tokens >= prompt_tokens as u64, so it never fabricates a latch during Restore before prefill finishes (while still latching full-prompt Endpoint hits for O(1) Resume/Decode steps).
    • Extended zero_fraction_grown_prompt_readmission_does_not_split_at_stale_prompt_end to verify both prefix=512 and prefix=1024 readmission paths: checkpoint_cut stays None after Restore commits, checkpoint_capture stays None, checkpoint_anchor_captures == 0, and no 1124 checkpoint is published.
    • Extended zero_fraction_full_prompt_cache_hit_refreshes_anchor_with_system_parent_and_latches with a full-prompt Endpoint (raw_anchor=512) subcase verifying STRIDE_RUNS > 0 on Restore and 0 on Resume/Decode.
  2. DCO sign-off: Rebuilt our merge (5553e02c) and review-fix (754f873a) commits on top of Fujitsu's signed 69bf2cf2 with Signed-off-by: on every commit.
  3. PR description: Updated to reflect the (raw_anchor, prompt_tokens, chosen) latch, stale baseline_interval filter, promote_request_anchor latching, and fresh verification on 754f873a:
    • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler:: → 403 passed, 0 failed, 4 ignored
    • python3 verification/helios-lifecycle/check.py --mutations --jobs 8 → all TLA+ models, all 8 observed-edge suites (68 CheckpointReservation.tla transitions), and all TLA+/Rust mutations passed
    • pytest (core boundary + design-review hook + scheduling suites) → 312 passed

@lukealonso
lukealonso merged commit c3489b2 into NVIDIA:main Nov 29, 2026
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. 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.

4 participants