[Bugfix] Send a downstream terminal chunk when a parked stage ends (#6889)

Signed-off-by: psv666 <2693925048@qq.com>
This commit is contained in:
psv666 authored and GitHub committed 2026-09-12 04:10:37 +00:00
1 parent 68294066e3
commit 9ef9fc442a
3 files changed
+519 -13

No files matched your search

@@ -688,6 +688,68 @@ class OmniSchedulerMixin:
engine_core_outputs[0] = output = EngineCoreOutputs()
output.scheduler_stats = stats
def add_request(self, request: Request) -> None:
"""Route a terminal streaming update that lands on a parked session.
Upstream ``Scheduler.add_request`` turns "final update (``resumable``
is False) arrives while the session sits in
``WAITING_FOR_STREAMING_REQ``" into a local
``finish_requests(FINISHED_ABORTED)``. That is fine for a stage whose
output the orchestrator forwards, but an async-chunk *sender* also
owes its downstream stage a terminal chunk: the receiver learns that a
stream ended only from a connector payload carrying ``finished``, and
an abort emits none. The downstream stage then parks in
``WAITING_FOR_CHUNK`` until ``VLLM_OMNI_INPUT_WAIT_TIMEOUT_S`` (600s by
default), long after the client's own deadline -- the realtime
async-chunk hang in vllm-project/vllm-omni#6670.
Whether this races is timing, not configuration: the stage parks only
when its own stop beats both the upstream terminal chunk and the
orchestrator's terminal update, a window of tens of milliseconds at
the end of the last segment. Emit the terminal chunk here so the
downstream stage terminates on the payload path either way.
"""
existing = self.requests.get(request.request_id)
if existing is not None and existing.status == RequestStatus.WAITING_FOR_STREAMING_REQ:
adapter = None if getattr(request, "resumable", False) else self._adapter_owing_terminal(existing)
if adapter is not None:
self._finish_parked_streaming_session(existing, adapter)
return
super().add_request(request)
def _adapter_owing_terminal(self, request: Request) -> OmniChunkTransferAdapter | None:
"""The adapter that owes *request*'s downstream stage a terminal chunk.
Sender ownership starts when the first chunk is queued, before the
background thread initializes its chunk counter. A prewarmed receiver
needs a terminal even if that first chunk has not been sent yet.
Final stages never queue sends, so they never match.
"""
adapter = getattr(self, "chunk_transfer_adapter", None)
if adapter is None:
return None
external_req_id = getattr(request, "external_req_id", None) or request.request_id
return adapter if adapter.has_active_sender(external_req_id) else None
def _finish_parked_streaming_session(self, request: Request, adapter: OmniChunkTransferAdapter) -> None:
"""End a parked async-chunk session with a downstream terminal chunk."""
request.resumable = False
# A segment stop already advanced the adapter's dedup watermark to
# ``generation + 1`` for the segment that never arrived. Claim that
# generation, exactly as ``_update_request_as_session`` would have,
# or ``save_async`` drops this chunk as a late duplicate.
request._omni_segment_generation = int(getattr(request, "_omni_segment_generation", 0) or 0) + 1
# ``force_request_finished``: the terminal must be enqueued *before*
# ``finish_requests``, which skips requests that already report
# ``is_finished()``.
adapter.save_async(
None,
request,
is_segment_finished=False,
force_request_finished=True,
)
self.finish_requests(request.request_id, RequestStatus.FINISHED_STOPPED)
def finish_requests(
self,
request_ids: str | Iterable[str] | None,