From a3aee7c37733c4cfb3ddf7f2f559fb8847dd9bae Mon Sep 17 00:00:00 2001 From: Pablo Iyu Guerrero <95311543+pabloiyu@users.noreply.github.com> Date: Wed, 27 Aug 2025 09:43:01 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20HiRadixCache:=20fix=20prefetch=20complet?= =?UTF-8?q?ion=C2=A0race=20(#9397)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/sglang/srt/mem_cache/hiradix_cache.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/mem_cache/hiradix_cache.py b/python/sglang/srt/mem_cache/hiradix_cache.py index c0bd0a3f8..61039913a 100644 --- a/python/sglang/srt/mem_cache/hiradix_cache.py +++ b/python/sglang/srt/mem_cache/hiradix_cache.py @@ -434,9 +434,12 @@ class HiRadixCache(RadixCache): if self.prefetch_stop_policy == "best_effort": return can_terminate - completed = ( - operation.completed_tokens == len(operation.hash_value) * self.page_size - ) + if len(operation.hash_value) == 0: + completed = False + else: + completed = ( + operation.completed_tokens == len(operation.hash_value) * self.page_size + ) if self.prefetch_stop_policy == "wait_complete": can_terminate = completed