From 0736d8d1268573b22522f444ae8b23160fee3af4 Mon Sep 17 00:00:00 2001 From: leavelet Date: Sun, 12 Oct 2025 08:29:36 +0000 Subject: [PATCH] [Fix]: add missing device attribute to ChunkCache --- python/sglang/srt/mem_cache/chunk_cache.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/sglang/srt/mem_cache/chunk_cache.py b/python/sglang/srt/mem_cache/chunk_cache.py index 54626dffd16e..34cd2083f640 100644 --- a/python/sglang/srt/mem_cache/chunk_cache.py +++ b/python/sglang/srt/mem_cache/chunk_cache.py @@ -27,6 +27,10 @@ def __init__( self.req_to_token_pool = req_to_token_pool self.token_to_kv_pool_allocator = token_to_kv_pool_allocator self.page_size = page_size + if self.token_to_kv_pool_allocator: + self.device = self.token_to_kv_pool_allocator.device + else: + self.device = torch.device("cpu") # NOTE (csy): this is to determine if a cache has prefix matching feature. # Chunk cache always return True to indicate no prefix matching.