Skip to content

helios,selene,selene-manager: add prefill-only KV handoff, announce barrier, and bounded pool-only capture - #718

Closed
fakoli wants to merge 2 commits into
NVIDIA:mainfrom
fakoli:feat/prefill-only-kv-handoff
Closed

fakoli wants to merge 2 commits into
NVIDIA:mainfrom
fakoli:feat/prefill-only-kv-handoff

Conversation

@fakoli

@fakoli fakoli commented Dec 4, 2026 •

Copy link
Copy Markdown

Why

Disaggregated prefill-to-decode serving over a shared Selene prefix-cache pool requires deterministic prompt-endpoint publication and an ordering confirmation before an external router dispatches the decode request to a separate worker. Without dedicated prefill-only handling, three gaps block reliable zero-delay HTTP handoff:

  1. Normal generation requests anchor checkpoints at interior message boundaries (LiveRequest::checkpoint_anchor) and price tail-endpoint snapshots against checkpoint_extra_work_fraction (with single-flight discovery of unmeasured snapshot or prefill graph costs), so a caller probing with max_tokens=1 can skip publishing the full prompt endpoint or execute decode and streaming steps unnecessarily.
  2. PooledStore::store returns before queued NoticeBatch frames are processed by selene-manager, so an immediate decode request on a peer worker can race ahead of pool index visibility unless the caller sleeps heuristically.
  3. Under --prefix-cache-pool with --prefix-cache-memory 0 (PrefixCacheOffload::pool_only()), prepare_with_inputs sizes the capture slab to the full multi-sequence GPU KV capacity (local_pages plus one row's slots, roughly 33 GiB on an RTX PRO 6000 96 GiB GPU for 1M-context cores), even though any single sequence checkpoint chain cannot exceed max_sequence_tokens.

Keeping disaggregated orchestration in an external caller with an HTTP opt-in header and an ordered pool barrier avoids changing selene.proto wire schemas, RequestPhase, GraphKind, or multi-host scheduling while keeping default request scheduling unchanged.

What changed

  • Scheduler & Helios runtime (helios/src/scheduler.rs, helios/src/scheduler/checkpoints.rs, helios/src/server/request.rs, helios/src/server/runtime.rs):

    • Before: checkpoint_anchor() stopped at the last eligible message boundary, deferred copy-out under tight host headroom skipped announcing GPU checkpoints to the pool, and finished requests always entered decode or token streaming unless stopped by token limits.
    • After: Added prefill_only: bool on runtime::Prompt, RequestSpec, and LiveRequest (propagated in Incoming::spec()), plus RequestScheduler::checkpoint_key(CheckpointId). When prefill_only is set, checkpoint_anchor() returns self.prompt_tokens, suppressed generation emits GenerationEvent::Finished { generated_tokens: 0, reason: "prefill", .. }, pending_prefill_finishes waits for Worker::service_store and requests HostStore::announce_barrier() when a prompt-end checkpoint key was published, and fail_all propagates worker failures to pending prefill completions. When Worker::service_store defers host copy-out due to headroom, it calls HostStore::announce_gpu(&publication) so GPU-resident checkpoints are still advertised to the pool.
  • Selene pool announce barrier & GPU announcement (selene/src/store.rs, selene/src/pool/shared.rs, selene/src/pool/lookup.rs, selene/src/pool/engine/mod.rs, selene/src/pool/store.rs, selene-manager/src/pool/lookup.rs):

    • Before: PooledStore only announced GPU checkpoints inside store(), offered no completion barrier after queued NoticeBatch frames, and selene-manager returned empty results without guaranteeing prior batch ordering for empty lookups.
    • After: Added HostStore::announce_gpu, HostStore::announce_barrier returning Option<AnnounceTicket>, and PoolClient::announce_barrier backed by AnnounceBarrier (ANNOUNCE_BARRIER_TIMEOUT = 5s). After flushing pending NoticeBatch frames on a ready session (respecting max_notices_per_batch), the engine emits an empty-boundary WireLookupRequest sentinel whose LookupOk reply resolves queued AnnounceTicket waiters. PooledStore::gpu_index_entry shares GPU index-entry construction across HostStore::store() and HostStore::evicted().
  • HTTP API (helios/src/server/http.rs, docs/api.md):

    • Before: /v1/chat/completions, /v1/completions, /v1/messages, and /v1/responses ignored prefill-only headers.
    • After: Added single-header X-Flare-Prefill-Only (true/1/false/0, case-insensitive; duplicate or malformed headers return HTTP 400, as does enabling true/1 on /v1/messages/count_tokens or multi-prompt /v1/completions batches). Prefill-only requests return HTTP 200 JSON (object: "prefill", checkpoint: { tokens, key, announced }) with X-Request-Id, X-Flare-Pool-Announced (true/false), and X-Flare-Checkpoint-Key (omitted when key is null), even when "stream": true is sent.
  • Single-sequence pool_only() capture bound & docs (selene/src/offload.rs, helios/src/runtime_core/memory.rs, helios/src/runtime_core/model.rs, docs/prefix-cache-offload.md):

    • Before: PrefixCacheOffload::pool_only() and host memory planning sized the CPU capture slab and headroom reserves to full GPU KV capacity (local_pages).
    • After: Added PrepareInputs::max_sequence_pages: Option<u64> populated from max_sequence_tokens.div_ceil(page_tokens) in runtime_core::model and runtime_core::memory; memory.rs also clamps minimum_pages, capture_growth, and planned_offload_host by max_sequence_pages so KV and host-budget planning match the capped capture slab. pool_only() bounds chain capture pages to local_pages.min(limit) when limit > 0 while preserving unbounded local_pages sizing for None or Some(0). Added an operational note in docs/prefix-cache-offload.md documenting that selene-manager backs staging with a power-of-two buddy allocator (Arena), so non-power-of-two --staging values split into descending power-of-two blocks and single >8 GiB exports require --staging 16G to avoid NoWindows.

Claimed benefit

An external HTTP router or client can offload prompt prefill to a dedicated prefill worker using X-Flare-Prefill-Only: true, wait for deterministic pool visibility via X-Flare-Pool-Announced: true without timer heuristics, and dispatch the request to a decode worker for immediate Selene KV pool reuse. Bounding pool_only() capture to prepared max-sequence pages limits the capture buffer on a 1M-context JMNI-Labs/Inkling-2-Mini-FLARE RTX PRO 6000 96 GiB prefill rank from full GPU-KV sizing (~33 GiB) down to one sequence chain plus one row (9.1 GiB / 8,293 slots), lowering combined committed RSS across selene, prefill, and decode ranks from 46.02 GiB to 41.77 GiB on 122 GiB host RAM (measuring committed pages rather than virtual reservation).

Tradeoffs and limitations of a 1-prefill / 1-decode worker (1P1D) deployment compared to two homogeneous TP1 replicas over the same GPUs: dedicating one GPU solely to decode isolates decode steps from concurrent prefill stalls under mixed concurrency (improving tail inter-token latency at Mixed C8), whereas single-stream concurrency-1 (C1) ultra-long requests (768K–960K) incur Selene copy/restore overhead and use only one GPU for decoding. Host DRAM footprint for 1P1D with Selene pool memory (16 GiB pool + 6 GiB staging + 9.1 GiB capture buffer, 41.77 GiB combined RSS) is higher than stateless 2x TP1 replicas (6.74 GiB combined host RAM). Live dual-GPU measurements below reflect the combined external router + Selene pool + disaggregated topology on the tested builds rather than isolated single-component benchmarks.

Evidence

Rebased focused checks on f705086 (#720, including #721 fix with no #714 workaround)

Executed inside flare-test-env:1.94.1 (--security-opt seccomp=unconfined --ulimit memlock=-1:-1 --ipc host):

  • flare-helios (cargo test --locked --features runtime-core,server --lib prefill_only): 4 passed, 0 failed (1,393 filtered)
  • flare-selene (cargo test --locked --features test-support --lib pool_only_caps_capture_buffer_to_max_sequence_pages): 1 passed, 0 failed (587 filtered)
  • flare-selene (cargo test --locked --features test-support --lib announce): 23 passed, 0 failed (565 filtered)
  • flare-selene-manager (cargo test --locked --features test-support --lib empty_boundary): 1 passed, 0 failed (206 filtered)

Full Rust suites and TLA+ lifecycle conformance on 45e1c1a baseline

Executed inside flare-test-env:1.94.1 (--security-opt seccomp=unconfined --ulimit memlock=-1:-1 --ipc host) with RUSTFLAGS="-D warnings" and FLARE_TEST_TEMPLATE_DIR prepared via tests/frontend/prepare_templates.py:

  • flare-eos: 12 passed, 0 failed, 0 ignored (cargo check --all-targets clean)
  • flare-selene (--features test-support): 589 passed, 0 failed, 0 ignored (cargo check --all-targets clean)
  • flare-selene-manager (--features test-support, --test-threads=1): 449 passed, 0 failed, 1 ignored (cargo check --all-targets clean)
  • flare-helios (--features runtime-core,server): 1,961 passed, 0 failed, 86 ignored (cargo check --lib clean; tested locally with a one-line fix for the missing external_extents field in helios/src/runtime_core/cache_memory.rs:1659 on 45e1c1a, later superseded by #721 / b10e1221 which closed #714)
  • flare: 255 passed, 0 failed, 4 ignored (cargo check --lib clean)
  • flare-cli: 248 passed, 0 failed, 3 ignored (cargo check --all-targets clean)
  • Total: 3,514 passed, 0 failed, 94 ignored (cargo test --locked --release)
  • verification/helios-lifecycle/check.py --tlc-jar tla2tools.jar --mutations: all 9 TLA+ model runs, observed Rust transition checks (1,710 Lifecycle, 1,291 RankProtocol, 7,940 DispatchRing, 8,490 OffloadTransfer, 222,817 CacheOwnership, 13,566 Speculation, 365,508 ResponseLifecycle, 68 CheckpointReservation, 314 AsyncTransfer), and Rust/TLA+ mutation gates passed (0 failures)

New unit and HTTP tests added across commits cover: prefill_only anchoring without snapshot costs or extra-work budget (helios/src/scheduler/checkpoints.rs), ordered AnnounceBarrier + AnnounceTicket completion (helios/src/server/runtime/phase_tests.rs, selene/src/pool/lookup.rs, selene/src/pool/engine/tests.rs, selene-manager/src/pool/lookup.rs), single/duplicate header HTTP 400 validation (helios/src/server/http.rs), and pool_only_caps_capture_buffer_to_max_sequence_pages (selene/src/offload/tests.rs).

Additional dual-GPU Qwen4-35B-A3B-FLARE live 1P1D validation (rebased onto f705086 + #716)

  • Conditions: Two NVIDIA RTX PRO 6000 Blackwell Workstation Edition GPUs (96 GiB each) on Linux (122 GiB host RAM), local-inference-lab/Qwen4-35B-A3B-FLARE (1,048,576 max context, disk-backed io_uring NVFP4 PLE Engram, pool_only() prefill capture bounded to 11.8 GiB / 16,475 slots) behind an external HTTP prefill_offload router (min_body_bytes=8192).
  • Capacity sweeps (temp=0.6, max_tokens=4096): 119/119 completions (0 failures), 4K C1 15,056 tok/s prefill / 326.1 tok/s decode p50, and Mixed C8 303.0 tok/s decode p50 (3.21 / 3.79 ms ITL p50/p95).
  • Native multimodal 1P1D handoff: 102/102 cached tokens (multimodal_tokens: {"image": 64}) handed off from prefill to decode over Selene.
  • Long-context Selene staging validation (NoWindows avoidance): Rebalancing selene-manager to --memory 6G --staging 16G (providing a contiguous 16 GiB buddy block vs --staging 14G splitting into 8G + 4G + 2G) eliminated NoWindows (8 -> 0) and delivered 100% cached KV handoff at 524K (528,059/528,059 cached, TTFT = 32.412s vs 66.03s, 2.04x faster) and 960K (960,056/960,056 cached, TTFT = 69.236s vs 140.15s, 2.02x faster).

Combined-stack dual-GPU measurements on pre-rebase JMNI-Labs/Inkling-2-Mini-FLARE builds (prior to 45e1c1a rebase)

  • Conditions: Two NVIDIA RTX PRO 6000 Blackwell Workstation Edition GPUs (SM120, 96 GiB each) on Linux (122 GiB host RAM), JMNI-Labs/Inkling-2-Mini-FLARE (1,048,576 max context), selene pool (16G memory, 6G staging, 24G /dev/shm) behind an external HTTP prefill_offload router (min_body_bytes=8192). Baseline comparison runs used 2x TP1 stock v0.5.3 replicas (prior to intervening main commits through 45e1c1a).
  • Pre-bound comparison (1P1D without max_sequence_pages cap vs stock v0.5.3 2x TP1 replicas):
    • Mixed-context concurrency 8 (Mixed C8, 16 requests sampled across prompt lengths up to the context window, --max-tokens 4096): 1P1D returned 16/16 HTTP 200 EOS completions at 200.8 tok/s median decode and 4.67 / 5.85 ms nearest-rank p50/p95 inter-token latency (369.0 tok/s aggregate output), vs 2x TP1 returning 16/16 HTTP 200 completions (15 EOS stops and 1 max_tokens=4096 length stop, 157.6 tok/s, 6.34 / 8.55 ms ITL).
    • Fixed-context concurrency 16 (4K C16, 32 requests, --max-tokens 4096): 1P1D reached 1,516.6 tok/s aggregate output (32/32 EOS, 0.81s time to first output [TTFO] p50).
    • Single-stream (C1) context ladder (32K–960K, n=2..3): both 1P1D and 2x TP1 passed 2/2 through 960,000 tokens (1P1D 344.84s vs 2x TP1 173.78s TTFO p50 at 960K).
    • Selene metrics counters across the campaign: 1,000 ok puts (0 errors), 1,647 LookupOk lookups, and 433 Copied claims.
  • Bounded pool_only() live verification: Prefill capture buffer configured to 9.1 GiB (8,293 slots, --prefix-cache-memory 0), lowering combined committed RSS of (selene + prefill + decode) from 46.02 GiB to 41.77 GiB; duplicate X-Flare-Prefill-Only headers returned HTTP 400; a routed 7,765-token smoke request returned cached tokens over Selene with +1 Copied claim and +1 ok put (0 errors).

Unrun checks

  • Hardware CUDA tests (FLARE_RUN_CUDA_TESTS=1), multi-host RoCE/RDMA suites, Windows native build/tests, Python ignition CPU/GPU suites on this branch, and Kani proofs (no Kani-proven validators were modified) have not been run on the rebased branch and rely on CI or maintainer runs.
  • Full 3,514-test release suite and TLA+ mutation runs were executed on the 45e1c1a baseline; after the f705086 rebase, the targeted flare-helios, flare-selene, and flare-selene-manager unit tests listed above were re-verified.

Discord: fakoli

Why:
Disaggregated prefill-to-decode serving over a shared Selene pool needs
deterministic prompt-endpoint checkpoint publication and ordered visibility
confirmation before an external router dispatches the decode hop. Without
prefill-only request handling, normal checkpoint selection anchors interior
message boundaries and PooledStore::store returns before selene-manager processes
queued NoticeBatch frames.

What changed:
- Scheduler & Helios runtime: Added prefill_only: bool on runtime::Prompt,
  RequestSpec, and LiveRequest (propagated in Incoming::spec()) and
  RequestScheduler::checkpoint_key(). Prefill-only requests anchor at
  prompt_tokens, skip decode/token streaming, call HostStore::announce_gpu when
  headroom defers copy-out, and wait on HostStore::announce_barrier().
- Selene & selene-manager: Added AnnounceBarrier / AnnounceTicket in selene::pool
  (flushing queued NoticeBatch frames before an empty-boundary LookupRequest
  sentinel) and HostStore::announce_gpu / announce_barrier, sharing GPU index
  construction via PooledStore::gpu_index_entry across store() and evicted().
- HTTP API & docs (helios/src/server/http.rs, docs/api.md): Added single-header
  X-Flare-Prefill-Only (`true`/`1`/`false`/`0`; duplicate/malformed headers and
  enabling on count_tokens or multi-prompt completions return HTTP 400), JSON
  object "prefill" responses, X-Flare-Pool-Announced, and X-Flare-Checkpoint-Key.

Claimed benefit:
Allows an external caller to offload prompt prefill and dispatch decode once
X-Flare-Pool-Announced: true is returned without heuristic delays or wire schema
changes, keeping normal scheduling unchanged. Combined 1P1D throughput/latency
results depend on external routing and shared pool hardware.

Evidence:
- 6-crate release test suite (flare-eos 12, flare-selene 589,
  flare-selene-manager 449, flare-helios 1961 with temporary NVIDIA#714 cache_memory
  build fix, flare 255, flare-cli 248): 3,514 passed, 0 failed, 94 ignored.
- verification/helios-lifecycle/check.py --mutations: all 9 TLA+ models,
  observed transition checks, and mutation checks passed.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: fakoli <fakoli@users.noreply.github.com>
Why:
Under --prefix-cache-pool with --prefix-cache-memory 0 (pool_only()), the host
capture slab and runtime_core::memory headroom planning previously sized
buffers for full multi-sequence GPU KV capacity (~33 GiB on an RTX PRO 6000
96 GiB card for 1M-context cores), even though any single sequence chain
cannot exceed max_sequence_tokens.

What changed:
- selene/src/offload.rs: Added PrepareInputs::max_sequence_pages: Option<u64>
  and capped pool_only() chain capture slots to local_pages.min(limit) +
  row_slots when limit > 0, keeping unbounded local_pages for None / Some(0).
- helios/src/runtime_core/{memory,model}.rs: Computed max_sequence_pages =
  max_sequence_tokens.div_ceil(page_tokens), passed it to PrepareInputs, and
  clamped minimum_pages, capture_growth, and planned_offload_host in memory.rs.
- docs/prefix-cache-offload.md & tests: Documented prepared max-sequence page
  capping and power-of-two --staging (Arena) sizing behavior for NoWindows
  avoidance on >8 GiB exports, and added
  pool_only_caps_capture_buffer_to_max_sequence_pages.

Claimed benefit:
Bounds pool_only() host capture allocation on a 1M-context JMNI-Labs/Inkling-2-Mini-FLARE
RTX PRO 6000 96 GiB prefill rank to one sequence chain plus one row (9.1 GiB /
8,293 slots), reducing combined committed RSS across selene, prefill, and decode
from 46.02 GiB to 41.77 GiB. Multi-sequence simultaneous capture still requires
explicit --prefix-cache-memory.

Evidence:
- 6-crate RUSTFLAGS="-D warnings" cargo check and release test suite (3,514
  passed, 0 failed, 94 ignored) on 45e1c1a baseline, plus focused re-verification
  of flare-helios, flare-selene, and flare-selene-manager tests after rebase
  onto f705086 (NVIDIA#720) including pool_only_caps_capture_buffer_to_max_sequence_pages.
- verification/helios-lifecycle/check.py --mutations passed all TLA+ models and
  observed Rust transitions on 45e1c1a.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: fakoli <fakoli@users.noreply.github.com>
@fakoli
fakoli force-pushed the feat/prefill-only-kv-handoff branch from 2c2154c to 17a532e Compare December 4, 2026 17:23
@fakoli
fakoli marked this pull request as ready for review December 4, 2026 17:23
@flare-autobot

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

Review Stopped

Auto-Review halted due to finding: It is low value or does not align with the project charter.
Value Proposition Report

@flare-autobot flare-autobot added area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. 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. labels Dec 4, 2026
@fakoli

fakoli commented Dec 5, 2026

Copy link
Copy Markdown
Author

Closing this PR after the triage review: the bundled X-Flare-Prefill-Only serving mode touches the disaggregation boundary already declined in #160 without prior owner sign-off, and keeping both changes together blocked review of the #455 capture-buffer fix.

  • Focused #455 follow-up: Opened https://github.com/NVIDIA/hyperflare-inference/pull/742 containing only the pool_only() max_sequence_pages capture bound, docs/prefix-cache-offload.md update, Qwen4-35B-A3B per-process memory accounting, and 6-crate test results directly on its head commit.
  • Disaggregation benchmark & scope request: Posted our 1P1D vs 2x TP1 and Qwen4-35B-A3B measurement summary on Roadmap question: prefill/decode disaggregation roles, now that the prefix cache pool exists? #160 per @yatesdr's reopen guidance for an explicit scope decision from @lukealonso before proposing any pool-visibility or prefill-only primitive separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants