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
12 changes: 9 additions & 3 deletions python/sglang/srt/managers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1841,14 +1841,17 @@ def get_next_batch_to_run(self) -> Optional[ScheduleBatch]:
self.running_batch.batch_is_full = False

# Merge the new batch into the running batch.
# For prefill-only batch, we can avoid going through decoding step.
if not self.last_batch.is_empty() and not self.last_batch.is_prefill_only:
if not self.last_batch.is_empty():
if self.running_batch.is_empty():
self.running_batch = self.last_batch
else:
# Merge running_batch with prefill batch
self.running_batch.merge_batch(self.last_batch)

# For prefill-only running batch, filter out finished requests since it won't run decode.
if self.running_batch.is_prefill_only:
self.running_batch.filter_batch()

new_batch = self.get_new_batch_prefill()

need_mlp_sync = self.require_mlp_sync
Expand All @@ -1867,7 +1870,10 @@ def get_next_batch_to_run(self) -> Optional[ScheduleBatch]:
ret = new_batch
else:
# Run decode
if not self.running_batch.is_empty():
if (
not self.running_batch.is_empty()
and not self.running_batch.is_prefill_only
):
self.running_batch = self.update_running_batch(self.running_batch)
ret = self.running_batch if not self.running_batch.is_empty() else None
else:
Expand Down
Loading