Skip to content

Conversation

py-andy-c
Copy link
Contributor

@py-andy-c py-andy-c commented Jul 24, 2025

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.

Purpose

Test Plan

Test Result

(Optional) Documentation Update

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 can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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.

🚀

@mergify mergify bot added the qwen Related to Qwen models label Jul 24, 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 enable 4bit bnb prequant MOE. The changes involve modifying the validation logic for MoE quantization and updating a model implementation to selectively quantize the MoE router gate.

My review identified a critical issue in the validation logic that could lead to a runtime crash, and a high-severity design issue in the model implementation that impacts maintainability and correctness. I've provided suggestions to fix both issues.

Comment on lines 424 to 433
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 incorrectly allows 8-bit MoE quantization when pre_quant is false. The BitsAndBytesMoEMethod for 8-bit weights is not implemented and raises a NotImplementedError (see vllm/model_executor/layers/quantization/bitsandbytes.py). This will lead to a runtime crash for a configuration that this check now allows.

To enable 4-bit pre-quantized MoE while correctly disallowing 8-bit MoE, you should only check for self.load_8bit. The original check for self.pre_quant was what blocked 4-bit pre-quant, and removing it is correct, but the self.load_8bit check should remain as it was to prevent using the unimplemented 8-bit MoE path.

if self.load_8bit:
    raise ValueError(
        "BitsAndBytes 8bit quantization with FusedMoE is not "
        "supported yet.")

Comment on lines 123 to 159
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This implementation for deciding whether to quantize the MoE gate has a couple of issues:

  1. Hardcoded Logic: It specifically checks for BitsAndBytesConfig, making it difficult to extend to other quantization methods that might also support gate quantization. This can lead to silent failures where a new quantization method is expected to quantize the gate but doesn't. A more extensible approach would be to have a method on the QuantizationConfig itself to indicate this capability.
  2. Incorrect Type Hint: The type hint for quant_config in _maybe_ignore_quant_config is QuantizationConfig, but it can be None at the call site.
  3. Clarity: The function name _maybe_ignore_quant_config is a bit ambiguous.
self.gate = ReplicatedLinear(config.hidden_size,
                                     config.num_experts,
                                     bias=False,
                                     quant_config=self._get_gate_quant_config(quant_config),
                                     prefix=f"{prefix}.gate")

    def _get_gate_quant_config(
        self, quant_config: Optional[QuantizationConfig]
    ) -> Optional[QuantizationConfig]:
        # The gate is only quantized for BitsAndBytes for now.
        if isinstance(quant_config, BitsAndBytesConfig):
            return quant_config
        return None

@jeejeelee jeejeelee self-assigned this Jul 25, 2025
@jeejeelee jeejeelee force-pushed the enable-4bit-bnb-prequant-moe branch from 128681c to ddc9e76 Compare August 11, 2025 03:34
@jeejeelee jeejeelee requested a review from sighingnow as a code owner August 11, 2025 03:34
Signed-off-by: Jee Jee Li <[email protected]>
Signed-off-by: Jee Jee Li <[email protected]>
Copy link
Collaborator

@jeejeelee jeejeelee left a comment

Choose a reason for hiding this comment

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

LGTM,thank you for your contribution

@jeejeelee jeejeelee enabled auto-merge (squash) August 11, 2025 10:12
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 11, 2025
@simon-mo simon-mo disabled auto-merge August 12, 2025 02:02
@simon-mo simon-mo merged commit 9b94d6e into vllm-project:main Aug 12, 2025
47 of 54 checks passed
@simon-mo
Copy link
Collaborator

Please add a PR description. Thanks!

paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
Signed-off-by: Jee Jee Li <[email protected]>
Co-authored-by: Jee Jee Li <[email protected]>
Signed-off-by: Paul Pak <[email protected]>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
Signed-off-by: Jee Jee Li <[email protected]>
Co-authored-by: Jee Jee Li <[email protected]>
Signed-off-by: Diego-Castan <[email protected]>
yiliu30 pushed a commit to yiliu30/vllm-fork that referenced this pull request Aug 19, 2025
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Jee Jee Li <[email protected]>
Co-authored-by: Jee Jee Li <[email protected]>
Signed-off-by: Xiao Yu <[email protected]>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
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.

3 participants