Skip to content

[Fix] Skip process_weights_after_loading for non-FusedMoE layers#6798

Open
wxsIcey wants to merge 1 commit intovllm-project:mainfrom
wxsIcey:fix_moe
Open

[Fix] Skip process_weights_after_loading for non-FusedMoE layers#6798
wxsIcey wants to merge 1 commit intovllm-project:mainfrom
wxsIcey:fix_moe

Conversation

@wxsIcey
Copy link
Copy Markdown
Collaborator

@wxsIcey wxsIcey commented Feb 25, 2026

What this PR does / why we need it?

Add isinstance check in AscendUnquantizedFusedMoEMethod and AscendFusedMoEMethod to guard process_weights_after_loading against being called on non-FusedMoE layer instances.

see vllm-project/vllm#35178

Does this PR introduce any user-facing change?

N/A

How was this patch tested?

CI passed with existing test.

Signed-off-by: wxsIcey <1790571317@qq.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @wxsIcey, 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 introduces defensive programming measures by adding type checks to the process_weights_after_loading methods in the Ascend-specific FusedMoE quantization methods. This ensures that these methods are only applied to actual FusedMoE layer instances, thereby preventing erroneous processing of incompatible layer types and improving the robustness of the weight loading mechanism.

Highlights

  • Defensive Type Checking: Implemented isinstance checks in process_weights_after_loading methods within AscendUnquantizedFusedMoEMethod and AscendFusedMoEMethod to ensure they only operate on FusedMoE layer instances.
  • Prevented Incorrect Method Calls: Guarded against process_weights_after_loading being called on layers that are not FusedMoE, preventing potential runtime errors or incorrect behavior during weight processing.

🧠 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
  • vllm_ascend/ops/fused_moe/fused_moe.py
    • Added a type check to process_weights_after_loading to ensure the layer argument is an instance of FusedMoE before proceeding.
  • vllm_ascend/quantization/method_adapters.py
    • Imported FusedMoE for use in type checking.
    • Introduced a type check in process_weights_after_loading to prevent processing non-FusedMoE layer instances.
Activity
  • CI passed with existing tests, indicating no regressions were introduced by these changes.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

Copy link
Copy Markdown
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 adds a safeguard in process_weights_after_loading for AscendUnquantizedFusedMoEMethod and AscendFusedMoEMethod to prevent errors when called on non-FusedMoE layers. The changes are correct and improve robustness.

Based on the repository's style guide, the pull request title should be updated to follow the [Module][Action] Title format.
Suggested PR Title:

[Ops][BugFix] Skip process_weights_after_loading for non-FusedMoE layers

@wxsIcey wxsIcey added ready read for review ready-for-test start test by label for PR labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ops module:quantization ready read for review ready-for-test start test by label for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant