From 5b3f280a6df68c4f8264014380249ba530173ed6 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Fri, 25 Sep 2026 02:36:26 +0800 Subject: [PATCH] [Bugfix] Count unsplit Idefics3 image patches (#48760) Signed-off-by: nightcityblade Co-authored-by: nightcityblade Co-authored-by: Cyrus Leung --- tests/models/multimodal/processing/test_smolvlm.py | 9 +++++++++ vllm/model_executor/models/idefics3.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/models/multimodal/processing/test_smolvlm.py b/tests/models/multimodal/processing/test_smolvlm.py index f27c4eb7b8..02181d5d6f 100644 --- a/tests/models/multimodal/processing/test_smolvlm.py +++ b/tests/models/multimodal/processing/test_smolvlm.py @@ -17,6 +17,7 @@ from ...utils import build_model_context [ ({"max_image_size": {"longest_edge": 384}}, 1377), ({"max_image_size": {"longest_edge": 768}}, 405), + ({"do_image_splitting": False}, 81), ], ) @pytest.mark.parametrize("num_imgs", [1, 2]) @@ -63,6 +64,14 @@ def test_processor_override( # Ensure the placeholders format are correct hf_processor = processor.info.get_hf_processor(**hf_processor_mm_kwargs) + num_patches = processor.info.get_num_patches( + image_width=dummy_image.width, + image_height=dummy_image.height, + processor=hf_processor, + mm_kwargs=hf_processor_mm_kwargs, + ) + assert num_patches == expected_toks_per_img // hf_processor.image_seq_len + hf_processed_inputs = hf_processor( text=prompt, images=mm_data["image"], diff --git a/vllm/model_executor/models/idefics3.py b/vllm/model_executor/models/idefics3.py index 80c71cfe79..7396e007b8 100644 --- a/vllm/model_executor/models/idefics3.py +++ b/vllm/model_executor/models/idefics3.py @@ -137,7 +137,7 @@ class Idefics3ProcessingInfo(BaseProcessingInfo): mm_kwargs=mm_kwargs, ) - return num_patches + return max(num_patches, 1) def _get_image_token(self, processor: Idefics3Processor) -> tuple[str, str, str]: image_token = processor.image_token