[DP encoder] Fix pos_emb layer TP issue when DP encoder enabled for Qwen3 VL#20788
[DP encoder] Fix pos_emb layer TP issue when DP encoder enabled for Qwen3 VL#20788ispobock merged 2 commits intosgl-project:mainfrom
pos_emb layer TP issue when DP encoder enabled for Qwen3 VL#20788Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a specific synchronization problem within the Qwen3-VL model's encoder when operating in a distributed environment that combines data parallelism with tensor parallelism. The change ensures that the positional embedding layer correctly handles its parallelism configuration, preventing deadlocks and improving the robustness of the distributed inference setup. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
pos_emb layer TP issue when DP encoder enabledpos_emb layer TP issue when DP encoder enabled for Qwen3 VL
There was a problem hiding this comment.
Code Review
This pull request addresses a tensor parallelism issue in the pos_emb layer of the vision encoder when data parallelism is enabled. The fix involves conditionally disabling tensor parallelism for this layer, which is a correct approach to prevent hangs in distributed environments with uneven data distribution. My review includes a minor suggestion to improve code readability by simplifying a boolean expression.
|
/tag-and-rerun-ci |
Issue description:
Enable DP encoder for qwen3-vl model and TP size = 2:
Where DP size shall also be equal to TP size, depending image distribution.
However, in current init code,
pos_emblayer in encoder is not correct (https://github.com/sgl-project/sglang/blob/v0.5.9/python/sglang/srt/models/qwen3_vl.py#L308-L313) .In corner case, where image is total 1 (e.g., sglang server launch warmpup) but total 2 DP encoder, once TP_rank 0 has 1 image as input (and enabled TP), but TP_rank 1 does not have image as input (will not respond to rank0), the
pos_emblayer will stuck for waiting.This PR adds minor fix to correct above issue.