Skip to content

helios,ignition: implement additive packed multi-request prefill (Contract 3) - #715

Open
original-el8 wants to merge 4 commits into
mainfrom
docs/packed-prefill-rfc
Open

original-el8 wants to merge 4 commits into
mainfrom
docs/packed-prefill-rfc

Conversation

@original-el8

@original-el8 original-el8 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Single-request prefill graphs (GraphKind::Prefill and GraphKind::TerminalPrefill with batch_capacity == 1) serialize concurrent short prompts and warm-prefix turns into separate full-model replays, and GraphKind::Mixed admits at most one prefill lane per step. On memory-bandwidth-bound GPUs, loading MoE expert weights dominates feed-forward latency up to 512–1,024 tokens (3,947.3 µs/layer at 64 rows vs. 7,625.4 µs/layer at 1,024 rows on NVIDIA GB10 DeepSeek V4.1 layer 3 TP4).

Extending Prefill and TerminalPrefill additively within ModelContract version 3 to allow batch_capacity >= 2 with explicit packed_token_capacity lets Helios coalesce concurrent text-only prefill lanes into one CUDA graph replay without per-model flags, contract version bumps, or changes to single-request or vision prefill.

Companion recipe PR: local-inference-lab/hyperflare-recipes#153.

What changed

  • Manifest, catalog, and selection (helios/src/execution/manifest.rs, helios/src/model/catalog.rs, helios/src/runtime_core/selection.rs):
    • Validates optional Prefill and TerminalPrefill graphs with batch_capacity $B \ge 2$, per-request token capacity $1 \le W \le P$, draft_tokens == 0, and 64-aligned packed_token_capacity $P$ ($\max(64, B) \le P \le B \times W$, $P \le \text{prefill_chunk_size}$).
    • Keeps single-request prefill ($B = 1$, packed_token_capacity == 0) and ScoredPrefill ($B = 1$) unchanged.
    • Filters B >= 2 packed prefill graphs by max_concurrency, dropping them when --max-concurrency 1.
  • Input packing (helios/src/model/packing.rs, helios/src/model/testing.rs):
    • Forbids vision bindings (ImageFeatureSlot, ImageFeatureIndex, ImageLeftContext, ImageRightContext) on B >= 2 prefill graphs.
    • Sizes InputIndexing::PackedToken buffers to packed_token_capacity when nonzero, and enforces lane.tokens <= token_capacity, sum(lane.tokens) <= packed_token_capacity, and image_slot.is_none() in pack_step.
  • Shared scheduler, cost model, and server runtime (helios/src/scheduler.rs, helios/src/scheduler/{cost,policy,checkpoints}.rs, helios/src/server/runtime.rs):
    • Registers B >= 2 packed prefill graphs in packed_prefill_catalog and tracks per-shape replay durations via ReplayTimes.
    • Builds text-only multi-lane prefill cohorts greedily by marginal value rate and value (with Init/Restore continuation valuation, padding pruning, refresh probe validation, and host_lengths materialization), competing on the same age-priced value-rate objective as solo Prefill, Decode/Speculative, and Mixed.
    • Validates packed prefill geometry in ScheduledStep::validate_mixed and commit, and tracks non-terminal packed prefill steps during checkpoint planning.
  • Ignition and direct-mode scheduler (ignition/preparation/execution.py, ignition/cli/serve.py, ignition/direct/scheduler.py):
    • Validates (B >= 2, W, P) text-only prefill and terminal_prefill GraphSignature geometry and rejects vision inputs on packed prefill signatures.
    • Scopes --packed-verification checks to speculative signatures and isolates B >= 2 packed prefill keys from B == 1 solo prefill catalogs in ignition.direct.scheduler.Layout.
  • Documentation and tests (helios/manifest.md, helios/model-contract.md, docs/packed-prefill-design.md, helios/src/execution/tests.rs, helios/src/model/tests.rs, helios/src/runtime_core/selection.rs, helios/src/scheduler/policy_tests.rs, tests/preparation/test_execution.py):
    • Documents the additive Contract 3 specification and adds unit tests covering manifest/catalog/selection validation, multi-lane packing and vision rejection, scheduler burst packing and isolation, and Ignition GraphSignature validation.

Claimed benefit and result

Before this change, Helios and Ignition rejected batch_capacity >= 2 on Prefill and TerminalPrefill graphs, forcing concurrent prefill requests to execute one lane per replay. After this change, any prepared model declaring text-only packed (B >= 2, W, P) prefill graphs within Contract 3 coalesces concurrent short or warm-prefix text requests into shared CUDA graph replays under the shared value-rate scheduler, while existing cores without B >= 2 prefill graphs load and serve unchanged.

On four NVIDIA GB10 GPUs (SM121, TP4, DeepSeek V4.1 Flash, flare run with identical binary and flags), enabling the six packed terminal_prefill shapes reduces concurrent short-prompt burst p95 TTFT by 1.68×–4.15× (3,590 ms → 865 ms at C=16, 93-token chat turns; 1,656 ms → 455 ms at C=16, 69-token completions) and raises aggregate burst prefill throughput by 1.75×–4.23× (383 → 1,622 tok/s at C=16 chat; 1,996 → 3,559 tok/s at C=16, 238-token completions), at a KV capacity cost of -4.2% (7,631,232 → 7,310,848 logical KV tokens/rank).

Supporting evidence and limitations

Live four-GPU NVIDIA GB10 (SM121) TP4 A/B (flare run, identical runtime binary 84f789af, --max-concurrency 32 --mtp-draft-tokens 7 --mtp-adaptive-verification --mtp-max-verification-token-budget 256 --mtp-adaptive-verification-alpha 1.0 --scheduler-policy balanced --embedding-table-storage disk --embedding-table-resident-scales --embedding-table-cache-size 22GiB --embedding-table-workers 4 --kv-cache-limit memory --scheduler-checkpoint-extra-work-fraction 0.05):

  • Solo baseline (pre-change 151-graph core 887785ad, confirming backward compatibility): 7,631,232 logical KV tokens/rank.
  • Packed prefill (157-graph core 4aea5c54, +6 packed terminal_prefill shapes (4,128,512), (4,256,1024), (8,128,1024), (8,256,2048), (16,128,1024), (16,128,2048)): 7,310,848 logical KV tokens/rank.
  • Barrier-synchronized burst matrix (median of 3 rounds, temperature=0):
Case C Prompt tok Prefill launches (Solo → Packed) TTFT p50 ms (Solo → Packed) TTFT p95 ms (Solo → Packed) GPU ms (Solo → Packed) Prefill tok/s (Solo → Packed)
comp_w60_c1 (solo control) 1 68 1 → 1 111.2 → 118.7 (0.94×) 111.2 → 118.7 (0.94×) 105.1 → 113.1 612 → 573
comp_w60_c4 4 69 4 → 1 328.7 → 196.2 (1.68×) 431.1 → 196.2 (2.20×) 407.4 → 184.6 (2.21×) 640 → 1,407 (2.20×)
comp_w60_c8 8 69 8 → 2 533.0 → 389.9 (1.37×) 837.6 → 390.2 (2.15×) 800.0 → 369.3 (2.17×) 659 → 1,415 (2.15×)
comp_w60_c16 16 69 16 → 3 994.6 → 337.1 (2.95×) 1,655.7 → 454.7 (3.64×) 1,678.4 → 533.3 (3.15×) 626 → 1,934 (3.09×)
comp_w105_c4 4 130 4 → 5 375.6 → 349.5 (1.07×) 498.9 → 397.8 (1.25×) 479.8 → 376.1 (1.28×) 1,042 → 1,307 (1.25×)
comp_w105_c8 8 130 8 → 10 625.0 → 651.1 (0.96×) 992.5 → 795.2 (1.25×) 957.2 → 752.1 (1.27×) 1,048 → 1,308 (1.25×)
comp_w105_c16 16 130 16 → 2 1,131.4 → 751.7 (1.51×) 1,876.3 → 752.2 (2.49×) 1,916.8 → 716.9 (2.67×) 1,040 → 2,765 (2.66×)
comp_w185_c4 4 238 4 → 2 356.8 → 363.0 (0.98×) 478.1 → 363.1 (1.32×) 458.4 → 349.2 (1.31×) 1,991 → 2,622 (1.32×)
comp_w185_c8 8 238 8 → 1 600.4 → 535.7 (1.12×) 953.9 → 535.7 (1.78×) 917.4 → 517.0 (1.77×) 1,996 → 3,554 (1.78×)
comp_w185_c16 16 238 16 → 2 1,077.2 → 1,069.3 (1.01×) 1,792.3 → 1,070.0 (1.68×) 1,830.2 → 1,033.4 (1.77×) 1,996 → 3,559 (1.78×)
chat_w65_c4_tok16 4 93 8 → 5 895.6 → 427.5 (2.09×) 1,066.7 → 512.1 (2.08×) 1,269.8 → 773.9 (1.64×) 349 → 726 (2.08×)
chat_w65_c8_tok16 8 93 16 → 10 1,600.6 → 785.5 (2.04×) 2,039.4 → 995.3 (2.05×) 2,267.7 → 1,294.9 (1.75×) 365 → 748 (2.05×)
chat_w65_c16_tok16 16 93 32 → 4 2,827.7 → 862.6 (3.28×) 3,590.1 → 865.0 (4.15×) 4,062.8 → 1,392.6 (2.92×) 383 → 1,622 (4.23×)
chat_w185_c8_tok16 8 255 16 → 3 1,449.6 → 828.9 (1.75×) 1,662.5 → 829.1 (2.01×) 1,944.6 → 1,165.4 (1.67×) 1,227 → 2,461 (2.01×)
chat_w185_c16_tok16 16 255 32 → 5 2,702.6 → 1,672.3 (1.62×) 3,212.4 → 1,696.7 (1.89×) 3,659.4 → 2,253.0 (1.62×) 1,241 → 2,168 (1.75×)
  • Non-burst sanity (packed-prefill core 4aea5c54): C=1 cold prefill 9,686 tok/s (8K, 0.85s TTFT) and 10,712 tok/s (32K, 3.06s TTFT); 8K sustained decode 73.8 tok/s (C=1), 167.5 tok/s (C=4), 329.4 tok/s (C=16).

Unit, conformance, and recipe suites:

  • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core --lib: 1,284 passed, 0 failed, 37 ignored (including in-crate lifecycle conformance suites scheduler_matches_lifecycle_model, bounded_cache_ownership_matches_tla, scheduler_matches_speculative_accounting_model, and async_transfer_scheduler_matches_lifecycle_model).
  • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib: 1,894 passed, 49 ignored, 6 failures solely from unset FLARE_TEST_TEMPLATE_DIR.
  • cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib: 230 passed, 6 ignored; flare and flare-cli suites: all passed.
  • Python suites (tests/preparation/test_execution.py, tests/direct, tests/test_scheduling_*.py, tests/test_prefill_capacities.py, tests/test_design_review_hook.py): 905 passed, 2 skipped (3 failures in tests/cli from an older installed flare_heliopause wheel in the local venv).
  • Companion recipe PR deepseek41,paged_batch: support packed multi-request text-only terminal prefill local-inference-lab/hyperflare-recipes#153: 6/6 NVIDIA GB10 CUDA + CPU packed prefill tests and 112/112 DeepSeek V4.1 CPU tests passed.

Limitations:

  • Standalone tla2tools.jar TLC runs and cargo-kani were not available on the build host (only in-crate Rust lifecycle conformance tests ran).
  • In the live A/B comparison, the baseline core (887785ad) was exported from an earlier FlashInfer revision while the packed-prefill core (4aea5c54) was exported against FlashInfer 5a8ceed80; both cores were served by the identical flare binary (84f789af), and the C=1 solo control (comp_w60_c1) measured 111.2 ms vs. 118.7 ms (0.94×).
  • Residual 2–3 token tails after chat message_boundary anchor checkpoints at C=4/8 (chat_w65_c4/c8) currently run solo (~50 ms/lane) because the smallest packed graph has P=512; a compact small-tail shape (e.g., P=256) is a separate catalog-tuning opportunity.

Discord: el8

@original-el8 original-el8 changed the title docs: RFC for packed multi-request prefill (GraphKind::Prefill / TerminalPrefill B >= 2) helios,ignition: implement additive packed multi-request prefill (Contract 3) Dec 4, 2026
@original-el8

Copy link
Copy Markdown
Collaborator Author

Implemented additive ModelContract version 3 packed multi-request prefill across Helios and Ignition (84f789af), paired with the opt-in --packed-prefill DeepSeek V4.1 recipe PR in local-inference-lab/hyperflare-recipes#153, exported a signed 4-GPU SM121 TP4 core (4aea5c54, 157 graphs/rank), and benchmarked it live through flare run against the pre-change 151-graph solo-prefill core (887785ad) on the identical flare binary.

Highlights (4× NVIDIA GB10, SM121, TP4, DeepSeek V4.1 Flash)

  • Backward compatibility: The pre-change 151-graph core (887785ad) loaded and served cleanly on the updated binary (7,631,232 logical KV tokens/rank vs. 7,310,848 with +6 packed terminal_prefill shapes, -4.2%).
  • Concurrent short-prompt bursts (median of 3 barrier-synchronized rounds):
    • chat_w65_c16_tok16 (C=16, 93 prompt tokens, 16 output tokens): prefill launches 32 → 4, p95 TTFT 3,590.1 ms → 865.0 ms (4.15×), prefill throughput 383 → 1,622 tok/s (4.23×), total GPU time 4,062.8 ms → 1,392.6 ms (2.92×).
    • comp_w60_c16 (C=16, 69 prompt tokens): prefill launches 16 → 3, p95 TTFT 1,655.7 ms → 454.7 ms (3.64×), GPU time 1,678.4 ms → 533.3 ms (3.15×).
    • comp_w105_c16 (C=16, 130 prompt tokens): prefill launches 16 → 2, p95 TTFT 1,876.3 ms → 752.2 ms (2.49×), prefill throughput 1,040 → 2,765 tok/s (2.66×).
    • comp_w185_c8 (C=8, 238 prompt tokens): prefill launches 8 → 1, p95 TTFT 953.9 ms → 535.7 ms (1.78×), prefill throughput 1,996 → 3,554 tok/s (1.78×).
    • chat_w185_c8_tok16 (C=8, 255 prompt tokens): prefill launches 16 → 3, p95 TTFT 1,662.5 ms → 829.1 ms (2.01×).
  • Non-burst sanity (4aea5c54): C=1 cold prefill 9,686 tok/s (8K) / 10,712 tok/s (32K); 8K sustained decode 73.8 (C=1), 167.5 (C=4), 329.4 (C=16) tok/s.

Full 15-cell A/B table, test results, and limitations are in the PR description above.

@original-el8
original-el8 marked this pull request as ready for review December 4, 2026 12:51
@flare-autobot

Copy link
Copy Markdown
Collaborator

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

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

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

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. triage:review Proposed change needs code review; this does not imply merge readiness. and removed triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The packed-prefill feature itself is well-built and correctly gated: geometry validation is complete and mutually consistent, the B == 1 and ScoredPrefill paths are genuinely untouched, and no per-model flag or hardcoded bucket list was added. Two hard gates are unmet — the extended prefill operation contract has no recorded owner approval, and testing-hierarchy layers 2–3 were not run — and two verified scheduler/validation asymmetries let packed prefill do things the solo planner provably never does and let Ignition accept a core Helios rejects.

  • Blockers: 2 · Should fix: 5 · Subtract/Simplify: 7 · Nits: 7
Walkthrough
  • Manifest / catalog / selection (helios/src/execution/manifest.rs:860-878, helios/src/model/catalog.rs:266-282, helios/src/runtime_core/selection.rs:260-275, helios/src/scheduler.rs:891-921): accept Prefill/TerminalPrefill with B >= 2, 1 <= W <= P, 64-aligned P, draft_tokens == 0, P <= prefill_chunk_size; B == 1 must keep packed == 0; selection.rs:341-350 drops B >= 2 graphs when --max-concurrency 1.
  • Packing (helios/src/model/packing.rs:113-126, :169-188, :422-439): vision bindings rejected on B >= 2 prefill, PACKED_TOKEN extent sized to P, and pack_step validates lanes/sum/image before staging.clear() at :440, so a rejected lane cannot leave half-written buffers.
  • Scheduler (helios/src/scheduler/policy.rs:1300-1426, :1623-1747, :1592-1621): two greedy cohort builders pack 2..B text-only lanes under sum(work) <= P, competing on the same age-priced ValueRate as solo Prefill, Decode/Speculative, and Mixed; scheduler.rs:436-465 re-validates the resulting geometry in validate_mixed.
  • Cost model (helios/src/scheduler/cost.rs:644-659, :581-583, :606-607): packed_prefill_duration keys packed shapes on (kind,B,W,P); PrefillCostModel creation and slope refresh are now gated on batch == 1 so packed shapes cannot poison the solo predictor.
  • Ignition (ignition/preparation/execution.py:80-96, ignition/direct/scheduler.py:197-201, :290-291): GraphSignature validates (B,W,P) geometry and rejects vision inputs; direct mode isolates the 4-tuple packed keys from the B == 1 capacities() catalog.
  • Docs (docs/packed-prefill-design.md, helios/model-contract.md:188-209, helios/manifest.md): additive Contract-3 subsection; docs/packed-prefill-design.md:45-46,112-137 documents recipe code that exists only in local-inference-lab/hyperflare-recipes#153.
Merge Risk: High · up to 84f789a
  • The change redefines what a PREFILL/TERMINAL_PREFILL graph is (multiple simultaneous requests per graph, a new PACKED_TOKEN row layout of extent P, per-lane SAMPLE_ENABLED completion, eligibility derived from absent vision bindings), so it needs owner sign-off that the repo does not record anywhere.
  • New greedy cohort code lands on helios/src/scheduler/policy.rs, the file five merged PRs (#645, #655, #661, #663, #697) touched in the five days before this one — and the same algorithm is written twice with three live divergences.
  • The headline 1.68×–4.15× A/B compares two different signed cores exported from different FlashInfer revisions, with the C=1 control moving 111.2 → 118.7 ms (0.94×), so the figures are not an isolated measurement of packed prefill.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings

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

Want a frontier second opinion? If these findings look noisy, request a one-time SuperAgent Review on 84f789a (~3–4 min; re-adjudicates existing findings without re-running discovery).

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

Solo prefill graphs (`GraphKind::Prefill` and `GraphKind::TerminalPrefill`)
require `batch_capacity == 1`, and `GraphKind::Mixed` admits at most one
prefill request per step. On memory-bandwidth-bound multi-host clusters such as
four NVIDIA GB10 GPUs running DeepSeek V4.1 Flash at TP4, reading MoE weights
dominates feed-forward latency up to 512–1,024 tokens (`3,947.3 us/layer` at 64
rows vs. `7,625.4 us/layer` at 1,024 rows on GB10 layer 3), so serializing
concurrent short or warm-prefix agentic bursts one request per replay inflates
p95/p99 TTFT.

Exact changes:
- Add `docs/packed-prefill-design.md`: specify a model-agnostic extension of
  `GraphKind::Prefill` and `GraphKind::TerminalPrefill` reusing the
  `(batch_capacity = B >= 2, token_capacity = W_req, packed_token_capacity = P)`
  geometry established for `GraphKind::Speculative`, binding-derived text-only
  eligibility via omitted `ValueSource::ImageFeatureSlot`, shared `ValueRate`
  scheduler cohort packing across all cache schemes, and DeepSeek V4.1 recipe
  integration without `PreparedDecoderSuffix` truncation for short bursts.
- No runtime, manifest, CLI, or recipe code is changed in this draft PR; it
  requests project-owner approval on the operation contract, `ModelContract`
  versioning, and non-terminal vs. terminal scope before implementation.

Expected benefit: enables design review and project-owner sign-off on packed
multi-request prefill before modifying Helios contracts, targeting a 3–6x
lossless reduction in concurrent short and warm-prefix burst TTFT on
bandwidth-constrained hardware with no impact on single-request prefill.

Evidence and material limitations:
- Single-GPU NVIDIA GB10 (SM121) layer-3 TP4 feed-forward CUDA-graph timings
  (uncompressed native-scale DeepSeek V4.1 Flash checkpoint, median of 7
  interleaved passes): 64 rows `3,947.3 us`, 128 rows `5,000.0 us`, 256 rows
  `5,629.1 us`, 512 rows `6,619.4 us`, 1,024 rows `7,625.4 us`.
- Verified referenced file paths and symbols (`helios/src/model/{catalog,packing}.rs`,
  `helios/src/scheduler/{cost,policy}.rs`, `helios/model-contract.md`) against
  `origin/main` (`45e1c1ad`).
- Limitation: design document only; no runtime or recipe implementation or
  end-to-end serving benchmark has been run yet.

Discord: el8

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
…tract 3)

Single-request prefill graphs (`GraphKind::Prefill` and
`GraphKind::TerminalPrefill` with `batch_capacity == 1`) serialize concurrent
short prompts and warm-prefix turns into separate full-model replays, and
`GraphKind::Mixed` admits at most one prefill lane per step. On
memory-bandwidth-bound GPUs, loading MoE expert weights dominates feed-forward
latency up to 512-1,024 tokens (`3,947.3 us/layer` at 64 rows vs.
`7,625.4 us/layer` at 1,024 rows on NVIDIA GB10 DeepSeek V4.1 layer 3 TP4).
Extending `Prefill` and `TerminalPrefill` additively within `ModelContract`
version 3 to accept `batch_capacity >= 2` with explicit `packed_token_capacity`
lets Helios pack concurrent text-only prefill lanes into one CUDA graph replay
without per-model flags, contract version bumps, or changes to single-request
or vision prefill.

Exact changes:
- Manifest, catalog, and selection (`helios/src/execution/manifest.rs`,
  `helios/src/model/catalog.rs`, `helios/src/runtime_core/selection.rs`):
  validate optional `Prefill` and `TerminalPrefill` graphs with
  `batch_capacity` B >= 2, `1 <= W <= P`, and 64-aligned
  `packed_token_capacity` P (`max(64, B) <= P <= B * W`,
  `P <= prefill_chunk_size`, `draft_tokens == 0`); keep `B == 1` prefill
  (`packed_token_capacity == 0`) and `ScoredPrefill` (`B == 1`) unchanged; and
  filter `B >= 2` packed prefill graphs by `max_concurrency` (dropping them
  when `--max-concurrency 1`).
- Input packing (`helios/src/model/packing.rs`, `helios/src/model/testing.rs`):
  forbid vision bindings (`ImageFeatureSlot`, `ImageFeatureIndex`,
  `ImageLeftContext`, `ImageRightContext`) on `B >= 2` prefill graphs, size
  `InputIndexing::PackedToken` buffers to `packed_token_capacity` when nonzero,
  and enforce `lane.tokens <= token_capacity`, `sum(lane.tokens) <=
  packed_token_capacity`, and `image_slot.is_none()` during `pack_step`.
- Shared scheduler, cost model, and server runtime (`helios/src/scheduler.rs`,
  `helios/src/scheduler/{cost,policy,checkpoints}.rs`,
  `helios/src/server/runtime.rs`): register `B >= 2` packed prefill graphs in
  `packed_prefill_catalog`, track per-shape durations via `ReplayTimes`, build
  multi-lane text-only prefill cohorts greedily by marginal value rate and
  value (with `Init`/`Restore` continuation valuation, padding pruning, refresh
  probe validation, and `host_lengths` materialization), validate packed
  prefill steps in `ScheduledStep::validate_mixed` and `commit`, and track
  non-terminal packed prefill steps during checkpoint planning.
- Ignition and direct-mode scheduler (`ignition/preparation/execution.py`,
  `ignition/cli/serve.py`, `ignition/direct/scheduler.py`): accept valid
  `(B >= 2, W, P)` text-only prefill and `terminal_prefill` signatures while
  rejecting vision inputs, scope `--packed-verification` checks to
  `speculative` signatures, and key `B >= 2` packed prefill graphs separately
  from `B == 1` solo prefill catalogs in `ignition.direct.scheduler.Layout`.
- Test compilation fix (`helios/src/runtime_core/cache_memory.rs`): populate
  `external_extents: vec![]` in the `#[cfg(test)]` `Core` struct literal so
  `--features runtime-core` unit tests compile.
- Documentation and unit tests (`helios/manifest.md`, `helios/model-contract.md`,
  `docs/packed-prefill-design.md`, `helios/src/execution/tests.rs`,
  `helios/src/model/tests.rs`, `helios/src/runtime_core/selection.rs`,
  `helios/src/scheduler/policy_tests.rs`, `tests/preparation/test_execution.py`):
  document the additive Contract 3 packed prefill rules and add tests covering
  manifest/catalog/selection validation, multi-lane packing and vision
  rejection, scheduler burst packing and isolation, and Ignition
  `GraphSignature` validation.

Claimed benefit and result:
Before this change, Helios and Ignition rejected `batch_capacity >= 2` on
`Prefill` and `TerminalPrefill` graphs, forcing concurrent prefill requests to
execute one lane at a time. After this change, any prepared model declaring
text-only packed `(B >= 2, W, P)` prefill graphs within Contract 3 can coalesce
concurrent short or warm-prefix text requests into one CUDA graph replay under
the shared value-rate scheduler, while existing cores without `B >= 2` prefill
graphs load and serve unchanged. End-to-end TP4 burst TTFT reductions are
expected from amortizing MoE weight loads and remain unmeasured until an
exported packed-prefill core is benchmarked through `flare run`.

Supporting evidence and limitations:
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core --lib`:
  1,284 passed, 0 failed, 37 ignored (including in-crate lifecycle conformance
  tests `scheduler_matches_lifecycle_model`, `bounded_cache_ownership_matches_tla`,
  `scheduler_matches_speculative_accounting_model`, and
  `async_transfer_scheduler_matches_lifecycle_model`).
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib`:
  1,894 passed, 49 ignored, 6 failures solely from unset `FLARE_TEST_TEMPLATE_DIR`.
- `cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib`:
  230 passed, 6 ignored; `cargo test --locked --release --manifest-path flare/Cargo.toml`
  and `flare-cli`: all passed.
- Python suites (`pytest tests/preparation/test_execution.py tests/direct
  tests/test_scheduling_sim.py tests/test_scheduling_continuation.py
  tests/test_scheduling_timing.py tests/test_scheduling_utility.py
  tests/test_scheduling_oracle.py tests/test_prefill_capacities.py
  tests/test_design_review_hook.py`): 905 passed, 2 skipped across the combined
  run (3 failures in `tests/cli` solely from an older installed
  `flare_heliopause` wheel in the local venv).
- Companion recipe PR `local-inference-lab/hyperflare-recipes#153` passed 6/6
  NVIDIA GB10 CUDA + CPU packed prefill tests and 112/112 DeepSeek V4.1 CPU
  tests.
- Limitations: standalone `tla2tools.jar` TLC runs and `cargo-kani` were not
  available on this host (only in-crate Rust conformance tests ran); full TP4
  `ignition export --packed-prefill`, `flare run` serving benchmarks, and
  pre-change exported core regression runs have not yet been executed.

Discord: el8

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@original-el8
original-el8 force-pushed the docs/packed-prefill-rfc branch from 84f789a to caaef5a Compare December 4, 2026 13:25
original-el8 added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 4, 2026
…al prefill

Single-request prefill graphs (`batch_capacity == 1`) serialize concurrent short
prompts and prefix-warmed turns into separate full-model replays. On
memory-bandwidth-bound GPUs, loading MoE expert weights dominates feed-forward
latency up to 512-1,024 tokens, leaving concurrent text bursts underutilized.
Opting into packed multi-request `terminal_prefill` graphs within Contract 3
amortizes weight loads across concurrent text-only lanes without altering
single-request or vision prefill execution.

Exact changes:
- `hyperflare_recipes/components/paged_batch.py`: allow `PreparedBatch` in
  `prefill` mode for `rows >= 2` when `validate_prefill is None` (text-only),
  validate per-lane `0 < lengths[i] <= max_query_tokens` and aggregate
  `sum(active lengths) <= token_capacity`, check prompt token bounds across all
  active packed tokens, and compute per-row rotary maxima in
  `RotaryBatch.commit_rotary` when `rows > 1`.
- `hyperflare_recipes/recipes/deepseek41/decoder.py`: restrict vision injection,
  `PreparedDecoderSuffix` bounded-replay truncation, and row-sharded encoder
  DMA/RoCE to single-request or encoder-only/packed-suffix prefill graphs so
  packed multi-request `terminal_prefill` graphs run all 40 layers directly.
- `hyperflare_recipes/recipes/deepseek41/recipe.py` and
  `hyperflare_recipes/recipes/deepseek41/bootstrap.py`: add opt-in
  `--packed-prefill` (`DeepSeek41Parameters.packed_prefill`, default `False`),
  prepare compact text-only `terminal_prefill` `(B, W_req, P)` shapes filtered
  to `max_concurrency` and `prefill_chunk_size`, and size prefill scratch,
  candidate buffers, and collective/DMA gather workspaces to cover the packed
  shapes.
- `tests/recipes/test_deepseek41_packed_prefill.py` and
  `tests/recipes/test_deepseek41_packed_prefill_cuda.py`: add CPU parameter,
  catalog, and feedback-capture tests plus CUDA tests for `PreparedBatch` graph
  capture and validation, `RotaryBatch` per-row offsets, and `PreparedGlobalKV`
  serial-prefill parity (`ratio=1` and `ratio=2` with odd/even starts and
  inactive-row isolation).

Claimed benefit and result:
Before this change, `PreparedBatch` rejected multi-row prefill graphs and
DeepSeek V4.1 could only prepare `batch_capacity == 1` prefill shapes. With
`--packed-prefill`, DeepSeek V4.1 prepares compact text-only multi-request
`terminal_prefill` shapes compatible with Helios's packed prefill scheduler
while keeping default preparation (`--packed-prefill` off), single-request
prefill, and vision prefill unchanged. End-to-end TP4 serving TTFT and
throughput gains are expected from amortizing MoE weight loads across concurrent
short prompts and remain unmeasured until an exported core is benchmarked
through `flare run`.

Supporting evidence and limitations:
- NVIDIA GB10 (SM121), `FLARE_RUN_CUDA_TESTS=1 pytest -v tests/recipes/test_deepseek41_packed_prefill.py tests/recipes/test_deepseek41_packed_prefill_cuda.py`:
  6 passed (`PreparedBatch` CUDA graph capture with zero steady-state
  allocations, `RotaryBatch` multi-row rotary commit, and `PreparedGlobalKV`
  numerical parity against serial solo prefill for both `ratio=2` and
  `ratio=1`).
- DeepSeek V4.1 CPU suites (`test_deepseek41_packed_prefill.py`,
  `test_deepseek41_catalog.py`, `test_deepseek41_decoder_prefill.py`,
  `test_deepseek41_row_shard_prefill.py`, `test_deepseek41_dspark.py`): 112
  passed, 1 skipped.
- Limitations: depends on NVIDIA/hyperflare-inference#715 for Helios and
  Ignition packed prefill support; full multi-rank checkpoint export
  (`ignition export --packed-prefill`) and end-to-end TP4 `flare run` serving
  benchmarks have not yet been run.

Discord: el8

Design-Signed-Off-By: Antigravity (Gemini); design-review=6fcc
original-el8 added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 4, 2026
…al prefill

Single-request prefill graphs (`batch_capacity == 1`) serialize concurrent short
prompts and prefix-warmed turns into separate full-model replays. On
memory-bandwidth-bound GPUs, loading MoE expert weights dominates feed-forward
latency up to 512-1,024 tokens, leaving concurrent text bursts underutilized.
Opting into packed multi-request `terminal_prefill` graphs within Contract 3
amortizes weight loads across concurrent text-only lanes without altering
single-request or vision prefill execution.

Exact changes:
- `hyperflare_recipes/components/paged_batch.py`: allow `PreparedBatch` in
  `prefill` mode for `rows >= 2` when `validate_prefill is None` (text-only),
  validate per-lane `0 < lengths[i] <= max_query_tokens` and aggregate
  `sum(active lengths) <= token_capacity`, check prompt token bounds across all
  active packed tokens, and compute per-row rotary maxima in
  `RotaryBatch.commit_rotary` when `rows > 1`.
- `hyperflare_recipes/recipes/deepseek41/decoder.py`: restrict vision injection,
  `PreparedDecoderSuffix` bounded-replay truncation, and row-sharded encoder
  DMA/RoCE to single-request or encoder-only/packed-suffix prefill graphs so
  packed multi-request `terminal_prefill` graphs run all 40 layers directly.
- `hyperflare_recipes/recipes/deepseek41/recipe.py` and
  `hyperflare_recipes/recipes/deepseek41/bootstrap.py`: add opt-in
  `--packed-prefill` (`DeepSeek41Parameters.packed_prefill`, default `False`),
  prepare compact text-only `terminal_prefill` `(B, W_req, P)` shapes filtered
  to `max_concurrency` and `prefill_chunk_size`, and size prefill scratch,
  candidate buffers, and collective/DMA gather workspaces to cover the packed
  shapes.
- `tests/recipes/test_deepseek41_packed_prefill.py` and
  `tests/recipes/test_deepseek41_packed_prefill_cuda.py`: add CPU parameter,
  catalog, and feedback-capture tests plus CUDA tests for `PreparedBatch` graph
  capture and validation, `RotaryBatch` per-row offsets, and `PreparedGlobalKV`
  serial-prefill parity (`ratio=1` and `ratio=2` with odd/even starts and
  inactive-row isolation).

Claimed benefit and result:
Before this change, `PreparedBatch` rejected multi-row prefill graphs and
DeepSeek V4.1 could only prepare `batch_capacity == 1` prefill shapes. With
`--packed-prefill`, DeepSeek V4.1 prepares compact text-only multi-request
`terminal_prefill` shapes compatible with Helios's packed prefill scheduler
while keeping default preparation (`--packed-prefill` off), single-request
prefill, and vision prefill unchanged. End-to-end TP4 serving TTFT and
throughput gains are expected from amortizing MoE weight loads across concurrent
short prompts and remain unmeasured until an exported core is benchmarked
through `flare run`.

Supporting evidence and limitations:
- NVIDIA GB10 (SM121), `FLARE_RUN_CUDA_TESTS=1 pytest -v tests/recipes/test_deepseek41_packed_prefill.py tests/recipes/test_deepseek41_packed_prefill_cuda.py`:
  6 passed (`PreparedBatch` CUDA graph capture with zero steady-state
  allocations, `RotaryBatch` multi-row rotary commit, and `PreparedGlobalKV`
  numerical parity against serial solo prefill for both `ratio=2` and
  `ratio=1`).
- DeepSeek V4.1 CPU suites (`test_deepseek41_packed_prefill.py`,
  `test_deepseek41_catalog.py`, `test_deepseek41_decoder_prefill.py`,
  `test_deepseek41_row_shard_prefill.py`, `test_deepseek41_dspark.py`): 112
  passed, 1 skipped.
- Limitations: depends on NVIDIA/hyperflare-inference#715 for Helios and
  Ignition packed prefill support; full multi-rank checkpoint export
  (`ignition export --packed-prefill`) and end-to-end TP4 `flare run` serving
  benchmarks have not yet been run.

Discord: el8

Design-Signed-Off-By: Antigravity (Gemini); design-review=6fcc
@flare-autobot flare-autobot added the community Community discussion or feedback without an actionable defect or feature request. label Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Between Round 1 (84f789a) and head caaef5a the branch rebased onto newer main (diff now 20 files / +1638 -56) with no post-review code fixes or maintainer sign-off. Direct verification clears the earlier code-correctness alarms on packed_prefill_lane_compatible, continuation_candidate, packing.rs, and ignition/cli/serve.py, but both governance/verification blockers and three should-fix items remain open.

  • Blockers: 2 · Should fix: 3 · Subtract/Simplify: 4 · Nits: 4
Walkthrough
  • Manifest, catalog, and selection (helios/src/execution/manifest.rs:860-878,914-924, helios/src/model/catalog.rs:266-282, helios/src/runtime_core/selection.rs:280-295,361-370, helios/src/scheduler.rs:891-921): validate Prefill/TerminalPrefill with 2 <= B <= request_capacity, 1 <= W <= P, 64-aligned P (max(64, B) <= P <= B * W, P <= prefill_chunk_size), draft_tokens == 0, keep B == 1 (P == 0) and ScoredPrefill unchanged, and filter B >= 2 shapes by max_batch (dropping all when --max-concurrency 1).
  • Input packing (helios/src/model/packing.rs:113-126,169-188,422-439, helios/src/model/inputs.rs:87-91): forbid vision bindings on B >= 2 prefill graphs, size InputIndexing::PackedToken buffers to P, validate per-lane tokens <= W, aggregate sum <= P, and image_slot.is_none() before staging.clear(), and drive per-lane SampleEnabled from start_position + tokens == prompt_tokens.
  • Scheduler, cost model, checkpoints, and runtime (helios/src/scheduler/policy.rs:1300-1426,1585-1747,2042-2072, helios/src/scheduler/cost.rs:581-583,606-607,644-659,969, helios/src/scheduler/checkpoints.rs:925-936, helios/src/scheduler.rs:436-465,940-955,2614-2632,2685-2700, helios/src/server/runtime.rs:849-900): register B >= 2 packed prefill shapes separately, gate PrefillCostModel and context-slope refresh on batch == 1, track packed replay times via ReplayTimes, greedily pack 2..B text-only prefill lanes in both single-step and Init/Restore continuation valuation, and track non-terminal packed steps for deferred_prefill and checkpoint capture.
  • Ignition and direct mode (ignition/preparation/execution.py:80-96, ignition/cli/serve.py:465-469, ignition/direct/scheduler.py:197-202,290-291): validate (B >= 2, W, P) text-only prefill signatures, scope --packed-verification checks to speculative signatures so packed prefill does not spoof speculative verification, and keep direct-mode capacities() isolated to B == 1 solo prefill.
  • Docs and tests (docs/packed-prefill-design.md, helios/model-contract.md:188-209, helios/manifest.md:264-273, helios/src/scheduler/policy_tests.rs:9600-9820, helios/src/model/tests.rs:2715-2819, helios/src/runtime_core/selection.rs:2150-2244, tests/preparation/test_execution.py:409-437): specify additive Contract 3 packed prefill and add unit tests covering geometry, vision/logprob isolation, multi-lane packing, mixed finishing/continuing lanes, and --max-concurrency filtering.
Merge Risk: High · up to caaef5a
  • Widens the PREFILL/TERMINAL_PREFILL captured-graph operation contract (batch_capacity >= 2, aggregate P-row PACKED_TOKEN layout, per-lane SAMPLE_ENABLED, binding-derived vision exclusion) without recorded owner approval under docs/design-review.md:22-26.
  • Adds ~342 lines to helios/src/scheduler/policy.rs (including a duplicated greedy cohort builder with a tie-break divergence and a ready-crowding-out-promoted edge case) without Layer 2 simulator evaluation or Layer 3 conformance fixtures covering the new B >= 2 geometry.
  • Ignition's GraphSignature / PreparedExecution validation omits P <= prefill_chunk_size, allowing a prepared core to export cleanly and then fail Helios core selection at load time.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: No prompt-injection or instruction-redirection content in the PR body, comments, or diff; all review/provenance text was treated strictly as content.
  • ✅ Charter & value fit: Model-agnostic runtime (capacities enumerated from core metadata via packed_prefill_graphs(), no per-model branches or hardcoded bucket lists), backward-compatible with pre-change cores (887785ad), and authored by a charter-named priority contributor (@original-el8).
  • ⚠️ Related / duplicate / conflict check: Additive feature with no duplication, but shares policy.rs, checkpoints.rs, and validation surfaces with active scheduling/admission work (#621, #693, #718).
  • ⚠️ Tests & verification evidence: Layer 1 Rust/Python unit coverage is strong and legacy core compatibility is demonstrated, but Layer 2 simulator coverage and Layer 3 packed-geometry conformance fixtures / mutation testing are missing, and the A/B baseline crosses FlashInfer revisions.

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.

…ort selection, and sync docs

Ignition's `PreparedModel` did not reject packed prefill signatures whose
`packed_token_capacity` exceeded `prefill_chunk_size` (which Helios
rejects at load time), the twin packed-prefill cohort builders in
`policy.rs` duplicated selection logic with a tie-break drift and allowed
ready lanes to crowd out promoted lanes in `continuation_candidate`,
`commit` repeated `validate_mixed` packed-prefill bounds checks, the
`(B, W, P)` geometry conjunction was repeated across four modules, and
`docs/scheduling-runtime-design.md` described `PrefillCostModel` without
noting its `batch == 1` scope vs. `ReplayTimes` for packed prefill.

Validate `packed_token_capacity <= prefill_chunk_size` in
`PreparedModel.__init__` with a regression test in `test_execution.py`,
share `valid_packed_prefill_geometry` from `helios/src/execution.rs`
across `manifest.rs`, `catalog.rs`, `selection.rs`, and `scheduler.rs`,
extract `select_packed_prefill_cohort` in `policy.rs` (reserving a
promoted lane in continuation valuation and unifying tie-breaking, plus
a unit test in `policy_tests.rs`), remove the unreachable packed-prefill
re-validation in `commit`, use `binary_search_by_key` in
`is_non_terminal_prefill_step`, and update
`docs/scheduling-runtime-design.md` and `docs/packed-prefill-design.md`.

Validated with `pytest tests/preparation/test_execution.py` (56 passed)
and full Layer-1 `FLARE_TEST_TEMPLATE_DIR=... cargo test --locked
--release --manifest-path helios/Cargo.toml --features
runtime-core,server` (1,918 lib + 62 integration passed, 0 failed).
Owner approval for the widened Contract 3 prefill operation contract and
Layer 2/3 simulator/conformance expansion remain pending.

Discord: el8
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@original-el8

Copy link
Copy Markdown
Collaborator Author

Updated in 49d58404 to address the review findings:

  1. Ignition chunk-bound validation: PreparedModel.__init__ (ignition/preparation/model.py) now enforces signature.packed_token_capacity <= prefill_chunk_size for packed prefill graphs before export/serving, with a regression test in tests/preparation/test_execution.py (56 passed).
  2. Scheduler & geometry cleanup:
    • Extracted shared valid_packed_prefill_geometry in helios/src/execution.rs (manifest.rs, catalog.rs, selection.rs, scheduler.rs).
    • Deduplicated the twin packed-prefill cohort builders in helios/src/scheduler/policy.rs into select_packed_prefill_cohort, unifying tie-breaking and reserving a promoted lane during continuation valuation so ready lanes cannot crowd out promoted lanes (covered by a new unit test in policy_tests.rs).
    • Removed the unreachable packed-prefill re-validation in commit (already enforced by step.validate_mixed()?) and switched is_non_terminal_prefill_step to binary_search_by_key.
  3. Docs sync: Updated docs/scheduling-runtime-design.md to document packed multi-request prefill (batch >= 2 using ReplayTimes, PrefillCostModel and context-slope borrowing scoped to batch == 1) and link docs/packed-prefill-design.md; clarified docs/packed-prefill-design.md regarding Helios runtime flags and companion recipe PR local-inference-lab/hyperflare-recipes#153.
  4. Validation: Full Layer-1 FLARE_TEST_TEMPLATE_DIR=... cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server (1,918 lib + 62 integration passed, 0 failed) and pytest tests/preparation/test_execution.py (56 passed).

@flare-autobot please re-review.

@flare-autobot flare-autobot added triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. triage:review Proposed change needs code review; this does not imply merge readiness. and removed triage:review Proposed change needs code review; this does not imply merge readiness. triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

At 49d5840, no blocking code-correctness or hot-path defects were found in the packed-prefill implementation, and most prior Should Fix / Subtract items are closed. Two governance/verification blockers remain (no recorded owner approval for the widened PREFILL/TERMINAL_PREFILL operation contract, and incomplete Layer 2 simulator / Layer 3 widened-geometry coverage), alongside a non-equivalent A/B baseline.

  • Blockers: 2 · Should fix: 1 · Subtract/Simplify: 4 · Nits: 5
Walkthrough
  • Shared geometry, manifest, catalog, and selection (helios/src/execution.rs:10, helios/src/execution/manifest.rs:452-468,881-900,936-950, helios/src/model/catalog.rs:266-288, helios/src/runtime_core/selection.rs:280-303,366-375, helios/src/scheduler.rs:889-918): enforce valid_packed_prefill_geometry (2 <= B <= max_batch, 1 <= W <= P, 64-aligned P within [max(64, B), min(B * W, i32::MAX)], optional P <= prefill_chunk_size, draft_tokens == 0) while keeping B == 1 (P == 0) and ScoredPrefill unchanged and dropping B >= 2 shapes when --max-concurrency 1.
  • Input packing (helios/src/model/packing.rs:113-126,169-179,422-439, helios/src/model/inputs.rs:87-91): forbid vision bindings on B >= 2 prefill graphs, size InputIndexing::PackedToken buffers to P, validate per-lane tokens <= W, image_slot.is_none(), and sum(tokens) <= P before staging.clear(), and drive per-lane SampleEnabled independently for finishing vs. continuing lanes.
  • Scheduler, cost model, checkpoints, and runtime (helios/src/scheduler/policy.rs:14-22,1311-1401,1560-1778,2073-2104, helios/src/scheduler/cost.rs:581-583,606-607,644-659,969-971, helios/src/scheduler/checkpoints.rs:925-936, helios/src/scheduler.rs:436-463,937-956,2615-2617, helios/src/server/runtime.rs:848-900): register B >= 2 packed prefill shapes separately, scope PrefillCostModel and context-slope refresh to batch == 1 (using ReplayTimes for batch >= 2), unify cohort selection in select_packed_prefill_cohort with promoted-lane seeding for continuation valuation, and classify non-terminal packed steps via binary_search_by_key.
  • Ignition and direct mode (ignition/preparation/execution.py:80-96, ignition/preparation/model.py:32-43, ignition/cli/serve.py:465-469, ignition/direct/scheduler.py:197-202,290-291): validate (B >= 2, W, P) text-only prefill signatures, reject P > prefill_chunk_size in PreparedModel.__init__, scope --packed-verification checks to speculative signatures, and keep direct-mode capacities() isolated to B == 1 solo prefill.
  • Docs and tests (docs/packed-prefill-design.md, docs/scheduling-runtime-design.md:21-25,455-475, helios/model-contract.md:188-209, helios/manifest.md, helios/src/scheduler/policy_tests.rs:9580-9836, helios/src/model/tests.rs, tests/preparation/test_execution.py:409-463): document additive Contract 3 packed prefill and cover geometry, chunk-bound rejection, vision/logprob isolation, multi-lane packing, mixed finishing/continuing lanes, and promoted-lane continuation reservation.
Merge Risk: High · up to 49d5840
  • Widens the PREFILL/TERMINAL_PREFILL captured-graph operation contract (batch_capacity >= 2, aggregate P-row PACKED_TOKEN layout, per-lane SAMPLE_ENABLED completion, binding-derived vision exclusion) without recorded project-owner approval under docs/design-review.md:22-26.
  • Adds +373 lines to helios/src/scheduler/policy.rs without Layer 2 simulator coverage or Layer 3 conformance/mutation coverage for the new B >= 2 prefill geometry, and shares 8 files (including policy.rs, cost.rs, scheduler.rs, and docs/scheduling-runtime-design.md) with maintainer PR #729.
  • The headline 1.68×–4.15× TTFT and 1.75×–4.23× throughput A/B compares two different signed cores exported across different FlashInfer revisions (C=1 solo control 0.94×), so the speedup is not yet isolated on an equivalent baseline.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: No prompt-injection or instruction-redirection content in the PR body, comments, or diff; all review and provenance material was treated strictly as content.
  • ✅ Charter & value fit: Model-agnostic Helios runtime (capacities read from core metadata via packed_prefill_graphs(), no per-model branches or hardcoded bucket lists), backward-compatible with pre-change cores (887785ad), and authored by priority contributor @original-el8.
  • ⚠️ Related / duplicate / conflict check: Genuinely additive with no duplication, but overlaps 8 files with maintainer PR #729 (including policy.rs, cost.rs, scheduler.rs, docs/scheduling-runtime-design.md) plus active scheduling/admission PRs (#621, #693, #718).
  • ⚠️ Tests & verification evidence: Layer 1 Rust/Python unit coverage is clean at 49d5840 (1,918 lib + 62 integration + 56 pytest), and CI covers existing TLC/Kani checks on helios/**, but Layer 2 simulator coverage, Layer 3 B >= 2 conformance fixtures / --mutations testing, and an equivalent A/B baseline remain missing.

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.

…mplify cohort/manifest paths

- Layer 3 formal conformance and mutation testing:
  - Add packed_prefill_scheduler_matches_lifecycle_model to
    helios/src/scheduler/lifecycle_tests.rs (322 states, 740 edges
    covering pipelined non-terminal B=2 Prefill, feedback-exclusive B=2
    TerminalPrefill, cancellation during in-flight packed prefill, and
    stale packed-prefill plan rejection) and verify all 2,450 observed
    Lifecycle.tla transitions via verification/helios-lifecycle/check.py.
  - Add three packed-prefill safety-guard mutations to check.py
    --mutations (image-conditioned lane bypass, aggregate packed token
    cap bypass, and non-terminal classification bypass) and close the
    corresponding negative pack_inputs tests in helios/src/model/tests.rs.
- Layer 2 scheduling simulator:
  - Extend scripts/scheduling_sim/{model,timing,scheduler,learning_policy,
    simulator,workloads,utility}.py with packed_prefill graph geometry
    (prefill_batch_capacity, packed_token_capacity) and two-order greedy
    cohort selection mirroring RequestScheduler::select_packed_prefill_cohort,
    keeping solo prefill interpolation scoped to prefill_batch_capacity == 1.
  - Add burst and budget tests in tests/test_scheduling_sim.py and run
    the screen (16-seed) and validate (62-scenario x 64-seed) catalogs.
- Simplifications and nits:
  - Remove duplicate valid_packed_prefill_geometry call in
    ExecutionManifest::validate (helios/src/execution/manifest.rs).
  - Unify packed prefill offer gathering (packed_prefill_offers) and
    finishing-lane fill (fill_finishing_lanes) in policy.rs, and derive
    PackedCohort counts from mask bitcounts.
  - Consolidate the four manifest prefill filter passes in
    helios/src/server/runtime.rs into one pass.
  - Fail closed when prefill_chunk_size is absent for cores declaring
    packed prefill in ignition/preparation/model.py (with test) and
    simplify total_tokens > graph.packed_tokens in packing.rs.

Validated:
- Layer 1: helios release --features runtime-core,server with prepared
  templates (1,919 lib + 62 integration passed, 0 failed); pytest on
  test_execution.py and test_scheduling_*.py (894 passed, 0 failed).
- Layer 2: scripts/scheduling_sim/learning.py screen (7x3x16) and
  validate (62x3x64, complete_core_suite=True, complete_validation_suite=True).
- Layer 3: verification/helios-lifecycle/check.py (all 9 TLA+ models,
  2,450 Lifecycle.tla edges) and all 3 packed-prefill mutations detected.

Discord: el8
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@original-el8

Copy link
Copy Markdown
Collaborator Author

Updated in 4e3e2c3d to resolve the Layer 2 / Layer 3 verification blocker and all Subtract/Simplify and Nit items:

  1. Layer 3 formal conformance & mutation testing (helios/src/scheduler/lifecycle_tests.rs, verification/helios-lifecycle/check.py, helios/src/model/tests.rs):
    • Added packed_prefill_scheduler_matches_lifecycle_model (322 states, 740 observed edges covering pipelined non-terminal B = 2 Prefill with barrier = 0, feedback-exclusive B = 2 TerminalPrefill with barrier = 1, cancellation during an in-flight packed prefill submission with deferred slot retirement, and stale packed-prefill plan rejection).
    • Verified python3 verification/helios-lifecycle/check.py end-to-end across all 9 TLA+ models (2,450 observed Lifecycle.tla transitions = 1,710 existing + 740 packed prefill).
    • Added three packed-prefill safety-guard mutations to check.py --mutations (packed prefill image lane bypass, packed prefill aggregate token cap bypass, and packed prefill non-terminal classification bypass) and closed the missing direct pack_inputs negative tests (live.image_slot.is_some() and aggregate total_tokens > P) in helios/src/model/tests.rs. All three new mutations (and existing suite mutations) are detected.
  2. Layer 2 scheduling simulator (scripts/scheduling_sim/ & tests/test_scheduling_sim.py):
    • Extended Graph, GraphSpec, candidates, LearningScheduler, UtilityScheduler, simulator, and workloads.catalog(packed_prefill=True) with prefill_batch_capacity / packed_token_capacity and two-order greedy cohort selection mirroring RequestScheduler::select_packed_prefill_cohort, while scoping solo prefill interpolation to prefill_batch_capacity == 1.
    • Ran pytest tests/preparation/test_execution.py tests/test_scheduling_*.py (894 passed, 0 failed), scripts/scheduling_sim/learning.py --preset screen (7 scenarios × 3 configs × 16 seeds), and --preset validate (62 scenarios × 3 configs × 64 seeds; complete_core_suite=True, complete_validation_suite=True, 0/64 stationary false resets).
    • Synthetic GB10 burst check (gb10_catalog + packed-b4-w512-p2048 / packed-b8-w512-p4096): 4×512 burst elapsed 392.0 → 227.0 ms (1.73×, mean TTFT 245.0 → 227.0 ms), 8×512 burst elapsed 784.0 → 380.0 ms (2.06×, mean TTFT 441.0 → 380.0 ms), 16×256 burst elapsed 1,040.0 → 760.0 ms (1.37×).
  3. Subtract / Simplify & Nits:
    • Removed the duplicate valid_packed_prefill_geometry call in ExecutionManifest::validate (helios/src/execution/manifest.rs).
    • Unified packed prefill offer gathering (packed_prefill_offers) and finishing-lane fill (fill_finishing_lanes) in helios/src/scheduler/policy.rs, and derived PackedCohort counts from mask.count_ones() / promoted_mask.count_ones().
    • Consolidated the four manifest prefill filter passes in helios/src/server/runtime.rs into a single pass.
    • Made PreparedModel.__init__ (ignition/preparation/model.py) fail closed when prefill_chunk_size is missing for cores declaring packed prefill (with regression test), simplified total_tokens > graph.packed_tokens in helios/src/model/packing.rs, and removed the stale cache_memory.rs bullet from the PR description.
  4. Layer 1 validation:
    • Full release helios suite (--features runtime-core,server with prepared templates): 1,919 lib + 62 integration passed, 0 failed.

Remaining non-code items: explicit project-owner approval from Luke Alonso for widening Contract 3 PREFILL/TERMINAL_PREFILL to B >= 2, and an equivalent-baseline same-FlashInfer-revision A/B benchmark.

@flare-autobot please re-review.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Commit 4e3e2c3 cleanly closes the Layer 3 conformance/mutation gap plus all Round 3 Subtract/Simplify and Nit items, and direct verification finds no blocking code-correctness or hot-path defects in the packed-prefill implementation. One author-conceded governance blocker remains (missing project-owner approval for widening the Contract 3 prefill operation contract), alongside two verified should-fix items on the A/B baseline and learning-scenario coverage.

  • Blockers: 1 · Should fix: 2 · Subtract/Simplify: 4 · Nits: 3
Walkthrough
  • Shared geometry, manifest, catalog, and selection (helios/src/execution.rs:10, helios/src/execution/manifest.rs:452-468,881-900,936-951, helios/src/model/catalog.rs:266-288, helios/src/runtime_core/selection.rs:280-303,366-375, helios/src/scheduler.rs:889-918): enforce valid_packed_prefill_geometry (2 <= B <= max_batch, 1 <= W <= P, 64-aligned P in [max(64, B), min(B * W, i32::MAX)], optional P <= prefill_chunk_size, draft_tokens == 0), keep B == 1 (P == 0) and ScoredPrefill untouched, and drop B >= 2 shapes when --max-concurrency 1.
  • Input packing and runtime dispatch (helios/src/model/packing.rs:113-126,169-179,422-439, helios/src/model/inputs.rs:87-91, helios/src/server/runtime.rs:849-874): forbid vision bindings on B >= 2 prefill graphs, size InputIndexing::PackedToken buffers to P, reject image-conditioned lanes before staging.clear(), drive per-lane SampleEnabled independently, and register solo vs. packed prefill catalogs in a single manifest pass.
  • Scheduler, cost model, and checkpoints (helios/src/scheduler/policy.rs:14-30,1306-1348,1518-1798,2093-2120, helios/src/scheduler/cost.rs:581-583,606-607,644-659,969-971, helios/src/scheduler/checkpoints.rs:925-936, helios/src/scheduler.rs:436-463,937-956,2615-2617): unify offer gathering (packed_prefill_offers), finishing-lane fill (fill_finishing_lanes), and cohort selection (select_packed_prefill_cohort with derived PackedCohort bitmask counts and promoted-lane seeding), scope PrefillCostModel and context-slope borrowing to batch == 1 (ReplayTimes for batch >= 2), and validate packed lane geometry in ScheduledStep::validate_mixed.
  • Ignition and direct mode (ignition/preparation/execution.py:80-96, ignition/preparation/model.py:32-39, ignition/cli/serve.py:465-469, ignition/direct/scheduler.py:197-202,290-291): validate (B >= 2, W, P) text-only prefill signatures, fail closed in PreparedModel.__init__ when prefill_chunk_size is missing or exceeded, scope --packed-verification to speculative signatures, and isolate direct-mode B == 1 prefill catalogs.
  • Verification layers and docs (helios/src/scheduler/lifecycle_tests.rs:64-192,849-946, verification/helios-lifecycle/check.py:18,185,255,748-801, scripts/scheduling_sim/{model,timing,scheduler,simulator,utility,learning_policy,workloads}.py, tests/test_scheduling_sim.py:324-352, docs/packed-prefill-design.md, docs/scheduling-runtime-design.md:21-25,455-475, helios/model-contract.md:188-209): add Lifecycle.tla conformance coverage and three packed-prefill mutation guards, extend the Python scheduling simulator to multi-lane packed prefill, and synchronize Contract 3 and scheduler design docs.
Merge Risk: High · up to 4e3e2c3
  • Widens the Contract 3 PREFILL/TERMINAL_PREFILL captured-graph operation contract (batch_capacity >= 2, aggregate P-row PACKED_TOKEN layout, per-lane SAMPLE_ENABLED completion, binding-derived vision exclusion) without recorded project-owner approval under docs/design-review.md:22-26.
  • Modifies +415/-39 lines in helios/src/scheduler/policy.rs and changes timing-estimation rules (cost.rs + learning_policy.py) while scripts/scheduling_sim/learning_scenarios.py has zero packed_prefill=True scenarios, and overlaps 8 shared files (including policy.rs, cost.rs, scheduler.rs, docs/scheduling-runtime-design.md) with maintainer PR #729.
  • The headline 1.68×–4.15× TTFT and 1.75×–4.23× throughput A/B compares two different signed cores exported across different FlashInfer revisions (C=1 solo control 0.94×), so the speedup is not yet isolated on an equivalent baseline.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: No prompt-injection or instruction-redirection content in the PR body, comments, or diff; all review requests and provenance notes were treated strictly as content.
  • ✅ Charter & value fit: Model-agnostic Helios runtime (capacities read from core metadata via packed_prefill_graphs(), no per-model branches or hardcoded bucket lists), backward-compatible with pre-change cores (887785ad), and authored by priority contributor @original-el8.
  • ⚠️ Related / duplicate / conflict check: Genuinely additive with no duplication, but overlaps 8 files with maintainer PR #729 (including policy.rs, cost.rs, scheduler.rs, docs/scheduling-runtime-design.md) plus active scheduling/admission PRs (#621, #693, #718).
  • ⚠️ Tests & verification evidence: Layer 1 (1,919 lib + 62 integration + 894 pytest) and Layer 3 (Lifecycle.tla packed conformance + 3 mutation guards) are now solid, but Layer 2's learning_scenarios.py catalog does not yet exercise packed_prefill=True and the live A/B baseline crosses FlashInfer revisions.

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.

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. community Community discussion or feedback without an actionable defect or feature request. enhancement New feature or request 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.

2 participants