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] Continue refactoring model tests (#17573)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Cyrus Leung committed
May 2, 2025 at 13:06 UTC
f89d0e11bf5302307c8ebfc74dd3e7923738b27f
6 files changed
+20
-16
examples/offline_inference/qwen2_5_omni/only_thinker.py
+2
-3
@@ -47,8 +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.mp4",
51
- num_frames=16).np_ndarrays,
50
+ VideoAsset(name="sample_demo_1", num_frames=16).np_ndarrays,
51
},
52
},
53
limit_mm_per_prompt={
@@ -66,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")
69
- asset = VideoAsset(name="sample_demo_1.mp4", num_frames=16)
68
+ asset = VideoAsset(name="sample_demo_1", 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.mp4",
1112
+ video = VideoAsset(name="sample_demo_1",
1113
num_frames=args.num_frames).np_ndarrays
1114
vid_questions = ["Why is this video funny?"]
1115
tests/conftest.py
+9
-1
@@ -97,13 +97,18 @@ class _VideoAssets(_VideoAssetsBase):
97
98
def __init__(self) -> None:
99
super().__init__([
100
- VideoAsset("sample_demo_1.mp4"),
100
+ VideoAsset("sample_demo_1"),
101
])
102
103
def prompts(self, prompts: _VideoAssetPrompts) -> list[str]:
104
return [prompts["sample_demo_1"]]
105
106
107
+class _AudioAssetPrompts(TypedDict):
108
+ mary_had_lamb: str
109
+ winning_call: str
110
+
111
+
112
class _AudioAssetsBase(UserList[AudioAsset]):
113
pass
114
@@ -116,6 +121,9 @@ class _AudioAssets(_AudioAssetsBase):
121
AudioAsset("winning_call"),
122
])
123
124
+ def prompts(self, prompts: _AudioAssetPrompts) -> list[str]:
125
+ return [prompts["mary_had_lamb"], prompts["winning_call"]]
126
+
127
128
IMAGE_ASSETS = _ImageAssets()
129
"""Singleton instance of :class:`_ImageAssets`."""
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.mp4", num_frames=16).np_ndarrays
32
+ video = VideoAsset(name="sample_demo_1", num_frames=16).np_ndarrays
33
34
inputs = [
35
(
tests/models/multimodal/pooling/test_intern_vit.py
renamed
+3
-6
@@ -1,13 +1,12 @@
1
# SPDX-License-Identifier: Apache-2.0
2
-
3
-from typing import Optional
4
-
2
import pytest
3
import torch
4
import torch.nn as nn
5
from huggingface_hub import snapshot_download
6
from transformers import AutoConfig, AutoModel, CLIPImageProcessor
7
8
+from vllm.distributed import cleanup_dist_env_and_memory
9
+
10
from ....conftest import _ImageAssets
11
12
# we use snapshot_download to prevent conflicts between
@@ -20,7 +19,6 @@ def run_intern_vit_test(
19
model_id: str,
20
*,
21
dtype: str,
23
- distributed_executor_backend: Optional[str] = None,
22
):
23
model = snapshot_download(model_id, allow_patterns=DOWNLOAD_PATTERN)
24
@@ -43,7 +41,6 @@ def run_intern_vit_test(
41
for pixel_value in pixel_values
42
]
43
46
- from vllm.distributed import cleanup_dist_env_and_memory
44
from vllm.model_executor.models.intern_vit import InternVisionModel
45
vllm_model = InternVisionModel(config)
46
vllm_model.load_weights(hf_model.state_dict().items())
@@ -71,7 +68,7 @@ def run_intern_vit_test(
68
])
69
@pytest.mark.parametrize("dtype", [torch.half])
70
@torch.inference_mode()
74
-def test_models(dist_init, image_assets, model_id, dtype: str) -> None:
71
+def test_models(image_assets, model_id, dtype: str) -> None:
72
run_intern_vit_test(
73
image_assets,
74
model_id,
vllm/assets/video.py
+4
-4
@@ -78,18 +78,18 @@ def video_to_pil_images_list(path: str,
78
79
@dataclass(frozen=True)
80
class VideoAsset:
81
- name: Literal["sample_demo_1.mp4"]
81
+ name: Literal["sample_demo_1"]
82
num_frames: int = -1
83
84
@property
85
def pil_images(self) -> list[Image.Image]:
86
- video_path = download_video_asset(self.name)
86
+ video_path = download_video_asset(self.name + ".mp4")
87
ret = video_to_pil_images_list(video_path, self.num_frames)
88
return ret
89
90
@property
91
def np_ndarrays(self) -> npt.NDArray:
92
- video_path = download_video_asset(self.name)
92
+ video_path = download_video_asset(self.name + ".mp4")
93
ret = video_to_ndarrays(video_path, self.num_frames)
94
return ret
95
@@ -99,5 +99,5 @@ class VideoAsset:
99
100
See also: examples/offline_inference/qwen2_5_omni/only_thinker.py
101
"""
102
- video_path = download_video_asset(self.name)
102
+ video_path = download_video_asset(self.name + ".mp4")
103
return librosa.load(video_path, sr=sampling_rate)[0]