[Perf][MoE] Use fused MiniMax2 routing with non-unit routed scaling (#58880)

Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
This commit is contained in:
Jiangyun Zhu
2026-09-27 19:37:33 +00:00
committed by GitHub
parent e7900156e1
commit 231fdb83cc
8 changed files with 135 additions and 21 deletions
@@ -118,7 +118,7 @@ class RoutingMethodType(IntEnum):
# SigmoidRenorm: Sigmoid -> TopK -> Renormalize (divide by sum of top-K)
SigmoidRenorm = (6,)
# MiniMax2: Sigmoid + Bias -> TopK -> ScaledSumNormalize
# (routeScale=1.0, epsilon=1e-20)
# (routeScale=routed_scaling_factor, epsilon=1e-20)
MiniMax2 = (7,)
# Sigmoid: Sigmoid -> TopK (no renormalization)
Sigmoid = (8,)
@@ -137,7 +137,6 @@ def get_routing_method_type(
renormalize: bool,
num_expert_group: int | None,
has_e_score_bias: bool,
routed_scaling_factor: float | None = 1.0,
) -> RoutingMethodType:
if scoring_func == "sqrtsoftplus":
# DeepSeek V4 uses sqrtsoftplus routing with optional routing bias
@@ -153,9 +152,7 @@ def get_routing_method_type(
return RoutingMethodType.Unspecified
if (num_expert_group or 0) > 0:
return RoutingMethodType.DeepSeekV3
if routed_scaling_factor in (None, 1.0):
return RoutingMethodType.MiniMax2
return RoutingMethodType.Unspecified
return RoutingMethodType.MiniMax2
else:
return RoutingMethodType.Unspecified