Skip to content

Conversation

LJH-LBJ
Copy link
Contributor

@LJH-LBJ LJH-LBJ commented Sep 19, 2025

Purpose

This PR refactors the Qwen3_VisionPatchMerger class to remove redundant assignments related to use_postshuffle_norm and the initialization of the normalization layer.

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: Junhong <liujunhong11@huawei.com>
@LJH-LBJ LJH-LBJ requested a review from sighingnow as a code owner September 19, 2025 03:07
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors.

You ask your reviewers to trigger select CI tests on top of fastcheck CI.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

@mergify mergify bot added the qwen Related to Qwen models label Sep 19, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to refactor Qwen3_VisionPatchMerger to remove redundant assignments. However, the current change introduces a critical bug by removing the assignment to self.use_postshuffle_norm, which is used in the forward method. This will lead to an AttributeError at runtime. Additionally, the logic for initializing the normalization layer is now incorrect when use_postshuffle_norm is true, which would cause a tensor shape mismatch. I've provided a suggestion to fix this.

self.use_postshuffle_norm = use_postshuffle_norm
self.norm = norm_layer(
self.hidden_size if use_postshuffle_norm else context_dim)
self.norm = norm_layer(context_dim)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change introduces a bug. By removing the assignment to self.use_postshuffle_norm, the forward method will raise an AttributeError because it relies on this attribute.

Furthermore, the normalization layer self.norm is now always initialized with context_dim. However, when use_postshuffle_norm is True, it should be initialized with self.hidden_size to match the tensor shape in the forward method. The current implementation will cause a shape mismatch error.

To fix this, you should restore the assignment and the conditional logic for the normalization dimension. Here is a suggested correction that keeps the logic correct while improving readability slightly.

        self.use_postshuffle_norm = use_postshuffle_norm
        norm_dim = self.hidden_size if use_postshuffle_norm else context_dim
        self.norm = norm_layer(norm_dim)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

self.use_postshuffle_norm is initialized in L220 and context_dim will be equal to self.hidden_size if self.use_postshuffle_norm is true in L221

Copy link
Member

@ywang96 ywang96 left a comment

Choose a reason for hiding this comment

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

Ah thanks for finding this out!

@ywang96 ywang96 added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 19, 2025
Copy link
Member

@Isotr0py Isotr0py left a comment

Choose a reason for hiding this comment

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

Thanks!

@mgoin mgoin merged commit d90e212 into vllm-project:main Sep 19, 2025
48 checks passed
debroy-rh pushed a commit to debroy-rh/vllm that referenced this pull request Sep 19, 2025
…25224)

Signed-off-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Roger Wang <hey@rogerw.io>
@LJH-LBJ LJH-LBJ deleted the qwen3_vl_opt branch September 22, 2025 01:16
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
…25224)

Signed-off-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Roger Wang <hey@rogerw.io>
charlifu pushed a commit to ROCm/vllm that referenced this pull request Sep 25, 2025
…25224)

Signed-off-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Junhong <liujunhong11@huawei.com>
Co-authored-by: Roger Wang <hey@rogerw.io>
Signed-off-by: charlifu <charlifu@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants