Skip to content

[Bugfix] fix video inference of qwen3vl and qwen3.5 series - #44474

Merged
zucchini-nlp merged 8 commits into
huggingface:mainfrom
JJJYmmm:main
Mar 10, 2026
Merged

zucchini-nlp merged 8 commits into
huggingface:mainfrom
JJJYmmm:main

Conversation

@JJJYmmm

@JJJYmmm JJJYmmm commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix QwenLM/Qwen3.8#58. In the latest code, Qwen3VL and Qwen3.5 use the same get_rope_index func of Qwen2VL. But they should be different since Qwen3VL/Qwen3.5 introduce text timestamps.

This PR fixs it follow the original impl

# Since we use timestamps to seperate videos, like <t1> <vision_start> <frame1> <vision_end> <t2> <vision_start> <frame2> <vision_end>, the video_grid_thw should also be split
if video_grid_thw is not None:
video_grid_thw = torch.repeat_interleave(video_grid_thw, video_grid_thw[:, 0], dim=0)
video_grid_thw[:, 0] = 1
.

cc @zucchini-nlp 🤗

@zucchini-nlp zucchini-nlp left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, also saw the error yesterday! Can you add integration tests in qwen3-vl for image and video inference, which will help us track this kind of issues before merging PRs? There are no tests atm because model was released day-0 and we prob forgot to add later

@JJJYmmm

JJJYmmm commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

@zucchini-nlp Hi, I have added the test for qwen3.5 and fix the previous qwen3vl test(now it can catch this type of error). I also add a slow qwen3.5-0.8b test. All added tests pass locally. 🫡

@zucchini-nlp

Copy link
Copy Markdown
Member

run-slow: qwen3_5, qwen3_5_moe, qwen3_vl, qwen3_vl_moe

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/qwen3_5", "models/qwen3_5_moe", "models/qwen3_vl", "models/qwen3_vl_moe"]
quantizations: []

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 8f1685bc workflow commit (merge commit)
PR 05affcec branch commit (from PR)
main 4f91111b base commit (on main)

Model CI Report

❌ 1 new failed tests from this PR 😭

  • qwen3_5:
    tests/models/qwen3_5/test_modeling_qwen3_5.py::Qwen3_5IntegrationTest::test_model_video_generation (✅ ⟹ ❌)

@zucchini-nlp

Copy link
Copy Markdown
Member

run-slow: qwen3_5

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/qwen3_5"]
quantizations: []

@zucchini-nlp

Copy link
Copy Markdown
Member

SSH-ing into runners isn't possible so I triggered CI again, let's copy from the error message when it fails

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 30314db8 workflow commit (merge commit)
PR aa318218 branch commit (from PR)
main b8d6b845 base commit (on main)

Model CI Report

❌ 1 new failed tests from this PR 😭

  • qwen3_5:
    tests/models/qwen3_5/test_modeling_qwen3_5.py::Qwen3_5IntegrationTest::test_model_video_generation (✅ ⟹ ❌)

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: qwen3_5, qwen3_5_moe, qwen3_vl, qwen3_vl_moe

@zucchini-nlp
zucchini-nlp enabled auto-merge (squash) March 9, 2026 16:08

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have approved so it can be auto-merged 🤦🏻

@zucchini-nlp
zucchini-nlp added this pull request to the merge queue Mar 10, 2026
Merged via the queue into huggingface:main with commit 5a098a1 Mar 10, 2026
22 checks passed
Dev-Jahn added a commit to Dev-Jahn/transformers that referenced this pull request Mar 18, 2026
…face#44474)

Expand video_grid_thw to per-frame rows before iterating in
get_rope_index(). Qwen3.5 uses timestamps to separate video frames
(<t1><frame1><t2><frame2>...), creating one mm_token_type_ids segment
per frame. grid_iters needs one grid_thw entry per segment.

Fix: repeat_interleave(grid_thw, grid_thw[:,0]) then set T=1 per row.

Applied to: qwen3_vl, qwen3_5, qwen3_vl_moe, qwen3_5_moe modeling files.
The modular_qwen3_vl.py already contains this fix but generated files
were not regenerated.
eustlb pushed a commit that referenced this pull request May 12, 2026
* fix video inference of qwen3vl and qwen3.5 series

* fix ci

* get_rope_index inhert from qwen2vl

* add test for qwen3vl,qwen3.5

* fix ci

* use assertListEqual instead

* update CI result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Huggingface transformers generation issue with video input on Qwen 3.5-9B

3 participants