Skip to content

Commit

Permalink
use deque
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy committed Oct 16, 2024
1 parent 6d85681 commit 01731ba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/sglang/srt/managers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import time
import warnings
from collections import deque
from types import SimpleNamespace
from typing import List, Optional, Union

Expand Down Expand Up @@ -292,9 +293,7 @@ def event_loop_normal(self):

@torch.inference_mode()
def event_loop_overlap(self):
from queue import Queue

result_queue = Queue()
result_queue = deque()

self.last_batch = None
self.running_batch = None
Expand All @@ -307,10 +306,10 @@ def event_loop_overlap(self):
self.cur_batch = batch
if batch:
result = self.run_batch(batch)
result_queue.put((batch.copy(), result))
result_queue.append((batch.copy(), result))

if self.last_batch:
tmp_batch, tmp_result = result_queue.get()
tmp_batch, tmp_result = result_queue.popleft()
self.process_batch_result(tmp_batch, tmp_result)
elif batch is None:
self.check_memory()
Expand Down

0 comments on commit 01731ba

Please sign in to comment.