Repository navigation
[P/D disagg] - support decode side radix cache - #19746
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
@ishandhanani Can this feature be understood as follows: Current status of pd-disagg: Based on this PR's implementation: |
Yep. This is correct |
|
/gemini review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
- Set req.prefix_indices in _pre_alloc so init_next_round_input(None) computes extend_input_len correctly from the cached prefix length. Without this, prepare_for_prebuilt runs a full-length extend instead of a delta extend. - Always call inc_lock_ref on the matched node (even on empty match) to match aggregated scheduler behavior. Prevents lock_ref underflow when cache_finished_req unconditionally calls dec_lock_ref.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Next step is testing with a larger model on B200. And then step after (maybe in follow up) is to do the same for mooncake |
|
@ishandhanani There seems to be a constraint here: |
|
Could you share the exact command you used to run this? I'd like to reproduce it and test it on my side. |
Theres a few things here.
|
Yea what Shangming said is correct. Our current solution for P and D sharing cache is with the L3 offloading. For more agentic use cases, the OSL is usually small enough to where the additional incremental prefill shouldn't be too much of a it IMO |
|
What space does the decode node use to cache the KV Cache? GPU memory or other space from HiCache? |
@dblate currently, we cache it in GPU mem, we will support HiCache for decode radix cache, after that, it could offload some kvcache to cpu mem/mooncake store/ssd. |
Decode-side radix cache (sgl-project#19746) previously rejected SWA hybrid models (e.g. gpt-oss) at startup. Enable them: full-attention layers reuse the matched radix prefix while the sliding-window state is transferred fresh per turn. - Cap prefix reuse at the sliding-window start so the window lands in the freshly allocated delta, and allocate via alloc_extend_swa_tail on radix hits (previously restricted to prefix_len == 0). - Mark the non-window prefix swa_evicted_seqlen so cache_(un)finished_req inserts it as an SWA tombstone, keeping the SWA pool accounting balanced (otherwise swa_evictable over-counts and the idle leak check fires). - Thread the SWA lock uuid from inc_lock_ref through every dec_lock_ref so swa_lock_ref does not underflow toward the root. - Use SWA-aware full-pool size accessors for the decode budget/eviction. - Keep DeepSeek-V4 (DSA), SWA-compress, and Mamba/SSM blocked. cache_unfinished_req now passes swa_evicted_seqlen to insert, matching cache_finished_req (0 in the aggregated path, so behavior there is unchanged). Validated on gpt-oss-20b 1P1D (nixl and mooncake): multi-turn decode prefix reuse, no memory leak at low (4x64) and high (32x192) concurrency with strict idle checking, gsm8k 0.555 vs 0.54 baseline.
@ShangmingCai --disaggregation-decode-enable-offload-kvcache cann't be satisfied? |
@ccilery, we prefer the decode radix cache + HiCache solution now. For now, we will not put much effort into the decode offload manager update. |
|
Hi, @ishandhanani , this is a very useful feature that aligns perfectly with my use case. Are there any major roadblocks or difficulties in adding support for other transfer backends and speculative decoding to the decode radix cache? |
|
I have a quick question about the dataflow at the start of turn 2. Scenario: A new request (tokens 1–9) triggers prefill.
Which behavior is correct? A. Local Recomputation: Prefill hits cache for 1–3, locally recomputes KV for 4–6, and prefill 7–9. Only KV 7–9 is transferred to the decoder. B. KV Transfer: The decoder transfers KV 4–6 to the prefill worker. The prefill worker only computes 7–9 (incurring communication cost, but potentially overlapped). I've checked the source code and consulted the agent, but I'm still unclear on this specific dataflow. A brief correction would be greatly appreciated! |
|
@Darcy-Lee Currently, it is A. |
…sts re-prefill chunk 1 forever until pool-exhaustion OOM Root cause (UPSTREAM bug, introduced by PR sgl-project#19746 'decode side radix cache'): Req.skip_radix_cache_insert (set iff bootstrap_host == FAKE_BOOTSTRAP_HOST, i.e. warmup requests) makes maybe_cache_unfinished_req skip cache_unfinished_req entirely. For a chunked prefill that call is not just a radix insert -- it is the chunk->prefix conversion that advances req.prefix_indices. With it skipped, PrefillAdder.add_chunked_req re-plans the SAME first chunk on every pass (extend_range stays [0, chunk)), each pass allocates fresh KV rows, #pending-token never decrements, and the token pool fills until the fail-loud RuntimeError('Out of memory...') kills the scheduler. This is Task sgl-project#99's 'Blocker 1': the historically reported 'admits only ~pool/4 tokens (usage 1.00 at 32.7k of a 131,080-row pool)' was a 32,768-token fake warm filling the 131,072-row pool after 64 re-prefills of chunk 1 -- the multiplier is pool/chunk_size, not 4. Real-bootstrap requests are unaffected (flag False; M2 temp-0 oracle incl. 28k needle was bit-identical). Fix: when the flag is set, perform the minimal ChunkCache-equivalent prefix_indices advance (rows from req_to_token up to extend_range.end) WITHOUT touching the tree. Rows stay request-owned and are freed at completion via cache_finished_req(is_insert=False) (release_kv_cache already routes the flag there). Non-disagg / real-bootstrap paths are byte-identical (flag is False everywhere outside fake warmups). Falsification test (A3B-AWQ TP=1 on the 5090, disagg-prefill server, --disable-radix-cache, chunked_prefill_size 2048, fake-bootstrap sends): - BEFORE (ctx 65,536, pool 219,948): 63,488-token send -> #pending-token frozen at 61,440, full token usage -> 1.00 after 108 batches (= pool / 2048 re-prefills), scheduler crashes RuntimeError OOM ('Available tokens: 0'). Log: /tmp/pd99/b1_prefill.log - AFTER (same config): #pending-token 61,440 -> 0 monotone, usage peaks 0.29 (= 63,488/219,948 exactly), 200 OK in 5.13 s, pool fully released (second 16,384 warm: 200 in 0.80 s, starts at usage 0.07 = 16,384/pool). Log: /tmp/pd99/b1_prefill_after.log - AFTER (ctx 131,072, pool 373,548): 122,880-token send -> 200 in 16.48 s, usage fills to 0.33 (= 122,880/373,548) and releases to 0.00. Log: /tmp/pd99/b1_120k.log Unblocks the eager fake-warm boot protocol needed for Blocker 2 (JIT/ workspace warm before the decode server boots).
|
Hi, @ishandhanani, this is a useful feature, why --disaggregation-decode-enable-radix-cache is incompatible with speculative decoding. |
|
ValueError: --disaggregation-decode-enable-radix-cache is incompatible with speculative decoding (--speculative-algorithm EAGLE) |
…sts re-prefill chunk 1 forever until pool-exhaustion OOM Root cause (UPSTREAM bug, introduced by PR sgl-project#19746 'decode side radix cache'): Req.skip_radix_cache_insert (set iff bootstrap_host == FAKE_BOOTSTRAP_HOST, i.e. warmup requests) makes maybe_cache_unfinished_req skip cache_unfinished_req entirely. For a chunked prefill that call is not just a radix insert -- it is the chunk->prefix conversion that advances req.prefix_indices. With it skipped, PrefillAdder.add_chunked_req re-plans the SAME first chunk on every pass (extend_range stays [0, chunk)), each pass allocates fresh KV rows, #pending-token never decrements, and the token pool fills until the fail-loud RuntimeError('Out of memory...') kills the scheduler. This is Task sgl-project#99's 'Blocker 1': the historically reported 'admits only ~pool/4 tokens (usage 1.00 at 32.7k of a 131,080-row pool)' was a 32,768-token fake warm filling the 131,072-row pool after 64 re-prefills of chunk 1 -- the multiplier is pool/chunk_size, not 4. Real-bootstrap requests are unaffected (flag False; M2 temp-0 oracle incl. 28k needle was bit-identical). Fix: when the flag is set, perform the minimal ChunkCache-equivalent prefix_indices advance (rows from req_to_token up to extend_range.end) WITHOUT touching the tree. Rows stay request-owned and are freed at completion via cache_finished_req(is_insert=False) (release_kv_cache already routes the flag there). Non-disagg / real-bootstrap paths are byte-identical (flag is False everywhere outside fake warmups). Falsification test (A3B-AWQ TP=1 on the 5090, disagg-prefill server, --disable-radix-cache, chunked_prefill_size 2048, fake-bootstrap sends): - BEFORE (ctx 65,536, pool 219,948): 63,488-token send -> #pending-token frozen at 61,440, full token usage -> 1.00 after 108 batches (= pool / 2048 re-prefills), scheduler crashes RuntimeError OOM ('Available tokens: 0'). Log: /tmp/pd99/b1_prefill.log - AFTER (same config): #pending-token 61,440 -> 0 monotone, usage peaks 0.29 (= 63,488/219,948 exactly), 200 OK in 5.13 s, pool fully released (second 16,384 warm: 200 in 0.80 s, starts at usage 0.07 = 16,384/pool). Log: /tmp/pd99/b1_prefill_after.log - AFTER (ctx 131,072, pool 373,548): 122,880-token send -> 200 in 16.48 s, usage fills to 0.33 (= 122,880/373,548) and releases to 0.00. Log: /tmp/pd99/b1_120k.log Unblocks the eager fake-warm boot protocol needed for Blocker 2 (JIT/ workspace warm before the decode server boots).
… output-token churn Root cause (garbling + accept collapse correlated with batch-finish window, 1114-1120 UTC): decode-side radix cache (upstream sgl-project#19746) inserted the FULL KV chain (req.origin_input_ids + req.output_ids) on EVERY decode batch via maybe_cache_unfinished_req. Under 80RPM replay the decode output tokens are almost never reused as a prefix (agent harness rewrites the last message), so each batch built a fresh growing tree key -> continuous node churn -> L2 write_back/eviction pressure spikes exactly when many requests finish (user observation: garble/accept dips preceded by a decode batch with many running reqs completing). Clamping kv_len_to_handle to input length keeps the tree key within origin_input_ids; after the first insert it is a no-op (radix match reuses the existing path), so it neither wastes perf nor generates churn. Prefill side unaffected (output_ids empty). Verified: py_compile; deploy + run6 pending.
Summary
In PD disaggregation, the decode worker can now use radix cache to reuse shared prefixes and request only the delta KV from prefill instead of transferring the full prefix on every turn.
This is enabled with
--disaggregation-decode-enable-radix-cacheon the decode server.For now, this path is supported only with
--disaggregation-transfer-backend nixl.server_args.pynow rejects other transfer backends early when the decode radix cache flag is enabled. Mooncake support will follow in a separate PR.Main Changes
decode_prefix_lenfrom decode to prefill for the NIXL path.--disaggregation-decode-enable-radix-cache.--disaggregation-transfer-backend nixlwhen that flag is set.Interface
Enable decode radix cache on the decode worker with:
Prefill continues to run with
--disaggregation-transfer-backend nixl.Note: DP attention is still experimental here. The flag is allowed, but good cache hit rates require prefix-aware DP routing.
Benchmark
Setup
Qwen/Qwen3-32B, FP8 KV cache, 3P1D, TP=2 per workerResults
Decode-side logs show the reason for the throughput gain: baseline decode ran near KV capacity (
token_usage ~ 0.99) and only fit ~37 running requests, while decode radix cache reduced duplicate prefix residency (token_usage ~ 0.75) and fit roughly 104-126 running requests. The ITL regression is expected from the larger decode batch.Test Plan
nixlinserver_args.py