fix: _get_num_multimodal_tokens video branch (#43329) #43330
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #43329
Summary
_get_num_multimodal_tokens(video_sizes=...)crashed in multiple multimodal processors because thevideo branch called
self.video_processor.get_number_of_video_patches(...)(not implemented on several videoprocessors), and used
merge_sizewithout initializing it (it was only set in the image branch).This meant CI never exercised the video route (tests only covered
image_sizes).Changes
self.video_processor.merge_size).
alias to the existing helper or as a small utility consistent with preprocessing).
branch is exercised in CI.
Affected processors
Relevant Tests
python -m pytest -q
tests/models/qwen2_vl/test_processing_qwen2_vl.py::Qwen2VLProcessorTest::test_get_num_vision_tokens
tests/models/qwen2_5_vl/
test_processing_qwen2_5_vl.py::Qwen2_5_VLProcessorTest::test_get_num_vision_tokens
tests/models/qwen3_vl/test_processing_qwen3_vl.py::Qwen3VLProcessorTest::test_get_num_vision_tokens
tests/models/video_llama_3/
test_processing_video_llama_3.py::VideoLlama3ProcessorTest::test_get_num_vision_tokens
tests/models/ernie4_5_vl_moe/
test_processing_ernie4_5_vl_moe.py::Ernie4_5_VL_MoeProcessorTest::test_get_num_vision_tokens
tests/models/glm4v/test_processor_glm4v.py::Glm4vProcessorTest::test_get_num_vision_tokens_video
tests/models/glm46v/test_processor_glm46v.py::Glm46VProcessorTest::test_get_num_vision_tokens_video