Skip to content

[Models] Qwen3VL and Qwen3VL-Moe CUDA graph Support - #5962

Merged
CSWYF3634076 merged 3 commits into
PaddlePaddle:developfrom
CSWYF3634076:qwen3vlmoe-cudagraph
Jan 9, 2026
Merged

CSWYF3634076 merged 3 commits into
PaddlePaddle:developfrom
CSWYF3634076:qwen3vlmoe-cudagraph

Conversation

@CSWYF3634076

@CSWYF3634076 CSWYF3634076 commented Jan 8, 2026

Copy link
Copy Markdown
Collaborator

Motivation

add Qwen3VL and Qwen3VL-Moe CUDA graph support

Modifications

本PR解决Qwen3VL和 Qwen3VL-MOE启动cuda graph的问题

1.多模长上下文请求后导致后续请求重复和乱码
原因为当前多模请求单batch token没有受到max-num-batched-tokens(默认8192)限制,叠加Qwen3VL self.deepstack_input_embeds在初始化时使用了该值作为开辟固定内存的参数。在上下文超过8192时触发了self.deepstack_input_embeds扩容重新分配,新地址未进graph,导致重复和乱码。通过使用max_model_len初始化开辟固定内存buffer

2.Qwen3VL-MOE多模长上下文先请求,多模短上下文后请求,输出看不到图片的问题
原因为VisionRotaryEmbedding中使用了self._freqs_cached,这部分内存会被重写,本应该是固定值,变成了未知的随机值,进而导致image feature精度问题,所以模型看不到图片。具体哪里重写的,并且为什么是Qwen3vlmoe特有还不清楚,不过仍然能修复问题,通过修改为直接计算freqs解决

TODO
待补充性能测试结果

Usage or Command

no

Accuracy Tests

no

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot

paddle-bot Bot commented Jan 8, 2026

Copy link
Copy Markdown

Thanks for your contribution!

@CSWYF3634076 CSWYF3634076 changed the title [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support [Models] Qwen3VL and Qwen3VL-Moe CUDA graph Support Jan 8, 2026
@codecov-commenter

codecov-commenter commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.47826% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@5218d40). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...loy/model_executor/models/qwen3_vl/qwen3_vl_moe.py 93.54% 0 Missing and 2 partials ⚠️
...tdeploy/model_executor/models/qwen3_vl/qwen3_vl.py 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5962   +/-   ##
==========================================
  Coverage           ?   67.03%           
==========================================
  Files              ?      348           
  Lines              ?    44687           
  Branches           ?     6876           
==========================================
  Hits               ?    29956           
  Misses             ?    12515           
  Partials           ?     2216           
Flag Coverage Δ
GPU 67.03% <93.47%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gongshaotian gongshaotian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

麻烦补充下 CUDAGraph 适配前后的性能数据

Comment on lines +154 to +157
# self.deepstack_input_embeds = [
# paddle.zeros([fd_config.scheduler_config.max_num_batched_tokens, self.context_hidden_size], dtype=dtype)
# for _ in range(self.deepstack_num_level)
# ]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

删除无用注释

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

这个注释保留主要是想如果后续框架多模单batch受到max_num_batched_tokens限制的话,后续做个替换,因为实验下来vllm是会受到max_num_batched_tokens限制的

@xiaoxiaohehe001 xiaoxiaohehe001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

# Note that the current multimodal model does not limit the number of tokens
# per batch to max_num_batched_tokens, so we use model_config.max_model_len here
buffer_seq_len = fd_config.model_config.max_model_len
# self.deepstack_input_embeds = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

注释代码清理下

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

这个注释保留主要是想如果后续框架多模单batch受到max_num_batched_tokens限制的话,后续做个替换,因为实验下来vllm是会受到max_num_batched_tokens限制的

@CSWYF3634076

CSWYF3634076 commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator Author

麻烦补充下 CUDAGraph 适配前后的性能数据

这个QA还在测试中,后续补充到PR上,我自测能看出解码速度提升

@CSWYF3634076
CSWYF3634076 merged commit e6cdea4 into PaddlePaddle:develop Jan 9, 2026
27 of 30 checks passed
chang-wenbin pushed a commit to chang-wenbin/FastDeploy that referenced this pull request Mar 2, 2026
* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support

* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support v2

* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support v3
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support

* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support v2

* [Models] add Qwen3VL and Qwen3VL-Moe CUDA graph support v3
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.

4 participants