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 14, 05:30 UTC
Migrate InternVLImagePixelInputs (in nemotron_vl.py) to TensorSchema (#22023)
Signed-off-by: Benji Beck <benjibeck@meta.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Benji Beck committed
Aug 18, 2025 at 22:48 UTC
e75f342261610c3150a9680f37731998d9e883d6
1 file changed
+5
-23
vllm/model_executor/models/nemotron_vl.py
+5
-23
@@ -458,27 +458,6 @@ class LlamaNemotronVLChatModel(nn.Module, SupportsMultiModal, SupportsPP,
458
vit_embeds = self.mlp1(vit_embeds)
459
return vit_embeds
460
461
- def _validate_pixel_values(self, data: torch.Tensor) -> torch.Tensor:
462
-
463
- #use force_image_size to get image_size
464
- h = w = self.config.force_image_size
465
- expected_dims = (3, h, w)
466
-
467
- def _validate_shape(d: torch.Tensor):
468
- actual_dims = tuple(d.shape)
469
-
470
- if actual_dims != expected_dims:
471
- expected_expr = str(expected_dims)
472
- raise ValueError(
473
- "The expected shape of pixel values per image per batch "
474
- f" per patch is {expected_expr}. "
475
- f"You supplied {tuple(d.shape)}.")
476
-
477
- for d in data:
478
- _validate_shape(d)
479
-
480
- return data
481
-
461
def _parse_and_validate_image_input(
462
self, **kwargs: object) -> Optional[InternVLImageInputs]:
463
pixel_values_flat = kwargs.pop("pixel_values_flat", None)
@@ -516,9 +495,12 @@ class LlamaNemotronVLChatModel(nn.Module, SupportsMultiModal, SupportsPP,
495
496
return InternVLImagePixelInputs(
497
type="pixel_values",
519
- pixel_values_flat=self._validate_pixel_values(
520
- pixel_values_flat),
498
+ pixel_values_flat=pixel_values_flat,
499
num_patches=image_num_patches,
500
+ resolve_bindings={
501
+ "h": self.config.force_image_size,
502
+ "w": self.config.force_image_size
503
+ },
504
)
505
506
raise AssertionError("This line should be unreachable.")