diff --git a/tests/models/multimodal/generation/test_transformers_video.py b/tests/models/multimodal/generation/test_transformers_video.py index bbb31b7be8..c6c47f9ac0 100644 --- a/tests/models/multimodal/generation/test_transformers_video.py +++ b/tests/models/multimodal/generation/test_transformers_video.py @@ -36,6 +36,7 @@ VIDEO_MODEL_SETTINGS: dict[str, dict[str, Any]] = { "<|VISION_START|><|VIDEO_PAD|><|VISION_END|>Describe this video." "<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>" ), + "patch_hf_runner": model_utils.cohere_compass_patch_hf_runner, }, "Qwen/Qwen2.5-VL-3B-Instruct": { "prompt": ( @@ -88,6 +89,9 @@ def test_transformers_video_generation( model_id, dtype="bfloat16", auto_cls=AutoModelForImageTextToText ) as hf_model: hf_model = model_utils.qwen3_vl_patch_hf_runner(hf_model) + patch_hf_runner = VIDEO_MODEL_SETTINGS[model_id].get("patch_hf_runner") + if patch_hf_runner is not None: + hf_model = patch_hf_runner(hf_model) hf_outputs = hf_model.generate_greedy_logprobs_limit( [prompt], 128, num_logprobs=10, videos=[video] ) diff --git a/tests/models/multimodal/generation/vlm_utils/model_utils.py b/tests/models/multimodal/generation/vlm_utils/model_utils.py index bc472c400f..9acbe2c0d6 100644 --- a/tests/models/multimodal/generation/vlm_utils/model_utils.py +++ b/tests/models/multimodal/generation/vlm_utils/model_utils.py @@ -1111,6 +1111,19 @@ def qwen3_vl_patch_hf_runner(hf_model: HfRunner) -> HfRunner: return hf_model +def cohere_compass_patch_hf_runner(hf_model: HfRunner) -> HfRunner: + """Declare the video modality that CohereCompass omits upstream. + + Without it ``generate`` leaves ``pixel_values_videos`` unconsumed and the + forward pass rejects it, see huggingface/transformers#49320. Drop this once + the pinned transformers declares the modality itself. + """ + model = hf_model.model + if "video" not in model.input_modalities: + model.input_modalities = (*model.input_modalities, "video") + return hf_model + + def voxtral_patch_hf_runner(hf_model: "HfRunner") -> "HfRunner": """Patch HfRunner for Voxtral's conversation-based processor.