From 01ca82d7650c597a9619cec01fd542ca7bcf8620 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Tue, 16 Jan 2024 01:42:46 +0800 Subject: [PATCH] fix radix cache match (#7) --- python/sglang/srt/managers/router/radix_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/managers/router/radix_cache.py b/python/sglang/srt/managers/router/radix_cache.py index a70f00da6..25043d7ed 100644 --- a/python/sglang/srt/managers/router/radix_cache.py +++ b/python/sglang/srt/managers/router/radix_cache.py @@ -116,12 +116,12 @@ class RadixCache: for c_key, child in node.children.items(): prefix_len = match(c_key, key) if prefix_len != 0: - if prefix_len == len(key) and prefix_len != len(c_key): + if prefix_len < len(c_key): new_node = self._split_node(c_key, child, prefix_len) value.append(new_node.value) last_node[0] = new_node else: - value.append(child.value[:prefix_len]) + value.append(child.value) last_node[0] = child self._match_prefix_helper(child, key[prefix_len:], value, last_node) break