[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:
@@ -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
|
||||
|
||||
|
||||
@@ -198,7 +198,6 @@ class CPURouter(BaseRouter):
|
||||
renormalize=self.renormalize,
|
||||
num_expert_group=self.num_expert_group,
|
||||
has_e_score_bias=self.e_score_correction_bias is not None,
|
||||
routed_scaling_factor=self.routed_scaling_factor,
|
||||
)
|
||||
|
||||
def _compute_routing(
|
||||
|
||||
@@ -391,7 +391,6 @@ class FusedTopKBiasRouter(BaseRouter):
|
||||
renormalize=self.renormalize,
|
||||
num_expert_group=None,
|
||||
has_e_score_bias=True,
|
||||
routed_scaling_factor=self.routed_scaling_factor,
|
||||
)
|
||||
|
||||
def _compute_routing(
|
||||
|
||||
@@ -283,7 +283,6 @@ class GroupedTopKRouter(BaseRouter):
|
||||
renormalize=self.renormalize,
|
||||
num_expert_group=self.num_expert_group,
|
||||
has_e_score_bias=self.e_score_correction_bias is not None,
|
||||
routed_scaling_factor=self.routed_scaling_factor,
|
||||
)
|
||||
|
||||
def _compute_routing(
|
||||
|
||||
@@ -188,7 +188,6 @@ def create_fused_moe_router(
|
||||
renormalize=renormalize,
|
||||
num_expert_group=groups,
|
||||
has_e_score_bias=e_score_correction_bias is not None,
|
||||
routed_scaling_factor=routed_scaling_factor,
|
||||
)
|
||||
|
||||
routing_method_preserved = advertised_routing_method(
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
import torch
|
||||
|
||||
from vllm.distributed.eplb.eplb_state import EplbLayerState
|
||||
from vllm.model_executor.layers.fused_moe.config import (
|
||||
RoutingMethodType,
|
||||
get_routing_method_type,
|
||||
)
|
||||
from vllm.model_executor.layers.fused_moe.config import RoutingMethodType
|
||||
from vllm.model_executor.layers.fused_moe.fused_moe import (
|
||||
zero_experts_compute_triton,
|
||||
)
|
||||
@@ -53,14 +50,9 @@ class ZeroExpertRouter(BaseRouter):
|
||||
|
||||
@property
|
||||
def routing_method_type(self) -> RoutingMethodType:
|
||||
return get_routing_method_type(
|
||||
scoring_func=self.scoring_func,
|
||||
top_k=self.top_k,
|
||||
renormalize=self.renormalize,
|
||||
num_expert_group=None,
|
||||
has_e_score_bias=True,
|
||||
routed_scaling_factor=self.routed_scaling_factor,
|
||||
)
|
||||
# Zero experts are resolved by this router, which kernels with
|
||||
# built-in routing (e.g. FlashInfer TRT-LLM) cannot reproduce.
|
||||
return RoutingMethodType.Unspecified
|
||||
|
||||
def _compute_routing(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user