Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions vllm/model_executor/models/molmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ class MolmoImageInputs(TensorSchema):
"""
Dimensions:
- bn: Batch size * number of images
- nc: Number of crops
- nc: Number of crops (dynamic)
- np: Number of patches
- tp: Token sequence positions
- pd: Patch dimension
"""
images: Annotated[Union[torch.Tensor, list[torch.Tensor]],
TensorShape("bn", "nc", "np", "pd")]
TensorShape("bn", "nc", "np", "pd", dynamic_dims={"nc"})]
# Number of crops may vary per batch and image, so pass it as a list.

image_masks: Annotated[Optional[Union[torch.Tensor, list[torch.Tensor]]],
TensorShape("bn", "nc", "np")]
TensorShape("bn", "nc", "np", dynamic_dims={"nc"})]

feat_is_patch: Annotated[Union[torch.Tensor, list[torch.Tensor]],
TensorShape("bn", "nc", "np")]
feat_is_patch: Annotated[
Union[torch.Tensor, list[torch.Tensor]],
TensorShape("bn", "nc", "tp", dynamic_dims={"nc"})]
Comment on lines +91 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The number of token sequence positions (tp) can also be dynamic for different images, similar to the number of crops (nc). The number of tokens depends on the image's height and width. To prevent potential ValueError during tensor shape validation when processing a batch of images with varying sizes, tp should also be marked as a dynamic dimension.

Suggested change
feat_is_patch: Annotated[
Union[torch.Tensor, list[torch.Tensor]],
TensorShape("bn", "nc", "tp", dynamic_dims={"nc"})]
feat_is_patch: Annotated[
Union[torch.Tensor, list[torch.Tensor]],
TensorShape("bn", "nc", "tp", dynamic_dims={"nc", "tp"})]

# A boolean mask indicating which image features correspond to patch tokens.

num_crops: Annotated[torch.Tensor, TensorShape("bn")]


Expand Down