[MoE Refactor] FusedMoE/MoERunner inversion refactor (#41184)

Signed-off-by: Bill Nell <bnell@redhat.com>
This commit is contained in:
bnellnm
2026-06-08 10:42:58 -04:00
committed by GitHub
parent 753e9d55e6
commit dc68bd8c41
90 changed files with 2738 additions and 2031 deletions
+38 -2
View File
@@ -1236,7 +1236,7 @@ class FusedMoEConfig:
num_experts: int
experts_per_token: int
hidden_dim: int
intermediate_size_per_partition: int
intermediate_size: int
num_local_experts: int
num_logical_experts: int
activation: MoEActivation
@@ -1258,7 +1258,6 @@ class FusedMoEConfig:
moe_backend: MoEBackend = "auto"
max_num_tokens: int = SchedulerConfig.DEFAULT_MAX_NUM_BATCHED_TOKENS_FOR_BATCHED_DP
has_bias: bool = False
is_act_and_mul: bool = True
is_lora_enabled: bool = False
# SwiGLU clamp limit. When set, backends that do not implement the clamp
@@ -1268,7 +1267,18 @@ class FusedMoEConfig:
max_capture_size: int = 0
# Set by __post_init__
intermediate_size_per_partition: int = -1
rocm_aiter_fmoe_enabled: bool = False
aiter_fmoe_shared_expert_enabled: bool = False
def __post_init__(self):
from vllm._aiter_ops import rocm_aiter_ops
tp_size = self.moe_parallel_config.tp_size
assert self.intermediate_size % tp_size == 0
self.intermediate_size_per_partition = self.intermediate_size // tp_size
if self.dp_size > 1:
logger.debug_once(
"Using FusedMoEConfig::max_num_tokens=%d", self.max_num_tokens
@@ -1286,6 +1296,32 @@ class FusedMoEConfig:
self.intermediate_size_per_partition
)
if self.is_act_and_mul:
self.rocm_aiter_fmoe_enabled = rocm_aiter_ops.is_fused_moe_enabled()
self.aiter_fmoe_shared_expert_enabled = (
rocm_aiter_ops.is_fusion_moe_shared_experts_enabled()
)
if self.use_mori_kernels:
assert self.rocm_aiter_fmoe_enabled, (
"Mori needs to be used with aiter fused_moe for now."
)
assert not self.aiter_fmoe_shared_expert_enabled, (
"Mori does not support fusion shared expert now. "
"Turn it off by setting VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0"
)
if not self.is_act_and_mul and not (
current_platform.is_cuda_alike() or current_platform.is_xpu()
):
raise NotImplementedError(
"is_act_and_mul=False is supported only for CUDA, XPU and ROCm for now"
)
@property
def is_act_and_mul(self) -> bool:
return self.activation.is_gated
@property
def tp_size(self):
return self.moe_parallel_config.tp_size