# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from dataclasses import dataclass, field from functools import partial import pytest from vllm.multimodal.video import sample_frames_from_video from vllm.platforms import current_platform from ....conftest import IMAGE_ASSETS, VIDEO_ASSETS from ...utils import dummy_hf_overrides from .vlm_utils.builders import sample_frames_with_video_metadata @dataclass class VitCudagraphTestConfig: model: str modalities: list[str] = field(default_factory=lambda: ["image", "video"]) image_prompt: str | None = None video_prompt: str | None = None dtype: str = "bfloat16" max_model_len: int = 4096 max_tokens: int = 64 max_num_seqs: int = 2 num_video_frames: int = 16 needs_video_metadata: bool = False vllm_runner_kwargs: dict = field(default_factory=dict) compilation_config_overrides: dict = field(default_factory=dict) marks: list = field(default_factory=list) def params_with_marks( configs: dict[str, VitCudagraphTestConfig], ) -> list[pytest.param]: return [ pytest.param(model_id, marks=cfg.marks) for model_id, cfg in configs.items() ] def qwen_vl_chat_template(content: str) -> str: return f"<|im_start|>user\n{content}<|im_end|>\n<|im_start|>assistant\n" def internvl_chat_template(content: str) -> str: return f"<|im_start|>user\n{content}<|im_end|>\n<|im_start|>assistant\n" def step3_vl_chat_template(content: str) -> str: return ( "<|begin▁of▁sentence|> You are a helpful assistant.<|BOT|>user\n " f"{content} <|EOT|><|BOT|>assistant\n" ) MODEL_CONFIGS: dict[str, VitCudagraphTestConfig] = { "internvl": VitCudagraphTestConfig( model="OpenGVLab/InternVL3-1B", num_video_frames=8, image_prompt=internvl_chat_template("\nWhat is in this image?"), video_prompt=internvl_chat_template( "