[ROCm][Perf] Fuse DeepSeek-V4 mHC post/pre and RMSNorm with AITER (#52737)

Signed-off-by: shen-shanshan <467638484@qq.com>
Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
This commit is contained in:
Shanshan Shen
2026-08-20 04:51:04 +00:00
committed by GitHub
parent cd5035379c
commit d626108b18
5 changed files with 272 additions and 10 deletions
+28 -2
View File
@@ -90,7 +90,8 @@ class MHCPreOp(CustomOp):
norm_eps: float = 0.0,
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
hidden_size = residual.shape[-1]
if HAS_AITER_MHC and hidden_size % 256 == 0:
hc_mult = residual.shape[-2]
if HAS_AITER_MHC and hidden_size % 256 == 0 and hc_mult == 4:
return torch.ops.vllm.mhc_pre_aiter(
residual,
fn,
@@ -101,6 +102,9 @@ class MHCPreOp(CustomOp):
hc_sinkhorn_eps,
hc_post_mult_value,
sinkhorn_repeat,
n_splits,
norm_weight,
norm_eps,
)
elif HAS_TILELANG_MHC:
return torch.ops.vllm.mhc_pre_tilelang(
@@ -222,7 +226,8 @@ class MHCPostOp(CustomOp):
comb_res_mix: torch.Tensor,
) -> torch.Tensor:
hidden_size = residual.shape[-1]
if HAS_AITER_MHC and hidden_size % 256 == 0:
hc_mult = residual.shape[-2]
if HAS_AITER_MHC and hidden_size % 256 == 0 and hc_mult == 4:
return torch.ops.vllm.mhc_post_aiter(
x,
residual,
@@ -444,6 +449,27 @@ class MHCFusedPostPreOp(CustomOp):
norm_weight: torch.Tensor | None = None,
norm_eps: float = 0.0,
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
hidden_size = residual.shape[-1]
hc_mult = residual.shape[-2]
if HAS_AITER_MHC and hidden_size % 256 == 0 and hc_mult == 4:
return torch.ops.vllm.mhc_fused_post_pre_aiter(
x,
residual,
post_layer_mix,
comb_res_mix,
fn,
hc_scale,
hc_base,
rms_eps,
hc_pre_eps,
hc_sinkhorn_eps,
hc_post_mult_value,
sinkhorn_repeat,
n_splits,
tile_n,
norm_weight,
norm_eps,
)
if HAS_TILELANG_MHC:
return torch.ops.vllm.mhc_fused_post_pre_tilelang(
x,