Merge origin/main into codex-vae-spatial-decode-auto
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
commit
089851e55a
244 files changed
+16669
-2175
No files matched your search
@@ -2156,12 +2156,12 @@ def test_direct_listen_decision_survives_inner_completion_metadata():
|
||||
)
|
||||
assert decision is not None
|
||||
output = attach_duplex_output_decision(
|
||||
OmniRequestOutput(
|
||||
OmniRequestOutput.from_stage_output(
|
||||
inner_output,
|
||||
request_id="duplex-direct-listen",
|
||||
finished=True,
|
||||
stage_id=0,
|
||||
final_output_type=decision.final_output_type,
|
||||
request_output=inner_output,
|
||||
metrics={
|
||||
"stage_metrics": {
|
||||
"0": {
|
||||
@@ -3049,12 +3049,12 @@ async def test_minicpmo_auto_response_listen_without_response_does_not_defer_com
|
||||
)
|
||||
assert decision is not None
|
||||
listen_output = attach_duplex_output_decision(
|
||||
OmniRequestOutput(
|
||||
OmniRequestOutput.from_stage_output(
|
||||
inner_output,
|
||||
request_id=request_id,
|
||||
finished=True,
|
||||
stage_id=0,
|
||||
final_output_type=decision.final_output_type,
|
||||
request_output=inner_output,
|
||||
),
|
||||
decision,
|
||||
)
|
||||
|
||||
@@ -119,7 +119,6 @@ class MockGenerationResult:
|
||||
|
||||
def __init__(self, images):
|
||||
self.images = images
|
||||
self.request_output = SimpleNamespace(images=images)
|
||||
self.stage_durations = {}
|
||||
self.peak_memory_mb = 0.0
|
||||
|
||||
@@ -137,10 +136,7 @@ class MockStageResult:
|
||||
outputs = [SimpleNamespace(text=text, index=0)]
|
||||
else:
|
||||
outputs = []
|
||||
self.request_output = SimpleNamespace(
|
||||
outputs=outputs,
|
||||
images=self.images,
|
||||
)
|
||||
self.outputs = outputs
|
||||
self.stage_durations = {}
|
||||
self.peak_memory_mb = 0.0
|
||||
|
||||
@@ -2080,22 +2076,20 @@ def test_extract_images_from_result():
|
||||
assert all(isinstance(img, Image.Image) for img in images)
|
||||
assert all(img.size == (64, 64) for img in images)
|
||||
|
||||
# Test dict path: result.request_output["images"]
|
||||
# Test result with "images" attribute set in __init__
|
||||
class DictRequestOutput:
|
||||
def __init__(self):
|
||||
self.request_output = {"images": [np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)]}
|
||||
self.images = [np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)]
|
||||
|
||||
result = DictRequestOutput()
|
||||
images = _extract_images_from_result(result)
|
||||
assert len(images) == 1
|
||||
assert isinstance(images[0], Image.Image)
|
||||
|
||||
# Test attribute path: result.request_output.images
|
||||
# Test result with "images" attribute from an inner object
|
||||
class AttrRequestOutput:
|
||||
def __init__(self):
|
||||
self.request_output = type(
|
||||
"obj", (), {"images": [np.random.randint(0, 255, (32, 32, 3), dtype=np.uint8)]}
|
||||
)()
|
||||
self.images = [np.random.randint(0, 255, (32, 32, 3), dtype=np.uint8)]
|
||||
|
||||
result = AttrRequestOutput()
|
||||
images = _extract_images_from_result(result)
|
||||
|
||||
@@ -180,10 +180,10 @@ def create_mock_audio_output_for_test(
|
||||
audio_tensor = torch.sin(torch.linspace(0, 440 * 2 * torch.pi, num_samples))
|
||||
mock_request_output = MockRequestOutput(request_id=request_id, audio_tensor=audio_tensor)
|
||||
|
||||
return OmniRequestOutput(
|
||||
return OmniRequestOutput.from_stage_output(
|
||||
mock_request_output,
|
||||
stage_id=0,
|
||||
final_output_type="audio",
|
||||
request_output=mock_request_output,
|
||||
)
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ class TestSpeechAPI:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_diffusion_speech_extra_params(self, mocker: MockerFixture):
|
||||
"""Test that extra_params are correctly applied to sampling_params_list in diffusion mode."""
|
||||
"""Test public diffusion speech success and extra_params propagation."""
|
||||
# Mock the engine client
|
||||
mock_engine = mocker.MagicMock()
|
||||
|
||||
@@ -704,7 +704,11 @@ class TestSpeechAPI:
|
||||
|
||||
req = OpenAICreateSpeechRequest(input="Hello", extra_params={"new_arg": 123, "existing_arg": "new_value"})
|
||||
|
||||
await server._create_diffusion_speech(req)
|
||||
response = await server.create_speech(req)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.media_type == "audio/wav"
|
||||
assert response.body == b"dummy"
|
||||
|
||||
# Verify generate was called
|
||||
mock_engine.generate.assert_called_once()
|
||||
@@ -737,6 +741,19 @@ class TestTTSMethods:
|
||||
yield server
|
||||
server.shutdown()
|
||||
|
||||
def test_diffusion_audio_encode_speed_skips_ar_adapter(self, mocker: MockerFixture):
|
||||
"""Pure-diffusion speech keeps generic speed handling outside AR adapters."""
|
||||
server = OmniOpenAIServingSpeech.for_diffusion(
|
||||
diffusion_engine=mocker.MagicMock(),
|
||||
model_name="test-model",
|
||||
)
|
||||
resolve_adapter = mocker.patch.object(serving_speech_module, "resolve_adapter")
|
||||
|
||||
speed = server._audio_encode_speed(OpenAICreateSpeechRequest(input="Hello", speed=1.25))
|
||||
|
||||
assert speed == 1.25
|
||||
resolve_adapter.assert_not_called()
|
||||
|
||||
def test_is_tts_detection_no_stage(self, speech_server):
|
||||
"""Test TTS model detection when no TTS stage exists."""
|
||||
# Fixture creates server with stage_configs = [] -> _is_tts should be False
|
||||
@@ -2292,10 +2309,10 @@ class TestStreamingResponse:
|
||||
self.prompt_logprobs = None
|
||||
self.kv_transfer_params = None
|
||||
|
||||
return OmniRequestOutput(
|
||||
return OmniRequestOutput.from_stage_output(
|
||||
MockRequestOutput(audio_tensor=chunk),
|
||||
stage_id=0,
|
||||
final_output_type="audio",
|
||||
request_output=MockRequestOutput(audio_tensor=chunk),
|
||||
finished=finished,
|
||||
)
|
||||
|
||||
@@ -3441,10 +3458,10 @@ class TestWAVStreaming:
|
||||
self.prompt_logprobs = None
|
||||
self.kv_transfer_params = None
|
||||
|
||||
return OmniRequestOutput(
|
||||
return OmniRequestOutput.from_stage_output(
|
||||
MockRequestOutput(audio_tensor=chunk),
|
||||
stage_id=0,
|
||||
final_output_type="audio",
|
||||
request_output=MockRequestOutput(audio_tensor=chunk),
|
||||
finished=finished,
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import base64
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
from fastapi import FastAPI, WebSocket
|
||||
from pytest_mock import MockerFixture
|
||||
from starlette.testclient import TestClient
|
||||
@@ -11,11 +12,24 @@ from starlette.websockets import WebSocketDisconnect
|
||||
from vllm_omni.entrypoints.openai import serving_speech_stream as streaming_speech_module
|
||||
from vllm_omni.entrypoints.openai.serving_speech import OmniOpenAIServingSpeech
|
||||
from vllm_omni.entrypoints.openai.serving_speech_stream import OmniStreamingSpeechHandler
|
||||
from vllm_omni.utils.forced_aligner import WordTimestamp
|
||||
from vllm_omni.model_executor.stage_input_processors.forced_aligner import ALIGNER_WORDS_KEY
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def _fake_aligner_res(pairs, words):
|
||||
"""Build a stand-in for the forced-aligner stage's pooling output.
|
||||
|
||||
Mirrors what rides the generator in production: ``res.outputs.data`` is a
|
||||
``[n_words, 2]`` int32 tensor of ``[start_ms, end_ms]`` and the word strings
|
||||
travel in ``additional_information``. Decoded by ``extract_word_timestamps``.
|
||||
"""
|
||||
return SimpleNamespace(
|
||||
outputs=SimpleNamespace(data=torch.tensor(pairs, dtype=torch.int32), additional_information=None),
|
||||
additional_information={ALIGNER_WORDS_KEY: list(words)},
|
||||
)
|
||||
|
||||
|
||||
def _build_test_app(
|
||||
speech_service=None,
|
||||
*,
|
||||
@@ -28,9 +42,9 @@ def _build_test_app(
|
||||
speech_service = mocker.MagicMock(spec=OmniOpenAIServingSpeech)
|
||||
speech_service._generate_audio_bytes = mocker.AsyncMock(return_value=(b"RIFF" + b"\x00" * 32, "audio/wav"))
|
||||
speech_service._prepare_speech_generation = mocker.AsyncMock(return_value=("req-1", object(), {}))
|
||||
speech_service.forced_aligner_config = None
|
||||
speech_service.forced_aligner_enabled = False
|
||||
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False):
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False, collect=None):
|
||||
for chunk in (b"\x01\x02", b"\x03\x04\x05"):
|
||||
yield (chunk, 24000) if include_sample_rate else chunk
|
||||
|
||||
@@ -235,7 +249,7 @@ class TestStreamingSpeechWebSocket:
|
||||
speech_service._generate_audio_bytes = mocker.AsyncMock(return_value=(b"", "audio/wav"))
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = None
|
||||
speech_service.forced_aligner_enabled = False
|
||||
|
||||
async def mock_prepare_speech_generation(request):
|
||||
captured_requests.append(request)
|
||||
@@ -311,13 +325,13 @@ class TestStreamingSpeechWebSocket:
|
||||
assert error["type"] == "error"
|
||||
assert "without --forced-aligner" in error["message"]
|
||||
|
||||
def test_word_timestamps_emit_sidecar_json_frame(self, mocker: MockerFixture):
|
||||
def test_word_timestamps_emit_pipeline_json_frame(self, mocker: MockerFixture):
|
||||
captured_requests = []
|
||||
speech_service = mocker.MagicMock(spec=OmniOpenAIServingSpeech)
|
||||
speech_service._generate_audio_bytes = mocker.AsyncMock(return_value=(b"", "audio/wav"))
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = SimpleNamespace(model="aligner")
|
||||
speech_service.forced_aligner_enabled = True
|
||||
|
||||
async def mock_prepare_speech_generation(request):
|
||||
captured_requests.append(request)
|
||||
@@ -328,19 +342,15 @@ class TestStreamingSpeechWebSocket:
|
||||
first_chunk = b"\x01" * 1000
|
||||
second_chunk = b"\x02" * 1000
|
||||
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False):
|
||||
# The forced-aligner stage rides the same generator: its pooling output
|
||||
# is surfaced via the ``collect`` channel once the audio has streamed.
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False, collect=None):
|
||||
for chunk in (first_chunk, second_chunk):
|
||||
yield (chunk, 1000) if include_sample_rate else chunk
|
||||
if collect is not None:
|
||||
collect["aligner_res"] = _fake_aligner_res([[0, 200], [200, 900]], ["Hello", "world"])
|
||||
|
||||
speech_service._generate_pcm_chunks = mock_generate_pcm_chunks
|
||||
# Sentence-level: aligner runs once over the whole sentence audio.
|
||||
mock_align = mocker.AsyncMock(
|
||||
return_value=[
|
||||
WordTimestamp("Hello", 0, 200),
|
||||
WordTimestamp("world", 200, 900),
|
||||
]
|
||||
)
|
||||
mocker.patch.object(streaming_speech_module, "forced_align", mock_align)
|
||||
app, _ = _build_test_app(speech_service)
|
||||
|
||||
with TestClient(app) as client:
|
||||
@@ -406,7 +416,6 @@ class TestStreamingSpeechWebSocket:
|
||||
}
|
||||
|
||||
assert captured_requests[0].word_timestamps is True
|
||||
assert mock_align.await_count == 1
|
||||
|
||||
def test_word_timestamps_emit_word_dicts(self, mocker: MockerFixture):
|
||||
# The streaming layer forwards the aligner's (already monotonic,
|
||||
@@ -415,21 +424,16 @@ class TestStreamingSpeechWebSocket:
|
||||
speech_service._generate_audio_bytes = mocker.AsyncMock(return_value=(b"", "audio/wav"))
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = SimpleNamespace(model="aligner")
|
||||
speech_service.forced_aligner_enabled = True
|
||||
speech_service._prepare_speech_generation = mocker.AsyncMock(return_value=("req", object(), {}))
|
||||
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False):
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False, collect=None):
|
||||
chunk = b"\x01" * 1000
|
||||
yield (chunk, 1000) if include_sample_rate else chunk
|
||||
if collect is not None:
|
||||
collect["aligner_res"] = _fake_aligner_res([[0, 1000], [1000, 1200]], ["Hello", "world"])
|
||||
|
||||
speech_service._generate_pcm_chunks = mock_generate_pcm_chunks
|
||||
mock_align = mocker.AsyncMock(
|
||||
return_value=[
|
||||
WordTimestamp("Hello", 0, 1000),
|
||||
WordTimestamp("world", 1000, 1200),
|
||||
]
|
||||
)
|
||||
mocker.patch.object(streaming_speech_module, "forced_align", mock_align)
|
||||
app, _ = _build_test_app(speech_service)
|
||||
|
||||
with TestClient(app) as client:
|
||||
@@ -572,7 +576,7 @@ class TestStreamingSpeechWebSocket:
|
||||
speech_service._generate_pcm_chunks = mocker.AsyncMock()
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = None
|
||||
speech_service.forced_aligner_enabled = False
|
||||
app, _ = _build_test_app(speech_service)
|
||||
|
||||
with TestClient(app) as client:
|
||||
@@ -602,7 +606,7 @@ class TestStreamingSpeechWebSocket:
|
||||
speech_service._prepare_speech_generation = mocker.AsyncMock(return_value=("req-stream-err", object(), {}))
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = None
|
||||
speech_service.forced_aligner_enabled = False
|
||||
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False):
|
||||
yield b"\x01\x02"
|
||||
@@ -696,7 +700,7 @@ class TestStreamingSpeechWebSocket:
|
||||
speech_service._prepare_speech_generation = mocker.AsyncMock(return_value=("req-abort", object(), {}))
|
||||
speech_service.engine_client = mocker.MagicMock()
|
||||
speech_service.engine_client.abort = mocker.AsyncMock()
|
||||
speech_service.forced_aligner_config = None
|
||||
speech_service.forced_aligner_enabled = False
|
||||
|
||||
async def mock_generate_pcm_chunks(_generator, _request_id, *, include_sample_rate=False):
|
||||
yield b"\x01\x02"
|
||||
|
||||
@@ -47,7 +47,7 @@ def _text_result(text: str) -> OmniRequestOutput:
|
||||
output.text = text
|
||||
request_output = RequestOutput()
|
||||
request_output.outputs = [output]
|
||||
return OmniRequestOutput(final_output_type="text", request_output=request_output)
|
||||
return OmniRequestOutput.from_stage_output(request_output, final_output_type="text")
|
||||
|
||||
|
||||
def _audio_result(audio_data: Any) -> OmniRequestOutput:
|
||||
@@ -61,7 +61,7 @@ def _audio_result(audio_data: Any) -> OmniRequestOutput:
|
||||
output.multimodal_output = {"audio": audio_data}
|
||||
request_output = RequestOutput()
|
||||
request_output.outputs = [output]
|
||||
return OmniRequestOutput(final_output_type="audio", request_output=request_output)
|
||||
return OmniRequestOutput.from_stage_output(request_output, final_output_type="audio")
|
||||
|
||||
|
||||
class MockWebSocket:
|
||||
|
||||
@@ -364,7 +364,7 @@ async def test_omni_generate_request_id():
|
||||
Text modality only; asserts caller-visible ids are preserved across the
|
||||
multi-stage orchestrator path on H100.
|
||||
"""
|
||||
engine = AsyncOmni(model=OMNI_MODEL, stage_configs_path=OMNI_STAGE_CONFIG)
|
||||
engine = AsyncOmni(model=OMNI_MODEL, deploy_config=OMNI_STAGE_CONFIG)
|
||||
try:
|
||||
for req_id in _OMNI_REQ_IDS:
|
||||
async for output in engine.generate(
|
||||
|
||||
@@ -478,12 +478,11 @@ def test_resolve_stage_configs_injects_additional_config_into_diffusion_stage(mo
|
||||
)
|
||||
|
||||
engine = AsyncOmniEngine.__new__(AsyncOmniEngine)
|
||||
engine._strip_single_engine_args = lambda kwargs: kwargs
|
||||
|
||||
_, stage_configs = engine._resolve_stage_configs(
|
||||
"dummy-model",
|
||||
{
|
||||
"stage_configs_path": "dummy.yaml",
|
||||
"deploy_config": "dummy.yaml",
|
||||
"additional_config": {"torchair_graph_config": {"enabled": True}},
|
||||
},
|
||||
trust_remote_code=False,
|
||||
@@ -516,12 +515,11 @@ def test_resolve_stage_configs_injects_quantization_config_into_diffusion_stage(
|
||||
)
|
||||
|
||||
engine = AsyncOmniEngine.__new__(AsyncOmniEngine)
|
||||
engine._strip_single_engine_args = lambda kwargs: kwargs
|
||||
|
||||
_, stage_configs = engine._resolve_stage_configs(
|
||||
"dummy-model",
|
||||
{
|
||||
"stage_configs_path": "dummy.yaml",
|
||||
"deploy_config": "dummy.yaml",
|
||||
"quantization_config": {"method": "bitsandbytes"},
|
||||
},
|
||||
trust_remote_code=False,
|
||||
|
||||
@@ -480,11 +480,9 @@ def test_async_omni_duplex_direct_output_prefers_outer_control_metadata():
|
||||
OmniRequestOutput(
|
||||
request_id="duplex-sid-e0-stage0",
|
||||
stage_id=0,
|
||||
request_output=SimpleNamespace(
|
||||
outputs=[],
|
||||
multimodal_output=SimpleNamespace(kind="processed-payload"),
|
||||
_custom_output={"inner": "completion"},
|
||||
),
|
||||
outputs=[],
|
||||
_multimodal_output={"kind": "processed-payload"},
|
||||
_custom_output={"inner": "completion"},
|
||||
),
|
||||
decision,
|
||||
)
|
||||
@@ -557,7 +555,7 @@ async def test_async_omni_duplex_collect_wraps_raw_response_stage_output():
|
||||
assert outputs[0].finished is False
|
||||
assert outputs[0].stage_id == 1
|
||||
assert outputs[0].final_output_type == "audio"
|
||||
assert outputs[0].request_output is raw_stage1_output
|
||||
assert outputs[0].peak_memory_mb == raw_stage1_output.peak_memory_mb
|
||||
|
||||
|
||||
def test_async_omni_duplex_request_info_includes_response_stage():
|
||||
|
||||
@@ -72,8 +72,8 @@ def make_output_msg(
|
||||
final_output_type=final_output_type,
|
||||
images=images or [],
|
||||
stage_durations={},
|
||||
outputs=[SimpleNamespace(text=payload, index=0)],
|
||||
)
|
||||
engine_output.payload = payload
|
||||
return OutputMessage(
|
||||
request_id=request_id,
|
||||
stage_id=stage_id,
|
||||
@@ -474,7 +474,7 @@ async def test_async_omni_yields_only_final_stage_outputs(monkeypatch: pytest.Mo
|
||||
app.shutdown()
|
||||
|
||||
assert [output.stage_id for output in outputs] == [2]
|
||||
assert [output.request_output.payload for output in outputs] == ["final"]
|
||||
assert [output.outputs[0].text for output in outputs] == ["final"]
|
||||
assert "req-1" not in app.request_states
|
||||
|
||||
|
||||
@@ -492,7 +492,7 @@ async def test_async_omni_accepts_multiple_final_stage_streams(monkeypatch: pyte
|
||||
app.shutdown()
|
||||
|
||||
assert [output.stage_id for output in outputs] == [0, 0, 0, 2, 2, 2]
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
"req-1-stage0-0",
|
||||
"req-1-stage0-1",
|
||||
"req-1-stage0-2",
|
||||
@@ -517,7 +517,7 @@ async def test_async_omni_stops_on_final_stage_finished(monkeypatch: pytest.Monk
|
||||
finally:
|
||||
app.shutdown()
|
||||
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
"req-1-stage0",
|
||||
"req-1-stage2-final",
|
||||
]
|
||||
@@ -544,7 +544,7 @@ async def test_async_omni_diffusion_only_yields_single_image_output(monkeypatch:
|
||||
assert outputs[0].stage_id == 0
|
||||
assert outputs[0].final_output_type == "image"
|
||||
assert outputs[0].images == ["req-1-image"]
|
||||
assert outputs[0].request_output.payload == "req-1-diffusion-final"
|
||||
assert outputs[0].outputs[0].text == "req-1-diffusion-final"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -565,7 +565,7 @@ async def test_async_omni_llm_diffusion_yields_text_stream_then_image(monkeypatc
|
||||
|
||||
assert [output.stage_id for output in outputs] == [0, 0, 0, 1]
|
||||
assert [output.final_output_type for output in outputs] == ["text", "text", "text", "image"]
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
"req-1-text-0",
|
||||
"req-1-text-1",
|
||||
"req-1-text-2",
|
||||
@@ -695,7 +695,7 @@ def test_omni_generate_py_generator_yields_final_outputs_for_each_request(monkey
|
||||
|
||||
assert len(outputs) == 4
|
||||
assert [output.stage_id for output in outputs] == [0, 2, 0, 2]
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
f"{engine.submitted[0]['request_id']}-stage0-0",
|
||||
f"{engine.submitted[0]['request_id']}-stage2-final",
|
||||
f"{engine.submitted[1]['request_id']}-stage0-0",
|
||||
@@ -739,7 +739,7 @@ def test_omni_generate_diffusion_only_yields_single_image_per_request(monkeypatc
|
||||
assert len(outputs) == 2
|
||||
assert [output.stage_id for output in outputs] == [0, 0]
|
||||
assert [output.final_output_type for output in outputs] == ["image", "image"]
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
f"{engine.submitted[0]['request_id']}-diffusion-final",
|
||||
f"{engine.submitted[1]['request_id']}-diffusion-final",
|
||||
]
|
||||
@@ -767,7 +767,7 @@ def test_omni_generate_llm_diffusion_yields_final_text_then_image_per_request(
|
||||
assert len(outputs) == 4
|
||||
assert [output.stage_id for output in outputs] == [0, 1, 0, 1]
|
||||
assert [output.final_output_type for output in outputs] == ["text", "image", "text", "image"]
|
||||
assert [output.request_output.payload for output in outputs] == [
|
||||
assert [output.outputs[0].text for output in outputs] == [
|
||||
f"{engine.submitted[0]['request_id']}-text-0",
|
||||
f"{engine.submitted[0]['request_id']}-image-final",
|
||||
f"{engine.submitted[1]['request_id']}-text-0",
|
||||
@@ -1046,7 +1046,6 @@ def _enqueue_stage_error(
|
||||
if kill_engine:
|
||||
engine._alive = False
|
||||
engine_output = OmniRequestOutput.from_error(msg["request_id"], error_text)
|
||||
engine_output.payload = ""
|
||||
engine.output_q.put_nowait(
|
||||
OutputMessage(
|
||||
request_id=msg["request_id"],
|
||||
|
||||
@@ -205,7 +205,7 @@ def test_run_headless_parses_and_forwards_stage_overrides(mocker: MockerFixture)
|
||||
with pytest.raises(ValueError, match="No stage config found for stage_id=0"):
|
||||
run_headless(args)
|
||||
|
||||
assert captured["args"][1] is None
|
||||
assert len(captured["args"]) == 2
|
||||
assert captured["deploy_config_path"] == "/tmp/deploy.yaml"
|
||||
assert captured["stage_overrides"] == {"0": {"devices": "0,1"}, "1": {"devices": "2"}}
|
||||
assert captured["strategy_config_path"] == "/tmp/strategy.yaml"
|
||||
|
||||
@@ -69,10 +69,10 @@ def _make_text_omni_output(
|
||||
],
|
||||
finished=finish_reason is not None,
|
||||
)
|
||||
return OmniRequestOutput(
|
||||
return OmniRequestOutput.from_stage_output(
|
||||
res,
|
||||
request_id=request_id,
|
||||
final_output_type="text",
|
||||
request_output=res,
|
||||
finished=finish_reason is not None,
|
||||
)
|
||||
|
||||
@@ -108,12 +108,12 @@ def _make_audio_omni_output(
|
||||
outputs=[completion],
|
||||
finished=True,
|
||||
)
|
||||
return OmniRequestOutput(
|
||||
return OmniRequestOutput.from_stage_output(
|
||||
res,
|
||||
request_id=request_id,
|
||||
stage_id=stage_id,
|
||||
replica_id=replica_id,
|
||||
final_output_type="audio",
|
||||
request_output=res,
|
||||
finished=True,
|
||||
)
|
||||
|
||||
@@ -151,7 +151,7 @@ def _build_serving_chat():
|
||||
)
|
||||
instance._create_audio_choice = MagicMock(
|
||||
side_effect=lambda omni_res, role, request, stream=False: _mock_audio_choices(
|
||||
index=omni_res.request_output.outputs[0].index,
|
||||
index=omni_res.outputs[0].index,
|
||||
role=role,
|
||||
)
|
||||
)
|
||||
@@ -489,7 +489,7 @@ async def test_audio_chunk_without_waveform_keeps_stream_alive():
|
||||
request = _make_request(modalities=["text", "audio"])
|
||||
|
||||
empty_audio = _make_audio_omni_output()
|
||||
empty_audio.request_output.outputs[0].multimodal_output = {"audio": []}
|
||||
empty_audio.outputs[0].multimodal_output = {"audio": []}
|
||||
|
||||
def create_audio_choice(omni_res, role, request, stream=False):
|
||||
return OmniOpenAIServingChat._create_audio_choice(serving_chat, omni_res, role, request, stream=stream)
|
||||
|
||||
@@ -381,7 +381,6 @@ class TestLoadAndResolveStageConfigs:
|
||||
|
||||
config_path, stage_configs, _ = load_and_resolve_stage_configs(
|
||||
model="black-forest-labs/FLUX.2-klein-4B",
|
||||
stage_configs_path=None,
|
||||
kwargs=kwargs,
|
||||
trust_remote_code=False,
|
||||
default_stage_cfg_factory=lambda: AsyncOmniEngine._create_default_diffusion_stage_cfg(kwargs),
|
||||
@@ -390,9 +389,7 @@ class TestLoadAndResolveStageConfigs:
|
||||
assert len(stage_configs) == 1
|
||||
assert "dtype" in stage_configs[0]["engine_args"]
|
||||
|
||||
def test_stage_configs_path_promotes_new_deploy_yaml_without_expanding_replicas(
|
||||
self, tmp_path, mocker: MockerFixture
|
||||
):
|
||||
def test_deploy_config_preserves_cli_overrides_and_replicas(self, tmp_path, mocker: MockerFixture):
|
||||
deploy_path = tmp_path / "qwen3_multi.yaml"
|
||||
deploy_path.write_text(
|
||||
'stages:\n - stage_id: 0\n devices: "0"\n - stage_id: 1\n devices: "1,2,3"\n num_replicas: 3\n',
|
||||
@@ -413,18 +410,23 @@ class TestLoadAndResolveStageConfigs:
|
||||
"vllm_omni.entrypoints.utils.load_stage_configs_from_model",
|
||||
return_value=(returned_stage_configs, None),
|
||||
)
|
||||
cli_overrides = {
|
||||
"interleave_mm_strings": True,
|
||||
"media_io_kwargs": {"video": {"fps": 1, "num_frames": 128}},
|
||||
"gpu_memory_utilization": 0.55,
|
||||
}
|
||||
|
||||
config_path, stage_configs, _ = load_and_resolve_stage_configs(
|
||||
model="dummy-model",
|
||||
stage_configs_path=str(deploy_path),
|
||||
kwargs={},
|
||||
kwargs=cli_overrides,
|
||||
trust_remote_code=True,
|
||||
deploy_config_path=str(deploy_path),
|
||||
)
|
||||
|
||||
load_stage_configs.assert_called_once_with(
|
||||
"dummy-model",
|
||||
trust_remote_code=True,
|
||||
base_engine_args={},
|
||||
base_engine_args=cli_overrides,
|
||||
deploy_config_path=str(deploy_path),
|
||||
stage_overrides=None,
|
||||
strategy_config_path=None,
|
||||
|
||||
Reference in new issue
Block a user