[Bugfix] AsyncLLMEngine hangs with asyncio.run (#5654)

This commit is contained in:
zifeitong
2024-06-19 13:57:12 -07:00
committed by GitHub
parent d571ca0108
commit 78687504f7
5 changed files with 271 additions and 47 deletions

View File

@@ -10,6 +10,7 @@ import vllm.envs as envs
from vllm.config import DecodingConfig, ModelConfig
from vllm.core.scheduler import SchedulerOutputs
from vllm.engine.arg_utils import AsyncEngineArgs
from vllm.engine.async_timeout import asyncio_timeout
from vllm.engine.llm_engine import LLMEngine
from vllm.executor.ray_utils import initialize_ray_cluster, ray
from vllm.inputs import LLMInputs, PromptInputs
@@ -545,8 +546,8 @@ class AsyncLLMEngine:
# Abort if iteration takes too long due to unrecoverable errors
# (eg. NCCL timeouts).
try:
has_requests_in_progress = await asyncio.wait_for(
self.engine_step(), ENGINE_ITERATION_TIMEOUT_S)
async with asyncio_timeout(ENGINE_ITERATION_TIMEOUT_S):
has_requests_in_progress = await self.engine_step()
except asyncio.TimeoutError as exc:
logger.error(
"Engine iteration timed out. This should never happen!")