@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / d7543862bd
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 12:15 UTC

[Misc] Rename assets for testing (#17575)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed May 2, 2025 at 18:29 UTC d7543862bd6b5a47496a53b3c3625ad5110215f8
28 files changed +145 -131
examples/offline_inference/qwen2_5_omni/only_thinker.py
+2 -2
@@ -47,7 +47,7 @@ def get_mixed_modalities_query() -> QueryResult:
47 "image":
48 ImageAsset("cherry_blossom").pil_image.convert("RGB"),
49 "video":
50 - VideoAsset(name="sample_demo_1", num_frames=16).np_ndarrays,
50 + VideoAsset(name="baby_reading", num_frames=16).np_ndarrays,
51 },
52 },
53 limit_mm_per_prompt={
@@ -65,7 +65,7 @@ def get_use_audio_in_video_query() -> QueryResult:
65 "<|im_start|>user\n<|vision_bos|><|VIDEO|><|vision_eos|>"
66 f"{question}<|im_end|>\n"
67 f"<|im_start|>assistant\n")
68 - asset = VideoAsset(name="sample_demo_1", num_frames=16)
68 + asset = VideoAsset(name="baby_reading", num_frames=16)
69 audio = asset.get_audio(sampling_rate=16000)
70 assert not envs.VLLM_USE_V1, ("V1 does not support use_audio_in_video. "
71 "Please launch this example with "
examples/offline_inference/vision_language.py
+1 -1
@@ -1109,7 +1109,7 @@ def get_multi_modal_input(args):
1109
1110 if args.modality == "video":
1111 # Input video and question
1112 - video = VideoAsset(name="sample_demo_1",
1112 + video = VideoAsset(name="baby_reading",
1113 num_frames=args.num_frames).np_ndarrays
1114 vid_questions = ["Why is this video funny?"]
1115
tests/conftest.py
+21 -35
@@ -1,9 +1,7 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -
2 import json
3 import os
4 import tempfile
6 -from collections import UserList
5 from enum import Enum
6 from typing import Any, Callable, Optional, TypedDict, TypeVar, Union
7
@@ -58,16 +56,12 @@ def _read_prompts(filename: str) -> list[str]:
56 return prompts
57
58
61 -class _ImageAssetPrompts(TypedDict):
59 +class ImageAssetPrompts(TypedDict):
60 stop_sign: str
61 cherry_blossom: str
62
63
66 -class _ImageAssetsBase(UserList[ImageAsset]):
67 - pass
68 -
69 -
70 -class _ImageAssets(_ImageAssetsBase):
64 +class ImageTestAssets(list[ImageAsset]):
65
66 def __init__(self) -> None:
67 super().__init__([
@@ -75,7 +69,7 @@ class _ImageAssets(_ImageAssetsBase):
69 ImageAsset("cherry_blossom"),
70 ])
71
78 - def prompts(self, prompts: _ImageAssetPrompts) -> list[str]:
72 + def prompts(self, prompts: ImageAssetPrompts) -> list[str]:
73 """
74 Convenience method to define the prompt for each test image.
75
@@ -85,35 +79,27 @@ class _ImageAssets(_ImageAssetsBase):
79 return [prompts["stop_sign"], prompts["cherry_blossom"]]
80
81
88 -class _VideoAssetPrompts(TypedDict):
89 - sample_demo_1: str
90 -
82 +class VideoAssetPrompts(TypedDict):
83 + baby_reading: str
84
92 -class _VideoAssetsBase(UserList[VideoAsset]):
93 - pass
85
95 -
96 -class _VideoAssets(_VideoAssetsBase):
86 +class VideoTestAssets(list[VideoAsset]):
87
88 def __init__(self) -> None:
89 super().__init__([
100 - VideoAsset("sample_demo_1"),
90 + VideoAsset("baby_reading"),
91 ])
92
103 - def prompts(self, prompts: _VideoAssetPrompts) -> list[str]:
104 - return [prompts["sample_demo_1"]]
93 + def prompts(self, prompts: VideoAssetPrompts) -> list[str]:
94 + return [prompts["baby_reading"]]
95
96
107 -class _AudioAssetPrompts(TypedDict):
97 +class AudioAssetPrompts(TypedDict):
98 mary_had_lamb: str
99 winning_call: str
100
101
112 -class _AudioAssetsBase(UserList[AudioAsset]):
113 - pass
114 -
115 -
116 -class _AudioAssets(_AudioAssetsBase):
102 +class AudioTestAssets(list[AudioAsset]):
103
104 def __init__(self) -> None:
105 super().__init__([
@@ -121,16 +107,16 @@ class _AudioAssets(_AudioAssetsBase):
107 AudioAsset("winning_call"),
108 ])
109
124 - def prompts(self, prompts: _AudioAssetPrompts) -> list[str]:
110 + def prompts(self, prompts: AudioAssetPrompts) -> list[str]:
111 return [prompts["mary_had_lamb"], prompts["winning_call"]]
112
113
128 -IMAGE_ASSETS = _ImageAssets()
129 -"""Singleton instance of :class:`_ImageAssets`."""
130 -VIDEO_ASSETS = _VideoAssets()
131 -"""Singleton instance of :class:`_VideoAssets`."""
132 -AUDIO_ASSETS = _AudioAssets()
133 -"""Singleton instance of :class:`_AudioAssets`."""
114 +IMAGE_ASSETS = ImageTestAssets()
115 +"""Singleton instance of :class:`ImageTestAssets`."""
116 +VIDEO_ASSETS = VideoTestAssets()
117 +"""Singleton instance of :class:`VideoTestAssets`."""
118 +AUDIO_ASSETS = AudioTestAssets()
119 +"""Singleton instance of :class:`AudioTestAssets`."""
120
121
122 @pytest.fixture(scope="function", autouse=True)
@@ -278,17 +264,17 @@ def example_long_prompts() -> list[str]:
264
265
266 @pytest.fixture(scope="session")
281 -def image_assets() -> _ImageAssets:
267 +def image_assets() -> ImageTestAssets:
268 return IMAGE_ASSETS
269
270
271 @pytest.fixture(scope="session")
286 -def video_assets() -> _VideoAssets:
272 +def video_assets() -> VideoTestAssets:
273 return VIDEO_ASSETS
274
275
276 @pytest.fixture(scope="session")
291 -def audio_assets() -> _AudioAssets:
277 +def audio_assets() -> AudioTestAssets:
278 return AUDIO_ASSETS
279
280
tests/models/multimodal/generation/test_common.py
+11 -10
@@ -13,8 +13,8 @@ from transformers import AutoModelForImageTextToText, AutoModelForVision2Seq
13 from vllm.platforms import current_platform
14 from vllm.utils import identity
15
16 -from ....conftest import (IMAGE_ASSETS, HfRunner, VllmRunner, _ImageAssets,
17 - _VideoAssets)
16 +from ....conftest import (IMAGE_ASSETS, HfRunner, ImageTestAssets,
17 + VideoTestAssets, VllmRunner)
18 from ....utils import (create_new_process_for_each_test, large_gpu_mark,
19 multi_gpu_marks)
20 from ...utils import check_outputs_equal
@@ -691,7 +691,7 @@ def test_single_image_models(tmp_path: PosixPath, model_type: str,
691 test_case: ExpandableVLMTestArgs,
692 hf_runner: type[HfRunner],
693 vllm_runner: type[VllmRunner],
694 - image_assets: _ImageAssets, monkeypatch):
694 + image_assets: ImageTestAssets, monkeypatch):
695 if model_type in REQUIRES_V0_MODELS:
696 monkeypatch.setenv("VLLM_USE_V1", "0")
697 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -716,7 +716,7 @@ def test_multi_image_models(tmp_path: PosixPath, model_type: str,
716 test_case: ExpandableVLMTestArgs,
717 hf_runner: type[HfRunner],
718 vllm_runner: type[VllmRunner],
719 - image_assets: _ImageAssets, monkeypatch):
719 + image_assets: ImageTestAssets, monkeypatch):
720 if model_type in REQUIRES_V0_MODELS:
721 monkeypatch.setenv("VLLM_USE_V1", "0")
722 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -741,7 +741,7 @@ def test_image_embedding_models(model_type: str,
741 test_case: ExpandableVLMTestArgs,
742 hf_runner: type[HfRunner],
743 vllm_runner: type[VllmRunner],
744 - image_assets: _ImageAssets, monkeypatch):
744 + image_assets: ImageTestAssets, monkeypatch):
745 if model_type in REQUIRES_V0_MODELS:
746 monkeypatch.setenv("VLLM_USE_V1", "0")
747 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -763,7 +763,7 @@ def test_image_embedding_models(model_type: str,
763 ))
764 def test_video_models(model_type: str, test_case: ExpandableVLMTestArgs,
765 hf_runner: type[HfRunner], vllm_runner: type[VllmRunner],
766 - video_assets: _VideoAssets, monkeypatch):
766 + video_assets: VideoTestAssets, monkeypatch):
767 if model_type in REQUIRES_V0_MODELS:
768 monkeypatch.setenv("VLLM_USE_V1", "0")
769 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -814,7 +814,7 @@ def test_single_image_models_heavy(tmp_path: PosixPath, model_type: str,
814 test_case: ExpandableVLMTestArgs,
815 hf_runner: type[HfRunner],
816 vllm_runner: type[VllmRunner],
817 - image_assets: _ImageAssets, monkeypatch):
817 + image_assets: ImageTestAssets, monkeypatch):
818 if model_type in REQUIRES_V0_MODELS:
819 monkeypatch.setenv("VLLM_USE_V1", "0")
820 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -840,7 +840,7 @@ def test_multi_image_models_heavy(tmp_path: PosixPath, model_type: str,
840 test_case: ExpandableVLMTestArgs,
841 hf_runner: type[HfRunner],
842 vllm_runner: type[VllmRunner],
843 - image_assets: _ImageAssets, monkeypatch):
843 + image_assets: ImageTestAssets, monkeypatch):
844 if model_type in REQUIRES_V0_MODELS:
845 monkeypatch.setenv("VLLM_USE_V1", "0")
846 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -866,7 +866,8 @@ def test_image_embedding_models_heavy(model_type: str,
866 test_case: ExpandableVLMTestArgs,
867 hf_runner: type[HfRunner],
868 vllm_runner: type[VllmRunner],
869 - image_assets: _ImageAssets, monkeypatch):
869 + image_assets: ImageTestAssets,
870 + monkeypatch):
871 if model_type in REQUIRES_V0_MODELS:
872 monkeypatch.setenv("VLLM_USE_V1", "0")
873 model_test_info = VLM_TEST_SETTINGS[model_type]
@@ -889,7 +890,7 @@ def test_image_embedding_models_heavy(model_type: str,
890 def test_video_models_heavy(model_type: str, test_case: ExpandableVLMTestArgs,
891 hf_runner: type[HfRunner],
892 vllm_runner: type[VllmRunner],
892 - video_assets: _VideoAssets, monkeypatch):
893 + video_assets: VideoTestAssets, monkeypatch):
894 if model_type in REQUIRES_V0_MODELS:
895 monkeypatch.setenv("VLLM_USE_V1", "0")
896 model_test_info = VLM_TEST_SETTINGS[model_type]
tests/models/multimodal/generation/test_florence2.py
+2 -2
@@ -9,7 +9,7 @@ from vllm.inputs.data import ExplicitEncoderDecoderPrompt, TextPrompt
9 from vllm.multimodal.image import rescale_image_size
10 from vllm.sequence import SampleLogprobs
11
12 -from ....conftest import IMAGE_ASSETS, HfRunner, VllmRunner, _ImageAssets
12 +from ....conftest import IMAGE_ASSETS, HfRunner, ImageTestAssets, VllmRunner
13 from ...utils import check_logprobs_close
14
15 MODELS = ["microsoft/Florence-2-base"]
@@ -118,7 +118,7 @@ def run_test(
118 @pytest.mark.parametrize("max_tokens", [64])
119 @pytest.mark.parametrize("num_logprobs", [5])
120 def test_models(hf_runner: type[HfRunner], vllm_runner: type[VllmRunner],
121 - image_assets: _ImageAssets, model: str,
121 + image_assets: ImageTestAssets, model: str,
122 size_factors: list[int], dtype: str, max_tokens: int,
123 num_logprobs: int) -> None:
124 images = [asset.pil_image for asset in image_assets]
tests/models/multimodal/generation/test_granite_speech.py
+5 -4
@@ -9,7 +9,8 @@ from transformers import AutoModelForSpeechSeq2Seq
9 from vllm.lora.request import LoRARequest
10 from vllm.sequence import SampleLogprobs
11
12 -from ....conftest import HfRunner, PromptAudioInput, VllmRunner, _AudioAssets
12 +from ....conftest import (AudioTestAssets, HfRunner, PromptAudioInput,
13 + VllmRunner)
14 from ...registry import HF_EXAMPLE_MODELS
15 from ...utils import check_logprobs_close
16
@@ -116,9 +117,9 @@ def run_test(
117 @pytest.mark.parametrize("max_model_len", [2048])
118 @pytest.mark.parametrize("max_tokens", [128])
119 @pytest.mark.parametrize("num_logprobs", [10])
119 -def test_models(hf_runner, vllm_runner, model: str, audio_assets: _AudioAssets,
120 - dtype: str, max_model_len: int, max_tokens: int,
121 - num_logprobs: int) -> None:
120 +def test_models(hf_runner, vllm_runner, model: str,
121 + audio_assets: AudioTestAssets, dtype: str, max_model_len: int,
122 + max_tokens: int, num_logprobs: int) -> None:
123 model_info = HF_EXAMPLE_MODELS.find_hf_info(model)
124 model_info.check_available_online(on_fail="skip")
125 model_info.check_transformers_version(on_fail="skip")
tests/models/multimodal/generation/test_interleaved.py
+1 -1
@@ -29,7 +29,7 @@ def test_models(vllm_runner, model, dtype: str, max_tokens: int) -> None:
29 image_cherry = ImageAsset("cherry_blossom").pil_image.convert("RGB")
30 image_stop = ImageAsset("stop_sign").pil_image.convert("RGB")
31 images = [image_cherry, image_stop]
32 - video = VideoAsset(name="sample_demo_1", num_frames=16).np_ndarrays
32 + video = VideoAsset(name="baby_reading", num_frames=16).np_ndarrays
33
34 inputs = [
35 (
tests/models/multimodal/generation/test_mllama.py
+8 -8
@@ -14,8 +14,8 @@ from vllm.model_executor.models.mllama import MllamaForConditionalGeneration
14 from vllm.multimodal.image import rescale_image_size
15 from vllm.sequence import SampleLogprobs
16
17 -from ....conftest import (IMAGE_ASSETS, HfRunner, PromptImageInput, VllmRunner,
18 - _ImageAssets)
17 +from ....conftest import (IMAGE_ASSETS, HfRunner, ImageTestAssets,
18 + PromptImageInput, VllmRunner)
19 from ....quantization.utils import is_quant_method_supported
20 from ....utils import (create_new_process_for_each_test, large_gpu_test,
21 multi_gpu_test)
@@ -90,7 +90,7 @@ def vllm_to_hf_output(vllm_output: tuple[list[int], str,
90
91
92 def _get_inputs(
93 - image_assets: _ImageAssets,
93 + image_assets: ImageTestAssets,
94 *,
95 size_factors: Optional[list[float]] = None,
96 sizes: Optional[list[tuple[int, int]]] = None,
@@ -126,7 +126,7 @@ def _get_inputs(
126 def run_test(
127 hf_runner: type[HfRunner],
128 vllm_runner: type[VllmRunner],
129 - image_assets: _ImageAssets,
129 + image_assets: ImageTestAssets,
130 model: str,
131 *,
132 size_factors: list[float],
@@ -143,7 +143,7 @@ def run_test(
143 def run_test(
144 hf_runner: type[HfRunner],
145 vllm_runner: type[VllmRunner],
146 - image_assets: _ImageAssets,
146 + image_assets: ImageTestAssets,
147 model: str,
148 *,
149 sizes: list[tuple[int, int]],
@@ -159,7 +159,7 @@ def run_test(
159 def run_test(
160 hf_runner: type[HfRunner],
161 vllm_runner: type[VllmRunner],
162 - image_assets: _ImageAssets,
162 + image_assets: ImageTestAssets,
163 model: str,
164 *,
165 size_factors: Optional[list[float]] = None,
@@ -433,7 +433,7 @@ def test_models_distributed(
433 @pytest.mark.skipif(not is_quant_method_supported("bitsandbytes"),
434 reason='bitsandbytes is not supported on this GPU type.')
435 def test_bnb_regression(
436 - image_assets: _ImageAssets,
436 + image_assets: ImageTestAssets,
437 model: str,
438 dtype: str,
439 max_tokens: int,
@@ -473,7 +473,7 @@ def test_bnb_regression(
473 @pytest.mark.parametrize("dtype", ["bfloat16"])
474 @pytest.mark.parametrize("max_tokens", [32])
475 def test_explicit_implicit_prompt(
476 - image_assets: _ImageAssets,
476 + image_assets: ImageTestAssets,
477 model: str,
478 dtype: str,
479 max_tokens: int,
tests/models/multimodal/generation/test_qwen2_vl.py
+1 -1
@@ -50,7 +50,7 @@ IMAGE_PROMPTS = IMAGE_ASSETS.prompts({
50 })
51
52 VIDEO_PROMPTS = VIDEO_ASSETS.prompts({
53 - "sample_demo_1":
53 + "baby_reading":
54 qwen2_vl_chat_template(
55 VIDEO_PLACEHOLDER,
56 "Describe this video with a short sentence ",
tests/models/multimodal/generation/test_ultravox.py
+25 -19
@@ -11,13 +11,22 @@ from transformers import AutoModel, AutoTokenizer
11 from vllm.multimodal.audio import resample_audio_librosa
12 from vllm.sequence import SampleLogprobs
13
14 -from ....conftest import HfRunner, VllmRunner, _AudioAssets
14 +from ....conftest import AUDIO_ASSETS, AudioTestAssets, HfRunner, VllmRunner
15 from ....utils import RemoteOpenAIServer
16 from ...registry import HF_EXAMPLE_MODELS
17 from ...utils import check_logprobs_close
18
19 MODEL_NAME = "fixie-ai/ultravox-v0_5-llama-3_2-1b"
20
21 +AUDIO_PROMPTS = AUDIO_ASSETS.prompts({
22 + "mary_had_lamb":
23 + "Transcribe this into English.",
24 + "winning_call":
25 + "What is happening in this audio clip?",
26 +})
27 +
28 +MULTI_AUDIO_PROMPT = "Describe each of the audios above."
29 +
30 AudioTuple = tuple[np.ndarray, int]
31
32 VLLM_PLACEHOLDER = "<|audio|>"
@@ -31,12 +40,6 @@ CHUNKED_PREFILL_KWARGS = {
40 }
41
42
34 -@pytest.fixture(scope="module", params=("mary_had_lamb", "winning_call"))
35 -def audio(request):
36 - from vllm.assets.audio import AudioAsset
37 - return AudioAsset(request.param)
38 -
39 -
43 def params_kwargs_to_cli_args(params_kwargs: dict[str, Any]) -> list[str]:
44 """Convert kwargs to CLI args."""
45 args = []
@@ -53,7 +56,7 @@ def params_kwargs_to_cli_args(params_kwargs: dict[str, Any]) -> list[str]:
56 pytest.param({}, marks=pytest.mark.cpu_model),
57 pytest.param(CHUNKED_PREFILL_KWARGS),
58 ])
56 -def server(request, audio_assets: _AudioAssets):
59 +def server(request, audio_assets: AudioTestAssets):
60 args = [
61 "--dtype", "bfloat16", "--max-model-len", "4096", "--enforce-eager",
62 "--limit-mm-per-prompt",
@@ -199,15 +202,19 @@ def run_multi_audio_test(
202 pytest.param({}, marks=pytest.mark.cpu_model),
203 pytest.param(CHUNKED_PREFILL_KWARGS),
204 ])
202 -def test_models(hf_runner, vllm_runner, audio, dtype: str, max_tokens: int,
203 - num_logprobs: int, vllm_kwargs: dict) -> None:
205 +def test_models(hf_runner, vllm_runner, audio_assets: AudioTestAssets,
206 + dtype: str, max_tokens: int, num_logprobs: int,
207 + vllm_kwargs: dict) -> None:
208 + audio_inputs = [(
209 + _get_prompt(1, audio, VLLM_PLACEHOLDER),
210 + _get_prompt(1, audio, HF_PLACEHOLDER),
211 + audio.audio_and_sample_rate,
212 + ) for audio in audio_assets]
213
205 - vllm_prompt = _get_prompt(1, "Describe the audio above.", VLLM_PLACEHOLDER)
206 - hf_prompt = _get_prompt(1, "Describe the audio above.", HF_PLACEHOLDER)
214 run_test(
215 hf_runner,
216 vllm_runner,
210 - [(vllm_prompt, hf_prompt, audio.audio_and_sample_rate)],
217 + audio_inputs,
218 MODEL_NAME,
219 dtype=dtype,
220 max_tokens=max_tokens,
@@ -224,13 +231,12 @@ def test_models(hf_runner, vllm_runner, audio, dtype: str, max_tokens: int,
231 pytest.param({}, marks=pytest.mark.cpu_model),
232 pytest.param(CHUNKED_PREFILL_KWARGS),
233 ])
227 -def test_models_with_multiple_audios(vllm_runner, audio_assets: _AudioAssets,
228 - dtype: str, max_tokens: int,
229 - num_logprobs: int,
234 +def test_models_with_multiple_audios(vllm_runner,
235 + audio_assets: AudioTestAssets, dtype: str,
236 + max_tokens: int, num_logprobs: int,
237 vllm_kwargs: dict) -> None:
238
232 - vllm_prompt = _get_prompt(len(audio_assets),
233 - "Describe each of the audios above.",
239 + vllm_prompt = _get_prompt(len(audio_assets), MULTI_AUDIO_PROMPT,
240 VLLM_PLACEHOLDER)
241 run_multi_audio_test(
242 vllm_runner,
@@ -245,7 +251,7 @@ def test_models_with_multiple_audios(vllm_runner, audio_assets: _AudioAssets,
251
252
253 @pytest.mark.asyncio
248 -async def test_online_serving(client, audio_assets: _AudioAssets):
254 +async def test_online_serving(client, audio_assets: AudioTestAssets):
255 """Exercises online serving with/without chunked prefill enabled."""
256
257 messages = [{
tests/models/multimodal/generation/vlm_utils/builders.py
+5 -5
@@ -11,7 +11,7 @@ from vllm.multimodal.image import rescale_image_size
11 from vllm.multimodal.video import (rescale_video_size, resize_video,
12 sample_frames_from_video)
13
14 -from .....conftest import _ImageAssets, _VideoAssets
14 +from .....conftest import ImageTestAssets, VideoTestAssets
15 from .types import (SINGLE_IMAGE_BASE_PROMPTS, TEST_IMG_PLACEHOLDER,
16 TEST_VIDEO_PLACEHOLDER, VIDEO_BASE_PROMPT,
17 ImageSizeWrapper, SizeType, VLMTestInfo)
@@ -69,7 +69,7 @@ def get_model_prompts(base_prompts: Iterable[str],
69
70 def build_single_image_inputs_from_test_info(
71 test_info: VLMTestInfo,
72 - image_assets: _ImageAssets,
72 + image_assets: ImageTestAssets,
73 size_wrapper: ImageSizeWrapper,
74 tmp_path: Optional[PosixPath] = None):
75 if test_info.prompt_formatter is None:
@@ -116,7 +116,7 @@ def build_single_image_inputs(images, model_prompts,
116
117 def build_multi_image_inputs_from_test_info(
118 test_info: VLMTestInfo,
119 - image_assets: _ImageAssets,
119 + image_assets: ImageTestAssets,
120 size_wrapper: ImageSizeWrapper,
121 tmp_path: Optional[PosixPath] = None):
122 if test_info.prompt_formatter is None:
@@ -159,7 +159,7 @@ def build_multi_image_inputs(image_lists, model_prompts,
159
160 def build_embedding_inputs_from_test_info(
161 test_info: VLMTestInfo,
162 - image_assets: _ImageAssets,
162 + image_assets: ImageTestAssets,
163 size_wrapper: ImageSizeWrapper,
164 ):
165 # These conditions will always be true if invoked through filtering,
@@ -192,7 +192,7 @@ def build_embedding_inputs_from_test_info(
192
193 def build_video_inputs_from_test_info(
194 test_info: VLMTestInfo,
195 - video_assets: _VideoAssets,
195 + video_assets: VideoTestAssets,
196 size_wrapper: ImageSizeWrapper,
197 num_frames: int,
198 ):
tests/models/multimodal/generation/vlm_utils/model_utils.py
+4 -4
@@ -16,7 +16,7 @@ from transformers import (AutoConfig, AutoTokenizer, BatchFeature,
16 from vllm.sequence import SampleLogprobs
17 from vllm.transformers_utils.tokenizer import patch_padding_side
18
19 -from .....conftest import HfRunner, ImageAsset, _ImageAssets
19 +from .....conftest import HfRunner, ImageAsset, ImageTestAssets
20 from .types import RunnerOutput
21
22
@@ -238,14 +238,14 @@ def minimax_vl_01_hf_output(hf_output: RunnerOutput,
238
239
240 ####### Functions for converting image assets to embeddings
241 -def get_llava_embeddings(image_assets: _ImageAssets):
241 +def get_llava_embeddings(image_assets: ImageTestAssets):
242 return [asset.image_embeds for asset in image_assets]
243
244
245 ####### Prompt path encoders for models that need models on disk
246 def qwen_prompt_path_encoder(
247 - tmp_path: PosixPath, prompt: str, assets: Union[list[ImageAsset],
248 - _ImageAssets]) -> str:
247 + tmp_path: PosixPath, prompt: str,
248 + assets: Union[list[ImageAsset], ImageTestAssets]) -> str:
249 """Given a temporary dir path, export one or more image assets into the
250 tempdir & replace its contents with the local path to the string so that
251 the HF version of Qwen-VL can resolve the path and load the image in its
tests/models/multimodal/generation/vlm_utils/runners.py
+6 -5
@@ -4,7 +4,8 @@ types / modalities.
4 """
5 from pathlib import PosixPath
6
7 -from .....conftest import HfRunner, VllmRunner, _ImageAssets, _VideoAssets
7 +from .....conftest import (HfRunner, ImageTestAssets, VideoTestAssets,
8 + VllmRunner)
9 from . import builders, core
10 from .types import ExpandableVLMTestArgs, VLMTestInfo
11
@@ -14,7 +15,7 @@ def run_single_image_test(*, tmp_path: PosixPath, model_test_info: VLMTestInfo,
15 test_case: ExpandableVLMTestArgs,
16 hf_runner: type[HfRunner],
17 vllm_runner: type[VllmRunner],
17 - image_assets: _ImageAssets):
18 + image_assets: ImageTestAssets):
19 assert test_case.size_wrapper is not None
20 inputs = builders.build_single_image_inputs_from_test_info(
21 model_test_info, image_assets, test_case.size_wrapper, tmp_path)
@@ -37,7 +38,7 @@ def run_multi_image_test(*, tmp_path: PosixPath, model_test_info: VLMTestInfo,
38 test_case: ExpandableVLMTestArgs,
39 hf_runner: type[HfRunner],
40 vllm_runner: type[VllmRunner],
40 - image_assets: _ImageAssets):
41 + image_assets: ImageTestAssets):
42 assert test_case.size_wrapper is not None
43 inputs = builders.build_multi_image_inputs_from_test_info(
44 model_test_info, image_assets, test_case.size_wrapper, tmp_path)
@@ -60,7 +61,7 @@ def run_embedding_test(*, model_test_info: VLMTestInfo,
61 test_case: ExpandableVLMTestArgs,
62 hf_runner: type[HfRunner],
63 vllm_runner: type[VllmRunner],
63 - image_assets: _ImageAssets):
64 + image_assets: ImageTestAssets):
65 assert test_case.size_wrapper is not None
66 inputs, vllm_embeddings = builders.build_embedding_inputs_from_test_info(
67 model_test_info, image_assets, test_case.size_wrapper)
@@ -86,7 +87,7 @@ def run_video_test(
87 test_case: ExpandableVLMTestArgs,
88 hf_runner: type[HfRunner],
89 vllm_runner: type[VllmRunner],
89 - video_assets: _VideoAssets,
90 + video_assets: VideoTestAssets,
91 ):
92 assert test_case.size_wrapper is not None
93 assert test_case.num_video_frames is not None
tests/models/multimodal/generation/vlm_utils/types.py
+3 -3
@@ -15,7 +15,7 @@ from vllm.config import TaskOption
15 from vllm.sequence import SampleLogprobs
16 from vllm.transformers_utils.tokenizer import AnyTokenizer
17
18 -from .....conftest import IMAGE_ASSETS, HfRunner, ImageAsset, _ImageAssets
18 +from .....conftest import IMAGE_ASSETS, HfRunner, ImageAsset, ImageTestAssets
19 from ....utils import check_logprobs_close
20
21 # meta image tag; will be replaced by the appropriate tag for the model
@@ -85,7 +85,7 @@ class VLMTestInfo(NamedTuple):
85
86 # Function for converting ImageAssets to image embeddings;
87 # We need to define this explicitly for embedding tests
88 - convert_assets_to_embeddings: Optional[Callable[[_ImageAssets],
88 + convert_assets_to_embeddings: Optional[Callable[[ImageTestAssets],
89 torch.Tensor]] = None
90
91 # Exposed options for vLLM runner; we change these in a several tests,
@@ -141,7 +141,7 @@ class VLMTestInfo(NamedTuple):
141 # for Qwen-VL, which requires encoding the image path / url into the prompt
142 # for HF runner
143 prompt_path_encoder: Optional[
144 - Callable[[PosixPath, str, Union[list[ImageAsset], _ImageAssets]],
144 + Callable[[PosixPath, str, Union[list[ImageAsset], ImageTestAssets]],
145 str]] = None # noqa: E501
146
147 # Allows configuring a test to run with custom inputs
tests/models/multimodal/pooling/test_intern_vit.py
+2 -2
@@ -7,7 +7,7 @@ from transformers import AutoConfig, AutoModel, CLIPImageProcessor
7
8 from vllm.distributed import cleanup_dist_env_and_memory
9
10 -from ....conftest import _ImageAssets
10 +from ....conftest import ImageTestAssets
11
12 # we use snapshot_download to prevent conflicts between
13 # dynamic_module and trust_remote_code for hf_runner
@@ -15,7 +15,7 @@ DOWNLOAD_PATTERN = ["*.json", "*.py", "*.safetensors", "*.txt", "*.model"]
15
16
17 def run_intern_vit_test(
18 - image_assets: _ImageAssets,
18 + image_assets: ImageTestAssets,
19 model_id: str,
20 *,
21 dtype: str,
tests/models/multimodal/processing/test_h2ovl.py
+2 -2
@@ -11,7 +11,7 @@ from vllm.multimodal import MULTIMODAL_REGISTRY
11 from vllm.multimodal.image import rescale_image_size
12 from vllm.multimodal.processing import BaseMultiModalProcessor
13
14 -from ....conftest import _ImageAssets
14 +from ....conftest import ImageTestAssets
15 from ...utils import build_model_context
16
17
@@ -137,7 +137,7 @@ def _run_check(
137 @pytest.mark.parametrize("kwargs_on_init", [True, False])
138 def test_processor_override(
139 model_id: str,
140 - image_assets: _ImageAssets,
140 + image_assets: ImageTestAssets,
141 size_factors: list[int],
142 min_dynamic_patch: int,
143 max_dynamic_patch: int,
tests/models/multimodal/processing/test_idefics3.py
+2 -2
@@ -5,7 +5,7 @@ from transformers import Idefics3Config
5
6 from vllm.multimodal import MULTIMODAL_REGISTRY
7
8 -from ....conftest import _ImageAssets
8 +from ....conftest import ImageTestAssets
9 from ...utils import build_model_context
10
11
@@ -21,7 +21,7 @@ from ...utils import build_model_context
21 @pytest.mark.parametrize("num_imgs", [1, 2])
22 @pytest.mark.parametrize("kwargs_on_init", [True, False])
23 def test_processor_override(
24 - image_assets: _ImageAssets,
24 + image_assets: ImageTestAssets,
25 model_id: str,
26 mm_processor_kwargs: dict[str, object],
27 expected_toks_per_img: int,
tests/models/multimodal/processing/test_internvl.py
+2 -2
@@ -11,7 +11,7 @@ from vllm.multimodal import MULTIMODAL_REGISTRY
11 from vllm.multimodal.image import rescale_image_size
12 from vllm.multimodal.processing import BaseMultiModalProcessor
13
14 -from ....conftest import _ImageAssets
14 +from ....conftest import ImageTestAssets
15 from ...utils import build_model_context
16
17
@@ -94,7 +94,7 @@ def _run_check(
94 @pytest.mark.parametrize("kwargs_on_init", [True, False])
95 def test_processor_override(
96 model_id: str,
97 - image_assets: _ImageAssets,
97 + image_assets: ImageTestAssets,
98 size_factors: list[int],
99 min_dynamic_patch: int,
100 max_dynamic_patch: int,
tests/models/multimodal/processing/test_llama4.py
+2 -2
@@ -6,7 +6,7 @@ import pytest
6 from vllm.multimodal import MULTIMODAL_REGISTRY
7 from vllm.transformers_utils.tokenizer import encode_tokens
8
9 -from ....conftest import _ImageAssets
9 +from ....conftest import ImageTestAssets
10 from ...utils import build_model_context
11
12
@@ -17,7 +17,7 @@ from ...utils import build_model_context
17 @pytest.mark.parametrize("disable_mm_preprocessor_cache", [True, False])
18 @pytest.mark.parametrize("tokenized_prompt", [True, False])
19 def test_processor_override(
20 - image_assets: _ImageAssets,
20 + image_assets: ImageTestAssets,
21 model_id: str,
22 mm_processor_kwargs: dict,
23 num_imgs: int,
tests/models/multimodal/processing/test_minimax_vl_01.py
+2 -2
@@ -7,14 +7,14 @@ from vllm.multimodal import MULTIMODAL_REGISTRY
7 from vllm.multimodal.parse import ImageSize
8 from vllm.multimodal.processing import BaseMultiModalProcessor
9
10 -from ....conftest import _ImageAssets
10 +from ....conftest import ImageTestAssets
11 from ...utils import build_model_context
12
13
14 @pytest.mark.parametrize("model_id", ["MiniMaxAI/MiniMax-VL-01"])
15 @pytest.mark.parametrize("num_imgs", [1, 2])
16 def test_processor_override(
17 - image_assets: _ImageAssets,
17 + image_assets: ImageTestAssets,
18 model_id: str,
19 num_imgs: int,
20 ):
tests/models/multimodal/processing/test_phi3v.py
+2 -2
@@ -4,7 +4,7 @@ import pytest
4
5 from vllm.multimodal import MULTIMODAL_REGISTRY
6
7 -from ....conftest import _ImageAssets
7 +from ....conftest import ImageTestAssets
8 from ...utils import build_model_context
9
10
@@ -22,7 +22,7 @@ from ...utils import build_model_context
22 @pytest.mark.parametrize("num_imgs", [1, 2])
23 @pytest.mark.parametrize("kwargs_on_init", [True, False])
24 def test_processor_override(
25 - image_assets: _ImageAssets,
25 + image_assets: ImageTestAssets,
26 model_id: str,
27 mm_processor_kwargs: dict[str, int],
28 expected_toks_per_img: int,
tests/models/multimodal/processing/test_phi4mm.py
+2 -2
@@ -4,7 +4,7 @@ import pytest
4
5 from vllm.multimodal import MULTIMODAL_REGISTRY
6
7 -from ....conftest import _ImageAssets
7 +from ....conftest import ImageTestAssets
8 from ...utils import build_model_context
9
10
@@ -22,7 +22,7 @@ from ...utils import build_model_context
22 @pytest.mark.parametrize("num_imgs", [1, 2])
23 @pytest.mark.parametrize("kwargs_on_init", [True, False])
24 def test_processor_override(
25 - image_assets: _ImageAssets,
25 + image_assets: ImageTestAssets,
26 model_id: str,
27 mm_processor_kwargs: dict[str, int],
28 expected_toks_per_img: int,
tests/models/multimodal/processing/test_qwen2_vl.py
+2 -2
@@ -4,7 +4,7 @@ import pytest
4
5 from vllm.multimodal import MULTIMODAL_REGISTRY
6
7 -from ....conftest import _ImageAssets
7 +from ....conftest import ImageTestAssets
8 from ...utils import build_model_context
9
10
@@ -19,7 +19,7 @@ from ...utils import build_model_context
19 @pytest.mark.parametrize("num_imgs", [1, 2])
20 @pytest.mark.parametrize("kwargs_on_init", [True, False])
21 def test_processor_override(
22 - image_assets: _ImageAssets,
22 + image_assets: ImageTestAssets,
23 model_id: str,
24 mm_processor_kwargs: dict[str, object],
25 expected_toks_per_img: int,
tests/models/multimodal/processing/test_smolvlm.py
+2 -2
@@ -5,7 +5,7 @@ from transformers import SmolVLMConfig
5
6 from vllm.multimodal import MULTIMODAL_REGISTRY
7
8 -from ....conftest import _ImageAssets
8 +from ....conftest import ImageTestAssets
9 from ...utils import build_model_context
10
11
@@ -21,7 +21,7 @@ from ...utils import build_model_context
21 @pytest.mark.parametrize("num_imgs", [1, 2])
22 @pytest.mark.parametrize("kwargs_on_init", [True, False])
23 def test_processor_override(
24 - image_assets: _ImageAssets,
24 + image_assets: ImageTestAssets,
25 model_id: str,
26 mm_processor_kwargs: dict[str, object],
27 expected_toks_per_img: int,
tests/models/quantization/test_awq.py
+2 -2
@@ -7,7 +7,7 @@ import torch
7
8 from vllm.multimodal.image import rescale_image_size
9
10 -from ...conftest import IMAGE_ASSETS, VllmRunner, _ImageAssets
10 +from ...conftest import IMAGE_ASSETS, ImageTestAssets, VllmRunner
11 from ..utils import check_logprobs_close
12
13 HF_IMAGE_PROMPTS = IMAGE_ASSETS.prompts({
@@ -20,7 +20,7 @@ HF_IMAGE_PROMPTS = IMAGE_ASSETS.prompts({
20
21 def run_awq_test(
22 vllm_runner: type[VllmRunner],
23 - image_assets: _ImageAssets,
23 + image_assets: ImageTestAssets,
24 source_model: str,
25 quant_model: str,
26 *,
vllm/assets/audio.py
+9 -3
@@ -18,19 +18,25 @@ except ImportError:
18
19 ASSET_DIR = "multimodal_asset"
20
21 +AudioAssetName = Literal["winning_call", "mary_had_lamb"]
22 +
23
24 @dataclass(frozen=True)
25 class AudioAsset:
24 - name: Literal["winning_call", "mary_had_lamb"]
26 + name: AudioAssetName
27 +
28 + @property
29 + def filename(self) -> str:
30 + return f"{self.name}.ogg"
31
32 @property
33 def audio_and_sample_rate(self) -> tuple[npt.NDArray, float]:
28 - audio_path = get_vllm_public_assets(filename=f"{self.name}.ogg",
34 + audio_path = get_vllm_public_assets(filename=self.filename,
35 s3_prefix=ASSET_DIR)
36 return librosa.load(audio_path, sr=None)
37
38 def get_local_path(self) -> Path:
33 - return get_vllm_public_assets(filename=f"{self.name}.ogg",
39 + return get_vllm_public_assets(filename=self.filename,
40 s3_prefix=ASSET_DIR)
41
42 @property
vllm/assets/image.py
+3 -1
@@ -10,10 +10,12 @@ from .base import get_vllm_public_assets
10
11 VLM_IMAGES_DIR = "vision_model_images"
12
13 +ImageAssetName = Literal["stop_sign", "cherry_blossom"]
14 +
15
16 @dataclass(frozen=True)
17 class ImageAsset:
16 - name: Literal["stop_sign", "cherry_blossom"]
18 + name: ImageAssetName
19
20 @property
21 def pil_image(self) -> Image.Image:
vllm/assets/video.py
+16 -5
@@ -2,7 +2,7 @@
2
3 from dataclasses import dataclass
4 from functools import lru_cache
5 -from typing import Literal, Optional
5 +from typing import ClassVar, Literal, Optional
6
7 import cv2
8 import numpy as np
@@ -76,20 +76,31 @@ def video_to_pil_images_list(path: str,
76 ]
77
78
79 +VideoAssetName = Literal["baby_reading"]
80 +
81 +
82 @dataclass(frozen=True)
83 class VideoAsset:
81 - name: Literal["sample_demo_1"]
84 + name: VideoAssetName
85 num_frames: int = -1
86
87 + _NAME_TO_FILE: ClassVar[dict[VideoAssetName, str]] = {
88 + "baby_reading": "sample_demo_1.mp4",
89 + }
90 +
91 + @property
92 + def filename(self) -> str:
93 + return self._NAME_TO_FILE[self.name]
94 +
95 @property
96 def pil_images(self) -> list[Image.Image]:
86 - video_path = download_video_asset(self.name + ".mp4")
97 + video_path = download_video_asset(self.filename)
98 ret = video_to_pil_images_list(video_path, self.num_frames)
99 return ret
100
101 @property
102 def np_ndarrays(self) -> npt.NDArray:
92 - video_path = download_video_asset(self.name + ".mp4")
103 + video_path = download_video_asset(self.filename)
104 ret = video_to_ndarrays(video_path, self.num_frames)
105 return ret
106
@@ -99,5 +110,5 @@ class VideoAsset:
110
111 See also: examples/offline_inference/qwen2_5_omni/only_thinker.py
112 """
102 - video_path = download_video_asset(self.name + ".mp4")
113 + video_path = download_video_asset(self.filename)
114 return librosa.load(video_path, sr=sampling_rate)[0]