Repository navigation
Conversation
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
force-pushed
the
feat/prefill-only-kv-handoff
branch
from
December 4, 2026 17:23
2c2154c to
17a532e
Compare
fakoli
marked this pull request as ready for review
December 4, 2026 17:23
Collaborator
|
A case file has been opened for 718. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Collaborator
Review StoppedAuto-Review halted due to finding: It is low value or does not align with the project charter. |
Author
|
Closing this PR after the triage review: the bundled
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
LiveRequest::checkpoint_anchor) and price tail-endpoint snapshots againstcheckpoint_extra_work_fraction(with single-flight discovery of unmeasured snapshot or prefill graph costs), so a caller probing withmax_tokens=1can skip publishing the full prompt endpoint or execute decode and streaming steps unnecessarily.PooledStore::storereturns before queuedNoticeBatchframes are processed byselene-manager, so an immediate decode request on a peer worker can race ahead of pool index visibility unless the caller sleeps heuristically.--prefix-cache-poolwith--prefix-cache-memory 0(PrefixCacheOffload::pool_only()),prepare_with_inputssizes the capture slab to the full multi-sequence GPU KV capacity (local_pagesplus one row's slots, roughly33 GiBon an RTX PRO 600096 GiBGPU for 1M-context cores), even though any single sequence checkpoint chain cannot exceedmax_sequence_tokens.Keeping disaggregated orchestration in an external caller with an HTTP opt-in header and an ordered pool barrier avoids changing
selene.protowire 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):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.prefill_only: boolonruntime::Prompt,RequestSpec, andLiveRequest(propagated inIncoming::spec()), plusRequestScheduler::checkpoint_key(CheckpointId). Whenprefill_onlyis set,checkpoint_anchor()returnsself.prompt_tokens, suppressed generation emitsGenerationEvent::Finished { generated_tokens: 0, reason: "prefill", .. },pending_prefill_finisheswaits forWorker::service_storeand requestsHostStore::announce_barrier()when a prompt-end checkpoint key was published, andfail_allpropagates worker failures to pending prefill completions. WhenWorker::service_storedefers host copy-out due to headroom, it callsHostStore::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):PooledStoreonly announced GPU checkpoints insidestore(), offered no completion barrier after queuedNoticeBatchframes, andselene-managerreturned empty results without guaranteeing prior batch ordering for empty lookups.HostStore::announce_gpu,HostStore::announce_barrierreturningOption<AnnounceTicket>, andPoolClient::announce_barrierbacked byAnnounceBarrier(ANNOUNCE_BARRIER_TIMEOUT = 5s). After flushing pendingNoticeBatchframes on a ready session (respectingmax_notices_per_batch), the engine emits an empty-boundaryWireLookupRequestsentinel whoseLookupOkreply resolves queuedAnnounceTicketwaiters.PooledStore::gpu_index_entryshares GPU index-entry construction acrossHostStore::store()andHostStore::evicted().HTTP API (
helios/src/server/http.rs,docs/api.md):/v1/chat/completions,/v1/completions,/v1/messages, and/v1/responsesignored prefill-only headers.X-Flare-Prefill-Only(true/1/false/0, case-insensitive; duplicate or malformed headers return HTTP 400, as does enablingtrue/1on/v1/messages/count_tokensor multi-prompt/v1/completionsbatches). Prefill-only requests return HTTP 200 JSON (object: "prefill",checkpoint: { tokens, key, announced }) withX-Request-Id,X-Flare-Pool-Announced(true/false), andX-Flare-Checkpoint-Key(omitted whenkeyisnull), even when"stream": trueis 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):PrefixCacheOffload::pool_only()and host memory planning sized the CPU capture slab and headroom reserves to full GPU KV capacity (local_pages).PrepareInputs::max_sequence_pages: Option<u64>populated frommax_sequence_tokens.div_ceil(page_tokens)inruntime_core::modelandruntime_core::memory;memory.rsalso clampsminimum_pages,capture_growth, andplanned_offload_hostbymax_sequence_pagesso KV and host-budget planning match the capped capture slab.pool_only()bounds chain capture pages tolocal_pages.min(limit)whenlimit > 0while preserving unboundedlocal_pagessizing forNoneorSome(0). Added an operational note indocs/prefix-cache-offload.mddocumenting thatselene-managerbacks staging with a power-of-two buddy allocator (Arena), so non-power-of-two--stagingvalues split into descending power-of-two blocks and single>8 GiBexports require--staging 16Gto avoidNoWindows.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 viaX-Flare-Pool-Announced: truewithout timer heuristics, and dispatch the request to a decode worker for immediate Selene KV pool reuse. Boundingpool_only()capture to prepared max-sequence pages limits the capture buffer on a 1M-contextJMNI-Labs/Inkling-2-Mini-FLARERTX PRO 600096 GiBprefill rank from full GPU-KV sizing (~33 GiB) down to one sequence chain plus one row (9.1 GiB/8,293slots), lowering combined committed RSS acrossselene, prefill, and decode ranks from46.02 GiBto41.77 GiBon122 GiBhost RAM (measuring committed pages rather than virtual reservation).Tradeoffs and limitations of a 1-prefill / 1-decode worker (
1P1D) deployment compared to two homogeneousTP1replicas 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 atMixed 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 for1P1Dwith Selene pool memory (16 GiBpool +6 GiBstaging +9.1 GiBcapture buffer,41.77 GiBcombined RSS) is higher than stateless2x TP1replicas (6.74 GiBcombined 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#721fix with no#714workaround)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,393filtered)flare-selene(cargo test --locked --features test-support --lib pool_only_caps_capture_buffer_to_max_sequence_pages):1 passed, 0 failed(587filtered)flare-selene(cargo test --locked --features test-support --lib announce):23 passed, 0 failed(565filtered)flare-selene-manager(cargo test --locked --features test-support --lib empty_boundary):1 passed, 0 failed(206filtered)Full Rust suites and TLA+ lifecycle conformance on
45e1c1abaselineExecuted inside
flare-test-env:1.94.1(--security-opt seccomp=unconfined --ulimit memlock=-1:-1 --ipc host) withRUSTFLAGS="-D warnings"andFLARE_TEST_TEMPLATE_DIRprepared viatests/frontend/prepare_templates.py:flare-eos: 12 passed, 0 failed, 0 ignored (cargo check --all-targetsclean)flare-selene(--features test-support): 589 passed, 0 failed, 0 ignored (cargo check --all-targetsclean)flare-selene-manager(--features test-support,--test-threads=1): 449 passed, 0 failed, 1 ignored (cargo check --all-targetsclean)flare-helios(--features runtime-core,server): 1,961 passed, 0 failed, 86 ignored (cargo check --libclean; tested locally with a one-line fix for the missingexternal_extentsfield inhelios/src/runtime_core/cache_memory.rs:1659on45e1c1a, later superseded by#721/b10e1221which closed#714)flare: 255 passed, 0 failed, 4 ignored (cargo check --libclean)flare-cli: 248 passed, 0 failed, 3 ignored (cargo check --all-targetsclean)cargo test --locked --release)verification/helios-lifecycle/check.py --tlc-jar tla2tools.jar --mutations: all 9 TLA+ model runs, observed Rust transition checks (1,710Lifecycle, 1,291RankProtocol, 7,940DispatchRing, 8,490OffloadTransfer, 222,817CacheOwnership, 13,566Speculation, 365,508ResponseLifecycle, 68CheckpointReservation, 314AsyncTransfer), and Rust/TLA+ mutation gates passed (0failures)New unit and HTTP tests added across commits cover:
prefill_onlyanchoring without snapshot costs or extra-work budget (helios/src/scheduler/checkpoints.rs), orderedAnnounceBarrier+AnnounceTicketcompletion (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), andpool_only_caps_capture_buffer_to_max_sequence_pages(selene/src/offload/tests.rs).Additional dual-GPU
Qwen4-35B-A3B-FLARElive1P1Dvalidation (rebased ontof705086+#716)96 GiBeach) on Linux (122 GiBhost RAM),local-inference-lab/Qwen4-35B-A3B-FLARE(1,048,576max context, disk-backedio_uringNVFP4 PLE Engram,pool_only()prefill capture bounded to11.8 GiB/16,475slots) behind an external HTTPprefill_offloadrouter (min_body_bytes=8192).temp=0.6,max_tokens=4096):119/119completions (0failures),4K C115,056 tok/sprefill /326.1 tok/sdecode p50, andMixed C8303.0 tok/sdecode p50 (3.21 / 3.79 msITL p50/p95).1P1Dhandoff:102/102cached tokens (multimodal_tokens: {"image": 64}) handed off from prefill to decode over Selene.NoWindowsavoidance): Rebalancingselene-managerto--memory 6G --staging 16G(providing a contiguous16 GiBbuddy block vs--staging 14Gsplitting into8G + 4G + 2G) eliminatedNoWindows(8 -> 0) and delivered100%cached KV handoff at524K(528,059/528,059cached,TTFT = 32.412svs66.03s,2.04xfaster) and960K(960,056/960,056cached,TTFT = 69.236svs140.15s,2.02xfaster).Combined-stack dual-GPU measurements on pre-rebase
JMNI-Labs/Inkling-2-Mini-FLAREbuilds (prior to45e1c1arebase)96 GiBeach) on Linux (122 GiBhost RAM),JMNI-Labs/Inkling-2-Mini-FLARE(1,048,576max context),selenepool (16Gmemory,6Gstaging,24G/dev/shm) behind an external HTTPprefill_offloadrouter (min_body_bytes=8192). Baseline comparison runs used2x TP1stockv0.5.3replicas (prior to interveningmaincommits through45e1c1a).1P1Dwithoutmax_sequence_pagescap vs stockv0.5.32x TP1replicas):Mixed C8,16requests sampled across prompt lengths up to the context window,--max-tokens 4096):1P1Dreturned16/16HTTP 200 EOS completions at200.8 tok/smedian decode and4.67 / 5.85 msnearest-rank p50/p95 inter-token latency (369.0 tok/saggregate output), vs2x TP1returning16/16HTTP 200 completions (15EOS stops and1max_tokens=4096length stop,157.6 tok/s,6.34 / 8.55 msITL).4K C16,32requests,--max-tokens 4096):1P1Dreached1,516.6 tok/saggregate output (32/32EOS,0.81stime to first output [TTFO] p50).C1) context ladder (32K–960K,n=2..3): both1P1Dand2x TP1passed2/2through960,000tokens (1P1D344.84svs2x TP1173.78sTTFO p50 at960K).metricscounters across the campaign:1,000okputs (0errors),1,647LookupOklookups, and433Copiedclaims.pool_only()live verification: Prefill capture buffer configured to9.1 GiB(8,293slots,--prefix-cache-memory 0), lowering combined committed RSS of (selene+ prefill + decode) from46.02 GiBto41.77 GiB; duplicateX-Flare-Prefill-Onlyheaders returned HTTP 400; a routed7,765-token smoke request returned cached tokens over Selene with+1 Copiedclaim and+1 okput (0errors).Unrun checks
FLARE_RUN_CUDA_TESTS=1), multi-host RoCE/RDMA suites, Windows native build/tests, PythonignitionCPU/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.45e1c1abaseline; after thef705086rebase, the targetedflare-helios,flare-selene, andflare-selene-managerunit tests listed above were re-verified.Discord: fakoli