[Refactor] Migrate Step-Audio2 online test to deploy config (#5309)
Signed-off-by: zwhzzz0821 <2831474076@qq.com>
This commit is contained in:
1 parent
8fc9df4331
commit
633ebbd8a4
4 files changed
+74
-113
No files matched your search
@@ -3,34 +3,32 @@
|
||||
"""
|
||||
E2E expansion tests for Step-Audio2 online serving (weekly CI).
|
||||
|
||||
Tests speech-to-speech translation via /v1/chat/completions.
|
||||
Tests audio-to-text generation via /v1/chat/completions.
|
||||
Request shape follows examples/online_serving/step_audio2/openai_chat_completion_client.py.
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.helpers.mark import hardware_test
|
||||
from tests.helpers.media import generate_synthetic_audio
|
||||
from tests.helpers.runtime import OmniServerParams
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
|
||||
os.environ.setdefault("VLLM_WORKER_MULTIPROC_METHOD", "spawn")
|
||||
|
||||
MODEL = "stepfun-ai/Step-Audio-2-mini"
|
||||
STAGE_CONFIG = str(Path(__file__).parent / "stage_configs" / "step_audio2_ci.yaml")
|
||||
DEPLOY_CONFIG = get_deploy_config_path("step_audio2_ci.yaml")
|
||||
SAMPLE_RATE = 16000
|
||||
SEED = 42
|
||||
# pyttsx3 synthetic input phrase; Step-Audio2 text output includes codec tokens
|
||||
# (<audio_NNNN>) so we validate audio only, not text↔audio similarity.
|
||||
SYNTH_PHRASE = "how are you"
|
||||
|
||||
TEST_PARAMS = [
|
||||
pytest.param(
|
||||
OmniServerParams(
|
||||
model=MODEL,
|
||||
stage_config_path=STAGE_CONFIG,
|
||||
server_args=["--deploy-config", DEPLOY_CONFIG, "--trust-remote-code"],
|
||||
env_dict={"VLLM_IMAGE_FETCH_TIMEOUT": "60"},
|
||||
),
|
||||
id="step_audio2",
|
||||
@@ -64,19 +62,11 @@ def _default_sampling_params_list() -> list[dict]:
|
||||
"detokenize": True,
|
||||
"repetition_penalty": 1.05,
|
||||
},
|
||||
{
|
||||
"temperature": 0.0,
|
||||
"top_p": 1.0,
|
||||
"top_k": -1,
|
||||
"max_tokens": 1,
|
||||
"seed": SEED,
|
||||
"detokenize": False,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def _build_s2st_request_config(omni_server, audio_base64: str) -> dict:
|
||||
"""Build audio-to-audio (S2ST) chat completion request config."""
|
||||
def _build_audio_to_text_request_config(omni_server, audio_base64: str) -> dict:
|
||||
"""Build an audio-to-text chat completion request config."""
|
||||
audio_url = f"data:audio/wav;base64,{audio_base64}"
|
||||
return {
|
||||
"model": omni_server.model,
|
||||
@@ -86,7 +76,7 @@ def _build_s2st_request_config(omni_server, audio_base64: str) -> dict:
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "You are an audio processing assistant. Listen and repeat the audio content.",
|
||||
"text": "You are a speech recognition assistant. Transcribe the audio accurately.",
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -94,26 +84,19 @@ def _build_s2st_request_config(omni_server, audio_base64: str) -> dict:
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "audio_url", "audio_url": {"url": audio_url}},
|
||||
{"type": "text", "text": "Please listen to this audio and repeat its content."},
|
||||
{"type": "text", "text": "Please transcribe the audio content."},
|
||||
],
|
||||
},
|
||||
{"role": "assistant", "content": "<tts_start>"},
|
||||
],
|
||||
# Thinker text includes undetokenized audio codec placeholders; assert audio only.
|
||||
"modalities": ["audio"],
|
||||
"audio_ref_text": SYNTH_PHRASE,
|
||||
"modalities": ["text"],
|
||||
"sampling_params_list": _default_sampling_params_list(),
|
||||
"extra_body": {
|
||||
"continue_final_message": True,
|
||||
"add_generation_prompt": False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "H100"}, num_cards=1)
|
||||
def test_single_s2st_request(omni_server, openai_client) -> None:
|
||||
"""Test single speech-to-speech request via chat completions API."""
|
||||
request_config = _build_s2st_request_config(
|
||||
def test_single_audio_to_text_request(omni_server, openai_client) -> None:
|
||||
"""Test a single audio-to-text request via the chat completions API."""
|
||||
request_config = _build_audio_to_text_request_config(
|
||||
omni_server,
|
||||
_synthetic_audio_base64(duration_sec=2),
|
||||
)
|
||||
@@ -122,9 +105,9 @@ def test_single_s2st_request(omni_server, openai_client) -> None:
|
||||
|
||||
@hardware_test(res={"cuda": "H100"}, num_cards=1)
|
||||
@pytest.mark.parametrize("request_num", [2, 4])
|
||||
def test_concurrent_s2st_requests(omni_server, openai_client, request_num: int) -> None:
|
||||
"""Test concurrent speech-to-speech requests."""
|
||||
request_config = _build_s2st_request_config(
|
||||
def test_concurrent_audio_to_text_requests(omni_server, openai_client, request_num: int) -> None:
|
||||
"""Test concurrent audio-to-text requests."""
|
||||
request_config = _build_audio_to_text_request_config(
|
||||
omni_server,
|
||||
_synthetic_audio_base64(duration_sec=2),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user