|
| 1 | +""" |
| 2 | +E2E online serving tests for Qwen3-Omni-MoE with PD (Prefill-Decode) disaggregation. |
| 3 | +
|
| 4 | +Tests both text-only and audio output modalities via the OpenAI-compatible API |
| 5 | +through the 4-stage PD pipeline: Prefill -> Decode -> Talker -> Code2Wav. |
| 6 | +""" |
| 7 | + |
| 8 | +import os |
| 9 | +from pathlib import Path |
| 10 | + |
| 11 | +import pytest |
| 12 | + |
| 13 | +from tests.conftest import ( |
| 14 | + dummy_messages_from_mix_data, |
| 15 | + generate_synthetic_audio, |
| 16 | + generate_synthetic_image, |
| 17 | + generate_synthetic_video, |
| 18 | +) |
| 19 | +from tests.utils import hardware_test |
| 20 | + |
| 21 | +os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" |
| 22 | +os.environ["VLLM_TEST_CLEAN_GPU_MEMORY"] = "0" |
| 23 | + |
| 24 | +models = ["Qwen/Qwen3-Omni-30B-A3B-Instruct"] |
| 25 | + |
| 26 | +# PD disaggregation CI stage config (requires 3x GPUs) |
| 27 | +stage_configs = [str(Path(__file__).parent.parent / "stage_configs" / "qwen3_omni_pd_ci.yaml")] |
| 28 | + |
| 29 | +# Create parameter combinations for model and stage config |
| 30 | +test_params = [(model, stage_config) for model in models for stage_config in stage_configs] |
| 31 | + |
| 32 | + |
| 33 | +def get_system_prompt(): |
| 34 | + return { |
| 35 | + "role": "system", |
| 36 | + "content": [ |
| 37 | + { |
| 38 | + "type": "text", |
| 39 | + "text": ( |
| 40 | + "You are Qwen, a virtual human developed by the Qwen Team, " |
| 41 | + "Alibaba Group, capable of perceiving auditory and visual inputs, " |
| 42 | + "as well as generating text and speech." |
| 43 | + ), |
| 44 | + } |
| 45 | + ], |
| 46 | + } |
| 47 | + |
| 48 | + |
| 49 | +def get_prompt(prompt_type="text_only"): |
| 50 | + prompts = { |
| 51 | + "text_only": "What is the capital of China? Answer in 20 words.", |
| 52 | + "mix": "What is recited in the audio? What is in this image? Describe the video briefly.", |
| 53 | + } |
| 54 | + return prompts.get(prompt_type, prompts["text_only"]) |
| 55 | + |
| 56 | + |
| 57 | +@pytest.mark.advanced_model |
| 58 | +@pytest.mark.core_model |
| 59 | +@pytest.mark.omni |
| 60 | +@hardware_test(res={"cuda": "H100"}, num_cards=3) |
| 61 | +@pytest.mark.parametrize("omni_server", test_params, indirect=True) |
| 62 | +def test_pd_text_to_text(omni_server, openai_client) -> None: |
| 63 | + """ |
| 64 | + Test PD disaggregation with text-only output via OpenAI API. |
| 65 | + Deploy Setting: PD separation yaml |
| 66 | + Input Modal: text |
| 67 | + Output Modal: text |
| 68 | + Input Setting: stream=False |
| 69 | + Datasets: single request |
| 70 | + """ |
| 71 | + messages = dummy_messages_from_mix_data( |
| 72 | + system_prompt=get_system_prompt(), |
| 73 | + content_text=get_prompt("text_only"), |
| 74 | + ) |
| 75 | + |
| 76 | + request_config = { |
| 77 | + "model": omni_server.model, |
| 78 | + "messages": messages, |
| 79 | + "stream": False, |
| 80 | + "modalities": ["text"], |
| 81 | + "key_words": {"text": ["beijing"]}, |
| 82 | + } |
| 83 | + |
| 84 | + openai_client.send_request(request_config) |
| 85 | + |
| 86 | + |
| 87 | +@pytest.mark.advanced_model |
| 88 | +@pytest.mark.core_model |
| 89 | +@pytest.mark.omni |
| 90 | +@hardware_test(res={"cuda": "H100"}, num_cards=3) |
| 91 | +@pytest.mark.parametrize("omni_server", test_params, indirect=True) |
| 92 | +def test_pd_mix_to_text_audio(omni_server, openai_client) -> None: |
| 93 | + """ |
| 94 | + Test PD disaggregation with multi-modal input and text+audio output via OpenAI API. |
| 95 | + Deploy Setting: PD separation yaml |
| 96 | + Input Modal: text + audio + video + image |
| 97 | + Output Modal: text + audio |
| 98 | + Input Setting: stream=True |
| 99 | + Datasets: single request |
| 100 | + """ |
| 101 | + video_data_url = f"data:video/mp4;base64,{generate_synthetic_video(224, 224, 300)['base64']}" |
| 102 | + image_data_url = f"data:image/jpeg;base64,{generate_synthetic_image(224, 224)['base64']}" |
| 103 | + audio_data_url = f"data:audio/wav;base64,{generate_synthetic_audio(5, 1)['base64']}" |
| 104 | + messages = dummy_messages_from_mix_data( |
| 105 | + system_prompt=get_system_prompt(), |
| 106 | + video_data_url=video_data_url, |
| 107 | + image_data_url=image_data_url, |
| 108 | + audio_data_url=audio_data_url, |
| 109 | + content_text=get_prompt("mix"), |
| 110 | + ) |
| 111 | + |
| 112 | + request_config = { |
| 113 | + "model": omni_server.model, |
| 114 | + "messages": messages, |
| 115 | + "stream": True, |
| 116 | + "key_words": { |
| 117 | + "audio": ["water", "chirping", "crackling", "rain"], |
| 118 | + "image": ["square", "quadrate"], |
| 119 | + }, |
| 120 | + } |
| 121 | + |
| 122 | + openai_client.send_request(request_config) |
0 commit comments