[AMD] Add MoE weights and scales padding - #21097
Conversation
Summary of ChangesHello, 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 refactors the handling of Mixture-of-Experts (MoE) weights and scales, introducing a unified padding mechanism tailored for AMD (HIP) platforms utilizing Aiter. It centralizes the logic for determining padding sizes and calculating the actual dimensions of MoE weights, ensuring proper memory allocation and data handling. The changes also adapt the weight loading and quantization compatibility checks to seamlessly integrate with the new Aiter-specific padding, improving robustness and performance for MoE layers. Highlights
🧠 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 AssistThe 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
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 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. Footnotes
|
1e672b4 to
c72e3a2
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces padding for MoE weights and scales, primarily for AMD hardware support using AITriton. The core logic is refactored into new utility functions get_moe_padding_size and get_moe_weight_sizes in srt/layers/moe/utils.py, which is a good approach to centralize the logic. The changes across various quantization schemes and model layers correctly adopt these new utilities.
My review includes a few suggestions to improve maintainability and readability, such as addressing code duplication and simplifying complex calculations. Overall, the changes are well-structured and seem correct for the intended purpose.
…and add padding size definition
1c06bdd to
2a10e53
Compare
hubertlu-tw
left a comment
There was a problem hiding this comment.
Other than a few comments I left, LGTM. Notice that this PR will also resolve an issue reported here:
#21918 (comment)
CC: @HaiShaw
|
@mqhc2020 could you please also add the commands you ran on the PR description? It may help the review process. Thanks! |
Here are the accuracy results: Grok1 INT4-FP8 Serve command: Accuracy: 0.825 Grok2 Serve command: Accuracy: 0.929 Serving command: Note that:
|
|
/rerun-failed-ci |
Co-authored-by: HAI <hixiao@gmail.com>
Co-authored-by: HAI <hixiao@gmail.com>
Motivation
Right now, Aiter MoE requires weights and scales to align with a fixed number. Since some models have intermediate sizes that don't fit this rule, we need to add extra padding to the weights so they can be processed by the Fused MoE.
Modifications
Add padding for the weights. Below listed are the models and configurations that has been verified with:
Accuracy Tests
We run GSM8K accuracy test for models below:
Qwen/Qwen3-235B-A22B-Instruct-2507-FP8 (TP8):
Serve command:
Accuracy: 0.980
Invalid: 0.000
Latency: 10.525 s
Output throughput: 2663.037 token/s
amd/Qwen3-235B-A22B-Instruct-2507-MXFP4 (TP8):
Serve command:
Accuracy: 0.940
Invalid: 0.000
Latency: 23.853 s
Output throughput: 7488.441 token/s
zai-org/GLM-4.7 (TP8):
Serve command:
(better than VLLM TP4 on model card)
Accuracy: 0.975
Invalid: 0.000
Latency: 7.349 s
Output throughput: 2683.189 token/s
Serving command:
python3 ./benchmark/gsm8k/bench_sglang.py --num-questions 1319 --parallel 1319Benchmarking and Profiling
Baseline benchmark for amd/Qwen3-235B-A22B-Instruct-2507-mxfp4 (TP4) and Qwen/Qwen3-235B-A22B-Instruct-2507-FP8 (TP8):

Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci