[3/5][core]refactor communication layer: PR 3 of 5, all other models in non async mode (#3719)
Signed-off-by: natureofnature <wzliu@connect.hku.hk>
This commit is contained in:
1 parent
0f3264a9c0
commit
3a347b10b0
38 files changed
+3021
-275
No files matched your search
@@ -22,9 +22,8 @@ from vllm.v1.spec_decode.metrics import SpecDecodingStats
|
||||
from vllm_omni.core.sched.omni_scheduler_mixin import OmniSchedulerMixin
|
||||
from vllm_omni.core.sched.omni_scheduling_coordinator import (
|
||||
OmniSchedulingCoordinator,
|
||||
uses_qwen3_omni_full_payload_input_coordinator,
|
||||
uses_full_payload_input_coordinator,
|
||||
)
|
||||
from vllm_omni.core.sched.output import OmniSchedulerOutput
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.chunk_transfer_adapter import (
|
||||
OmniChunkTransferAdapter,
|
||||
)
|
||||
@@ -81,7 +80,7 @@ class OmniARScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
if getattr(model_config, "async_chunk", False):
|
||||
self.chunk_transfer_adapter = OmniChunkTransferAdapter(self.vllm_config)
|
||||
self.input_coordinator: OmniSchedulingCoordinator | None = None
|
||||
if uses_qwen3_omni_full_payload_input_coordinator(model_config):
|
||||
if uses_full_payload_input_coordinator(model_config):
|
||||
self.input_coordinator = OmniSchedulingCoordinator(
|
||||
scheduler_max_num_seqs=self.vllm_config.scheduler_config.max_num_seqs,
|
||||
stage_id=getattr(model_config, "stage_id", 0),
|
||||
@@ -211,18 +210,8 @@ class OmniARScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
for req in list(queue):
|
||||
if getattr(req, "status", None) == RequestStatus.FINISHED_ABORTED:
|
||||
queue.remove(req)
|
||||
connector_output = self._latest_omni_connector_output
|
||||
self._latest_omni_connector_output = None
|
||||
if self.input_coordinator:
|
||||
if connector_output and connector_output.request_metadata:
|
||||
self.input_coordinator.update_request_metadata(
|
||||
self.requests, connector_output.request_metadata, model_mode="ar"
|
||||
)
|
||||
self.input_coordinator.process_pending_full_payload_inputs(
|
||||
self.waiting,
|
||||
self.running,
|
||||
connector_output.stage_recv_req_ids if connector_output else set(),
|
||||
)
|
||||
self._consume_pending_connector_output(model_mode="ar")
|
||||
self._process_pending_input_timeouts()
|
||||
|
||||
if self.chunk_transfer_adapter:
|
||||
self.chunk_transfer_adapter.process_pending_chunks(self.waiting, self.running)
|
||||
@@ -278,13 +267,9 @@ class OmniARScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
finished_reqs = {}
|
||||
|
||||
# Wrap in omni scheduler output to carry transfer metadata.
|
||||
base_fields = SchedulerOutput.__dataclass_fields__.keys()
|
||||
base_data = {name: getattr(scheduler_output, name) for name in base_fields}
|
||||
input_regs = self.input_coordinator.pending_input_registrations if self.input_coordinator else []
|
||||
return OmniSchedulerOutput(
|
||||
**base_data,
|
||||
return self._wrap_omni_scheduler_output(
|
||||
scheduler_output,
|
||||
finished_requests_needing_kv_transfer=finished_reqs,
|
||||
pending_input_registrations=input_regs,
|
||||
)
|
||||
|
||||
def update_from_output(
|
||||
@@ -581,15 +566,7 @@ class OmniARScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
engine_core_outputs[0] = eco = EngineCoreOutputs()
|
||||
eco.scheduler_stats = stats
|
||||
|
||||
omni_output = getattr(model_runner_output, "omni_connector_output", None)
|
||||
if omni_output is not None:
|
||||
self._latest_omni_connector_output = omni_output
|
||||
if self.input_coordinator and omni_output.request_metadata:
|
||||
self.input_coordinator.update_request_metadata(
|
||||
self.requests,
|
||||
omni_output.request_metadata,
|
||||
model_mode="ar",
|
||||
)
|
||||
self._capture_omni_connector_output(model_runner_output)
|
||||
|
||||
# Free blocks that were held for transfer (kv_ready and
|
||||
# active_kv_transfers updates already done before the per-request loop).
|
||||
@@ -668,70 +645,73 @@ class OmniARScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
if self.finished_req_ids_dict is not None:
|
||||
self.finished_req_ids_dict[request.client_index].add(request_id)
|
||||
|
||||
# 2. Omni Specific: Check if we need to transfer KV
|
||||
if self._should_transfer_kv_for_request(request_id):
|
||||
already_triggered = request_id in self.transfer_triggered_requests
|
||||
is_active = request_id in self.active_kv_transfers
|
||||
# Mirror the generation scheduler's try/finally pattern so the
|
||||
# input_coordinator entry is always pruned along every return path,
|
||||
# including the early returns for in-flight / waiting KV transfers
|
||||
# below. _free_input_coordinator_request is a no-op when the
|
||||
# coordinator is None, so the unconditional finally is safe.
|
||||
try:
|
||||
# 2. Omni Specific: Check if we need to transfer KV
|
||||
if self._should_transfer_kv_for_request(request_id):
|
||||
already_triggered = request_id in self.transfer_triggered_requests
|
||||
is_active = request_id in self.active_kv_transfers
|
||||
|
||||
if already_triggered:
|
||||
if is_active:
|
||||
# It triggered but hasn't finished yet. We MUST wait.
|
||||
logger.debug(f"[Omni] Request {request_id} finished but transfer is still ACTIVE. Waiting.")
|
||||
self.waiting_for_transfer_free.add(request_id)
|
||||
if self.input_coordinator is not None:
|
||||
self._free_input_coordinator_request(request_id)
|
||||
kv_xfer_params = None
|
||||
return kv_xfer_params
|
||||
elif request_id in self.waiting_for_transfer_free:
|
||||
# Blocks held until KV extraction completes in a future step.
|
||||
if self.input_coordinator is not None:
|
||||
self._free_input_coordinator_request(request_id)
|
||||
return None
|
||||
if already_triggered:
|
||||
if is_active:
|
||||
# It triggered but hasn't finished yet. We MUST wait.
|
||||
logger.debug(f"[Omni] Request {request_id} finished but transfer is still ACTIVE. Waiting.")
|
||||
self.waiting_for_transfer_free.add(request_id)
|
||||
kv_xfer_params = None
|
||||
return kv_xfer_params
|
||||
elif request_id in self.waiting_for_transfer_free:
|
||||
# Blocks held until KV extraction completes in a future step.
|
||||
return None
|
||||
else:
|
||||
logger.debug(
|
||||
f"[Omni] Request {request_id} finished and transfer no longer ACTIVE (extracted/acked). "
|
||||
"Freeing immediately."
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
f"[Omni] Request {request_id} finished and transfer no longer ACTIVE (extracted/acked). "
|
||||
"Freeing immediately."
|
||||
)
|
||||
else:
|
||||
self.waiting_for_transfer_free.add(request_id)
|
||||
confirmed_computed = self._get_confirmed_num_computed_tokens(request)
|
||||
self._mark_request_for_kv_transfer(request_id, confirmed_computed)
|
||||
# Return KV transfer metadata so it propagates to RequestOutput
|
||||
if request_id in self.requests_needing_kv_transfer:
|
||||
transfer_data = self.requests_needing_kv_transfer[request_id]
|
||||
kv_xfer_params = {
|
||||
"past_key_values": transfer_data["block_ids"],
|
||||
"kv_metadata": {"seq_len": transfer_data["seq_len"], "block_ids": transfer_data["block_ids"]},
|
||||
}
|
||||
# Also update request.additional_information for good measure
|
||||
add_info = getattr(request, "additional_information", None)
|
||||
# If additional_information is an AdditionalInformationPayload-like object,
|
||||
# unpack it into a plain dict.
|
||||
if (
|
||||
add_info is not None
|
||||
and hasattr(add_info, "entries")
|
||||
and isinstance(getattr(add_info, "entries"), dict)
|
||||
):
|
||||
request.additional_information = deserialize_additional_information(add_info)
|
||||
add_info = request.additional_information
|
||||
if add_info is None:
|
||||
request.additional_information = {}
|
||||
add_info = request.additional_information
|
||||
if isinstance(add_info, dict):
|
||||
add_info.update(kv_xfer_params)
|
||||
self.waiting_for_transfer_free.add(request_id)
|
||||
confirmed_computed = self._get_confirmed_num_computed_tokens(request)
|
||||
self._mark_request_for_kv_transfer(request_id, confirmed_computed)
|
||||
# Return KV transfer metadata so it propagates to RequestOutput
|
||||
if request_id in self.requests_needing_kv_transfer:
|
||||
transfer_data = self.requests_needing_kv_transfer[request_id]
|
||||
kv_xfer_params = {
|
||||
"past_key_values": transfer_data["block_ids"],
|
||||
"kv_metadata": {
|
||||
"seq_len": transfer_data["seq_len"],
|
||||
"block_ids": transfer_data["block_ids"],
|
||||
},
|
||||
}
|
||||
# Also update request.additional_information for good measure
|
||||
add_info = getattr(request, "additional_information", None)
|
||||
# If additional_information is an AdditionalInformationPayload-like object,
|
||||
# unpack it into a plain dict.
|
||||
if (
|
||||
add_info is not None
|
||||
and hasattr(add_info, "entries")
|
||||
and isinstance(getattr(add_info, "entries"), dict)
|
||||
):
|
||||
request.additional_information = deserialize_additional_information(add_info)
|
||||
add_info = request.additional_information
|
||||
if add_info is None:
|
||||
request.additional_information = {}
|
||||
add_info = request.additional_information
|
||||
if isinstance(add_info, dict):
|
||||
add_info.update(kv_xfer_params)
|
||||
|
||||
if self.input_coordinator is not None:
|
||||
self._free_input_coordinator_request(request_id)
|
||||
return kv_xfer_params
|
||||
return kv_xfer_params
|
||||
|
||||
# 3. Standard Freeing
|
||||
delay_free_blocks |= connector_delay_free_blocks
|
||||
if self.input_coordinator is not None:
|
||||
# 3. Standard Freeing
|
||||
delay_free_blocks |= connector_delay_free_blocks
|
||||
if not delay_free_blocks:
|
||||
self._free_blocks(request)
|
||||
|
||||
return kv_xfer_params
|
||||
finally:
|
||||
self._free_input_coordinator_request(request_id)
|
||||
if not delay_free_blocks:
|
||||
self._free_blocks(request)
|
||||
|
||||
return kv_xfer_params
|
||||
|
||||
def _free_blocks(self, request: Request):
|
||||
# Helper to match base class structure if not directly available
|
||||
|
||||
@@ -26,9 +26,9 @@ from vllm.v1.spec_decode.metrics import SpecDecodingStats
|
||||
from vllm_omni.core.sched.omni_scheduler_mixin import OmniSchedulerMixin
|
||||
from vllm_omni.core.sched.omni_scheduling_coordinator import (
|
||||
OmniSchedulingCoordinator,
|
||||
uses_qwen3_omni_full_payload_input_coordinator,
|
||||
uses_full_payload_input_coordinator,
|
||||
)
|
||||
from vllm_omni.core.sched.output import OmniCachedRequestData, OmniNewRequestData, OmniSchedulerOutput
|
||||
from vllm_omni.core.sched.output import OmniCachedRequestData, OmniNewRequestData
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.chunk_transfer_adapter import (
|
||||
OmniChunkTransferAdapter,
|
||||
)
|
||||
@@ -46,7 +46,7 @@ class OmniGenerationScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
self.chunk_transfer_adapter = OmniChunkTransferAdapter(self.vllm_config)
|
||||
self._pending_finish_reqs: list[Request] = []
|
||||
self.input_coordinator: OmniSchedulingCoordinator | None = None
|
||||
if uses_qwen3_omni_full_payload_input_coordinator(model_config):
|
||||
if uses_full_payload_input_coordinator(model_config):
|
||||
self.input_coordinator = OmniSchedulingCoordinator(
|
||||
scheduler_max_num_seqs=self.vllm_config.scheduler_config.max_num_seqs,
|
||||
stage_id=getattr(model_config, "stage_id", 0),
|
||||
@@ -82,18 +82,8 @@ class OmniGenerationScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
# Temporary queue: preserve waiting order, do not disturb non-diffusion requests
|
||||
skipped_waiting_requests = create_request_queue(self.policy)
|
||||
req_index = 0
|
||||
connector_output = self._latest_omni_connector_output
|
||||
self._latest_omni_connector_output = None
|
||||
if self.input_coordinator:
|
||||
if connector_output and connector_output.request_metadata:
|
||||
self.input_coordinator.update_request_metadata(
|
||||
self.requests, connector_output.request_metadata, model_mode="generation"
|
||||
)
|
||||
self.input_coordinator.process_pending_full_payload_inputs(
|
||||
self.waiting,
|
||||
self.running,
|
||||
connector_output.stage_recv_req_ids if connector_output else set(),
|
||||
)
|
||||
self._consume_pending_connector_output(model_mode="generation")
|
||||
self._process_pending_input_timeouts()
|
||||
if self.chunk_transfer_adapter:
|
||||
self.chunk_transfer_adapter.process_pending_chunks(self.waiting, self.running)
|
||||
|
||||
@@ -227,14 +217,7 @@ class OmniGenerationScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
res = super().schedule()
|
||||
if self.input_coordinator:
|
||||
self.input_coordinator.restore_queues(self.waiting, self.running)
|
||||
base_fields = SchedulerOutput.__dataclass_fields__.keys()
|
||||
base_data = {name: getattr(res, name) for name in base_fields}
|
||||
return OmniSchedulerOutput(
|
||||
**base_data,
|
||||
pending_input_registrations=(
|
||||
self.input_coordinator.pending_input_registrations if self.input_coordinator else []
|
||||
),
|
||||
)
|
||||
return self._wrap_omni_scheduler_output(res)
|
||||
|
||||
# Compute common prefix blocks (aligned with v1)
|
||||
num_common_prefix_blocks = [0] * len(self.kv_cache_config.kv_cache_groups)
|
||||
@@ -362,14 +345,7 @@ class OmniGenerationScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
if self.input_coordinator:
|
||||
self.input_coordinator.restore_queues(self.waiting, self.running)
|
||||
|
||||
base_fields = SchedulerOutput.__dataclass_fields__.keys()
|
||||
base_data = {name: getattr(scheduler_output, name) for name in base_fields}
|
||||
return OmniSchedulerOutput(
|
||||
**base_data,
|
||||
pending_input_registrations=(
|
||||
self.input_coordinator.pending_input_registrations if self.input_coordinator else []
|
||||
),
|
||||
)
|
||||
return self._wrap_omni_scheduler_output(scheduler_output)
|
||||
|
||||
def finish_requests(self, request_ids, finished_status: RequestStatus) -> list[tuple[str, int]]:
|
||||
"""Handles the finish signal from outside the scheduler.
|
||||
@@ -683,15 +659,7 @@ class OmniGenerationScheduler(OmniSchedulerMixin, VLLMScheduler):
|
||||
engine_core_outputs[0] = eco = EngineCoreOutputs()
|
||||
eco.scheduler_stats = stats
|
||||
|
||||
omni_output = getattr(model_runner_output, "omni_connector_output", None)
|
||||
if omni_output is not None:
|
||||
self._latest_omni_connector_output = omni_output
|
||||
if self.input_coordinator and omni_output.request_metadata:
|
||||
self.input_coordinator.update_request_metadata(
|
||||
self.requests,
|
||||
omni_output.request_metadata,
|
||||
model_mode="generation",
|
||||
)
|
||||
self._capture_omni_connector_output(model_runner_output)
|
||||
|
||||
return engine_core_outputs
|
||||
|
||||
|
||||
@@ -1,8 +1,37 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from vllm.logger import init_logger
|
||||
from vllm.v1.core.sched.output import SchedulerOutput
|
||||
from vllm.v1.engine import EngineCoreEventType
|
||||
from vllm.v1.request import Request, RequestStatus, StreamingUpdate
|
||||
|
||||
from vllm_omni.core.sched.output import OmniChunkRecvHandle, OmniSchedulerOutput
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
# Upper bound on how long a request may sit in full-payload-input wait
|
||||
# (the state ``OmniSchedulingCoordinator`` records via ``_waiting_since``)
|
||||
# before the scheduler force-fails it. Defends against stuck consumer-side
|
||||
# requests when the producer drops a full-payload, send fails, or recv
|
||||
# never arrives. Override per-deployment via
|
||||
# VLLM_OMNI_INPUT_WAIT_TIMEOUT_S; set <=0 to disable the safety net.
|
||||
#
|
||||
# Scope: this constant only covers the full-payload coordinator path
|
||||
# (``input_coordinator``). The async-chunk path uses
|
||||
# ``chunk_transfer_adapter`` and is not affected by this constant.
|
||||
_INPUT_WAIT_TIMEOUT_RAW = os.environ.get("VLLM_OMNI_INPUT_WAIT_TIMEOUT_S", "300")
|
||||
try:
|
||||
DEFAULT_INPUT_WAIT_TIMEOUT_S: float = float(_INPUT_WAIT_TIMEOUT_RAW)
|
||||
except ValueError:
|
||||
logger.warning(
|
||||
"Invalid VLLM_OMNI_INPUT_WAIT_TIMEOUT_S=%r; falling back to 300 seconds.",
|
||||
_INPUT_WAIT_TIMEOUT_RAW,
|
||||
)
|
||||
DEFAULT_INPUT_WAIT_TIMEOUT_S = 300.0
|
||||
|
||||
|
||||
class OmniSchedulerMixin:
|
||||
"""Shared scheduler helpers for omni-specific request handling."""
|
||||
@@ -13,6 +42,111 @@ class OmniSchedulerMixin:
|
||||
if input_coordinator is not None:
|
||||
input_coordinator.free_finished_request(request_id)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Shared scheduler/output helpers (lift the AR / generation duplicates)
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def _consume_pending_connector_output(self, model_mode: str) -> None:
|
||||
"""Drain ``self._latest_omni_connector_output`` into the coordinator.
|
||||
|
||||
Called at the top of every ``schedule()`` cycle. Identical between
|
||||
AR and generation schedulers except for the ``model_mode`` argument
|
||||
forwarded to ``update_request_metadata``.
|
||||
"""
|
||||
connector_output = getattr(self, "_latest_omni_connector_output", None)
|
||||
self._latest_omni_connector_output = None
|
||||
input_coordinator = getattr(self, "input_coordinator", None)
|
||||
if input_coordinator is None:
|
||||
return
|
||||
if connector_output and connector_output.request_metadata:
|
||||
input_coordinator.update_request_metadata(
|
||||
self.requests, connector_output.request_metadata, model_mode=model_mode
|
||||
)
|
||||
input_coordinator.process_pending_full_payload_inputs(
|
||||
self.waiting,
|
||||
self.running,
|
||||
connector_output.stage_recv_req_ids if connector_output else set(),
|
||||
)
|
||||
|
||||
def _process_pending_input_timeouts(self) -> None:
|
||||
"""Force-fail requests waiting on the full-payload coordinator too long.
|
||||
|
||||
Called at the top of every ``schedule()`` cycle, right after
|
||||
``_consume_pending_connector_output``. Without this hook, a request
|
||||
whose producer dropped a payload would sit in the
|
||||
full-payload-input wait state indefinitely (the runner mixin
|
||||
protects ``_pending_load_reqs`` from prune sweeps).
|
||||
|
||||
Reads ``_waiting_since`` timestamps maintained by the input
|
||||
coordinator and delegates to the base scheduler's
|
||||
``finish_requests`` to mark expired requests FINISHED_ERROR.
|
||||
Disabled when ``DEFAULT_INPUT_WAIT_TIMEOUT_S`` is <= 0.
|
||||
|
||||
Scope: only covers ``input_coordinator`` (full-payload path).
|
||||
Async-chunk requests park in ``chunk_transfer_adapter`` instead
|
||||
and are not handled here -- if a similar safety net is needed
|
||||
for the chunk path, it belongs in the chunk adapter.
|
||||
"""
|
||||
if DEFAULT_INPUT_WAIT_TIMEOUT_S <= 0:
|
||||
return
|
||||
input_coordinator = getattr(self, "input_coordinator", None)
|
||||
if input_coordinator is None:
|
||||
return
|
||||
timed_out_ids = input_coordinator.collect_timed_out_request_ids(timeout_s=DEFAULT_INPUT_WAIT_TIMEOUT_S)
|
||||
if not timed_out_ids:
|
||||
return
|
||||
present_ids = {req_id for req_id in timed_out_ids if req_id in self.requests}
|
||||
if not present_ids:
|
||||
return
|
||||
logger.warning(
|
||||
"Marking %d request(s) as FINISHED_ERROR after waiting > %.0fs for connector input: %s",
|
||||
len(present_ids),
|
||||
DEFAULT_INPUT_WAIT_TIMEOUT_S,
|
||||
sorted(present_ids),
|
||||
)
|
||||
self.finish_requests(present_ids, RequestStatus.FINISHED_ERROR)
|
||||
|
||||
def _capture_omni_connector_output(self, model_runner_output: Any) -> None:
|
||||
"""Stash the model runner's omni_connector_output for next schedule().
|
||||
|
||||
Called at the tail of every ``update_from_output()`` -- identical
|
||||
between AR and generation schedulers. Only stashes the output;
|
||||
applying the metadata is the responsibility of
|
||||
``_consume_pending_connector_output()`` at the start of the next
|
||||
``schedule()`` cycle. Applying it twice (once here, once on
|
||||
consume) is unsafe under ``update_request_metadata`` in
|
||||
generation mode, which resets ``prompt_token_ids`` /
|
||||
``_output_token_ids`` / ``num_computed_tokens`` and would
|
||||
clobber any progress between the two calls.
|
||||
"""
|
||||
omni_output = getattr(model_runner_output, "omni_connector_output", None)
|
||||
if omni_output is None:
|
||||
return
|
||||
self._latest_omni_connector_output = omni_output
|
||||
|
||||
def _wrap_omni_scheduler_output(
|
||||
self,
|
||||
base: SchedulerOutput,
|
||||
*,
|
||||
finished_requests_needing_kv_transfer: dict | None = None,
|
||||
pending_input_registrations: list[OmniChunkRecvHandle] | None = None,
|
||||
) -> OmniSchedulerOutput:
|
||||
"""Wrap a base ``SchedulerOutput`` in ``OmniSchedulerOutput``.
|
||||
|
||||
Pulls each base ``SchedulerOutput`` dataclass field via ``getattr``
|
||||
and forwards optional omni-specific fields. Lifted from 4 separate
|
||||
copy-pastes between AR (1) and generation (3) schedulers.
|
||||
"""
|
||||
base_data = {name: getattr(base, name) for name in SchedulerOutput.__dataclass_fields__}
|
||||
input_coordinator = getattr(self, "input_coordinator", None)
|
||||
if pending_input_registrations is None:
|
||||
pending_input_registrations = input_coordinator.pending_input_registrations if input_coordinator else []
|
||||
return OmniSchedulerOutput(
|
||||
**base_data,
|
||||
finished_requests_needing_kv_transfer=finished_requests_needing_kv_transfer or {},
|
||||
pending_input_registrations=pending_input_registrations,
|
||||
)
|
||||
|
||||
def _replace_session_with_streaming_update(
|
||||
self,
|
||||
session: Request,
|
||||
|
||||
@@ -19,16 +19,64 @@ from typing import Any
|
||||
from vllm.logger import init_logger
|
||||
from vllm.v1.request import Request, RequestStatus
|
||||
|
||||
from vllm_omni.core.sched.output import OmniChunkRecvHandle
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def uses_qwen3_omni_full_payload_input_coordinator(model_config: Any) -> bool:
|
||||
return (
|
||||
getattr(model_config, "stage_id", 0) > 0
|
||||
and not getattr(model_config, "async_chunk", False)
|
||||
and getattr(model_config, "model_arch", None) == "Qwen3OmniMoeForConditionalGeneration"
|
||||
and getattr(model_config, "model_stage", None) in {"talker", "code2wav"}
|
||||
# (arch, model_stage) pairs that route their full_payload stage input via
|
||||
# the worker connector and therefore need the scheduler-side coordinator to
|
||||
# park requests in WAITING_FOR_INPUT until the recv side delivers. This set
|
||||
# must stay aligned with the arch scope of `init_omni_connectors` in
|
||||
# gpu_ar_model_runner.py and gpu_generation_model_runner.py. Adding a stage
|
||||
# here without also wiring its worker connector init produces a permanent
|
||||
# Stage 1 hang (gate parks the request, no transport ever releases it).
|
||||
#
|
||||
_FULL_PAYLOAD_INPUT_STAGES: frozenset[tuple[str, str]] = frozenset(
|
||||
{
|
||||
("Qwen3OmniMoeForConditionalGeneration", "talker"),
|
||||
("Qwen3OmniMoeForConditionalGeneration", "code2wav"),
|
||||
# qwen2_5_omni thinker->talker uses the real full-payload
|
||||
# producer builder (text_hidden_states routed via
|
||||
# pooler_output["hidden"] -> accumulator -> connector). Both
|
||||
# stages of qwen2_5_omni are enabled.
|
||||
("Qwen2_5OmniForConditionalGeneration", "talker"),
|
||||
("Qwen2_5OmniForConditionalGeneration", "code2wav"),
|
||||
# covo_audio: fused_thinker_talker (Stage 0) -> code2wav (Stage 1).
|
||||
("CovoAudioForConditionalGeneration", "code2wav"),
|
||||
# mimo_audio: fused_thinker_talker (Stage 0) -> code2wav (Stage 1).
|
||||
("MiMoAudioModel", "code2wav"),
|
||||
# qwen3_tts: Qwen3TTSTalkerForConditionalGeneration (Stage 0)
|
||||
# -> Qwen3TTSCode2Wav (Stage 1). Stage 1 is the consumer.
|
||||
("Qwen3TTSCode2Wav", "code2wav"),
|
||||
# cosyvoice3: cosyvoice3_talker (Stage 0) -> cosyvoice3_code2wav (Stage 1).
|
||||
("CosyVoice3Model", "cosyvoice3_code2wav"),
|
||||
# dynin: token2text (Stage 0) -> token2image (Stage 1) ->
|
||||
# token2audio (Stage 2). Producer wires via
|
||||
# custom_process_next_stage_input_func: *_full_payload in deploy yaml.
|
||||
("DyninOmniForConditionalGeneration", "token2image"),
|
||||
("DyninOmniForConditionalGeneration", "token2audio"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def uses_full_payload_input_coordinator(model_config: Any) -> bool:
|
||||
"""Returns True iff this stage parks pending requests in
|
||||
WAITING_FOR_INPUT awaiting a full_payload delivery on the worker connector.
|
||||
|
||||
Gated by (model_arch, model_stage) — see _FULL_PAYLOAD_INPUT_STAGES for the
|
||||
rationale on why this is a whitelist instead of a marker-driven structural
|
||||
gate.
|
||||
"""
|
||||
if getattr(model_config, "stage_id", 0) <= 0:
|
||||
return False
|
||||
if getattr(model_config, "async_chunk", False):
|
||||
return False
|
||||
key = (
|
||||
getattr(model_config, "model_arch", None),
|
||||
getattr(model_config, "model_stage", None),
|
||||
)
|
||||
return key in _FULL_PAYLOAD_INPUT_STAGES
|
||||
|
||||
|
||||
class OmniSchedulingCoordinator:
|
||||
@@ -59,7 +107,11 @@ class OmniSchedulingCoordinator:
|
||||
|
||||
# Requests waiting for full_payload stage input (WAITING_FOR_INPUT).
|
||||
self._waiting_for_input: deque[Any] = deque()
|
||||
self.pending_input_registrations: list[Any] = []
|
||||
# Per-cycle list of minimal handles to ship to the model runner so it
|
||||
# can call register_chunk_recv(). Typed concretely (not list[Any]) so
|
||||
# the surrounding OmniSchedulerOutput stays msgspec-friendly across
|
||||
# default, PD-disagg, and multi-node executor IPC paths.
|
||||
self.pending_input_registrations: list[OmniChunkRecvHandle] = []
|
||||
|
||||
# Monotonic timestamp recording when each request first entered
|
||||
# WAITING_FOR_CHUNK or WAITING_FOR_INPUT. Used by
|
||||
@@ -166,7 +218,12 @@ class OmniSchedulingCoordinator:
|
||||
self._waiting_since.setdefault(request.request_id, time.monotonic())
|
||||
to_remove.append(request)
|
||||
self._waiting_for_input.append(request)
|
||||
self.pending_input_registrations.append(request)
|
||||
self.pending_input_registrations.append(
|
||||
OmniChunkRecvHandle(
|
||||
request_id=request.request_id,
|
||||
external_req_id=getattr(request, "external_req_id", None),
|
||||
)
|
||||
)
|
||||
elif request.status == RequestStatus.WAITING_FOR_INPUT:
|
||||
if request.request_id in stage_recv_req_ids:
|
||||
request.status = RequestStatus.WAITING
|
||||
@@ -174,7 +231,12 @@ class OmniSchedulingCoordinator:
|
||||
else:
|
||||
to_remove.append(request)
|
||||
self._waiting_for_input.append(request)
|
||||
self.pending_input_registrations.append(request)
|
||||
self.pending_input_registrations.append(
|
||||
OmniChunkRecvHandle(
|
||||
request_id=request.request_id,
|
||||
external_req_id=getattr(request, "external_req_id", None),
|
||||
)
|
||||
)
|
||||
if to_remove:
|
||||
# Use the bulk-remove helper: one O(N) sweep instead of N
|
||||
# repeated O(N) removes from a list-backed queue.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from vllm.v1.core.sched.output import CachedRequestData, NewRequestData, SchedulerOutput
|
||||
from vllm.v1.request import Request
|
||||
@@ -72,9 +71,26 @@ class OmniCachedRequestData(CachedRequestData):
|
||||
additional_information: dict[str, dict | None]
|
||||
|
||||
|
||||
@dataclass
|
||||
class OmniChunkRecvHandle:
|
||||
"""Minimal identifier carried from scheduler to runner for chunk-recv
|
||||
registration.
|
||||
|
||||
The runner's ``register_chunk_recv`` only consumes ``request_id`` and
|
||||
``external_req_id`` from each pending request, so we ship just those
|
||||
two fields instead of the full Request object. Concrete typing
|
||||
keeps msgspec serialization deterministic across IPC (default,
|
||||
PD-disagg, multi-node executor variants) and avoids the
|
||||
``list[Any]`` fallback path.
|
||||
"""
|
||||
|
||||
request_id: str
|
||||
external_req_id: str | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class OmniSchedulerOutput(SchedulerOutput):
|
||||
"""Scheduler output with omni-specific transfer metadata."""
|
||||
|
||||
finished_requests_needing_kv_transfer: dict[str, dict] = field(default_factory=dict)
|
||||
pending_input_registrations: list[Any] = field(default_factory=list)
|
||||
pending_input_registrations: list[OmniChunkRecvHandle] = field(default_factory=list)
|
||||
Reference in new issue
Block a user