From 1b97fa769b20631f18ce7301108477d63f3ad161 Mon Sep 17 00:00:00 2001 From: Yi Zhang <1109276519@qq.com> Date: Wed, 21 Jan 2026 17:12:57 +0800 Subject: [PATCH] [BUGFIX] fix value oom in radix tree (#17400) --- python/sglang/srt/mem_cache/hiradix_cache.py | 6 +++--- python/sglang/srt/mem_cache/mamba_radix_cache.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/mem_cache/hiradix_cache.py b/python/sglang/srt/mem_cache/hiradix_cache.py index f74881f1b..d4e3de146 100644 --- a/python/sglang/srt/mem_cache/hiradix_cache.py +++ b/python/sglang/srt/mem_cache/hiradix_cache.py @@ -796,7 +796,7 @@ class HiRadixCache(RadixCache): new_node.parent = node new_node.key = key new_node.value = None - new_node.host_value = host_value + new_node.host_value = host_value.clone() new_node.hash_value = hash_value node.children[child_key] = new_node return matched_length @@ -897,7 +897,7 @@ class HiRadixCache(RadixCache): # shared-prefix node should also reflect max priority new_node.priority = max(new_node.priority, priority) if new_node.evicted: - new_node.value = value[:prefix_len] + new_node.value = value[:prefix_len].clone() self.evictable_size_ += len(new_node.value) else: self._inc_hit_count(new_node, chunked) @@ -914,7 +914,7 @@ class HiRadixCache(RadixCache): new_node = TreeNode(priority=priority) new_node.parent = node new_node.key = key - new_node.value = value + new_node.value = value.clone() node.children[child_key] = new_node self.evictable_size_ += len(value) diff --git a/python/sglang/srt/mem_cache/mamba_radix_cache.py b/python/sglang/srt/mem_cache/mamba_radix_cache.py index 24dc81fd3..c8bae716b 100644 --- a/python/sglang/srt/mem_cache/mamba_radix_cache.py +++ b/python/sglang/srt/mem_cache/mamba_radix_cache.py @@ -1052,7 +1052,7 @@ class MambaRadixCache(BasePrefixCache): new_node = TreeNode() new_node.parent = node new_node.key = key - new_node.value = value + new_node.value = value.clone() new_node.mamba_value = mamba_value self.full_lru_list.insert_mru(new_node) self.mamba_lru_list.insert_mru(new_node)