[CI/Bugfix] Async Request ID Aliasing (#3953)

Signed-off-by: Alex Brooks <albrooks@redhat.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Alex BrooksandHongsheng Liu authored and GitHub committed 2026-05-30 16:59:42 +08:00
1 parent 802a6242f0
commit 8d13b54383
5 files changed
+296 -63

No files matched your search

+51 -7
View File
@@ -23,6 +23,7 @@ from vllm.pooling_params import PoolingParams
from vllm.renderers.inputs.preprocess import extract_prompt_components
from vllm.sampling_params import RequestOutputKind, SamplingParams
from vllm.tasks import SupportedTask
from vllm.utils import random_uuid
from vllm.v1.engine.exceptions import EngineDeadError
from vllm_omni.diffusion.data import OmniACK, OmniSleepTask, OmniWakeTask
@@ -215,6 +216,19 @@ class AsyncOmni(EngineClient, OmniBase):
return None
return vllm_config.model_config
@staticmethod
def _get_unique_request_id(external_request_id: str):
"""Get a random new request ID for this request; at the server level,
this is usually set by the calling entrypoint, but in direct calls, we
need to set it explicitly since we do not allow empty IDs.
NOTE: in the upstream vLLM, this is done in the InputProcessor's
`assign_request_id`.
"""
uuid = random_uuid()
prefix = "" if not external_request_id else f"{external_request_id}-"
return f"{prefix}{uuid:.8}"
# ==================== Generate Method ====================
async def generate(
@@ -249,7 +263,8 @@ class AsyncOmni(EngineClient, OmniBase):
Args:
prompt: A single prompt **or** a list of prompts. A list
triggers batch mode when the diffusion stage is reached.
request_id: Unique identifier for this request.
request_id: Unique identifier for this request. If one is not provided,
a random one will be generated.
sampling_params_list: List of SamplingParams, one per stage.
Must have the same length as the number of stages.
If *None*, uses default sampling params for each stage.
@@ -263,11 +278,17 @@ class AsyncOmni(EngineClient, OmniBase):
Raises:
ValueError: If sampling_params_list has incorrect length.
"""
# Append a random UUID suffix to the request_id to ensure it is unique
# and non-empty, similar to vLLM's input processor. The suffix is used
# only for internal tracking throughout the request's life.
external_request_id = request_id
request_id = self._get_unique_request_id(external_request_id)
# Wait until generation is resumed if the engine is paused
async with self._pause_cond:
await self._pause_cond.wait_for(lambda: not self._paused)
logger.debug(f"[AsyncOmni] generate() called for request {request_id}")
logger.debug(f"[AsyncOmni] generate() called for request {external_request_id}")
input_stream_task: asyncio.Task | None = None
try:
@@ -302,7 +323,11 @@ class AsyncOmni(EngineClient, OmniBase):
wall_start_ts,
final_stage_id_for_e2e,
)
req_state = ClientRequestState(request_id)
req_state = ClientRequestState(
request_id=request_id,
external_request_id=external_request_id,
)
req_state.metrics = metrics
self.request_states[request_id] = req_state
@@ -353,11 +378,11 @@ class AsyncOmni(EngineClient, OmniBase):
except (asyncio.CancelledError, GeneratorExit):
if input_stream_task is not None and not input_stream_task.done():
input_stream_task.cancel()
await self.abort(request_id)
await self._abort_internal_requests(request_id)
logger.info(f"[AsyncOmni] Request {request_id} aborted.")
raise
except Exception as e:
await self.abort(request_id)
await self._abort_internal_requests(request_id)
logger.info(f"[AsyncOmni] Request {request_id} failed (input error): {e}")
raise
@@ -541,6 +566,8 @@ class AsyncOmni(EngineClient, OmniBase):
)
if output_to_yield:
# Set the external request ID back to the user yielded input
output_to_yield.request_id = req_state.external_request_id or output_to_yield.request_id
logger.debug(
"[AsyncOmni] req=%s stage-%s yielding final_output_type=%s",
request_id,
@@ -687,9 +714,26 @@ class AsyncOmni(EngineClient, OmniBase):
async def abort(self, request_id: str | Iterable[str]) -> None:
"""Abort request(s) via the Orchestrator."""
request_ids = [request_id] if isinstance(request_id, str) else list(request_id)
# Map the external user request IDs to internal IDs used by the Orchestrator.
# NOTE: If the user request_id matches multiple requests, all of them will be
# aborted. This is also what happens in this case in vLLM's output processor.
internal_ids = [s.request_id for s in self.request_states.values() if s.external_request_id in request_ids]
await self._abort(internal_ids)
async def _abort_internal_requests(self, request_id: str | Iterable[str]):
"""Abort request(s) via the Orchestrator given internal request IDs,
which take the format <external_request_id>-<UUID>.
"""
request_ids = [request_id] if isinstance(request_id, str) else list(request_id)
# Request IDs are already internal, so we just need to get the matching states.
internal_req_ids = [rid for rid in request_ids if rid in self.request_states]
await self._abort(internal_req_ids)
async def _abort(self, request_ids: list[str]) -> None:
"""Submit request IDs to be aborted to the engine."""
await self.engine.abort_async(request_ids)
for req_id in request_ids:
self.request_states.pop(req_id, None)
for rid in request_ids:
self.request_states.pop(rid, None)
if self.log_stats:
logger.info("[AsyncOmni] Aborted request(s) %s", ",".join(request_ids))
@@ -6,8 +6,14 @@ from vllm_omni.metrics import OrchestratorAggregator
class ClientRequestState:
"""Tracks the state of an individual request in the orchestrator."""
def __init__(self, request_id: str, queue: asyncio.Queue | None = None):
def __init__(
self,
request_id: str,
external_request_id: str | None = None,
queue: asyncio.Queue | None = None,
):
self.request_id = request_id
self.external_request_id = external_request_id
self.stage_id: int | None = None
self.queue = queue if queue is not None else asyncio.Queue()
self.metrics: OrchestratorAggregator | None = None