Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion vllm/v1/core/sched/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ def schedule(self) -> SchedulerOutput:
while self.waiting and token_budget > 0:
if len(self.running) == self.max_num_running_reqs:
break

if len(scheduled_resumed_reqs) + len(scheduled_new_reqs) >= max(
1,
self.max_num_running_reqs
// self.parallel_config.pipeline_parallel_size,
):
break
Comment on lines +400 to +405
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The division by self.parallel_config.pipeline_parallel_size on line 361 assumes this value is non-zero. If it were misconfigured to be 0, this would lead to a ZeroDivisionError, causing the scheduler to crash. While pipeline_parallel_size defaults to 1, adding a check to ensure it's positive would make the code more robust against configuration errors. The suggested change also improves readability by extracting the limit into a variable.

Suggested change
if len(scheduled_resumed_reqs) + len(scheduled_new_reqs) >= max(
1,
self.max_num_running_reqs
// self.parallel_config.pipeline_parallel_size,
):
break
pp_size = self.parallel_config.pipeline_parallel_size
if pp_size <= 0:
raise ValueError(
"pipeline_parallel_size must be positive, but is "
f"{pp_size}")
limit = max(1, self.max_num_running_reqs // pp_size)
if len(scheduled_resumed_reqs) + len(scheduled_new_reqs) >= limit:
break

request = self.waiting.peek_request()

# KVTransfer: skip request if still waiting for remote kvs.
Expand Down