Splitting Prefill and Decode on Flare: Two Cards, Zero Sleep, and Three Engine Primitives
Splitting prefill and decode across two workstation GPUs over shared host memory with zero router sleep kept speculative decoding alive and cut mixed tail jitter below 26 ms.
Sekou M. Doumbouya
Listen to this article
The views expressed here are my own and do not represent those of any current or former employer.
The stall hit seven seconds before a single token moved. I had two 96 GiB NVIDIA RTX PRO 6000 Blackwell Max-Q cards sitting in a dual-socket workstation over PCIe Gen5 x16, with no NVLink, no RDMA NICs, 122.7 GiB of system RAM, and 62 GiB of /dev/shm. When a 90,831-token prompt landed on Inkling 2 Mini alongside two active decode streams on a single card under SGLang, chunked prefill froze both streams for 7.14 seconds. Moving to SGLang NIXL 1P1D across both cards cut those stalls down to 18.9 to 85.2 milliseconds, which looked like a clean win until I read the throughput logs. SGLang’s inkling2_mtp_worker.py explicitly rejects disaggregated speculative decoding (DSpark-8), cutting uncontended decode speed roughly in half to 106.9 to 129.4 tokens per second.
So I tested unmodified Flare v0.5.3 on a single card. It booted in 12.2 seconds, fifteen to twenty times faster than SGLang’s 190 to 240 seconds, expanded KV capacity 3.6 times to 3.654 million tokens with NVFP4 4o6k, cut host RAM 7.4 times to 2.98 GiB, and hit 304.6 tokens per second decoding 30.3K prompts. Its adaptive chunking even shrank single-GPU mixed stalls roughly eighteen times, down to 390.9 to 404.2 milliseconds. Yet a 400-millisecond stutter is still noticeable when two interactive streams share a card with a 90,000-token ingestion burst. Even with strong single-card throughput and adaptive chunking, strict tail-latency isolation under heavy concurrent prefills still earns disaggregated prefill and decode when two conditions hold: the decode card keeps speculative drafting (DFlash2-7) active, and the serving engine exposes clean endpoint-capture and ordered synchronization primitives rather than fragile router sleeps.
Three Blockers Inside Stock Shared-Memory Handoff
Before writing a line of Rust, I wanted proof that Flare’s selene-manager shared-memory pool could carry Inkling 2 Mini’s hybrid global, sliding-window, and Mamba state across PCIe Gen5 without NVLink or RDMA. Warm diagnostic probes on unmodified Flare v0.5.3 answered that immediately. Once a checkpoint landed in /dev/shm, selene-manager moved a 109,467-token checkpoint (1.05 GiB) from the prefill GPU to the decode GPU in 139.2 milliseconds of end-to-end Decode time to first token, then sustained 309.2 tokens per second with DFlash2-7 drafting enabled and zero prompt recompute. At 36,537 tokens, warm handoffs took 87.0 to 88.7 milliseconds.
The transport worked. The automation around it broke in three places.
First, Helios enforces a 30-second time-to-live on its GraphKind::Snapshot cost estimate inside checkpoint_selection_uncached. If more than 30 seconds pass without a fresh sample, unknown_cost aborts endpoint capture completely. I learned that one the hard way during my first automated suite run, watching every single prompt recompute from scratch on the decode card because I had spent 51 seconds reading earlier probe logs and quietly wandered past the 30-second window. Across those five offloaded prompts, the prefill worker logged 79 unknown_cost skips and zero snapshot publications, inflating 30.3K TTFT to 3.30 seconds, 121.1K TTFT to 17.29 seconds, and mixed-workload wall time to 13.81 seconds.
Second, stock HTTP requests race with NoticeBatch publication. Flare returns the first generated token to the caller before service_store() finishes flushing NoticeBatch frames and indexing the checkpoint inside selene-manager. With zero router sleep, a cold 36,537-token lookup on the decode card missed completely (0 of 36,537 cached tokens) and recomputed the prompt. Adding a 150-millisecond sleep in the router masked the symptom. A sleep call is not a synchronization primitive. It is a bet on timing that loses the moment prompt length or host load shifts. Passing a live KV cache between two GPUs without a barrier is like handing off an assembly-line crate in the dark: if the shipping bay rings the bell before the crate is latched, the next station rebuilds the whole unit from raw stock.
Third, running the workers with --prefix-cache-memory 0 (pool_only()) sizes the host capture buffer from full GPU KV capacity, allocating roughly 33.3 GiB on a single 96 GiB card and exhausting bounded container memory. Switching to --prefix-cache-memory 4G kept each worker around 10.17 to 10.28 GiB RSS and avoided the over-allocation, leaving the pool_only() buffer calculation as an explicit scope boundary to keep the engine patch surgical.
Three Layers and Zero Router Sleep
Fixing stock disaggregation meant adding clean handoff support across three layers of hyperflare-inference (HTTP edge, Helios scheduler, and the selene::pool barrier), with zero selene.proto wire changes and zero new RequestPhase, GraphKind, or GenerationEvent variants. Telemetry belongs on the wire; synchronization does not belong in a sleep call.
At the HTTP edge across chat, completions, messages, and responses endpoints, X-Flare-Prefill-Only (true, 1, false, or 0, rejecting invalid headers, token-counting routes, and multi-prompt batches with HTTP 400) turns a prefill worker into an explicit checkpoint producer. The runtime forces a minimal decode step, suppresses generated tokens and stream events, waits for service_store() and the pool barrier, and returns an HTTP 200 JSON receipt even when the client requested "stream": true. That response carries X-Request-Id, X-Flare-Pool-Announced, and X-Flare-Checkpoint-Key in headers alongside a compact body:
{
"id": "chatcmpl-020198a60e606a6e-1",
"object": "prefill",
"created": 1796292510,
"model": "inkling2-mini-flare",
"usage": {
"prompt_tokens": 923,
"prompt_tokens_details": { "cached_tokens": 0 }
},
"checkpoint": {
"tokens": 923,
"key": "aaec795b5aed21d6954b55643d9a6b21",
"announced": true
}
}
Inside the Helios scheduler, RequestSpec.prefill_only and LiveRequest.prefill_only route into checkpoint_anchor(), which captures exact prompt_tokens with RetentionRole::Anchor and looks up the key via checkpoint_key(). When snapshots > 0, prefill_only bypasses fraction == 0.0, the 30-second Snapshot cost TTL expiry, and extra-work budget gates without altering normal colocated request heuristics.
Inside selene::pool, AnnounceBarrier, AnnounceTicket, Registry.barriers, and SessionEngine::send_announce_barrier close the publish race without altering the protobuf wire schema. After flushing queued NoticeBatch frames over the ordered session stream, the worker sends an empty-boundary LookupRequest sentinel as a FIFO barrier that fails closed on disconnect or a five-second timeout (selene-manager already handles this safely, verified by empty_boundary_lookup_succeeds_as_ordered_barrier). Headroom-independent announce_gpu on HostStore and PooledStore pairs with that barrier so committed GPU checkpoints register even when synchronous DRAM export is deferred.
Above those two workers sits a 441-line Python 3 stdlib router (flare_1p1d_router.py, passing three of three offline unit tests). Requests below 8 KiB go straight to Decode. Larger payloads hit Prefill with X-Flare-Prefill-Only: true, verify X-Flare-Pool-Announced: true, and stream to Decode with zero JSON mutation and zero sleep. Across all five Rust crates in cargo test --locked --release, 3,388 tests passed with 91 ignored and zero failed: 555 in flare-selene, 427 in flare-selene-manager, 1,905 in flare-helios including the TLA+ Rust conformance suites, 246 in flare-cli, and 255 in flare. I staged the complete validation branch cleanly on my fork in pull request 1 before proposing anything upstream.
Seven Configurations on One Mixed Workload
With the three-layer patch running against selene-manager (4G pool plus 4G staging in /dev/shm), I re-ran the identical parity, JSON Schema, multi-turn tool-calling, vision, 30.3K and 121.1K long-context, and mixed interference suite across seven configurations. The mixed workload runs two concurrent 1,024-token decode streams alongside a 90,831-token prefill.
The patched Flare 1P1D setup finished the mixed workload in 7.926 seconds, beating SGLang 1P1D at 9.79 seconds and Flare 2x TP1 at 9.85 seconds by nearly two full seconds. While GPU 0 prefills those 90,831 tokens, GPU 1 keeps both active decode streams humming. They sustained 231.4 and 223.8 tokens per second, with worst-case inter-token latency held to 25.2 and 18.3 milliseconds (15.5 and 15.3 milliseconds at p99). Compared to colocated Flare’s 390.9 to 432.6 millisecond stalls, that is a sixteen to twenty-four times reduction in tail decode jitter.
Not one handoff relied on a sleep timer. Across the validation and benchmark suite, 9 out of 9 offloaded prompts returned X-Flare-Pool-Announced: true and hit 100 percent cached_tokens reuse on the decode card up to 144,656 prompt tokens. Those nine transfers moved 753,693 cached tokens (7.46 GiB over /dev/shm) with zero fetch failures, zero fallbacks, and zero decode recompute on offloaded requests. End-to-end handoff overhead stayed between 74 and 192 milliseconds (1.671 seconds TTFT and 282.7 tokens per second on 30.3K, then 8.713 seconds TTFT and 266.8 tokens per second on 121.1K). On a deliberate TTL-idle regression test that slept 36 seconds past the 30-second Snapshot TTL before sending a cold 38,746-token prompt, Flare still captured the anchor, announced it, and reused all 38,746 tokens (2.156 seconds TTFT, 310.3 tokens per second decode).
| Metric | SGLang 1x TP1 | SGLang 1P1D NIXL (No DSpark) | SGLang 2x TP1 | Flare 1x TP1 | Flare 2x TP1 | Flare Stock 1P1D (TTL miss baseline) | Flare Patched 1P1D (0 ms sleep) |
|---|---|---|---|---|---|---|---|
| GPUs Used | 1 | 2 (P+D) | 2 | 1 | 2 | 2 (P+D + selene) | 2 (P+D + selene) |
| KV Pool Capacity | 1.015M (BF16) | 1.943M / GPU (BF16) | 2.030M agg (BF16) | 3.654M (NVFP4 4o6k) | 7.307M agg (NVFP4 4o6k) | 3.654M / GPU (NVFP4 4o6k) | 3.654M / GPU (NVFP4 4o6k) |
| Cold Start Time | ~190 s | ~194 s | ~240 s | 12.2 s | ~12 s / GPU | ~12 s / GPU | ~12 s / GPU |
| Host Container RAM | 21.97 GiB | 11.97 GiB | 14.34 GiB | 2.98 GiB | 6.01 GiB | 28.36 GiB total | 20.55 GiB RSS (+ /dev/shm) |
| JSON / Tools / Vision | PASS / PASS / PASS | PASS / PASS / PASS | PASS / PASS / PASS | PASS / PASS / PASS | PASS / PASS / PASS | PASS / PASS / PASS | PASS / PASS / PASS |
| C1 30.3K TTFT | 2.21 s | 2.30 s (+97 ms) | 2.22 s | 1.54 s | 1.59 s | 3.30 s | 1.671 s (+74 ms D) |
| C1 30.3K Decode | 231.1 tok/s | 129.4 tok/s | 233.2 tok/s | 304.6 tok/s | 271.1 tok/s | 261.5 tok/s | 282.7 tok/s |
| C1 121.1K TTFT | 11.98 s | 12.04 s (+54 ms) | 12.08 s | 8.49 s | 8.62 s | 17.29 s | 8.713 s (+167 ms D) |
| C1 121.1K Decode | 211.5 tok/s | 106.9 tok/s | 210.5 tok/s | 239.4 tok/s | 256.3 tok/s | 248.7 tok/s | 266.8 tok/s |
| Mixed decode_a (tok/s, max ITL) | 80.9, 7,142 ms | 124.2, 85.2 ms | 259.5, 14.0 ms | 140.4, 404.2 ms | 294.8, 48.1 ms | 237.7, 18.3 ms | 231.4, 25.2 ms |
| Mixed decode_b (tok/s, max ITL) | 82.9, 7,142 ms | 125.4, 18.9 ms | 80.8, 8,195 ms | 149.6, 390.9 ms | 145.7, 432.6 ms | 213.4, 18.3 ms | 223.8, 18.3 ms |
| Mixed 90.8K Prefill TTFT | 7.18 s | 7.18 s | 8.31 s | 9.03 s | 7.81 s | 11.88 s | 5.985 s (+123 ms D) |
| Mixed Total Wall Time | 12.80 s | 9.79 s | 12.72 s | 10.99 s | 9.85 s | 13.81 s | 7.926 s |
Worst-case active decode stall under concurrent 90.8K prefill (max ITL, ms, lower is better).
Exact 7-way benchmark measurements
| Configuration | Mixed Max ITL | Slowest Stream | Mixed Wall | 121K TTFT | 121K Decode |
|---|---|---|---|---|---|
| SGLang 1x TP1 + DSpark-8 | 7,142 ms | 80.9 tok/s | 12.80 s | 11.98 s | 211.5 tok/s |
| SGLang 1P1D NIXL (No DSpark) | 85.2 ms | 124.2 tok/s | 9.79 s | 12.04 s | 106.9 tok/s |
| SGLang 2x TP1 + DSpark-8 | 8,195 ms | 80.8 tok/s | 12.72 s | 12.08 s | 210.5 tok/s |
| Flare v0.5.3 1x TP1 | 404.2 ms | 140.4 tok/s | 10.99 s | 8.49 s | 239.4 tok/s |
| Flare v0.5.3 2x TP1 | 432.6 ms | 145.7 tok/s | 9.85 s | 8.62 s | 256.3 tok/s |
| Flare Stock 1P1D (TTL miss) | 18.3 ms | 213.4 tok/s | 13.81 s | 17.29 s | 248.7 tok/s |
| Flare Patched 1P1D (0 ms sleep) | 25.2 ms | 223.8 tok/s | 7.93 s | 8.71 s | 266.8 tok/s |
What Does Not Work Yet
I want to be explicit about where this system still stops short.
First, full coding and reasoning quality evaluation against my current primary model has not run yet. These runs verified JSON Schema, multi-turn tool calling, vision, and 128K needle retrieval, and speed plus protocol receipts are not promotion readiness. Second, upstream Flare still hits a known temperature=0.0 sampling-floor behavior that produces verbose chain-of-thought output, causing the 512-token math parity check and the 256-token 32K needle check to hit length limits while the 128K needle completed in 240 tokens.
Third, --prefix-cache-memory 0 (pool_only()) buffer sizing remains unpatched to keep the pull request tight. Running 1P1D today still requires passing a non-zero local budget such as --prefix-cache-memory 4G, putting combined worker active RSS around 20.55 GiB alongside the 8 GiB selene-manager shared-memory pool. Finally, while all Rust TLA+ trace-conformance tests passed, standalone TLC model checking (tla2tools.jar) and scripts/scheduling_sim/ simulator sweeps did not run locally.
Replace Timers With Synchronization Contracts
Whenever a distributed serving path needs a magic sleep to pass, look for the missing completion signal inside the engine rather than tuning the delay outside it. And never accept a disaggregation speedup on paper without checking which accelerators the split forced you to turn off.
Co-authored with AI, based on the author's working sessions, dictations, and notes.
Explore the source
fakoli/hyperflare-inference
This article discusses an open-source project. Star it, fork it, or open an issue.