@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 80162c44b1
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 16, 18:15 UTC

[Bugfix] Fix Phi-3v crash when input images are of certain sizes (#7840)

zifeitong committed Aug 24, 2024 at 18:16 UTC 80162c44b1d1e59a2c10f65b6adb9b0407439b1f
2 files changed +22 -7
tests/models/test_phi3v.py
+22 -5
@@ -3,13 +3,14 @@ import re
3 from typing import List, Optional, Tuple, Type
4
5 import pytest
6 +from PIL import Image
7 from transformers import AutoTokenizer
8
9 from vllm.multimodal.utils import rescale_image_size
10 from vllm.sequence import SampleLogprobs
11 from vllm.utils import is_cpu, is_hip
12
12 -from ..conftest import IMAGE_ASSETS, HfRunner, VllmRunner, _ImageAssets
13 +from ..conftest import IMAGE_ASSETS, HfRunner, VllmRunner
14 from .utils import check_logprobs_close
15
16 pytestmark = pytest.mark.vlm
@@ -58,7 +59,7 @@ if is_hip():
59 def run_test(
60 hf_runner: Type[HfRunner],
61 vllm_runner: Type[VllmRunner],
61 - image_assets: _ImageAssets,
62 + images: List[Image.Image],
63 model: str,
64 *,
65 size_factors: List[float],
@@ -77,8 +78,6 @@ def run_test(
78 Note, the text input is also adjusted to abide by vllm contract.
79 The text output is sanitized to be able to compare with hf.
80 """
80 - images = [asset.pil_image for asset in image_assets]
81 -
81 inputs_per_image = [(
82 [prompt for _ in size_factors],
83 [
@@ -159,7 +158,7 @@ def test_models(hf_runner, vllm_runner, image_assets, model, size_factors,
158 run_test(
159 hf_runner,
160 vllm_runner,
162 - image_assets,
161 + [asset.pil_image for asset in image_assets],
162 model,
163 size_factors=size_factors,
164 dtype=dtype,
@@ -167,3 +166,21 @@ def test_models(hf_runner, vllm_runner, image_assets, model, size_factors,
166 num_logprobs=num_logprobs,
167 tensor_parallel_size=1,
168 )
169 +
170 +
171 +@pytest.mark.parametrize("model", models)
172 +@pytest.mark.parametrize("dtype", [target_dtype])
173 +def test_regression_7840(hf_runner, vllm_runner, image_assets, model,
174 + dtype) -> None:
175 + # Regression test for #7840.
176 + run_test(
177 + hf_runner,
178 + vllm_runner,
179 + [image_assets[0].pil_image.resize((465, 226))],
180 + model,
181 + size_factors=[1.0],
182 + dtype=dtype,
183 + max_tokens=128,
184 + num_logprobs=10,
185 + tensor_parallel_size=1,
186 + )
vllm/model_executor/models/phi3v.py
-2
@@ -400,8 +400,6 @@ def input_processor_for_phi3v(ctx: InputContext, llm_inputs: LLMInputs):
400 image_data = multi_modal_data["image"]
401 if isinstance(image_data, Image.Image):
402 w, h = image_data.size
403 - w, h = _calc_hd_transform_size(width=w, height=h)
404 -
403 image_feature_size = get_phi3v_image_feature_size(hf_config,
404 input_width=w,
405 input_height=h)