Skip to content

disable moe_calibrate_all_experts for Autoround example. - #2877

Open
changwangss wants to merge 6 commits into
vllm-project:mainfrom
changwangss:wangchang/llama4
Open

disable moe_calibrate_all_experts for Autoround example.#2877
changwangss wants to merge 6 commits into
vllm-project:mainfrom
changwangss:wangchang/llama4

Conversation

@changwangss

@changwangss changwangss commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

SUMMARY:

  1. llmcompressor now applies linearize_moe in oneshot, so MoE experts may already be linearized before AutoRound runs.
    Because of this, we added a skip in AutoRound (Skip fused_moe replacement when llm-compressor oneshot already linearizes experts intel/auto-round#1966) to avoid redundant fused_moe replacement when linearized experts are detected.
    For Llama4, the default linearized flow calibrates all experts at once, which can OOM on an 80GB GPU.
    Setting moe_calibrate_all_experts=False avoids this, and with 128 samples + 200 iterations we still get sufficient expert coverage during calibration.

  2. moe_calibrate_all_experts=False for Qwen-30B-A3B mxfp8 was already introduced in an earlier PR ([Fix AutoRound ignore-layer metadata handling and add Qwen3-30B to mxfp8 example. #2695]. It was likely lost after multiple example updates, so this change restores it.

TEST PLAN:
"please outline how the changes were tested"

… linearize_moe

Signed-off-by: changwangss <chang1.wang@intel.com>
Signed-off-by: changwangss <chang1.wang@intel.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5305481b-f6ce-4ff2-87b6-2c8f75241ff3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds the moe_calibrate_all_experts=False argument to oneshot(...) calls in three AutoRound quantization example scripts, controlling whether all Mixture-of-Experts experts are calibrated. One file also adds inline comments explaining single-GPU OOM constraints for expert calibration.

Changes

AutoRound Example MoE Calibration Flag

Layer / File(s) Summary
Add moe_calibrate_all_experts flag to oneshot calls
examples/autoround/quantization_w8a8_fp8/llama4_dynamic_quant_example.py, examples/autoround/quantization_w8a8_fp8/llama4_static_quant_example.py, examples/autoround/quantization_w8a8_mxfp8/autoround_example.py
Adds moe_calibrate_all_experts=False to oneshot(...) invocations in all three example scripts; the mxfp8 example also adds inline comments explaining potential OOM on a single 80GB GPU when calibrating all experts.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • vllm-project/llm-compressor#2565: Introduces the underlying calibrate_all_experts MoE calibration behavior that the moe_calibrate_all_experts flag added here configures.

Suggested labels

bug, qwen, llama, moe, autoround

Suggested reviewers

  • HDCharles
  • brian-dellabetta
  • kylesayrs
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: disabling moe_calibrate_all_experts in AutoRound examples.
Description check ✅ Passed The description is directly related to the changes and explains the MoE calibration adjustment and its motivation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped vllm-project/compressed-tensors.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates several AutoRound quantization examples by explicitly setting the moe_calibrate_all_experts parameter to False. This includes the LLaMA 4 dynamic and static quantization examples, as well as the MXFP8 example where a comment is added explaining that disabling this option prevents out-of-memory (OOM) errors on a single 80GB GPU. There are no review comments, and I have no feedback to provide.

@mergify mergify Bot added the documentation Improvements or additions to documentation label Jun 30, 2026
@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

@changwangss
changwangss marked this pull request as ready for review July 1, 2026 01:30
@mergify mergify Bot added the two-reviews When a PR requires two reviews label Jul 1, 2026
@mergify

mergify Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Require one maintainer review

All PRs must have at least one approving review from a maintainer before merging.

  • #changes-requested-reviews-by = 0
  • any of:
    • approved-reviews-by=brian-dellabetta
    • approved-reviews-by=kylesayrs
    • approved-reviews-by=yiliu30
    • approved-reviews-by=HDCharles
    • approved-reviews-by=dsikka

🟢 Require two reviews

PRs labelled "two-reviews" must have at least two approving reviews before merging.

  • #approved-reviews-by >= 2
  • #changes-requested-reviews-by = 0

@coderabbitai coderabbitai Bot added autoround For any PR / issue related to autoround support bug Something isn't working llama For any PR / issue related to Llama herd support moe qwen For any PR / issue related to Qwen support labels Jul 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
examples/autoround/quantization_w8a8_fp8/llama4_dynamic_quant_example.py (1)

51-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a rationale comment, matching the mxfp8 example.

The PR objective explains this flag avoids OOM when llmcompressor has already linearized MoE experts, while 128 samples/200 iterations still give sufficient expert coverage. The mxfp8 example documents this reasoning inline, but this file doesn't. Adding a short comment here would help readers understand why the flag is set.

📝 Suggested comment
+    # Disable calibrating all experts to avoid OOM when llmcompressor's
+    # linearize_moe has already run before AutoRound; 128 samples / 200 iters
+    # still provide sufficient expert routing coverage.
     moe_calibrate_all_experts=False,

As per path instructions, "Review for clarity, correctness, and educational value... comments and documentation are helpful for users learning the library."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/autoround/quantization_w8a8_fp8/llama4_dynamic_quant_example.py` at
line 51, Add a short rationale comment near the moe_calibrate_all_experts
setting in the llama4_dynamic_quant_example example, matching the inline
explanation used in the mxfp8 example. Mention that disabling expert-wide
calibration avoids OOM when llmcompressor has already linearized MoE experts,
while the 128 samples/200 iterations still provide sufficient expert coverage.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/autoround/quantization_w8a8_fp8/llama4_dynamic_quant_example.py`:
- Line 51: Add a short rationale comment near the moe_calibrate_all_experts
setting in the llama4_dynamic_quant_example example, matching the inline
explanation used in the mxfp8 example. Mention that disabling expert-wide
calibration avoids OOM when llmcompressor has already linearized MoE experts,
while the 128 samples/200 iterations still provide sufficient expert coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 228b27af-3a56-4edd-91b1-c0fbc1399834

📥 Commits

Reviewing files that changed from the base of the PR and between 930e5b8 and 344726d.

📒 Files selected for processing (3)
  • examples/autoround/quantization_w8a8_fp8/llama4_dynamic_quant_example.py
  • examples/autoround/quantization_w8a8_fp8/llama4_static_quant_example.py
  • examples/autoround/quantization_w8a8_mxfp8/autoround_example.py

@yiliu30 yiliu30 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks!

Signed-off-by: changwangss <chang1.wang@intel.com>
@kylesayrs

Copy link
Copy Markdown
Collaborator

For Llama4, the default linearized flow calibrates all experts at once, which can OOM on an 80GB GPU.

In my understanding, AutoRound's memory usage is purely a function of (number of gradients which is proportional to number of activated experts), NOT the number of samples

The samples are reduced into gradients, so as long as each expert gets at least one sample, then adding more samples via calibrate_all_experts shouldn't increase memory usage, right?

As long as each expert gets at least one sample, I don't see a reason why moe_calibrate_all_experts=False would decrease memory usage.

@kylesayrs

kylesayrs commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

I think the things I need to understand are

  1. Why does moe_calibrate_all_experts=False use less memory than moe_calibrate_all_experts=True?
  2. Is there ever a risk that a module goes uncalibrated or badly calibrated? What if someone modifies the example to use (a different model/ a different dataset/ a different seed)?
  3. What if someone want to use activation quantization with AutoRound? Will experts with very few activations fail to calibrate correctly?

@changwangss

changwangss commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

sorry for the late response. Let me answer the questions.

  1. Why does moe_calibrate_all_experts=False use less memory than moe_calibrate_all_experts=True?

The main memory usage is not from the final gradient tensors. With moe_calibrate_all_experts=True, every expert processes all tokens, producing much larger QDQ inputs and intermediate activations. With False, each token is processed only by its top-8 routed experts, significantly reducing peak memory.

  1. Is there ever a risk that a module goes uncalibrated or badly calibrated? What if someone modifies the example to use (a different model/ a different dataset/ a different seed)?

With 128 calibration samples, a sequence length of 2048, and top-8 routing, each MoE layer receives approximately 2.1 million expert-token assignments. In our DeepSeek-R1 test with the same calibration configuration, every expert was activated. The distribution was not perfectly uniform, as expected for MoE routing, but no expert was extremely underrepresented. Therefore, we expect this configuration to provide sufficient coverage in practice, although the exact distribution remains model- and dataset-dependent.

  1. What if someone want to use activation quantization with AutoRound? Will experts with very few activations fail to calibrate correctly?

The current MXFP8 example uses dynamic activation quantization, where activation scales are computed at runtime, See the MXFP8 configuration
For static activation quantization, fewer activations may make the collected range less representative. If an expert is not activated at all, AutoRound fills its missing amax using the maximum value from calibrated experts, see the set_amax_for_uncalibrated_experts()

@brian-dellabetta

Copy link
Copy Markdown
Collaborator

@yiliu30 are you satisfied with the changes and explanation for us to merge this in?

@kylesayrs kylesayrs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@changwangss Good to merge from my side, just adding my comments here

  1. With moe_calibrate_all_experts=True, every expert processes all tokens, producing much larger QDQ inputs and intermediate activations

Note that LLM Compressor linearizes experts. This means that experts are executed sequentially, and therefore processing more experts does not increase peak memory usage, only increases runtime.

Even when sequential_targets="ExpertWithGate" and you care about offload memory, the sequential pipeline's tracing will guarantee that the expert outputs are added to the fixed size summing tensor, not accumulated before adding.

  1. In our DeepSeek-R1 test with the same calibration configuration, every expert was activated.

That's interesting to hear. We initially added this feature for DSV3 and found that many experts received insufficient samples. This could be reflective of either models having better expert distribution, or autoround being more resilient to low calibration data than GPTQ

  1. If an expert is not activated at all, AutoRound fills its missing amax using the maximum value from calibrated experts

Sounds good

@kylesayrs kylesayrs added the ready When a PR is ready for full CI testing before merge label Aug 19, 2026
@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/llm-compressor/blob/main/CONTRIBUTING.md

@mergify mergify Bot removed the quality-failed label Aug 20, 2026
@yiliu30
yiliu30 self-requested a review August 20, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoround For any PR / issue related to autoround support bug Something isn't working documentation Improvements or additions to documentation llama For any PR / issue related to Llama herd support moe qwen For any PR / issue related to Qwen support ready When a PR is ready for full CI testing before merge two-reviews When a PR requires two reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants