[Bugfix] Fix ZeroDivisionError in Qwen3-VL video sampling when the source fps is unknown (#60501)

Signed-off-by: Vadim Gimpelson <vadim.gimpelson@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Vadim Gimpelson
2026-10-08 06:28:44 +00:00
committed by GitHub
co-authored by Claude
parent f226af0e11
commit ee406adf0c
2 changed files with 42 additions and 1 deletions
+10
View File
@@ -361,6 +361,15 @@ class Qwen3VLVideoBackend(VideoBackend):
_MAX_FRAMES: ClassVar[int] = 768
_MAX_FPS: ClassVar[int] = 30
@classmethod
def _prepare_source(cls, source: VideoSourceMetadata) -> VideoSourceMetadata:
# vLLM reports an unknown source fps as 0. HF's Qwen3VLVideoProcessor
# assumes a 24 fps source then, and keeps it in the metadata for the
# frame timestamps.
if source.original_fps > 0:
return source
return VideoSourceMetadata(source.total_frames_num, 24.0, source.duration)
@classmethod
def compute_frames_index_to_sample(
cls,
@@ -368,6 +377,7 @@ class Qwen3VLVideoBackend(VideoBackend):
target: VideoTargetMetadata,
**kwargs,
) -> list[int]:
source = cls._prepare_source(source)
total_frames_num = source.total_frames_num
original_fps = source.original_fps
fps = min(target.fps, cls._MAX_FPS)