[Hardware][Ascend] Enable VoxCPM2 eager optimizations (#7207)
Signed-off-by: Big2Wheel <1404207590@qq.com>
This commit is contained in:
1 parent
b2b6c6c7a9
commit
b6b868f3de
7 files changed
+234
-36
No files matched your search
@@ -13,7 +13,7 @@ from tests.helpers.mark import hardware_test
|
||||
from tests.helpers.runtime import OmniRunner
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
|
||||
VOXCPM2_MODEL = "openbmb/VoxCPM2"
|
||||
VOXCPM2_MODEL = os.environ.get("VOXCPM2_MODEL", "openbmb/VoxCPM2")
|
||||
DEPLOY_CONFIG = get_deploy_config_path("voxcpm2.yaml")
|
||||
SAMPLE_RATE = 48000
|
||||
|
||||
@@ -44,7 +44,7 @@ def _extract_audio(multimodal_output: dict) -> torch.Tensor:
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
def test_voxcpm2_zero_shot_001(omni_runner: OmniRunner) -> None:
|
||||
"""Test zero-shot TTS produces valid audio output."""
|
||||
outputs = omni_runner.omni.generate([{"prompt": "Hello, this is a test."}])
|
||||
@@ -57,7 +57,7 @@ def test_voxcpm2_zero_shot_001(omni_runner: OmniRunner) -> None:
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
def test_voxcpm2_voice_clone_002(omni_runner: OmniRunner) -> None:
|
||||
"""Test voice cloning with a reference audio file.
|
||||
|
||||
@@ -98,7 +98,7 @@ def test_voxcpm2_voice_clone_002(omni_runner: OmniRunner) -> None:
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
def test_voxcpm2_prefill_decode_mixed_batch_003(omni_runner: OmniRunner) -> None:
|
||||
"""Regression: prefill+decode mixed batch must not crash (PR #2903)."""
|
||||
long_prompt = (
|
||||
|
||||
@@ -18,7 +18,7 @@ from tests.helpers.mark import hardware_test
|
||||
from tests.helpers.runtime import OmniServerParams
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
|
||||
MODEL = "openbmb/VoxCPM2"
|
||||
MODEL = os.environ.get("VOXCPM2_MODEL", "openbmb/VoxCPM2")
|
||||
DEFAULT_AUDIO_SPEECH_TIMEOUT_S = 300.0
|
||||
MAX_CONCURRENT = 4
|
||||
|
||||
@@ -48,7 +48,7 @@ tts_server_params = [
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_text_to_audio_001(omni_server, online_client) -> None:
|
||||
"""
|
||||
@@ -73,7 +73,7 @@ def test_text_to_audio_001(omni_server, online_client) -> None:
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_text_to_audio_002(omni_server, online_client) -> None:
|
||||
"""
|
||||
|
||||
@@ -20,7 +20,7 @@ pytestmark = [pytest.mark.slow, pytest.mark.tts]
|
||||
|
||||
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
|
||||
|
||||
MODEL = "openbmb/VoxCPM2"
|
||||
MODEL = os.environ.get("VOXCPM2_MODEL", "openbmb/VoxCPM2")
|
||||
DEFAULT_AUDIO_SPEECH_TIMEOUT_S = 300.0
|
||||
_MIN_AUDIO_BYTES = 40_000
|
||||
MAX_CONCURRENT = 4
|
||||
@@ -47,7 +47,7 @@ tts_server_params = [
|
||||
]
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_voice_clone_streaming_001(omni_server, online_client) -> None:
|
||||
"""
|
||||
@@ -72,7 +72,7 @@ def test_voice_clone_streaming_001(omni_server, online_client) -> None:
|
||||
online_client.send_audio_speech_request(request_config, request_num=MAX_CONCURRENT)
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@hardware_test(res={"cuda": "L4", "npu": "A2"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_response_format_001(omni_server, online_client) -> None:
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
"""Regression tests for VoxCPM2 talker per-request state lifecycle."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -72,6 +72,99 @@ def _seed_cached_decode(talker, req_id: str):
|
||||
|
||||
|
||||
class TestStateEvictionContract:
|
||||
def test_eager_optimizations_do_not_require_torch_inductor(self, monkeypatch) -> None:
|
||||
from vllm_omni.model_executor.models.voxcpm2 import voxcpm2_talker as tk
|
||||
|
||||
class FakeEstimator:
|
||||
pass
|
||||
|
||||
class FakeFeatDecoder:
|
||||
def __init__(self, estimator) -> None:
|
||||
self.estimator = estimator
|
||||
self.mean_mode = False
|
||||
|
||||
class FakeTTS:
|
||||
def __init__(self, estimator) -> None:
|
||||
self.feat_decoder = FakeFeatDecoder(estimator)
|
||||
|
||||
talker = _make_bare_talker()
|
||||
estimator = FakeEstimator()
|
||||
talker._tts = FakeTTS(estimator)
|
||||
_, _, RuntimeConfig = _voxcpm2_talker_mod()
|
||||
talker._runtime_config = RuntimeConfig()
|
||||
talker._enable_torch_compile = False
|
||||
|
||||
applied: list[str] = []
|
||||
|
||||
def install_qkv(*_args, **_kwargs) -> int:
|
||||
applied.append("qkv")
|
||||
return 12
|
||||
|
||||
def install_mlp(*_args, **_kwargs) -> int:
|
||||
applied.append("mlp")
|
||||
return 12
|
||||
|
||||
def install_zero_dt(*_args, **_kwargs) -> bool:
|
||||
applied.append("zero_dt")
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(
|
||||
tk,
|
||||
"_install_locdit_fused_qkv",
|
||||
install_qkv,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
tk,
|
||||
"_install_locdit_fused_mlp",
|
||||
install_mlp,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
tk,
|
||||
"_install_locdit_zero_dt_cache",
|
||||
install_zero_dt,
|
||||
)
|
||||
|
||||
talker._setup_execution_optimizations()
|
||||
|
||||
assert applied == ["qkv", "mlp", "zero_dt"]
|
||||
assert talker._eager_optimizations_applied is True
|
||||
assert not hasattr(estimator, "_compiled")
|
||||
|
||||
def test_profiler_drops_invalid_accelerator_graph_events(self, monkeypatch) -> None:
|
||||
from vllm_omni.model_executor.models.voxcpm2 import voxcpm2_talker as tk
|
||||
|
||||
timer = tk._PerfTimer(enabled=False)
|
||||
timer._enabled = True
|
||||
|
||||
class InvalidEvent:
|
||||
def elapsed_time(self, _end) -> float:
|
||||
raise RuntimeError("event recorder null")
|
||||
|
||||
timer._pairs.append(("captured", InvalidEvent(), object()))
|
||||
monkeypatch.setattr(torch.accelerator, "synchronize", lambda: None)
|
||||
|
||||
assert timer.breakdown() == ""
|
||||
assert timer._pairs == []
|
||||
|
||||
def test_profiler_disables_device_without_timing_events(self, monkeypatch) -> None:
|
||||
from vllm_omni.model_executor.models.voxcpm2 import voxcpm2_talker as tk
|
||||
|
||||
class DeviceWithoutEvents:
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(
|
||||
torch,
|
||||
"get_device_module",
|
||||
lambda _device: DeviceWithoutEvents(),
|
||||
)
|
||||
|
||||
timer = tk._PerfTimer(enabled=True)
|
||||
timer.start("cpu")
|
||||
|
||||
assert timer._enabled is False
|
||||
assert timer._device_module is None
|
||||
assert timer._starts == {}
|
||||
|
||||
def test_runtime_config_normalizes_mutually_exclusive_paths(self) -> None:
|
||||
_, _, RuntimeConfig = _voxcpm2_talker_mod()
|
||||
|
||||
@@ -295,6 +388,7 @@ class TestChunkedPrefillContract:
|
||||
talker._get_multichar_zh_split = lambda: {}
|
||||
talker._perf = _NoopPerf()
|
||||
talker._enable_torch_compile = False
|
||||
talker._setup_execution_optimizations = lambda: None
|
||||
talker._setup_cfm_buffers = lambda: None
|
||||
talker._run_cfm_for_state = lambda *_args: torch.ones(1, 1, 4)
|
||||
|
||||
|
||||
Reference in new issue
Block a user