[Bugfix][Model] Honor Molmo2 dummy video num_frames >= 2 override (#53830)
Signed-off-by: hungh <hungh@nvidia.com>
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm.model_executor.models.molmo2 import build_flat_image_bool_length
|
||||
from vllm.config.multimodal import VideoDummyOptions
|
||||
from vllm.model_executor.models.molmo2 import (
|
||||
Molmo2DummyInputsBuilder,
|
||||
build_flat_image_bool_length,
|
||||
)
|
||||
|
||||
|
||||
def test_build_flat_image_bool_length_matches_molmoweb_processor_tokens():
|
||||
@@ -54,3 +59,32 @@ def test_build_flat_image_bool_length_respects_disabled_col_tokens():
|
||||
assert len(image_tokens) == 45
|
||||
assert image_tokens[0].item() == hf_config.low_res_image_start_token_id
|
||||
assert (image_tokens == hf_config.image_col_id).sum().item() == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("num_frames_override", "expected_frames"),
|
||||
[(1, 2), (2, 2), (3, 3)],
|
||||
)
|
||||
def test_dummy_video_num_frames_override_honors_min_of_two(
|
||||
num_frames_override, expected_frames
|
||||
):
|
||||
"""A ``num_frames`` override below 2 must be ignored (the model needs at
|
||||
least 2 frames), matching the "cannot be less than 2, will be ignored"
|
||||
warning."""
|
||||
builder = object.__new__(Molmo2DummyInputsBuilder)
|
||||
builder.info = SimpleNamespace(
|
||||
get_hf_processor=lambda: SimpleNamespace(
|
||||
video_processor=SimpleNamespace(size={"width": 64, "height": 64})
|
||||
),
|
||||
get_num_frames_with_most_features=lambda seq_len, mm_counts: 16,
|
||||
get_image_size_with_most_features=lambda: (64, 64),
|
||||
)
|
||||
|
||||
data = builder.get_dummy_mm_data(
|
||||
seq_len=128,
|
||||
mm_counts={"image": 0, "video": 1},
|
||||
mm_options={"video": VideoDummyOptions(num_frames=num_frames_override)},
|
||||
)
|
||||
|
||||
video, _metadata = data["video"][0]
|
||||
assert video.shape[0] == expected_frames
|
||||
|
||||
@@ -1879,6 +1879,7 @@ class Molmo2DummyInputsBuilder(BaseDummyInputsBuilder[Molmo2ProcessingInfo]):
|
||||
num_frames_override,
|
||||
)
|
||||
target_num_frames = min(target_num_frames, num_frames_override)
|
||||
target_num_frames = max(target_num_frames, 2)
|
||||
|
||||
dummy_videos = self._get_dummy_videos(
|
||||
width=video_size["width"],
|
||||
|
||||
Reference in New Issue
Block a user