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

[Model][Gemma3] Simplify image input validation (#18710)

Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>

Lukas Geiger committed May 27, 2025 at 04:13 UTC 0eebd74842d56a2c84374ee2559ef99f9c841774
1 file changed +6 -12
vllm/model_executor/models/gemma3_mm.py
+6 -12
@@ -504,18 +504,12 @@ class Gemma3ForConditionalGeneration(nn.Module, SupportsMultiModal, SupportsPP,
504 return next(self.parameters()).dtype
505
506 def _validate_pixel_values(self, data: torch.Tensor) -> torch.Tensor:
507 - h = w = self.config.vision_config.image_size
508 - expected_dims = (3, h, w)
509 -
510 - def _validate_shape(d: torch.Tensor):
511 - if d.shape != expected_dims:
512 - raise ValueError(
513 - "The expected shape of pixel values per image per batch "
514 - f"is {expected_dims}. You supplied {tuple(d.shape)}.")
515 -
516 - for d in data:
517 - _validate_shape(d)
518 -
507 + image_size = self.config.vision_config.image_size
508 + expected_dims = (3, image_size, image_size)
509 + if data.shape[1:] != expected_dims:
510 + raise ValueError(
511 + "The expected shape of pixel values per image per batch is "
512 + f"{expected_dims}. You supplied {tuple(data.shape)}.")
513 return data
514
515 def _parse_and_validate_image_input(