[Bugfix][GLM4V] Fix video dummy profiling and memory usage (#48729)
Signed-off-by: xiaoming <1259730330@qq.com>
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.assets.video import VideoAsset
|
||||
from vllm.model_executor.models.glm4_1v import (
|
||||
Glm4vForConditionalGeneration,
|
||||
Glm4vProcessingInfo,
|
||||
)
|
||||
from vllm.multimodal import MULTIMODAL_REGISTRY
|
||||
from vllm.multimodal.inputs import batched_tensors_equal
|
||||
from vllm.multimodal.video import DynamicVideoBackend, VideoBackend
|
||||
@@ -11,6 +17,52 @@ from vllm.multimodal.video import DynamicVideoBackend, VideoBackend
|
||||
from ...utils import build_model_context
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
(
|
||||
"max_video_pixels",
|
||||
"max_tokens",
|
||||
"expected_num_frames",
|
||||
),
|
||||
[
|
||||
(47_040_000, 124_988, 11),
|
||||
(47_040_000, 30_000, 24),
|
||||
(100_352_000, 124_988, 21),
|
||||
(100_352_000, 30_000, 7),
|
||||
(100_352_000, 0, 1),
|
||||
],
|
||||
)
|
||||
def test_get_max_video_frames_matches_glm_resize(
|
||||
max_video_pixels: int,
|
||||
max_tokens: int,
|
||||
expected_num_frames: int,
|
||||
):
|
||||
info = Mock(spec=Glm4vProcessingInfo)
|
||||
info.get_image_size_with_most_features.return_value = (2184, 2184)
|
||||
info._get_video_max_pixels.return_value = max_video_pixels
|
||||
vision_config = info.get_hf_config.return_value.vision_config
|
||||
vision_config.patch_size = 14
|
||||
vision_config.spatial_merge_size = 2
|
||||
vision_config.temporal_patch_size = 2
|
||||
info._get_vision_info.side_effect = lambda **kwargs: (
|
||||
Glm4vProcessingInfo._get_vision_info(info, **kwargs)
|
||||
)
|
||||
|
||||
num_frames = Glm4vProcessingInfo._get_max_video_frames(
|
||||
info,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
|
||||
assert num_frames == expected_num_frames
|
||||
assert info._get_video_max_pixels.call_count == 1
|
||||
assert info._get_vision_info.call_count == 600
|
||||
|
||||
|
||||
def test_encoder_cudagraph_uses_model_video_frame_limit():
|
||||
model = Mock()
|
||||
|
||||
assert Glm4vForConditionalGeneration.get_max_frames_per_video(model) == 600
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_id", ["zai-org/GLM-4.1V-9B-Thinking"])
|
||||
@pytest.mark.parametrize("expected_toks_per_frame", [299])
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user