Repository navigation
[AMD] Fix DeepSeek-V4 FP4 MoE expert memory bloat - #31450
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the FP4 MoE alignment parameter fp4_k_align from 256 to 128 in fp8.py. This change leverages the FlyDSL kernel's support for tile_k=128 to avoid unnecessary padding (e.g., skipping padding from 384 to 512 for DeepSeek-V4-Pro at TP8), thereby reducing routed-expert memory usage by approximately 25%. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@bingxche please check on aiter upgrade. |
I will do more perf check on it. |
|
Hi, @HaiShaw w/ vs. w/o the moe intermediate padding (inter_dim padded to 512 vs kept at 384):
Capture the torch kernel tracing. The difference comes mainly from moe1 (stage-1):
|
|
@bingxche would you please help aiter scout to land aiter commit #id after PR#4130. Urgent. |
Sure, I found a suspect AITER commit that regress our DSv32 and DSv4-pro in the latest AITER scout, will upgrade AITER once resolve this. |
|
@bingxche aiter scout green? |


Need aiter version bump before merge.
Needed aiter: PR#4130
Motivation
On AMD M355 each layer's MoE weights take 2.105 GB, while the same layer on NVIDIA B200 is 1.582 GB (~25% gap).
The cause is that on AMD we pad the
w13expert weight up to a multiple of 256.For DeepSeek-V4-Pro on 8 GPUs (TP8) the per-partition intermediate size is
3072 / 8 = 384, which gets rounded up to 512, inflating the routed-expert weights by ~1/3.After this change, per-layer per-rank MoE drops to 1.592 GiB (close to NV's 1.582 GiB), reducing total model weights by ~40 GiB.
Modifications
Change
fp4_k_alignfrom256to128inprocess_weights_after_loading_block_quant().DeepSeek-V4 MoE runs on the FlyDSL kernel, which supports
tile_k=128, so K only needs to be padded to a multiple of 128.384stays384instead of512.This cannot affect other models: the code path is guarded by
and
is_fp4_expertis only set for DeepSeek-V4:This change also requires cherry-picking aiter PR#4130 (merged): the shuffle_scale in the currently pinned aiter only supports 256-padded shapes; non-256 shapes are supported starting from that PR.
Accuracy Tests
GSM8k:
Speed Tests and Profiling
Client Cmd
8k1k, cc8, random=0.8 (no regression)
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #29491528112
Latest PR Test (Extra): ✅ Run #29491540358