Skip to content

[P/D Disagg] DeepSeek-V4 decode radix cache with MTP support - #31097

Open
TobyMint wants to merge 25 commits into
sgl-project:mainfrom
TobyMint:dsv4-decode-radix-cache-mtp-support
Open

TobyMint wants to merge 25 commits into
sgl-project:mainfrom
TobyMint:dsv4-decode-radix-cache-mtp-support

Conversation

@TobyMint

@TobyMint TobyMint commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Motivation

PR #27770 (by Ishan Dhanani) added device-only SWA decode radix cache support on the unified radix tree, but explicitly blocked DeepSeek-V4 due to its C128 compression and DSA indexer specifics. This PR removes that guard and adds full DeepSeek-V4 decode radix cache support by porting zhangxiaolei's DS-V4 patch series to the upstream API.

Co-authored-by: zhangxiaolei zhangxiaolei123456@users.noreply.github.com

Accuracy Tests

MMLU (200 examples) on DeepSeek-V4-Flash with decode radix cache enabled:

Score: 0.905
Total latency: 296.983 s
Output throughput: 66.802 token/s

Speed Tests

Shared-prefix benchmark (256 requests, 8 groups, 8192-token system prompts) on 8x NVIDIA H20 (PD disaggregation, NIXL transfer):

Successful requests:         256/256 (100%)
Total token throughput:      7970 tok/s
Mean TTFT:                   1.68s
Mean TPOT:                   130.66ms

Checklist


CI States

Latest PR Test (Base): ❌ Run #30235651399
Latest PR Test (Extra): ❌ Run #30235651325

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@TobyMint
TobyMint force-pushed the dsv4-decode-radix-cache-mtp-support branch 2 times, most recently from 70dbe33 to 3e51bd4 Compare July 15, 2026 03:41
@TobyMint
TobyMint force-pushed the dsv4-decode-radix-cache-mtp-support branch from 3e51bd4 to 82c284d Compare July 24, 2026 10:45
ishandhanani and others added 12 commits July 27, 2026 11:51
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
TobyMint and others added 13 commits July 27, 2026 11:52
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
…free, full match

Co-authored-by: zhangxiaolei <zhangxiaolei123456@users.noreply.github.com>
Match the radix-cache eviction margin: keep enough SWA before the
page-aligned insert boundary for the cached key to contain a complete
window. `seq_len - 1` is the last committed position.

Backport of sgl-project#27770 commit 0bca294.
- Add _release_matched_prefix_lock: unified lock release with
  swa_prefix_lock_released tracking to avoid double-freeing SWA locks
- Add _reclaim_swa_tail_capacity: proactively evict SWA cache entries
  before allocation to avoid unnecessary admission failures
- Call dec_swa_lock_only after prefix match: retain only full-attention
  lock when decode will transfer fresh SWA tail
- Replace inline dec_lock_ref calls with _release_matched_prefix_lock
- Recalculate swa_allocatable_tokens via _swa_tail_allocatable_token_budget
  instead of simple decrement to account for page rounding and eviction
- Count swa_evictable_size in SWA admission budget
- Hoist uses_swa_tail/swa_tail_len in _pre_alloc and reclaim SWA capacity
- Fix resume_retracted_reqs to recalculate SWA budget

Backport of sgl-project#27770 commit 6543121.
- test_swa_tail_len_keeps_page_aligned_matchable_window: verify the
  insertion margin keeps a full SWA window inside the cached key
- test_swa_admission_counts_evictable_capacity: SWA budget includes
  evictable radix-cache entries
- test_reclaim_swa_tail_capacity_page_rounds: page-rounding in SWA
  capacity reclaim triggers correct eviction
- test_reclaim_swa_tail_capacity_fails_before_allocation: RuntimeError
  when SWA eviction cannot satisfy the required capacity
- Update test_pop_preallocated_rechecks_budget_after_lock for new
  dec_swa_lock_only + swa_prefix_lock_released flow
- Add swa_available_size mock in test_hisparse_allocator

Backport of sgl-project#27770 commits 0bca294 and 6543121.
_uses_dsv4_decode_radix_cache() already guarantees the pool is a
DeepSeekV4TokenToKVPool, so compression_ratios always exists. Drop the
getattr fallback to fail fast instead of silently degrading to an
empty list.
page_size, is_eagle (BasePrefixCache) and cache_protected_len,
swa_evicted_seqlen (Req) are always-initialized standard attributes.
Drop getattr fallbacks in _maybe_insert_dsv4_decode_radix_prompt so
real init bugs surface instead of silently using defaults.

force_radix_leaf_creation stays getattr'd: it is a runtime-armed flag
that only DS-V4 donation sets, so it is legitimately absent on most reqs.
@TobyMint
TobyMint force-pushed the dsv4-decode-radix-cache-mtp-support branch from 82c284d to 0539913 Compare July 27, 2026 03:53
@b8zhong b8zhong mentioned this pull request Aug 5, 2026
41 tasks
@dongyibo

Copy link
Copy Markdown

@TobyMint hello, can this support Dspark?

lizhigong1988 pushed a commit to HYGON-AI/sglang-das that referenced this pull request Aug 27, 2026
…ject/sglang#31097; 2. SGLANG_ENABLE_UNIFIED_RADIX_TREE=1 & SGLANG_ENABLE_UNIFIED_RADIX_TREE=1 & --disaggregation-decode-enable-radix-cache should be enable in D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants