Skip to content

Commit 1b290ac

Browse files
Run default _AsyncLLMEngine._run_workers_async in threadpool (#1628)
1 parent 0d57822 commit 1b290ac

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

vllm/engine/async_llm_engine.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,17 @@ async def _run_workers_async(
206206
**kwargs,
207207
) -> Any:
208208
"""Runs the given method on all workers."""
209-
all_outputs = []
209+
coros = []
210210
for worker in self.workers:
211211
if self.parallel_config.worker_use_ray:
212-
executor = partial(worker.execute_method.remote, method)
212+
coros.append(
213+
worker.execute_method.remote(method, *args, **kwargs))
213214
else:
214215
executor = getattr(worker, method)
216+
coros.append(asyncio.get_event_loop().run_in_executor(
217+
None, partial(executor, *args, **kwargs)))
215218

216-
output = executor(*args, **kwargs)
217-
all_outputs.append(output)
218-
219-
if self.parallel_config.worker_use_ray:
220-
all_outputs = await asyncio.gather(*all_outputs)
219+
all_outputs = await asyncio.gather(*coros)
221220

222221
if get_all_outputs:
223222
return all_outputs

0 commit comments

Comments
 (0)