From a6b55196167815f8f44901f43956942c65e7bb95 Mon Sep 17 00:00:00 2001 From: Yueqian Lin <70319226+linyueqian@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:06:20 -0400 Subject: [PATCH] [Bugfix] Report supported tasks for omni models to skip unnecessary chat init (#1645) Signed-off-by: linyueqian --- .../openai_api/test_serving_speech.py | 24 +++++++++++++++++++ vllm_omni/entrypoints/async_omni.py | 7 ++++++ vllm_omni/entrypoints/openai/api_server.py | 5 +++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/entrypoints/openai_api/test_serving_speech.py b/tests/entrypoints/openai_api/test_serving_speech.py index 8b7177365..47790286a 100644 --- a/tests/entrypoints/openai_api/test_serving_speech.py +++ b/tests/entrypoints/openai_api/test_serving_speech.py @@ -1017,3 +1017,27 @@ class TestStreamingResponse: response = client.post("/v1/audio/speech", json={"input": "Hello", "response_format": "wav"}) assert response.status_code == 200 assert "audio/wav" in response.headers["content-type"] + + +class TestAsyncOmniSupportedTasks: + """Test that AsyncOmni reports correct supported tasks based on output modalities.""" + + @pytest.mark.asyncio + async def test_tts_only_no_generate_task(self): + """TTS-only models (audio output, no text) should not include 'generate'.""" + from vllm_omni.entrypoints.async_omni import AsyncOmni + + omni = AsyncOmni.__new__(AsyncOmni) + omni.output_modalities = [None, "audio"] + tasks = await omni.get_supported_tasks() + assert "generate" not in tasks + + @pytest.mark.asyncio + async def test_omni_model_includes_generate(self): + """Models with text output (e.g. Qwen3-Omni) should include 'generate'.""" + from vllm_omni.entrypoints.async_omni import AsyncOmni + + omni = AsyncOmni.__new__(AsyncOmni) + omni.output_modalities = ["text", None, "audio"] + tasks = await omni.get_supported_tasks() + assert "generate" in tasks diff --git a/vllm_omni/entrypoints/async_omni.py b/vllm_omni/entrypoints/async_omni.py index 3c3cb4cd6..0761ae6ef 100644 --- a/vllm_omni/entrypoints/async_omni.py +++ b/vllm_omni/entrypoints/async_omni.py @@ -140,6 +140,13 @@ class AsyncOmni(OmniBase): getattr(self, "_inline_engine", None), ) + async def get_supported_tasks(self) -> set[str]: + """Return supported tasks based on the configured stage output modalities.""" + tasks: set[str] = set() + if "text" in self.output_modalities: + tasks.add("generate") + return tasks + def _create_default_diffusion_stage_cfg(self, kwargs: dict[str, Any]) -> dict[str, Any]: """Create default diffusion stage configuration.""" # TODO: here is different from the Omni class. We should merge the two in the future. diff --git a/vllm_omni/entrypoints/openai/api_server.py b/vllm_omni/entrypoints/openai/api_server.py index 7e7b206f5..98c9752d2 100644 --- a/vllm_omni/entrypoints/openai/api_server.py +++ b/vllm_omni/entrypoints/openai/api_server.py @@ -245,7 +245,10 @@ async def omni_run_server_worker(listen_address, sock, args, client_config=None, else: supported_tasks = ("generate",) if not supported_tasks: - supported_tasks = ("generate",) + # Only default to "generate" when get_supported_tasks is not implemented; + # TTS-only models intentionally return an empty set. + if not hasattr(engine_client, "get_supported_tasks"): + supported_tasks = ("generate",) # OMNI: Pass supported_tasks to build_app (required by upstream vLLM) app = build_openai_app(args, supported_tasks)