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)