Skip to content

Enable unified cache out-of-window slot freeing by default - #34653

Merged
ispobock merged 2 commits into
mainfrom
flip-free-out-of-window-default
Aug 13, 2026
Merged

ispobock merged 2 commits into
mainfrom
flip-free-out-of-window-default

Conversation

@ispobock

@ispobock ispobock commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

SGLANG_OPT_UNIFIED_CACHE_FREE_OUT_OF_WINDOW_SLOTS releases SWA slots that have already left the sliding window while a chunked prefill is being cached, instead of holding them until the request finishes. It has been opt-in since it landed; this makes it the default.

This is a default flip, so it changes behavior for every server running the unified radix cache with an SWA component. The single consumer is the chunked-prefill caching path in unified_radix_cache.py, gated behind SGLANG_ENABLE_UNIFIED_RADIX_TREE; passing False restores the old behavior.

The risk worth calling out is not the freeing itself but what it does to prefix reuse: how much SWA data stays resident decides how deep a later request can match, since a hit needs a full window of live SWA below the match point. Freeing earlier could in principle shorten that and silently cost cache hits.

Accuracy

test_unified_radix_cache_kl_hybrid_bitexact.py is the sharpest check available for this: it asserts prefill and decode score every token identically (kl_div floor 1e-9, measured exactly 0), and its hicache case additionally asserts the reused prefix length per request. One H200 (SM90, same architecture as the 1-gpu-large CI runner), both fixes in, flag defaulted on:

SELFCHECK flag_effective True

test_logprobs_match ... avg_kl_div=0.0 ok
test_prefill_cache_hit ... avg_kl_div=0.0 ok
test_decode_cache_hit ... avg_kl_div=0.0 ok
test_multiturn_decode_cache_hit_branching ... avg_kl_div=0.0 ok

Ran 4 tests in 427.750s

OK

The per-request cached_tokens assertion in the multi-turn case passes unchanged, so the reusable prefix does not shrink.

Two things this does not cover, and I would rather say so than imply otherwise: only the hybrid SWA + mamba configuration was measured, not the SWA-only or mamba-only models in the same directory, and the reason it originally shipped opt-in is not recorded anywhere I could find (the introducing commit carries no rationale). Running the full unified_radix_tree/ suite on this PR would close the first gap.


CI States

Latest PR Test (Base): ✅ Run #31661339455
Latest PR Test (Extra): ✅ Run #31661339489

@ispobock ispobock added run-ci CI: run the baseline test suite on this PR bypass-fastfail run-ci-extra CI: also run the extra suite (requires run-ci) labels Aug 13, 2026
@ispobock

ispobock commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_hybrid_bitexact.py
test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_swa.py
test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_mamba.py
test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_hybrid_bitexact.py:

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_hybrid_bitexact.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_swa.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_mamba.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_swa.py:

🚀 2-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_swa.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py:

🚀 2-gpu-h100 (1 test): ❌ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_mamba.py:

🚀 4-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_mamba.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py:

🚀 2-gpu-h100 (1 test): ❌ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py:

🚀 2-gpu-h100 (1 test): ❌ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_full.py

@ispobock
ispobock merged commit ebc144c into main Aug 13, 2026
169 of 218 checks passed
@ispobock
ispobock deleted the flip-free-out-of-window-default branch August 13, 2026 06:31
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
YaoleWu added a commit to YaoleWu/sglang that referenced this pull request Nov 30, 2026
…ault

The hook mirrored the reference launcher's
SGLANG_OPT_UNIFIED_CACHE_FREE_OUT_OF_WINDOW_SLOTS=0, but with the switch off
the SWA pool retains window KV for every cached prompt, so a few long
conversations exhaust it and prefix matches - which need live SWA at the
branch point - stop matching (sgl-project#50416: 0.1% vs 96.9% cache hit on one node).
Leave the switch to the global default (True since sgl-project#34653).

Signed-off-by: wuyaole <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant