[Config] Disable Async Chunk for Unsupported Pipelines (#5099)

Signed-off-by: Alex Brooks <albrooks@redhat.com>
This commit is contained in:
Alex Brooks authored and GitHub committed 2026-09-29 09:52:09 -06:00
1 parent 1ea0ee3b38
commit 764a109f66
5 files changed
+273 -129

No files matched your search

+87 -8
View File
@@ -1405,6 +1405,21 @@ class TestDeployConfigLoading:
with pytest.raises(ValueError, match=r"stage_args.*PipelineConfig.*stages"):
load_deploy_config(deploy_path)
@pytest.mark.parametrize(
("yaml_val", "expected"),
[
('"2"', 2),
('""', 0),
("null", 0),
],
)
def test_coerces_active_stream_window_to_int(self, tmp_path, yaml_val, expected):
"""Ensure active stream window coerces str to int."""
deploy_path = tmp_path / "deploy.yaml"
deploy_path.write_text(f"active_stream_window: {yaml_val}\n", encoding="utf-8")
deploy = load_deploy_config(deploy_path)
assert deploy.active_stream_window == expected
@pytest.mark.parametrize(
("filename", "max_sessions"),
[
@@ -3511,14 +3526,10 @@ class TestSentinelDefaultPrecedence:
assert stage1.sync_process_input_func is not None
assert stage1.sync_process_input_func.endswith("thinker2talker_token_only")
# async_chunk=True must now be rejected: removing the fake hook means
# there is no next-stage input processor for the validator to accept.
# (Positive consequence -- users can't accidentally enable async_chunk
# on an arch that doesn't actually support it.)
import pytest as _pytest
with _pytest.raises(ValueError, match="async_chunk=True"):
merge_pipeline_deploy(pipeline, DeployConfig(async_chunk=True))
# ensure merging the pipeline deploy with async chunk set to True disables it,
# since currently it is not supported for this pipeline.
stage_configs = merge_pipeline_deploy(pipeline, DeployConfig(async_chunk=True))
assert all([not stg_cfg.yaml_engine_args["async_chunk"] for stg_cfg in stage_configs])
# async_chunk=False merges cleanly and stage-0 yaml_engine_args carries
# no spurious full-payload hook.
@@ -3687,3 +3698,71 @@ class TestObjectStorageConfigResolution:
matching = "s3://any-bucket/my-cosyvoice3-model"
assert StageConfigFactory.try_infer_model_type(model=matching, trust_remote_code=False) == "cosyvoice3"
class TestAsyncChunkDefaults:
def test_async_chunk_auto_disabled_without_processor(self):
"""Ensure a multi-stage model that doesn't support async chunk turns it off by default."""
pipeline = PipelineConfig(
model_type="test_no_async",
model_arch="TestNoAsync",
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="ar",
execution_type=StageExecutionType.LLM_AR,
final_output=True,
),
StagePipelineConfig(
stage_id=1,
model_stage="generation",
execution_type=StageExecutionType.LLM_GENERATION,
input_sources=(0,),
),
),
)
deploy = DeployConfig()
# async chunk should not try to default to True in this case,
# since doing so will just raise a ValueError in validation.
merge_pipeline_deploy(pipeline, deploy)
assert not deploy.async_chunk
def test_async_chunk_auto_disabled_when_yaml_omits_key(self, tmp_path):
"""Ensure a multi-stage model that doesn't support async chunk turns it off by default
when a deploy config is provided that doesn't explicitly set it."""
deploy_path = tmp_path / "no_async_chunk.yaml"
deploy_path.write_text(
"""
stages:
- stage_id: 0
devices: "0"
- stage_id: 1
devices: "0"
""",
encoding="utf-8",
)
deploy = load_deploy_config(deploy_path)
pipeline = PipelineConfig(
model_type="test_no_async",
model_arch="TestNoAsync",
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="ar",
execution_type=StageExecutionType.LLM_AR,
final_output=True,
),
StagePipelineConfig(
stage_id=1,
model_stage="generation",
execution_type=StageExecutionType.LLM_GENERATION,
input_sources=(0,),
),
),
)
merge_pipeline_deploy(pipeline, deploy)
assert not deploy.async_chunk
+73 -11
View File
@@ -4,6 +4,7 @@
from __future__ import annotations
import logging
import warnings
from dataclasses import fields, replace
from inspect import Parameter, signature
@@ -54,6 +55,7 @@ from vllm_omni.config.stage_config import (
load_deploy_config,
merge_pipeline_deploy,
resolve_deploy_yaml,
update_deploy_config_async_chunk_enabled,
)
from vllm_omni.diffusion.diffusion_kv.config import DiffusionKVCacheMode
from vllm_omni.engine.stage_engine_startup import _serialize_stage_config
@@ -64,22 +66,27 @@ pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
_DEPLOY_DIR = Path(__file__).parents[2] / "vllm_omni" / "deploy"
@pytest.mark.parametrize("async_chunk", [False, True])
def test_native_kv_transfer_requires_completed_ar_stage(async_chunk):
from types import SimpleNamespace
pipeline = SimpleNamespace(stages=(), model_type="test")
@pytest.mark.parametrize("async_chunk", [None, False, True])
def test_native_kv_transfer_disables_async_chunk(async_chunk):
"""Ensure that a multistage pipeline that supports async chunk disables it if we have a kv transfer config."""
pipeline = PipelineConfig(
model_type="test",
stages=(
# async_chunk_process_next_stage_input_func doesn't matter, it just needs to exist for this test.
StagePipelineConfig(stage_id=0, model_stage="ar", async_chunk_process_next_stage_input_func="foo.bar"),
StagePipelineConfig(stage_id=1, model_stage="dit", input_sources=(0,), final_output=True),
),
)
kv_transfer_config = {"kv_connector": "MooncakeConnector"}
deploy = DeployConfig(
async_chunk=async_chunk,
stages=[
StageDeployConfig(stage_id=0, engine_extras={"kv_transfer_config": {"kv_connector": "MooncakeConnector"}})
StageDeployConfig(stage_id=0, engine_extras={"kv_transfer_config": kv_transfer_config}),
StageDeployConfig(stage_id=1, engine_extras={"kv_transfer_config": kv_transfer_config}),
],
)
if async_chunk:
with pytest.raises(ValueError, match="requires async_chunk=False"):
omni_config_module._validate_async_chunk_support(pipeline, deploy)
else:
omni_config_module._validate_async_chunk_support(pipeline, deploy)
update_deploy_config_async_chunk_enabled(pipeline, deploy)
assert not deploy.async_chunk
@pytest.fixture(autouse=True)
@@ -780,6 +787,33 @@ def test_from_pipeline_config_dispatches_async_chunk_processors_without_mutating
assert pipeline.get_stage(1).custom_process_input_func is None
def test_from_pipeline_config_async_chunk_none_preserves_yaml_default():
"""Ensure passing None for async chunk in when creating from pipeline keeps yaml defaults."""
config = _from_pipeline_key("qwen3_tts", cli_overrides={"async_chunk": None})
talker_cfg = config.stage_by_id(0)
custom_proc = talker_cfg.custom_process_next_stage_input_func
assert custom_proc is not None
assert custom_proc.endswith("talker2code2wav_async_chunk")
def test_from_pipeline_config_warns_when_single_stage_async_chunk_enabled(caplog: pytest.LogCaptureFixture):
"""Ensure that we get a warning indicating async chunk is disabled if requested for single stage models."""
pipeline = PipelineConfig(
model_type="single_stage",
stages=(StagePipelineConfig(stage_id=0, model_stage="stage", final_output=True),),
)
with caplog.at_level(logging.WARNING, logger="vllm_omni.config.stage_config"):
config = VllmOmniConfig.from_pipeline_config(pipeline, cli_overrides={"async_chunk": True})
assert config.stage_by_id(0).connector_config.async_chunk is False
assert any(
record.levelno == logging.WARNING
and "async chunk is inapplicable to single stage models" in record.getMessage()
for record in caplog.records
)
def test_joyai_code2wav_waits_for_full_payload():
config = _from_pipeline_key("joyai_vl_interaction")
talker = config.stage_by_id(1)
@@ -2285,3 +2319,31 @@ def test_platform_stage_overlay_rejects_invalid_model_runner():
)
with pytest.raises(ValueError, match="model_runner must be 'v1' or 'v2'"):
_apply_platform_overrides(deploy, platform="cuda")
def test_async_chunk_auto_disabled_without_processor():
"""Ensure a multi-stage model that doesn't support async chunk turns it off by default."""
pipeline = PipelineConfig(
model_type="test_no_async",
model_arch="TestNoAsync",
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="ar",
execution_type=StageExecutionType.LLM_AR,
final_output=True,
),
StagePipelineConfig(
stage_id=1,
model_stage="generation",
execution_type=StageExecutionType.LLM_GENERATION,
input_sources=(0,),
),
),
)
deploy = DeployConfig()
# async chunk should not try to default to True in this case,
# since doing so will just raise a ValueError in validation.
merge_pipeline_deploy(pipeline, deploy)
assert not deploy.async_chunk