diff --git a/python/sglang/srt/managers/schedule_policy.py b/python/sglang/srt/managers/schedule_policy.py index 933b1ca20..b64746037 100644 --- a/python/sglang/srt/managers/schedule_policy.py +++ b/python/sglang/srt/managers/schedule_policy.py @@ -860,7 +860,14 @@ class PrefillAdder: if swa_needed >= self.rem_swa_tokens: return AddReqResult.NO_TOKEN - if real_input_tokens >= self.rem_input_tokens and len(self.can_run_list) != 0: + if ( + self.rem_chunk_tokens is None + and len(self.can_run_list) != 0 + and real_input_tokens >= self.rem_input_tokens + ): + # If without chunked prefill: + # - if the can_run_list is not empty, we satisfy the constraint of (max_prefill_tokens) + # - if the can_run_list is empty, always accept the first prefill request return AddReqResult.OTHER with self._lock_node(req.last_node): @@ -888,7 +895,14 @@ class PrefillAdder: input_tokens = self.ceil_paged_tokens(req.extend_input_len) - if input_tokens >= self.rem_input_tokens and len(self.can_run_list) != 0: + if ( + self.rem_chunk_tokens is None + and len(self.can_run_list) != 0 + and input_tokens >= self.rem_input_tokens + ): + # If without chunked prefill: + # - if the can_run_list is not empty, we satisfy the constraint of (max_prefill_tokens) + # - if the can_run_list is empty, always accept the first prefill request return AddReqResult.OTHER if self.dllm_config is not None: