@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 996aa70f00
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, 04:30 UTC

[Bugfix] Fix broken phi3-v mm_processor_kwargs tests (#11263)

Signed-off-by: Isotr0py <2037008807@qq.com>

Isotr0py committed Dec 19, 2024 at 02:16 UTC 996aa70f00818933866d8cfdbbf8f131a6a63664
2 files changed +17 -12
tests/models/decoder_only/vision_language/mm_processor_kwargs/test_phi3v.py
+5 -7
@@ -58,16 +58,14 @@ def test_max_tokens_override(get_max_phi3v_image_tokens, model: str,
58
59 @pytest.mark.parametrize("model", models)
60 @pytest.mark.parametrize(
61 - "num_crops,expected_toks_per_img,num_imgs",
61 + "num_crops,expected_toks_per_img",
62 [
63 - (4, 757, 1),
64 - (4, 757, 2),
65 - (16, 1921, 1),
66 - (16, 1921, 2),
63 + (4, 757),
64 + (16, 1921),
65 # the default num_crops of phi-3.5-vision is 4
68 - (None, 757, 2),
69 - (None, 757, 2),
66 + (None, 757),
67 ])
68 +@pytest.mark.parametrize("num_imgs", [1, 2])
69 def test_processor_override(processor_for_phi3v, image_assets: _ImageAssets,
70 model: str, num_crops: Optional[int],
71 expected_toks_per_img: int, num_imgs: int):
vllm/model_executor/models/phi3v.py
+12 -5
@@ -302,11 +302,18 @@ class Phi3HDImageEmbedding(Phi3ImageEmbeddingBase):
302 return image_features_hd_newline
303
304
305 -def get_max_phi3v_image_tokens(ctx: InputContext) -> int:
306 - processor = ctx.get_hf_processor()
307 - image_processor = processor.image_processor # type: ignore
308 -
309 - return image_processor.calc_num_image_tokens_from_image_size(
305 +def get_max_phi3v_image_tokens(
306 + ctx: InputContext,
307 + *,
308 + num_crops: Optional[int] = None,
309 +) -> int:
310 + mm_processor_kwargs = {}
311 + if num_crops:
312 + mm_processor_kwargs["num_crops"] = num_crops
313 +
314 + processor = ctx.get_hf_processor(**mm_processor_kwargs)
315 +
316 + return processor.calc_num_image_tokens_from_image_size(
317 width=MAX_IMAGE_FEATURE_SIZE_WIDTH,
318 height=MAX_IMAGE_FEATURE_SIZE_HEIGHT,
319 )