Skip to content

Feat Dynamic Quantization for MoE Layers in GPTQ Marlin Backend#19395

Merged
mgoin merged 5 commits intovllm-project:mainfrom
Jun-Howie:main
Jun 23, 2025
Merged

Feat Dynamic Quantization for MoE Layers in GPTQ Marlin Backend#19395
mgoin merged 5 commits intovllm-project:mainfrom
Jun-Howie:main

Conversation

@Jun-Howie
Copy link
Copy Markdown
Contributor

@Jun-Howie Jun-Howie commented Jun 10, 2025

dynamic Quantization Does Not Take Effect for MoE Modules with gptq_marlin in vLLM

Problem:
When running Mixture of Experts (MoE) modules using the gptq_marlin backend in vLLM, the dynamic quantization settings from the gptq configuration are not applied.

Root Cause:
In the GPTQMarlinConfig class (defined in gptq_marlin.py), the get_quant_method function uses a utility function called get_linear_quant_method (imported from gptq_utils.py) to handle per-layer dynamic quantization settings for standard linear layers. However, for MoE layers, there is currently no equivalent function in vLLM to process and apply the dynamic flag.

Solution:
To address this, we created a new helper function get_moe_quant_method (currently placed in gptq_marlin.py for simplicity) that mirrors the behavior of get_linear_quant_method, but for MoE layers. This function processes the dynamic quantization setting and returns the appropriate quantization method for each MoE layer.

Following vLLM's existing structure, this helper should ideally be moved to gptq_utils.py (similar to get_linear_quant_method) and imported into gptq_marlin.py.

Validation:
This fix can be verified using our R1 repository https://huggingface.co/QuantTrio/DeepSeek-R1-0528-GPTQ-Int4-Int8Mix-Medium

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions
Copy link
Copy Markdown

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

🚀

Comment on lines 189 to 190
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to override the config for MoeWNA16Config too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This modification will not impact the standard W4A16 model. However, if WNA intends to support mix as well, it hasn't been adapted for that yet.

@Jun-Howie
Copy link
Copy Markdown
Contributor Author

Friendly bump

@mergify mergify bot added documentation Improvements or additions to documentation ci/build frontend llama Related to Llama models multi-modality Related to multi-modality (#4194) rocm Related to AMD ROCm structured-output speculative-decoding v1 tpu Related to Google TPUs labels Jun 13, 2025
@Jun-Howie
Copy link
Copy Markdown
Contributor Author

I've merged the latest changes from the main branch. Could you please take another look at this PR?

Copy link
Copy Markdown
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mgoin mgoin added ready ONLY add when PR is ready to merge/full CI is needed quantization and removed documentation Improvements or additions to documentation rocm Related to AMD ROCm structured-output frontend speculative-decoding ci/build v1 multi-modality Related to multi-modality (#4194) tool-calling llama Related to Llama models labels Jun 13, 2025
@Jun-Howie
Copy link
Copy Markdown
Contributor Author

Thanks! Looking forward to seeing this in the next release.

@Jun-Howie
Copy link
Copy Markdown
Contributor Author

Hi @robertgshaw2-redhat
@tlrmchlsmth
could you please take a look when you have a moment? All checks are green and @mgoin has approved. Thanks!

Copy link
Copy Markdown
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

Thanks for the ping, merging

@mgoin mgoin merged commit dd2ccf8 into vllm-project:main Jun 23, 2025
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants