Add pre-suffle weight for new aiter MoE support.#12908
Merged
HaiShaw merged 10 commits intosgl-project:mainfrom Nov 10, 2025
Merged
Add pre-suffle weight for new aiter MoE support.#12908HaiShaw merged 10 commits intosgl-project:mainfrom
HaiShaw merged 10 commits intosgl-project:mainfrom
Conversation
HaiShaw
requested changes
Nov 10, 2025
| ) | ||
|
|
||
| _is_hip = is_hip() | ||
| _is_shuffle_moe = get_bool_env_var("AITER_MXFP4_MOE_SF") and _is_hip |
Collaborator
There was a problem hiding this comment.
suggest change to _is_shuffle_moe_mxfp4
| logger = logging.getLogger(__name__) | ||
|
|
||
| _is_hip = is_hip() | ||
| _is_shuffle_moe = get_bool_env_var("AITER_MXFP4_MOE_SF") and _is_hip |
Collaborator
There was a problem hiding this comment.
change to _is_shuffle_moe_mxfp4
HaiShaw
approved these changes
Nov 10, 2025
Collaborator
|
@BowenBao @kkHuang-amd please have a review. |
BowenBao
reviewed
Nov 10, 2025
| layer.w2_weight_scale.data = w2_weight_scale.view(s0, s1, -1) | ||
|
|
||
| # Pre-shuffle weight | ||
| if _is_shuffle_moe_mxfp4: |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR introduces a pre-shuffle step for MoE weights to improve runtime performance and memory access efficiency.
Modifications
Added shuffle_weight from aiter.ops.shuffle to pre-shuffle w13_weight and w2_weight with a (16, 16) granularity matching aiter kernel tile size for better locality and performance.
Accuracy Tests
Model: amd/DeepSeek-R1-MXFP4-Preview
python3 benchmark/gsm8k/bench_sglang.py --num-questions 2000 --parallel 2000 --port 8000
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [01:50<00:00, 11.96it/s]
Accuracy: 0.946
Invalid: 0.000
Latency: 110.434 s
Output throughput: 1180.643 token/s
Benchmarking and Profiling
Machine: MI355 * 8 GPU
Docker Image: rocm/sgl-dev:v0.5.4.post3-rocm700-mi35x-20251106
Command:
SGLANG_USE_AITER=1 RCCL_MSCCL_ENABLE=0 SGLANG_INT4_WEIGHT=0 SGLANG_MOE_PADDING=1 SGLANG_USE_ROCM700A=1 SGLANG_SET_CPU_AFFINITY=1 SGLANG_ROCM_FUSED_DECODE_MLA=1 python3 -m sglang.launch_server --model-path /data2/deepseek-ai/DeepSeek-R1-MXFP4-Preview/ --tensor-parallel-size 8 --trust-remote-code --chunked-prefill-size 131072 --host 0.0.0.0 --port 8000 --log-requests --disable-radix-cache --mem-fraction-static 0.5 --speculative-algorithm EAGLE --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
Prefill 1 8 16
Wo MoE Update 0.0109 0.6524 1.2924
With MoE Update 0.1071 0.6505 1.2965
Decode 1 8 16
Wo MoE Update 0.0109 0.0123 0.0139
With MoE Update 0.0103 0.0118 0.0133
Checklist