[Rebase] Rebase to vllm 0.20.0 (#3232)

Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
Signed-off-by: Zhou Taichang <tzhouam@connect.ust.hk>
Signed-off-by: Yuanheng Zhao <jonathan.zhaoyh@gmail.com>
Co-authored-by: Yuanheng Zhao <54058983+yuanheng-zhao@users.noreply.github.com>
This commit is contained in:
Zhou TaichangandYuanheng Zhao authored and GitHub committed 2026-04-30 09:56:59 +12:00
1 parent dd0fa02547
commit 7f2b1e9386
70 files changed
+1191 -273

No files matched your search

@@ -8,8 +8,10 @@ from __future__ import annotations
import importlib.util
import sys
import types
from pathlib import Path
import numpy as np
import pytest
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@@ -167,3 +169,58 @@ def test_attach_sets_seed_tts_row_even_without_extra_body():
row_pos = src.index("seed_tts_row")
not_ex_pos = src.index("if not ex:")
assert row_pos < not_ex_pos, "seed_tts_row must be set before 'if not ex: return'"
def test_seed_tts_whisper_transcribe_passes_attention_mask(monkeypatch):
from vllm_omni.benchmarks.data_modules import seed_tts_eval
calls = {}
class FakeTensor:
def __init__(self, name: str):
self.name = name
self.device = None
def to(self, device):
self.device = device
return self
class FakeProcessor:
def __call__(self, wav, *, sampling_rate, return_tensors, return_attention_mask=False):
calls["return_attention_mask"] = return_attention_mask
assert sampling_rate == 16000
assert return_tensors == "pt"
assert len(wav) > 0
return types.SimpleNamespace(
input_features=FakeTensor("features"),
attention_mask=FakeTensor("mask") if return_attention_mask else None,
)
def get_decoder_prompt_ids(self, *, language, task):
assert language == "english"
assert task == "transcribe"
return [(1, 2)]
def batch_decode(self, predicted_ids, *, skip_special_tokens):
assert skip_special_tokens
assert predicted_ids == [[42]]
return ["hello"]
class FakeModel:
def generate(self, input_features, **kwargs):
calls["input_features"] = input_features
calls["generate_kwargs"] = kwargs
return [[42]]
monkeypatch.setattr(seed_tts_eval, "_ensure_en_asr", lambda: None)
monkeypatch.setattr(seed_tts_eval, "_en_processor", FakeProcessor())
monkeypatch.setattr(seed_tts_eval, "_en_model", FakeModel())
monkeypatch.setattr(seed_tts_eval, "_device", "cuda:1")
text = seed_tts_eval._transcribe_en_f32_16k(np.ones(1600, dtype=np.float32))
assert text == "hello"
assert calls["return_attention_mask"] is True
assert calls["input_features"].device == "cuda:1"
assert calls["generate_kwargs"]["attention_mask"].device == "cuda:1"
assert calls["generate_kwargs"]["forced_decoder_ids"] == [(1, 2)]
@@ -456,8 +456,8 @@ def test_generation_scheduler_calls_cleanup_on_finished(monkeypatch, mocker: Moc
client_index=0,
take_events=lambda: [],
trace_headers=None,
num_cached_tokens=0,
num_external_computed_tokens=0,
has_encoder_inputs=False,
take_prefill_stats=lambda: None,
num_nans_in_logits=0,
get_finished_reason=lambda: "stop",
)
@@ -537,8 +537,8 @@ def test_ar_scheduler_defers_cleanup_and_queues_save_on_finished(mocker: MockerF
client_index=0,
take_events=lambda: [],
trace_headers=None,
num_cached_tokens=0,
num_external_computed_tokens=0,
has_encoder_inputs=False,
take_prefill_stats=lambda: None,
num_nans_in_logits=0,
get_finished_reason=lambda: "stop",
)
@@ -180,6 +180,7 @@ def test_text_to_text_001(omni_server, openai_client) -> None:
@pytest.mark.omni
@hardware_test(res={"cuda": "H100", "rocm": "MI325"}, num_cards=2)
@pytest.mark.parametrize("omni_server", prefix_test_params, indirect=True)
@pytest.mark.skip(reason="Flaky: identical greedy requests diverge on text_content (prefix caching path).")
def test_thinker_prefix_caching(omni_server, openai_client) -> None:
"""
Test thinker prefix caching by sending identical requests with an image (i.e.,
@@ -9,11 +9,13 @@ from vllm.inputs import PromptType
from tests.helpers.mark import hardware_test
from tests.helpers.stage_config import get_deploy_config_path
from vllm_omni.config.stage_config import _PIPELINE_REGISTRY
from vllm_omni.entrypoints.async_omni import AsyncOmni
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
SEED = 42
pipeline = _PIPELINE_REGISTRY["qwen2_5_omni_thinker_only"]
# Single-stage thinker-only deploy, materialized from tests.helpers.stage_config._CI_OVERLAYS.
stage_config = get_deploy_config_path("ci/qwen2_5_omni_thinker_only.yaml")
+14 -6
View File
@@ -1137,13 +1137,20 @@ class TestLaunchDiffusionStage:
"vllm_omni.engine.async_omni_engine.StageDiffusionClient.from_addresses",
return_value=diffusion_client,
)
mock_acquire_locks = mocker.patch(
"vllm_omni.engine.async_omni_engine.acquire_diffusion_device_locks",
return_value=[101],
)
mock_release_locks = mocker.patch("vllm_omni.engine.async_omni_engine.release_device_locks")
result = engine._launch_diffusion_stage(
stage_cfg=stage_cfg,
metadata=metadata,
omni_master_server=omni_master_server,
stage_init_timeout=60,
)
mock_acquire_locks.assert_called_once_with(5, "diffusion-config", 60)
mock_register.assert_called_once_with(
omni_master_address="127.0.0.1",
omni_master_port=25000,
@@ -1158,7 +1165,8 @@ class TestLaunchDiffusionStage:
request_address="tcp://127.0.0.1:25002",
response_address="tcp://127.0.0.1:25003",
)
mock_handshake.assert_called_once_with(proc, "tcp://127.0.0.1:25001")
mock_handshake.assert_called_once_with(proc, "tcp://127.0.0.1:25001", 60)
mock_release_locks.assert_called_once_with([101])
mock_from_addresses.assert_called_once_with(
metadata,
request_address="tcp://127.0.0.1:25002",
@@ -1205,7 +1213,7 @@ class TestCreateRemoteLlmStage:
@contextmanager
def fake_connect_cm(*args, **kwargs):
yield eng_mgr, coordinator, fake_addresses
yield eng_mgr, coordinator, fake_addresses, None
mocker.patch(
"vllm_omni.engine.async_omni_engine.build_engine_args_dict",
@@ -1265,7 +1273,7 @@ class TestCreateRemoteLlmStage:
@contextmanager
def fake_connect_cm(*args, **kwargs):
yield mocker.Mock(), mocker.Mock(), fake_addresses
yield mocker.Mock(), mocker.Mock(), fake_addresses, None
mocker.patch(
"vllm_omni.engine.async_omni_engine.build_engine_args_dict",
@@ -1329,7 +1337,7 @@ class TestCreateRemoteLlmStage:
@contextmanager
def boom(*args, **kwargs):
yield mocker.Mock(), mocker.Mock(), mocker.Mock()
yield mocker.Mock(), mocker.Mock(), mocker.Mock(), None
raise RuntimeError("handshake failed")
mocker.patch(
@@ -1402,7 +1410,7 @@ class TestConnectRemoteEngineCoresCoordinator:
vllm_config=vllm_config,
omni_master_server=omni_master_server,
stage_id=7,
) as (_, yielded_coordinator, yielded_addresses):
) as (_, yielded_coordinator, yielded_addresses, _tensor_queue):
assert yielded_coordinator is None
assert yielded_addresses.coordinator_input == "tcp://coord-in"
assert yielded_addresses.coordinator_output == "tcp://coord-out"
@@ -1439,7 +1447,7 @@ class TestConnectRemoteEngineCoresCoordinator:
vllm_config=vllm_config,
omni_master_server=omni_master_server,
stage_id=7,
) as (_, yielded_coordinator, yielded_addresses):
) as (_, yielded_coordinator, yielded_addresses, _tensor_queue):
assert yielded_coordinator is None
assert yielded_addresses.coordinator_input is None
assert yielded_addresses.coordinator_output is None
@@ -278,12 +278,14 @@ class TestHandleQueryErrors:
@pytest.mark.asyncio
async def test_query_returns_error_response(self):
"""create_chat_completion returns ErrorResponse → error forwarded."""
from vllm.entrypoints.openai.engine.protocol import ErrorResponse
from vllm.entrypoints.openai.engine.protocol import ErrorInfo, ErrorResponse
err = ErrorResponse(
message="model overloaded",
type="server_error",
code=503,
error=ErrorInfo(
message="model overloaded",
type="server_error",
code=503,
),
)
chat = AsyncMock()
+2 -1
View File
@@ -426,8 +426,9 @@ def test_openai_serving_models_can_consume_async_omni_compat_attrs():
assert serving_models.model_config is model_config
assert serving_models.renderer is renderer
assert serving_models.io_processor is io_processor
assert serving_models.input_processor is input_processor
# vLLM 0.20 keeps io_processor on the engine client instead of copying it.
assert serving_models.engine_client.io_processor is io_processor
def test_get_diffusion_od_config_returns_diffusion_stage_config():
+1 -1
View File
@@ -108,7 +108,7 @@ def test_run_headless_registers_stage_once_and_launches_all_local_engines(mocker
assert manager_kwargs["local_client"] is False
assert manager_kwargs["handshake_address"] == "tcp://127.0.0.1:26001"
assert manager_kwargs["log_stats"] is False
engine_manager.join_first.assert_called_once_with()
engine_manager.monitor_engine_liveness.assert_called_once_with()
engine_manager.shutdown.assert_called_once_with()
@@ -13,7 +13,6 @@ from tests.helpers.mark import hardware_marks
pytestmark = [pytest.mark.full_model, pytest.mark.example, *hardware_marks(res={"cuda": "H100"})]
T2I_SCRIPT = EXAMPLES / "offline_inference" / "text_to_image" / "text_to_image.py"
README_PATH = T2I_SCRIPT.with_name("README.md")
EXAMPLE_OUTPUT_SUBFOLDER = "example_offline_t2i"
@@ -4,6 +4,9 @@ See examples/online_serving/qwen2_5_omni/README.md
"""
import os
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
from pathlib import Path
import pytest
@@ -22,8 +25,6 @@ from tests.helpers.stage_config import get_deploy_config_path
pytestmark = [pytest.mark.full_model, pytest.mark.example, pytest.mark.omni]
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
models = ["Qwen/Qwen2.5-Omni-7B"]
# Single CI deploy YAML; rocm/xpu deltas are picked automatically via the
@@ -4,6 +4,9 @@ See examples/online_serving/qwen3_omni/README.md
"""
import os
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
from pathlib import Path
import pytest
@@ -22,8 +25,6 @@ from tests.helpers.stage_config import get_deploy_config_path
pytestmark = [pytest.mark.full_model, pytest.mark.example, pytest.mark.omni]
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
models = ["Qwen/Qwen3-Omni-30B-A3B-Instruct"]
+8 -1
View File
@@ -3,7 +3,14 @@
"""Pytest marks and decorators for hardware / resource selection (CUDA, ROCm, …)."""
import pytest
from vllm.utils.torch_utils import cuda_device_count_stateless
try:
from vllm.utils.torch_utils import cuda_device_count_stateless
except ImportError:
import torch
def cuda_device_count_stateless() -> int:
return torch.cuda.device_count()
# Re-exported from tests.helpers.env (GPU wait + DeviceMemoryMonitor).
+8 -1
View File
@@ -1084,7 +1084,14 @@ class OmniRunner:
seed: int = 42,
stage_init_timeout: int = 600,
batch_timeout: int = 10,
init_timeout: int = 900,
# Bumped from 900s -> 1800s to give CI cold-cache loads of large
# diffusion models enough headroom (Buildkite #8418 hit a 6-second
# overrun loading Tongyi-MAI/Z-Image-Turbo: weights alone took 690s,
# the full stage was ready at ~896s, but the orchestrator wrapper
# finished at ~906s, just past the previous 900s ceiling). Engine
# production default in AsyncOmniEngine remains 600s; this only
# affects the test runner wrapper.
init_timeout: int = 1800,
shm_threshold_bytes: int = 65536,
log_stats: bool = False,
stage_configs_path: str | None = None,
@@ -411,10 +411,10 @@ def test_gpu_ar_model_runner_supplies_req_output_history_to_model_sampler():
runner.input_batch = _DummyInputBatch()
runner.model = SimpleNamespace(
prefer_model_sampler=True,
sample=lambda logits, sampling_metadata: seen_histories.append(
[list(x) for x in sampling_metadata.output_token_ids]
)
or SamplerOutput(sampled_token_ids=torch.tensor([[7]], dtype=torch.int32), logprobs_tensors=None),
sample=lambda logits, sampling_metadata: (
seen_histories.append([list(x) for x in sampling_metadata.output_token_ids])
or SamplerOutput(sampled_token_ids=torch.tensor([[7]], dtype=torch.int32), logprobs_tensors=None)
),
)
runner.sampler = lambda **_: (_ for _ in ()).throw(AssertionError("fallback sampler should not be used"))
@@ -450,10 +450,10 @@ def test_gpu_ar_model_runner_repairs_async_placeholders_for_model_sampler():
runner.input_batch = _DummyInputBatch()
runner.model = SimpleNamespace(
prefer_model_sampler=True,
sample=lambda logits, sampling_metadata: seen_histories.append(
[list(x) for x in sampling_metadata.output_token_ids]
)
or SamplerOutput(sampled_token_ids=torch.tensor([[7]], dtype=torch.int32), logprobs_tensors=None),
sample=lambda logits, sampling_metadata: (
seen_histories.append([list(x) for x in sampling_metadata.output_token_ids])
or SamplerOutput(sampled_token_ids=torch.tensor([[7]], dtype=torch.int32), logprobs_tensors=None)
),
)
runner.sampler = lambda **_: (_ for _ in ()).throw(AssertionError("fallback sampler should not be used"))
@@ -0,0 +1,22 @@
from __future__ import annotations
from transformers import PreTrainedModel
from vllm_omni.model_executor.models.dynin_omni.dynin_omni_token2audio import (
_ensure_transformers_tied_weights_compat,
)
def test_transformers_tied_weights_compat(monkeypatch):
monkeypatch.delattr(PreTrainedModel, "all_tied_weights_keys", raising=False)
_ensure_transformers_tied_weights_compat()
model = PreTrainedModel.__new__(PreTrainedModel)
model._tied_weights_keys = ["decoder.weight"]
model._dynamic_tied_weights_keys = {"lm_head.weight": "decoder.weight"}
assert model.all_tied_weights_keys == {
"decoder.weight": None,
"lm_head.weight": "decoder.weight",
}