[Refactor][2/N Scheduler]Replace _FULL_PAYLOAD_INPUT_STAGES with a resolved stage transport capability. (#6149)

Signed-off-by: wy17003 <yaow17003@gmail.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
wy17003andHongsheng Liu authored and GitHub committed 2026-08-25 15:24:59 +08:00
1 parent bae58f84b8
commit b454e34966
37 files changed
+370 -310

No files matched your search

+8 -7
View File
@@ -2753,22 +2753,23 @@ class TestSentinelDefaultPrecedence:
)
def test_ming_flash_omni_topology(self):
"""Guard ming_flash_omni's SIP cleanup: stage 0 has no full-payload
producer hook (arch is not in ``_FULL_PAYLOAD_INPUT_STAGES``), and
stage 1 uses only ``thinker2talker_token_only`` (sync_process_input_func).
"""Guard ming_flash_omni's SIP cleanup: stage 0 has no
``custom_process_next_stage_input_func``, and stage 1 does not set
``requires_full_payload_input=True``. Stage 1 uses only
``thinker2talker_token_only`` (sync_process_input_func).
The dead ``thinker2talker`` (custom_process_input_func) was removed
because ming_flash_omni has no async_chunk support and both functions
called ``_build_talker_inputs`` identically.
Merge under either async_chunk mode must not re-introduce a
stage-0 full-payload hook."""
Merge under either async_chunk mode must not re-introduce either
full-payload transport gate."""
pipeline = resolve_pipeline_config("ming_flash_omni")
assert isinstance(pipeline, PipelineConfig)
stage0, stage1 = pipeline.stages
assert stage0.custom_process_next_stage_input_func is None, (
"ming_flash_omni stage 0 must not declare a full-payload producer "
"(connector path is not active for this arch)."
"ming_flash_omni stage 0 must not declare a full-payload producer hook."
)
assert stage1.requires_full_payload_input is False
assert stage1.custom_process_input_func is None
assert stage1.sync_process_input_func is not None
assert stage1.sync_process_input_func.endswith("thinker2talker_token_only")
+33
View File
@@ -244,6 +244,36 @@ def test_from_pipeline_config_rejects_unowned_deploy_engine_extras(engine_extras
VllmOmniConfig.from_pipeline_config(pipeline, user_deploy_config=deploy)
@pytest.mark.parametrize(
("engine_extras", "cli_overrides"),
[
({"requires_full_payload_input": False}, {}),
({}, {"stage_1_requires_full_payload_input": False}),
],
ids=["deploy", "stage-cli"],
)
def test_from_pipeline_config_rejects_full_payload_input_capability_overrides(
engine_extras,
cli_overrides,
):
pipeline = _resolve_pipeline_or_skip("qwen3_tts")
deploy = DeployConfig(
stages=[
StageDeployConfig(
stage_id=1,
engine_extras=engine_extras,
)
]
)
with pytest.raises(ValueError, match=r"no structured config owner: requires_full_payload_input"):
VllmOmniConfig.from_pipeline_config(
pipeline,
user_deploy_config=deploy,
cli_overrides=cli_overrides,
)
@pytest.mark.parametrize(
("cli_overrides", "stage_id"),
[
@@ -443,10 +473,12 @@ def test_from_pipeline_config_dispatches_async_chunk_processors_without_mutating
async_config = _from_pipeline_key("qwen3_tts")
assert async_config.stage_by_id(0).custom_process_next_stage_input_func.endswith("talker2code2wav_async_chunk")
assert async_config.stage_by_id(1).custom_process_input_func is None
assert async_config.stage_by_id(1).model_config.requires_full_payload_input is True
sync_config = _from_pipeline_key("qwen3_tts", cli_overrides={"async_chunk": False})
assert sync_config.stage_by_id(0).custom_process_next_stage_input_func.endswith("talker2code2wav_full_payload")
assert sync_config.stage_by_id(1).custom_process_input_func.endswith("talker2code2wav_token_only")
assert sync_config.stage_by_id(1).model_config.requires_full_payload_input is True
assert pipeline.get_stage(0).custom_process_next_stage_input_func.endswith("talker2code2wav_full_payload")
assert pipeline.get_stage(1).custom_process_input_func is None
@@ -567,6 +599,7 @@ def test_sub_config_fields_match_structured_scopes():
# legacy engine-args path.
"model_subdir",
"tokenizer_subdir",
"requires_full_payload_input",
}
vllm_load_fields = {f.name for f in fields(VllmLoadConfig)}
assert issubclass(OmniStageLoadConfig, VllmLoadConfig)
@@ -4,10 +4,8 @@ from types import SimpleNamespace
import pytest
from vllm.v1.engine import FinishReason
from vllm_omni.core.sched.omni_scheduler_mixin import (
DEFAULT_INPUT_WAIT_TIMEOUT_S,
OmniSchedulerMixin,
)
from vllm_omni.core.sched import omni_scheduler_mixin
from vllm_omni.core.sched.omni_scheduler_mixin import OmniSchedulerMixin
from vllm_omni.core.sched.output import OmniChunkRecvHandle
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@@ -17,6 +15,77 @@ class _Scheduler(OmniSchedulerMixin):
pass
def test_async_chunk_adapter_initializes_for_stage_zero_sender_and_stage_one_receiver(monkeypatch):
created_adapters = []
def adapter_factory(config):
adapter = SimpleNamespace(vllm_config=config)
created_adapters.append(adapter)
return adapter
monkeypatch.setattr(omni_scheduler_mixin, "OmniChunkTransferAdapter", adapter_factory)
def init_scheduler(**model_config):
scheduler = _Scheduler()
scheduler.vllm_config = SimpleNamespace(model_config=SimpleNamespace(**model_config))
scheduler._init_omni_io_scheduling_state()
return scheduler
producer = init_scheduler(
stage_id=0,
async_chunk=True,
requires_full_payload_input=False,
custom_process_next_stage_input_func="test.pipeline.produce_async_chunk",
)
receiver = init_scheduler(
stage_id=1,
async_chunk=True,
requires_full_payload_input=True,
custom_process_next_stage_input_func=None,
)
terminal_stage = init_scheduler(
stage_id=2,
async_chunk=True,
requires_full_payload_input=False,
custom_process_next_stage_input_func=None,
)
assert producer.chunk_transfer_adapter is not None
assert receiver.chunk_transfer_adapter is not None
assert terminal_stage.chunk_transfer_adapter is not None
assert receiver.input_coordinator is None
assert len(created_adapters) == 3
@pytest.mark.parametrize(
("stage_id", "async_chunk", "required", "enabled"),
[
(0, False, True, False),
(1, True, True, False),
(1, False, False, False),
(1, False, True, True),
],
)
def test_full_payload_coordinator_matches_legacy_gate(monkeypatch, stage_id, async_chunk, required, enabled):
monkeypatch.setattr(
omni_scheduler_mixin,
"OmniChunkTransferAdapter",
lambda _config: SimpleNamespace(),
)
scheduler = _Scheduler()
scheduler.vllm_config = SimpleNamespace(
model_config=SimpleNamespace(
stage_id=stage_id,
async_chunk=async_chunk,
requires_full_payload_input=required,
)
)
scheduler._init_omni_io_scheduling_state()
assert (scheduler.input_coordinator is not None) is enabled
def test_schedule_lifecycle_helpers_process_and_restore_both_input_paths():
calls = []
scheduler = _Scheduler()
@@ -58,7 +127,7 @@ def test_schedule_lifecycle_helpers_process_and_restore_both_input_paths():
("process", scheduler.waiting, scheduler.running, scheduler.requests),
# The chunk deadline runs after chunks are applied, so a chunk that
# arrived this cycle resets the clock before it is measured (R1.1).
("chunk-timeouts", DEFAULT_INPUT_WAIT_TIMEOUT_S),
("chunk-timeouts", omni_scheduler_mixin.DEFAULT_INPUT_WAIT_TIMEOUT_S),
("failed-sends",),
("restore-chunks", scheduler.waiting, scheduler.running, scheduler.requests),
("restore-full", scheduler.waiting),
@@ -20,7 +20,6 @@ import torch
import vllm_omni.core.sched.omni_scheduling_coordinator as coord_mod
from vllm_omni.core.sched.omni_scheduling_coordinator import (
OmniSchedulingCoordinator,
uses_full_payload_input_coordinator,
)
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@@ -96,109 +95,6 @@ class MockQueue:
# ------------------------------------------------------------------ #
class TestFullPayloadCoordinatorSelection(unittest.TestCase):
"""Tests for the (model_arch, model_stage) whitelist gate.
The init_omni_connectors arch allowlist is keyed by ``model_arch`` and
is a superset of the stages registered here -- consumer-wait stages
must be registered explicitly in ``_FULL_PAYLOAD_INPUT_STAGES``, while
the init allowlist covers both producer- and consumer-side runners.
These tests pin which ``(arch, stage)`` pairs the gate fires for today.
"""
# Expected whitelist (model_arch, model_stage). Hardcoded to avoid the
# tautology of importing _FULL_PAYLOAD_INPUT_STAGES and asserting it
# against itself; any drift between this matrix and the whitelist will
# fail loudly here.
EXPECTED_FULL_PAYLOAD_INPUT_STAGES: frozenset[tuple[str, str]] = frozenset(
{
("Qwen3OmniMoeForConditionalGeneration", "talker"),
("Qwen3OmniMoeForConditionalGeneration", "code2wav"),
("Qwen2_5OmniForConditionalGeneration", "talker"),
("Qwen2_5OmniForConditionalGeneration", "code2wav"),
("CovoAudioForConditionalGeneration", "code2wav"),
("MiMoAudioModel", "code2wav"),
("Qwen3TTSCode2Wav", "code2wav"),
("MiniCPMO45Code2Wav", "code2wav"),
# nemotron_voicechat: sync-path RVQ-VAE decode waits for the
# talker's full [frames, 31] code-stack payload.
("NemotronVoiceChatCode2Wav", "code2wav"),
("CosyVoice3Model", "cosyvoice3_code2wav"),
# audex: sync-path TTS decoder (async_chunk: false deploys) and
# the TTA XCodec1 stage (always sync full-payload).
("AudexCode2Wav", "audex_code2wav"),
("AudexXCodec1", "audex_xcodec"),
("IndexTTS2S2MelDecoder", "indextts2_s2mel_decoder"),
("IndexTTS25S2MelDecoder", "indextts2_5_s2mel_decoder"),
("DyninOmniForConditionalGeneration", "token2image"),
("DyninOmniForConditionalGeneration", "token2audio"),
}
)
def test_whitelist_matches_expected_matrix(self):
"""_FULL_PAYLOAD_INPUT_STAGES must equal the hardcoded expected matrix.
Catches both accidental additions (which would silently enable the
consumer-wait gate for a new arch) and accidental removals (which
would silently disable an enabled arch).
"""
from vllm_omni.core.sched.omni_scheduling_coordinator import _FULL_PAYLOAD_INPUT_STAGES
self.assertEqual(
frozenset(_FULL_PAYLOAD_INPUT_STAGES),
self.EXPECTED_FULL_PAYLOAD_INPUT_STAGES,
msg="_FULL_PAYLOAD_INPUT_STAGES drifted from the expected matrix; "
"update EXPECTED_FULL_PAYLOAD_INPUT_STAGES if intentional.",
)
def test_all_whitelisted_arch_stage_pairs_fire_gate(self):
"""Every (arch, stage) pair in the expected matrix must fire
the gate when stage_id > 0 and async_chunk=False.
"""
for arch, stage in self.EXPECTED_FULL_PAYLOAD_INPUT_STAGES:
model_config = SimpleNamespace(
stage_id=1,
async_chunk=False,
model_arch=arch,
model_stage=stage,
)
self.assertTrue(
uses_full_payload_input_coordinator(model_config),
msg=f"expected gate to fire for {arch}/{stage}",
)
def test_other_arch_or_stage_or_mode_does_not_fire(self):
cases = [
SimpleNamespace(
stage_id=1, async_chunk=True, model_arch="Qwen3OmniMoeForConditionalGeneration", model_stage="talker"
),
SimpleNamespace(
stage_id=0, async_chunk=False, model_arch="Qwen3OmniMoeForConditionalGeneration", model_stage="thinker"
),
SimpleNamespace(
stage_id=1,
async_chunk=False,
model_arch="Qwen3OmniMoeForConditionalGeneration",
model_stage="some_future_stage",
),
SimpleNamespace(
stage_id=1, async_chunk=False, model_arch="Qwen3TTSForConditionalGeneration", model_stage="code2wav"
),
SimpleNamespace(
stage_id=1, async_chunk=False, model_arch="MingFlashOmniForConditionalGeneration", model_stage="talker"
),
SimpleNamespace(stage_id=1, async_chunk=False, model_arch=None, model_stage="talker"),
SimpleNamespace(
stage_id=1, async_chunk=False, model_arch="Qwen3OmniMoeForConditionalGeneration", model_stage=None
),
]
for model_config in cases:
self.assertFalse(
uses_full_payload_input_coordinator(model_config),
msg=f"expected gate OFF for {model_config}",
)
class TestCoordinatorUpdateRequestMetadata(unittest.TestCase):
"""Test update_request_metadata applies scheduling metadata to requests."""
+102 -3
View File
@@ -8,6 +8,8 @@ import inspect
import json
import os
import shutil
import sys
import types
from types import SimpleNamespace
from unittest.mock import Mock
@@ -20,6 +22,8 @@ from vllm.engine.arg_utils import EngineArgs
from vllm_omni.config.model import OmniModelConfig
from vllm_omni.engine.arg_utils import OmniEngineArgs
from vllm_omni.engine.stage_init_utils import build_engine_args_dict
from vllm_omni.platforms import current_omni_platform
from vllm_omni.worker.omni_connector_model_runner_mixin import OmniConnectorModelRunnerMixin
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@@ -42,7 +46,102 @@ def test_default_stage_id_is_concrete_int():
assert cfg.stage_id == 0
def test_multimodal_kwarg_overrides(mocker):
def test_full_payload_capability_reaches_omni_model_config(monkeypatch):
"""Keep the pipeline capability intact through the engine adapter."""
captured: dict[str, object] = {}
baseline_config = Mock()
worker_module = types.ModuleType("test_connector_worker")
class ConnectorRunner(OmniConnectorModelRunnerMixin):
pass
class ConnectorWorker:
model_runner_cls = ConnectorRunner
worker_module.ConnectorWorker = ConnectorWorker
monkeypatch.setitem(sys.modules, worker_module.__name__, worker_module)
monkeypatch.setattr(OmniEngineArgs, "_ensure_omni_models_registered", lambda _self: None)
monkeypatch.setattr(EngineArgs, "create_model_config", lambda _self: baseline_config)
def capture_omni_config(_cls, model_config, **omni_kwargs):
assert model_config is baseline_config
captured.update(omni_kwargs)
return baseline_config
monkeypatch.setattr(
OmniModelConfig,
"from_vllm_model_config",
classmethod(capture_omni_config),
)
OmniEngineArgs(
stage_id=1,
requires_full_payload_input=True,
worker_cls="test_connector_worker.ConnectorWorker",
).create_model_config()
assert captured["requires_full_payload_input"] is True
def test_stage_without_connector_configuration_accepts_plain_runner(monkeypatch):
worker_module = types.ModuleType("test_async_scheduler_worker")
class WorkerWithoutConnector:
model_runner_cls = object
worker_module.WorkerWithoutConnector = WorkerWithoutConnector
monkeypatch.setitem(sys.modules, worker_module.__name__, worker_module)
args = OmniEngineArgs(
stage_id=1,
async_chunk=True,
worker_cls="test_async_scheduler_worker.WorkerWithoutConnector",
)
assert args.requires_full_payload_input is False
def test_full_payload_capability_requires_selected_worker_connector(monkeypatch):
worker_module = types.ModuleType("test_worker_without_connector")
class WorkerWithoutConnector:
model_runner_cls = object
worker_module.WorkerWithoutConnector = WorkerWithoutConnector
monkeypatch.setitem(sys.modules, worker_module.__name__, worker_module)
with pytest.raises(ValueError, match="does not provide an Omni connector model runner"):
OmniEngineArgs(
stage_id=1,
requires_full_payload_input=True,
worker_cls="test_worker_without_connector.WorkerWithoutConnector",
)
def test_full_payload_capability_validates_platform_selected_worker(monkeypatch):
worker_module = types.ModuleType("test_platform_worker_without_connector")
class WorkerWithoutConnector:
model_runner_cls = object
worker_module.WorkerWithoutConnector = WorkerWithoutConnector
monkeypatch.setitem(sys.modules, worker_module.__name__, worker_module)
monkeypatch.setattr(
current_omni_platform,
"get_omni_ar_worker_cls",
lambda: "test_platform_worker_without_connector.WorkerWithoutConnector",
)
with pytest.raises(ValueError, match="does not provide an Omni connector model runner"):
OmniEngineArgs(
stage_id=1,
requires_full_payload_input=True,
worker_type="ar",
)
def test_multimodal_kwarg_overrides(monkeypatch):
"""Ensure that overrides in the multimodal config are preserved."""
sig = inspect.signature(OmniEngineArgs)
default_mm_cache = sig.parameters["mm_processor_cache_gb"].default
@@ -56,8 +155,8 @@ def test_multimodal_kwarg_overrides(mocker):
assert self.mm_processor_cache_gb == override_val
return fake_model_config
mocker.patch.object(EngineArgs, "create_model_config", _fake_parent_create_model_config)
mocker.patch.object(OmniModelConfig, "from_vllm_model_config", side_effect=lambda model_config, **_: model_config)
monkeypatch.setattr(EngineArgs, "create_model_config", _fake_parent_create_model_config)
monkeypatch.setattr(OmniModelConfig, "from_vllm_model_config", lambda model_config, **_: model_config)
cfg = OmniEngineArgs(
model="Qwen/Qwen2-VL-2B-Instruct",
+12
View File
@@ -48,6 +48,7 @@ from vllm_omni.engine.stage_init_utils import (
build_engine_args_dict_from_omni_stage_config,
build_legacy_engine_args_dict,
)
from vllm_omni.worker.omni_connector_model_runner_mixin import OmniConnectorModelRunnerMixin
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@@ -123,6 +124,17 @@ def _stable_engine_arg_environment(monkeypatch, tmp_path):
monkeypatch.setattr(stage_init_utils, "resolve_worker_cls", _resolve_test_worker)
class _TestConnectorRunner(OmniConnectorModelRunnerMixin):
pass
class _TestWorker:
model_runner_cls = _TestConnectorRunner
for worker_type in ("ar", "generation"):
worker_module = types.ModuleType(f"test.{worker_type}")
worker_module.Worker = _TestWorker
monkeypatch.setitem(sys.modules, worker_module.__name__, worker_module)
def _engine_arg_inputs(tmp_path: Path) -> tuple[PipelineConfig, DeployConfig, str]:
parent_model = tmp_path / "parent-model"
@@ -67,15 +67,6 @@ def test_architectures_registered() -> None:
assert arch in _OMNI_MODELS, f"{arch} missing from _OMNI_MODELS"
def test_full_payload_whitelists_cover_code2wav_only() -> None:
from vllm_omni.core.sched.omni_scheduling_coordinator import _FULL_PAYLOAD_INPUT_STAGES
assert ("NemotronVoiceChatCode2Wav", "code2wav") in _FULL_PAYLOAD_INPUT_STAGES
# The thinker->talker hop is token-path only: the talker must NOT wait on a
# connector payload or stage 1 hangs.
assert ("NemotronVoiceChatTalkerForConditionalGeneration", "talker") not in _FULL_PAYLOAD_INPUT_STAGES
def test_config_parses_nemo_layout_without_hub_access(monkeypatch) -> None:
# Provide the thinker text config explicitly so the test never touches HF.
cfg = NemotronVoiceChatConfig(