Repository navigation
[Unified Tree] Support Branching-Point Caching for the SWA Component - #34565
Conversation
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
7b01a3d to
22a279b
Compare
|
/rerun-group radix_cache/unified_radix_tree |
|
Results for 🚀 🚀 🚀 🚀 🚀 |
|
/rerun-group hicache |
|
Results for 🚀 🚀 🚀 🚀 ⛔ |
# Conflicts: # python/sglang/srt/mem_cache/unified_cache/unified_tree_core.py # python/sglang/srt/mem_cache/unified_cache/unified_tree_core_interface.py # python/sglang/srt/mem_cache/unified_radix_cache.py
…gl-project#34565) Co-authored-by: alphabetc1 <[email protected]> Co-authored-by: Shuwen Wang <[email protected]>
Motivation
With out-of-window SWA slot freeing now enabled by default in #34653, chunked prefill releases SWA states outside the last sliding window. This significantly reduces swa memory usage, but later requests branching from an earlier shared prefix may still have reusable Full KV while the corresponding swa state is no longer available, forcing unnecessary prefix recomputation.
Modifications
Reuse most of the existing mamba branching for SWA: and preserve the SWA cache at that boundary when releasing out-of-window slots, and has no effect when the
SGLANG_OPT_UNIFIED_CACHE_FREE_OUT_OF_WINDOW_SLOTSis disabled.Add four relevant tests covering Device and Host Full KV branching, EAGLE insertion boundaries, and releasing unused SWA slots after branch insertion.
Accuracy Tests
Speed Tests and Profiling
Server
Internal Shared-Prefix Simulates
python -m sglang.benchmark.serving \ --flush-cache \ --model deepseek-ai/DeepSeek-V4-Flash-0731 \ --host 127.0.0.1 \ --port 30003 \ --backend sglang-oai-chat \ --dataset-name generated-shared-prefix \ --num-prompts 64 \ --gsp-num-groups 8 \ --gsp-prompts-per-group 8 \ --gsp-system-prompt-len 24576 \ --gsp-question-len 8192 \ --gsp-output-len 128 \ --gsp-range-ratio 1 \ --request-rate 2 \ --max-concurrency 8 \ --seed 42 \ --temperature 0 \ --top-p 1 \ --extra-request-body '{"top_k":-1}' \ --cache-reportPublic AgentX Scenario
Overall Results
The overall AgentX results are similar because most requests continue existing conversations and already have reusable SWA states. The patch introduces no significant performance regression.
The disabled runs used the same 1,800-second duration. Baseline and This PR completed 716 and 729 requests respectively, so these aggregate results represent fixed-duration workload behavior rather than a request-for-request comparison.
Newly Forked Subagent Requests
This subset includes the first request from each new subagent (43 requests).
For new subagent requests, the patch improves the token hit rate by 3.87 percentage points and adds 48,384 cached tokens.
With slot freeing disabled, a few first requests lose large cache hits and lower the result for this subset. The overall run still improves because it also includes later requests that can reuse the newly created branching points.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #33893909201
Latest PR Test (Extra): ⏳ Run #34116727761
Latest PR Test (AMD ROCm 7.2): 🚫 Run #33893909236