From 2e130b76188c443b22868159dec966d4cf0cfb78 Mon Sep 17 00:00:00 2001 From: zhangzuo21 <99539591+zhangzuo21@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:42:37 +0800 Subject: [PATCH] [HiCache]bug fix: fixed blank item in host_mem_release_queue (#11005) Co-authored-by: Zuoyuan Zhang Co-authored-by: Zhiqiang Xie --- python/sglang/srt/managers/cache_controller.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/managers/cache_controller.py b/python/sglang/srt/managers/cache_controller.py index a78e140bb..c2c14707e 100644 --- a/python/sglang/srt/managers/cache_controller.py +++ b/python/sglang/srt/managers/cache_controller.py @@ -575,9 +575,11 @@ class HiCacheController: return operation.completed_tokens, operation.hash_value def append_host_mem_release(self, host_indices: torch.Tensor): - chunks = host_indices.split(self.mem_pool_host.page_size) - for chunk in chunks: - self.host_mem_release_queue.put(chunk) + if host_indices.numel() == 0: + return + pages = host_indices.split(self.mem_pool_host.page_size) + for page in pages: + self.host_mem_release_queue.put(page) def _page_get_zero_copy(self, operation, hash_values, host_indices): results = self.storage_backend.batch_get_v1(hash_values, host_indices)