Skip to content

Make compressed-tensors MoEs support ignored layers#17828

Merged
AniZpZ merged 5 commits intosgl-project:mainfrom
LHXuuu:ignore_moe
Feb 9, 2026
Merged

Make compressed-tensors MoEs support ignored layers#17828
AniZpZ merged 5 commits intosgl-project:mainfrom
LHXuuu:ignore_moe

Conversation

@LHXuuu
Copy link
Contributor

@LHXuuu LHXuuu commented Jan 27, 2026

Motivation

When the MoE layer is not fully quantized, certain layers must be ignored during weight loading.

Modifications

  • Extract the common function get_scheme_dict to provide a unified interface for both Linear and FusedMoE layers, determining whether a rollback is needed and matching the appropriate target to return the corresponding scheme_dict.
  • Add FusedMoE to the target_scheme_map, then match normally by either layer or module type.

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LHXuuu, 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 significantly improves the handling of quantization for Mixture-of-Experts (MoE) layers, particularly when only a subset of layers are intended for quantization. It refactors the core logic for retrieving quantization schemes, making it more robust and unified across different layer types. The changes ensure that FusedMoE layers correctly inherit and apply quantization settings, and crucially, properly bypass quantization when designated as ignored, facilitating more flexible mixed-precision quantization strategies.

Highlights

  • Unified Quantization Scheme Lookup: Extracted the logic for determining quantization schemes into a new get_scheme_dict method. This centralizes the process of retrieving QuantizationArgs for a given layer, including checks for ignored layers, and is now used by both general quantization and MoE-specific methods.
  • FusedMoE Layer Support: Enhanced the quantization configuration to explicitly support FusedMoE layers. A new helper method _add_fused_moe_to_target_scheme_map ensures that quantization schemes defined for Linear layers are also applied to FusedMoE modules, as they are composed of linear projections.
  • Ignored MoE Layer Handling: Implemented specific logic within CompressedTensorsMoEMethod.get_moe_method to correctly identify and return an UnquantizedFusedMoEMethod when a FusedMoE layer is configured to be ignored. This ensures that partially quantized MoE models can function as intended.
  • MoE Projection Scheme Consistency: Added a validation step to ensure that all constituent linear projections (gate_proj, up_proj, down_proj) within a FusedMoE layer share the same quantization scheme. This prevents inconsistent quantization within a single MoE block.

🧠 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.

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.

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 introduces support for ignoring layers during quantization for Mixture-of-Experts (MoE) layers when using compressed-tensors. The changes are well-structured, involving a refactoring to centralize the logic for retrieving quantization schemes into a new get_scheme_dict method. This new method correctly handles ignored layers. The MoE quantization logic is updated to use this new method, ensuring that projections within an MoE layer have consistent quantization schemes and correctly fall back to an unquantized method when ignored. Overall, this is a solid improvement that enhances the flexibility of the quantization framework for MoE models. I have one minor suggestion to improve code clarity.

Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com>
@liusy58
Copy link
Collaborator

liusy58 commented Jan 27, 2026

Great!

@AniZpZ AniZpZ self-assigned this Jan 29, 2026
@AniZpZ AniZpZ added the run-ci label Jan 29, 2026
@liusy58
Copy link
Collaborator

liusy58 commented Feb 3, 2026

/rerun-failed-ci

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@AniZpZ AniZpZ merged commit 107958a into sgl-project:main Feb 9, 2026
208 of 221 checks passed
@LHXuuu LHXuuu deleted the ignore_moe branch February 9, 2026 06:40
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com>
Co-authored-by: Peng Zhang <aniz1905@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants