Repository navigation
[Fix] radix-cache: Separate logical and reclaimable value lengths in tree components - #45238
Merged
Merged
Conversation
metamergebot
requested review from
Jialin,
Ying1123,
alphabetc1,
hanming-lu,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann and
yizhang2077
as code owners
October 19, 2026 21:50
metamergebot
force-pushed
the
oss-sync-3cc5dd45b8
branch
2 times, most recently
from
October 20, 2026 05:30
9c1c8c8 to
f9112e8
Compare
…tree components A tree node's device value has two lengths that happened to coincide: the logical length of the stored index tensor, used for slicing, prefix matching and path spans, and the number of allocator slots handed back when the value is evicted, used by the evictable/protected ledgers. A component whose backing is released or shared under a value can occupy fewer pool rows than the logical value describes, and the ledgers then drift from what the allocator actually gets back. Keep the two apart in both the Python and the Rust tree cores: - Python: TreeComponent.reclaimable_tokens becomes reclaimable_value_len, and every ledger site in the Full, SWA and Mamba components (insert, lock, release, materialize, evict, recount) reads it instead of len(value). value_len stays the logical length. - Rust: Node gains device_reclaimable_value_len, zero for roots and absent values, and the same ledger sites in the Full, SWA and Mamba components and the core use it instead of device_value_len or the tensor's first dimension. The SWA component's private value_len helper goes away. - adjust_component_size rejects a delta that would drive a ledger negative with ValueError and leaves the counters untouched, on both cores; the interface docstring says so. - evict_device_next_node reports progress when a step freed device or host backing even though no node was consumed, so an eviction walk over zero-accounted nodes keeps going instead of stopping early. Tests cover the Rust node accessor, the negative-delta rejection, a Full component with side backing across lock transitions and a locked split, and Python SWA/Mamba components whose reclaimable length differs from the logical one through lock/release and internal eviction. Co-authored-by: Jialin <[email protected]>
metamergebot
force-pushed
the
oss-sync-3cc5dd45b8
branch
from
October 20, 2026 08:32
f9112e8 to
a887748
Compare
Collaborator
Author
|
This port clears our bar on gate✓ lint✓ build 4✓✗1✂1 A✓ B✓ C 0/14⏳ other✓ · accel ✗amd,npu @fei-xx @merrymercy @Jialin — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side. |
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 30, 2026
… C closure -- the post-merge port queue is now decided ARRIVAL SCAN (git log 12dc623..2a6c204 --grep) + LIVE gh STATE + head-sha comparison for EVERY deferred item. Verdicts: RELEASED-BY-MERGE: sgl-project#42689 (@ 7a632cf in-range -- the SECTION-B cherry is now redundant; behavior note rides the restart). CLOSED (C-items whose PRs arrived and whose integration this stack performed): C1 (the dedicated merge week WAS merge sgl-project#5; all eight precursor PRs in-range), C2 (sgl-project#44993/sgl-project#44994 -- B5), C3 (sgl-project#45232/ sgl-project#45236/sgl-project#45334 -- B2), C4 (sgl-project#45238/sgl-project#45241/sgl-project#45242 -- B3), C5 (sgl-project#44912/ sgl-project#44913 -- arrived; entry-230 canary re-planted as its guard), C9 (sgl-project#39727 -- verified OPT-IN, no purge; BOOT_DELTA anti-needle), C0a (arrival shas already recorded at entry 310 -- Section C now carries NO open code-integration items: C6/C10 retain only their explicitly-named docs/boot-measurement remainders, re-stated). STILL-OPEN: sgl-project#44342 (head unchanged; auto-merge comfort LOST to #46970x), sgl-project#46153/sgl-project#37106/sgl-project#32479/sgl-project#45391 (gh CONFLICTING -- stale bases, rebase before any port), sgl-project#41624/sgl-project#42525/sgl-project#42660/sgl-project#44462/sgl-project#35617 (open, heads unchanged), sgl-project#46191/sgl-project#39845-class (watch-list, none in range). HOLD STANDS (operator decision, binding): sgl-project#43356/sgl-project#46452/sgl-project#43240/ sgl-project#43471 KV route -- step-1 'MERGE sgl-project#5 lands first' is NOW MET; the sequence may be re-visited ONLY with the post-merge PCIe-IPC measurement at an operator sitting. sgl-project#44732: the 'one purge if done WITH the merge' premise LAPSED when merge sgl-project#5 completed without it -- later execution costs the SAME single purge once; no penalty, no haste. Recorded for the operator, not decided by B6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A tree node's device value has two lengths that the tree cores treated as one: the logical length of the stored index tensor, which slicing, prefix matching and
collect_path_infospans read, and the number of allocator slots the pool gets back when the value is evicted, which the evictable/protected ledgers count. A component whose backing is released or shared under a value can occupy fewer pool rows than the logical value describes, and the ledgers then drift from what the allocator actually reclaims: prefill admission adds the evictable ledger to the allocator's free space and the eviction walk counts it toward its request, so both over-report.Modifications
TreeComponent.reclaimable_tokensbecomesreclaimable_value_len, and every ledger site in the Full, SWA and Mamba components (insert, lock, release, materialize, evict, recount) reads it instead oflen(value).value_lenstays the logical length.Nodegainsdevice_reclaimable_value_len, zero for roots and absent values, and the same ledger sites in the Full, SWA and Mamba components and the core use it instead ofdevice_value_lenor the tensor's first dimension. The SWA component's privatevalue_lenhelper goes away.adjust_component_sizerejects a delta that would drive a ledger negative withValueErrorand leaves the counters untouched, on both cores; the interface docstring says so.evict_device_next_nodereports progress when a step freed device or host backing even though no node was consumed, so an eviction walk over zero-accounted nodes keeps going instead of stopping early.Nothing changes for components whose reclaimable length equals the logical one, which is every in-tree component today.
Accuracy Tests
Not applicable: no model or kernel numerics change.
Benchmarking and Profiling
Not applicable: the ledger sites already called a per-node accessor; this changes which one.
Checklist
cargo test --libinrust/sglang-radix-tree, including the newtests/node.rsassertions.test/registered/unit/mem_cache/test_rust_tree_core_integration.py,test_unified_radix_cache_unittest.py,test_tree_core_registry.pyandtest_swa_locked_full_recover_unified.pyon both tree-core backends.CI States
Latest PR Test (Base): ✅ Run #39394107972
Latest PR Test (Extra): ❌ Run #39394107869
Latest PR Test (AMD ROCm 10): ❌ Run #39394108029