[ROCm][Perf][DeepSeek V4] Fuse native FP8 shared expert with MXFP4 routed experts (#53161)

Signed-off-by: fai <fangzhouai@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: Cursor Agent <agent@cursor.com>
This commit is contained in:
Fangzhou Ai
2026-09-06 19:42:21 -07:00
committed by GitHub
co-authored by OpenAI Codex Cursor Agent
parent 294fbb4f59
commit de69e821b7
4 changed files with 839 additions and 6 deletions
@@ -250,6 +250,11 @@ def rocm_aiter_fused_experts(
num_local_tokens: torch.Tensor | None = None,
output_dtype: torch.dtype | None = None,
moe_sorting_dispatch_policy: int = 0,
shared_w1: torch.Tensor | None = None,
shared_w2: torch.Tensor | None = None,
shared_w1_scale: torch.Tensor | None = None,
shared_w2_scale: torch.Tensor | None = None,
shared_expert_id: int = -1,
) -> torch.Tensor:
"""ROCm AITER fused MoE expert computation."""
if quant_config is None:
@@ -419,8 +424,18 @@ def rocm_aiter_fused_experts(
bias1=quant_config.w1_bias if quant_config.use_mxfp4_w4a16 else None,
bias2=quant_config.w2_bias if quant_config.use_mxfp4_w4a16 else None,
moe_sorting_dispatch_policy=moe_sorting_dispatch_policy,
swiglu_limit=(
0.0
if moe_config.swiglu_limit is None
else float(moe_config.swiglu_limit)
),
beta=moe_config.activation_situ_beta,
linear_beta=moe_config.activation_situ_linear_beta,
shared_w1=shared_w1,
shared_w2=shared_w2,
shared_w1_scale=shared_w1_scale,
shared_w2_scale=shared_w2_scale,
shared_expert_id=shared_expert_id,
)