Skip to content

[Bugfix] Fix missing per_act_token parameter in compressed_tensors_moe #20509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2025

Conversation

luccafong
Copy link
Collaborator

@luccafong luccafong commented Jul 5, 2025

Purpose

Fix maverick serving broken issue from refactor PR #19636.

per_act_token was added in cutlass_moe_fp8 in PR #19636, but not passed in in some caller (e.g. CompressedTensorsW8A8Fp8MoECutlassMethod) and not given default value, causing failure,

e.g.

return self.fused_experts(
x,
layer.w13_weight,
layer.w2_weight,
topk_weights,
topk_ids,
activation=activation,

the per_act_token assignment was removed in PR #19636, so we add back the value if it is not passed (default None) to fix Maverick serving issue

Test Plan

Serving:

export MODEL=/data/users/vllm/models/maverick_instruct_fp8_oss; VLLM_DISABLE_COMPILE_CACHE=1 lm_eval --model vllm --tasks gsm8k --model_args pretrained=$MODEL,max_model_len=131072,tensor_parallel_size=8 --batch_size auto

lm_eval:

VLLM_DISABLE_COMPILE_CACHE=1 lm_eval --model vllm --tasks gsm8k --model_args pretrained=$MODEL,max_model_len=131072,tensor_parallel_size=8 --batch_size auto
vllm (pretrained=/data/users/vllm/models/maverick_instruct_fp8_oss,max_model_len=131072,tensor_parallel_size=8), gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: auto
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|     5|exact_match|↑  |0.9227|±  |0.0074|
|     |       |strict-match    |     5|exact_match|↑  |0.9212|±  |0.0074|

Copy link

github-actions bot commented Jul 5, 2025

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

🚀

@luccafong luccafong marked this pull request as ready for review July 5, 2025 08:20
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.

Summary of Changes

Hello @luccafong, 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 delivers a crucial bugfix that resolves a serving issue impacting MoE layer operations, specifically within the cutlass_moe_fp8 function. It addresses a regression introduced by a prior refactor by making a key parameter optional and providing robust default value derivation, thereby restoring stability and preventing runtime failures in quantized MoE models.

Highlights

  • Bugfix for MoE Layer: Addressed a critical 'maverick serving broken issue' that arose from a previous refactor (PR #19636). The issue was due to the per_act_token parameter being added to cutlass_moe_fp8 but not consistently passed by callers or given a default value, leading to failures.
  • Parameter Signature Update: Modified the cutlass_moe_fp8 function signature in vllm/model_executor/layers/fused_moe/cutlass_moe.py to make the per_act_token parameter Optional[bool] and assign it a default value of None.
  • Dynamic Parameter Derivation: Implemented logic within the cutlass_moe_fp8 function to dynamically determine the value of per_act_token if it is None. This derivation is based on checking the numel() of a1_scale or a2_scale, ensuring correct behavior even when the parameter is not explicitly provided by the caller.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 addresses a bug where the per_act_token parameter was missing in some callers of cutlass_moe_fp8. The fix makes the parameter optional and infers its value when not provided, preventing crashes. The implementation is robust and I've added suggestions to improve the code's documentation and readability.

@@ -322,7 +322,7 @@ def cutlass_moe_fp8(
topk_ids: torch.Tensor,
w1_scale: torch.Tensor,
w2_scale: torch.Tensor,
per_act_token: bool,
per_act_token: Optional[bool] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding a docstring to explain the purpose of the per_act_token parameter, especially now that it's optional. This will help users understand when and how to use this parameter.

per_act_token: Optional[bool] = None,  """Whether to use a different scale for each token."""

Comment on lines +369 to +371
if per_act_token is None:
per_act_token = a1_scale.numel() != 1 if a1_scale is not None else (
a2_scale.numel() != 1 if a2_scale is not None else False)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The nested ternary expression can be difficult to read. Refactoring this into a more explicit if/elif/else block would improve code clarity and maintainability.

    if per_act_token is None:
        if a1_scale is not None:
            per_act_token = a1_scale.numel() != 1
        elif a2_scale is not None:
            per_act_token = a2_scale.numel() != 1
        else:
            per_act_token = False

@luccafong luccafong requested a review from houseroad July 5, 2025 08:22
@facebook-github-bot
Copy link

@luccafong has imported this pull request. If you are a Meta employee, you can view this in D77824312.

Copy link
Collaborator

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

We need to find a fundamental solution to guard the code

@houseroad houseroad added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 5, 2025
@DarkLight1337 DarkLight1337 merged commit 4328708 into vllm-project:main Jul 6, 2025
78 checks passed
@huydhn huydhn mentioned this pull request Jul 7, 2025
huydhn pushed a commit to huydhn/vllm that referenced this pull request Jul 8, 2025
Chen-zexi pushed a commit to Chen-zexi/vllm that referenced this pull request Jul 13, 2025
patrickvonplaten pushed a commit to patrickvonplaten/vllm that referenced this pull request Jul 15, 2025
vllm-project#20509)

Signed-off-by: Lu Fang <fanglu@fb.com>
Signed-off-by: Patrick von Platen <patrick.v.platen@gmail.com>
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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants