Skip to content

Commit d8e82bc

Browse files
authored
[Bugfix] fix V1 Engine crash while handling requests with duplicate request id (#15043)
Signed-off-by: Jiahui Sun <[email protected]>
1 parent 086b568 commit d8e82bc

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

tests/v1/engine/test_engine_core.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ def test_engine_core(monkeypatch: pytest.MonkeyPatch):
158158
assert len(engine_core.scheduler.waiting) == 0
159159
assert len(engine_core.scheduler.running) == 0
160160

161+
# Sending duplicate requests with same request_id
162+
req0 = make_request()
163+
req1 = make_request()
164+
req0.request_id = req1.request_id = "test"
165+
engine_core.add_request(req0)
166+
167+
while len(engine_core.step().outputs) > 0:
168+
pass
169+
170+
engine_core.add_request(req1)
171+
while len(engine_core.step().outputs) > 0:
172+
pass
173+
174+
assert len(engine_core.scheduler.waiting) == 0
175+
assert len(engine_core.scheduler.running) == 0
176+
161177

162178
@create_new_process_for_each_test()
163179
def test_engine_core_advanced_sampling(monkeypatch: pytest.MonkeyPatch):

vllm/v1/engine/core.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,6 @@ def step(self) -> EngineCoreOutputs:
179179
scheduler_stats=self.scheduler.make_stats(),
180180
)
181181
scheduler_output = self.scheduler.schedule()
182-
183-
# This case may occur when the only unfinished requests are
184-
# structured output requests where the grammar has not finished
185-
# compiling yet, so there's nothing to run.
186-
if scheduler_output.total_num_scheduled_tokens == 0:
187-
return EngineCoreOutputs(
188-
outputs=[],
189-
scheduler_stats=self.scheduler.make_stats(),
190-
)
191-
192182
output = self.model_executor.execute_model(scheduler_output)
193183
engine_core_outputs = self.scheduler.update_from_output(
194184
scheduler_output, output) # type: ignore

0 commit comments

Comments
 (0)