Migrate Glm4vImageInputs, Glm4vVideoInputs to TensorSchema (#21678)

Signed-off-by: Benji Beck <benjibeck@meta.com>
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Benji Beck
2025-07-27 22:36:08 -07:00
committed by GitHub
co-authored by Cyrus Leung
parent d8937de4c8
commit 88e46c7c8d
2 changed files with 73 additions and 70 deletions
+23 -1
View File
@@ -5,6 +5,7 @@ import pytest
import torch
from vllm.model_executor.models.fuyu import FuyuImagePatchInputs
from vllm.model_executor.models.glm4_1v import Glm4vImageEmbeddingInputs
from vllm.model_executor.models.phi3v import Phi3VImagePixelInputs
@@ -145,4 +146,25 @@ def test_tensor_schema_with_list_of_symbolic_dim_mismatch_in_length():
FuyuImagePatchInputs(
flat_data=flat_data,
patches_per_image=patches_per_image,
)
)
def test_valid_tensor_schema_with_static_last_dim():
image_embeds = torch.randn(256, 1024)
image_grid_thw = torch.randint(0, 4, (2, 3))
Glm4vImageEmbeddingInputs(
image_embeds=image_embeds,
image_grid_thw=image_grid_thw,
)
def test_invalid_tensor_schema_with_static_last_dim():
image_embeds = torch.randn(256, 1024)
image_grid_thw = torch.randint(0, 4, (2, 4)) # Wrong last dim
with pytest.raises(ValueError, match="dim\\[1\\] expected 3, got 4"):
Glm4vImageEmbeddingInputs(
image_embeds=image_embeds,
image_grid_thw=image_grid_thw,
)