From b26cb1c55ad283a54360206f110626250c55436f Mon Sep 17 00:00:00 2001 From: Zhiqiang Xie Date: Tue, 6 May 2025 00:19:47 -0700 Subject: [PATCH] Fix problem of large page size with chunked prefill (#6046) --- python/sglang/srt/managers/schedule_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/managers/schedule_policy.py b/python/sglang/srt/managers/schedule_policy.py index 4b36281ac..3cd2be26b 100644 --- a/python/sglang/srt/managers/schedule_policy.py +++ b/python/sglang/srt/managers/schedule_policy.py @@ -499,12 +499,12 @@ class PrefillAdder: ), ) else: - if self.rem_chunk_tokens == 0: + # Make sure at least one page is available + trunc_len = self.rem_chunk_tokens - self.tree_cache.page_size + 1 + if trunc_len <= 0: return AddReqResult.OTHER # Chunked prefill - trunc_len = self.rem_chunk_tokens - req.extend_input_len = trunc_len req.fill_ids = req.fill_ids[: len(req.prefix_indices) + trunc_len]