[Core][Model] Enable Qwen3-TTS MRV2 and optimize the TTS pipeline (#7781)
Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
103 files changed
+10232
-661
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Guard against out-of-vocabulary stop ids in min-tokens masking (#4962).
|
||||
|
||||
vLLM's input processor folds the stage tokenizer's EOS id into
|
||||
@@ -19,7 +19,7 @@ from vllm.v1.sample.logits_processor import (
|
||||
MinTokensLogitsProcessor,
|
||||
)
|
||||
|
||||
from vllm_omni.worker.sampling_utils import sanitize_min_tokens_stop_ids
|
||||
from vllm_omni.worker.sampling_utils import sanitize_min_tokens_stop_ids, sanitize_sampling_params_min_tokens_stop_ids
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
@@ -28,6 +28,12 @@ CODEC_EOS = 2150
|
||||
TEXT_EOS = 151645
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _disable_vllm_pin_memory_for_cpu(monkeypatch: pytest.MonkeyPatch):
|
||||
"""Keep the module-level H2D helper in CPU-only mode."""
|
||||
monkeypatch.setattr("vllm.utils.torch_utils.PIN_MEMORY", False)
|
||||
|
||||
|
||||
def _make_min_tokens_proc(stop_token_ids: list[int], eos_token_id: int | None) -> MinTokensLogitsProcessor:
|
||||
"""Build a MinTokensLogitsProcessor with one active request, mirroring
|
||||
the production path (engine folds the tokenizer EOS via
|
||||
@@ -113,3 +119,14 @@ def test_guard_handles_multiple_requests():
|
||||
assert out[0, CODEC_EOS] == -float("inf")
|
||||
assert out[1, 7] == -float("inf")
|
||||
assert int((out == -float("inf")).sum()) == 2
|
||||
|
||||
|
||||
def test_sampling_params_guard_filters_only_unreachable_min_tokens_ids():
|
||||
params = SamplingParams(min_tokens=2, stop_token_ids=[CODEC_EOS])
|
||||
params.update_from_generation_config({}, TEXT_EOS)
|
||||
|
||||
sanitize_sampling_params_min_tokens_stop_ids(params, TALKER_VOCAB)
|
||||
|
||||
assert params.all_stop_token_ids == {CODEC_EOS}
|
||||
assert params.stop_token_ids == [CODEC_EOS]
|
||||
assert params.eos_token_id == TEXT_EOS
|
||||
@@ -1724,3 +1724,16 @@ class TestSendRetry(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"fallback,external,expected", [("r", None, "mapped"), (None, "ext", "ext"), (None, None, None)]
|
||||
)
|
||||
def test_resolve_request_id_requires_internal_or_external_id(fallback, external, expected):
|
||||
host = SimpleNamespace(_request_ids_mapping={"r": "mapped"})
|
||||
request = SimpleNamespace(external_req_id=external)
|
||||
if expected is None:
|
||||
with pytest.raises(ValueError, match="request ID"):
|
||||
OmniConnectorModelRunnerMixin._resolve_external_req_id(host, request, fallback)
|
||||
else:
|
||||
assert OmniConnectorModelRunnerMixin._resolve_external_req_id(host, request, fallback) == expected
|
||||
@@ -770,8 +770,10 @@ def test_accumulate_full_payload_output_keeps_all_zero_qwen3_omni_prefill_placeh
|
||||
def test_full_payload_output_accumulation_hook_matrix():
|
||||
assert _make_full_payload_accumulation_runner(model_stage="thinker")._should_accumulate_full_payload_output()
|
||||
assert _make_full_payload_accumulation_runner(model_stage="talker")._should_accumulate_full_payload_output()
|
||||
assert not _make_full_payload_accumulation_runner(
|
||||
model_stage="code2wav", final_output=True
|
||||
# A stage may publish a user-visible output and still feed another stage
|
||||
# (Qwen3-Omni thinker publishes text while sending audio state to talker).
|
||||
assert _make_full_payload_accumulation_runner(
|
||||
model_stage="thinker", final_output=True
|
||||
)._should_accumulate_full_payload_output()
|
||||
assert not _make_full_payload_accumulation_runner(
|
||||
model_stage="token2audio",
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from vllm.compilation.cuda_graph import CUDAGraphMode
|
||||
|
||||
from vllm_omni.worker_v2.omni_model_runner import OmniGPUModelRunner
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dp_size", [1, 2])
|
||||
def test_dispatch_eager_and_manager_paths(monkeypatch, dp_size):
|
||||
runner = object.__new__(OmniGPUModelRunner)
|
||||
runner.cudagraph_manager = None
|
||||
runner.dp_size = dp_size
|
||||
runner.dp_rank = 1
|
||||
|
||||
import vllm.v1.worker.gpu.dp_utils as dp_utils
|
||||
|
||||
expected_tokens = object()
|
||||
sync_calls = []
|
||||
|
||||
def sync_padding(*args, **kwargs):
|
||||
sync_calls.append((args, kwargs))
|
||||
return args[1], expected_tokens
|
||||
|
||||
monkeypatch.setattr(
|
||||
dp_utils,
|
||||
"sync_cudagraph_and_dp_padding",
|
||||
sync_padding,
|
||||
)
|
||||
|
||||
batch_desc, num_tokens_across_dp = runner._dispatch_batch_descriptor(
|
||||
num_reqs=1, num_toks=8, uniform_tok_count=8, num_active_loras=0, use_eager=True, max_query_len=8
|
||||
)
|
||||
assert batch_desc.cg_mode == CUDAGraphMode.NONE
|
||||
if dp_size == 1:
|
||||
assert num_tokens_across_dp is None
|
||||
assert sync_calls == []
|
||||
else:
|
||||
assert num_tokens_across_dp is expected_tokens
|
||||
|
||||
# Non-eager dispatch goes through the cudagraph manager.
|
||||
expected = SimpleNamespace(cg_mode=CUDAGraphMode.PIECEWISE, num_tokens=8, num_reqs=1)
|
||||
dispatch_calls = []
|
||||
|
||||
def dispatch(*args, **kwargs):
|
||||
dispatch_calls.append((args, kwargs))
|
||||
return expected
|
||||
|
||||
runner.cudagraph_manager = SimpleNamespace(dispatch=dispatch)
|
||||
runner.dp_size = 1
|
||||
batch_desc, _ = runner._dispatch_batch_descriptor(
|
||||
num_reqs=1, num_toks=8, uniform_tok_count=8, num_active_loras=0, use_eager=False, max_query_len=8
|
||||
)
|
||||
assert batch_desc is expected
|
||||
assert dispatch_calls == [((1, 8, 8), {"num_active_loras": 0, "max_query_len": 8})]
|
||||
@@ -0,0 +1,34 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.worker import sampling_utils
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def test_fixed_seed_contract_separates_stage_sampler_from_talker_mtp_rng() -> None:
|
||||
assert hasattr(sampling_utils, "apply_fixed_seed_to_sampling_params")
|
||||
assert hasattr(sampling_utils, "get_tts_local_seed")
|
||||
|
||||
stage_only = SimpleNamespace(seed=None, extra_args=None)
|
||||
sampling_utils.apply_fixed_seed_to_sampling_params(
|
||||
stage_only,
|
||||
17,
|
||||
seed_talker_mtp=False,
|
||||
)
|
||||
assert stage_only.seed == 17
|
||||
assert sampling_utils.get_tts_local_seed(stage_only) is None
|
||||
|
||||
talker = SimpleNamespace(seed=None, extra_args={"preserved": True})
|
||||
sampling_utils.apply_fixed_seed_to_sampling_params(
|
||||
talker,
|
||||
23,
|
||||
seed_talker_mtp=True,
|
||||
)
|
||||
assert talker.seed == 23
|
||||
assert talker.extra_args == {"preserved": True, "tts_local_seed": 23}
|
||||
assert sampling_utils.get_tts_local_seed(talker) == 23
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Characterization tests for ``vllm_omni.worker.base.OmniGPUWorkerBase``.
|
||||
|
||||
Pins the CURRENT behaviour of ``determine_available_memory`` (device-level
|
||||
|
||||
Reference in new issue
Block a user