Skip to content

Commit 0eebd74

Browse files
authored
[Model][Gemma3] Simplify image input validation (#18710)
Signed-off-by: Lukas Geiger <[email protected]>
1 parent 27bebcd commit 0eebd74

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

vllm/model_executor/models/gemma3_mm.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,12 @@ def dtype(self):
504504
return next(self.parameters()).dtype
505505

506506
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)}.")
519513
return data
520514

521515
def _parse_and_validate_image_input(

0 commit comments

Comments
 (0)