[Bugfix][MM] Fix OpenPangu video backend crash on num_frames=-1 - #56390
Open
hungnnvidia wants to merge 1 commit into
Open
hungnnvidia wants to merge 1 commit into
hungnnvidia wants to merge 1 commit into
Conversation
`OpenCVDynamicOpenPanguVideoBackend.compute_frames_index_to_sample` never normalized the "-1 = no cap / all frames" sentinel that every other video backend honors (`if num_frames > 0`). With the backend's own default `num_frames=-1`, the `fps > 0` cap branch condition `num_frames >= int(total_duration * fps) + 1` is `-1 >= (>=1)` -> False, so `num_frames` stayed `-1` and reached `np.linspace(0, total_duration, -1)`, raising `ValueError: Number of samples, -1, must be non-negative`. The `fps == -1` path crashed the same way. Treat `num_frames < 0` as "no cap": use the fps-derived count when `fps > 0`, and sample every frame when `fps == -1`. Positive num_frames (within or above the cap) and the invalid-fps error are unchanged. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Signed-off-by: hungh <hungh@nvidia.com>
hungnnvidia
marked this pull request as ready for review
September 11, 2026 04:29
hungnnvidia
requested review from
DarkLight1337,
NickLucche,
shen-shanshan,
tjtanaa and
ywang96
as code owners
September 11, 2026 04:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
OpenCVDynamicOpenPanguVideoBackend.compute_frames_index_to_samplenever normalizes thenum_frames = -1("no cap / all frames") sentinel that every other video backend honors viaif num_frames > 0. The backend's ownload_bytesdefault isnum_frames=-1, so with the default thefps > 0cap branch conditionnum_frames >= int(total_duration * fps) + 1evaluates to-1 >= (>=1)→False, leavingnum_frames == -1, which then hits:→
ValueError: Number of samples, -1, must be non-negative. Thefps == -1("no fps limit") path crashes the same way.Fix
Treat
num_frames < 0as "no cap":fps > 0: use the fps-derived count (int(total_duration * fps) + 1).fps == -1: sample every frame (total_frames_num).Positive
num_frames(within or above the fps cap) and the invalid-fpsValueErrorare unchanged.Reproduction (from the real code)
Before (
origin/main):After:
Test Plan / Result
test_openpangu_num_frames_sentinel(parametrizedfps=2andfps=-1) totests/multimodal/test_video.py.pytest tests/multimodal/test_video.py -k openpangu_num_frames_sentinel→ 2 passed.pre-commit run ruff-check --files vllm/multimodal/video.py tests/multimodal/test_video.py→ Passed.Not a duplicate
Searched open PRs on
vllm-project/vllm(openpangu num_frames,OpenPangu video sampling); none address this. This is distinct from the recent zero-fps guard PRs (#54390 Qwen3-VL, #54396 GLM-GA), which fix a differentZeroDivisionError, not thenum_frames=-1sentinel.Notes
The
openpangubackend is opt-in (registered without avideo_processorauto-mapping), but its own default parameter value crashes it, so any explicit selection without also overridingnum_frameshits this. AI assistance was used to locate, reproduce, fix, and test this bug; a human has reviewed the change.