diff --git a/vllm/model_executor/layers/fused_moe/config.py b/vllm/model_executor/layers/fused_moe/config.py index d7ad59b46c..b065d2142c 100644 --- a/vllm/model_executor/layers/fused_moe/config.py +++ b/vllm/model_executor/layers/fused_moe/config.py @@ -1279,6 +1279,8 @@ class FusedMoEConfig: hidden_dim_unpadded: int | None = None # Defaults to intermediate_size_per_partition if not specified. intermediate_size_per_partition_unpadded: int | None = None + # Model specific override + intermediate_pad: int | None = None moe_backend: MoEBackend = "auto" max_num_tokens: int = SchedulerConfig.DEFAULT_MAX_NUM_BATCHED_TOKENS_FOR_BATCHED_DP diff --git a/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py b/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py index bd9b285fe7..4f191334bb 100644 --- a/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py @@ -251,12 +251,17 @@ def rocm_aiter_fused_experts( if quant_config is None: quant_config = FUSED_MOE_UNQUANTIZED_CONFIG + # Gate/up interleave hint; only the SWIGLUOAI activations override it. + activation_interleave = None if activation == MoEActivation.SILU: activation_method = ActivationMethod.SILU elif activation == MoEActivation.GELU: activation_method = ActivationMethod.GELU elif activation == MoEActivation.SWIGLUOAI: activation_method = rocm_aiter_ops.get_aiter_activation_type("swiglu") + elif activation == MoEActivation.SWIGLUOAI_UNINTERLEAVE: + activation_method = rocm_aiter_ops.get_aiter_activation_type("swiglu") + activation_interleave = False else: raise ValueError(f"Unsupported activation: {activation}") @@ -337,9 +342,14 @@ def rocm_aiter_fused_experts( assert moe_config.intermediate_size_per_partition_unpadded is not None hidden_pad = hidden_states.shape[1] - moe_config.hidden_dim_unpadded intermediate_pad = ( - moe_config.intermediate_size_per_partition - - moe_config.intermediate_size_per_partition_unpadded + ( + moe_config.intermediate_size_per_partition + - moe_config.intermediate_size_per_partition_unpadded + ) + if moe_config.intermediate_pad is None + else moe_config.intermediate_pad ) + # Round hidden_pad/intermediate_pad to match AITER's CK/FlyDSL MoE # dispatch (currently pinned to v0.1.13.post1): # https://github.com/ROCm/aiter/blob/v0.1.13.post1/aiter/fused_moe.py#L1073 @@ -357,14 +367,17 @@ def rocm_aiter_fused_experts( # `rocm_aiter_ops.shuffle_weight_a16w4` in `oracle/mxfp4.py`, # which always sets `is_guinterleave=True`. # Hence, we pass in GateMode.INTERLEAVE to match the weight shuffling. + from aiter.ops.flydsl.moe_common import GateMode + gate_mode = "" if quant_config.use_mxfp4_w4a16: - try: - from aiter.ops.flydsl.moe_common import GateMode - - gate_mode = GateMode.INTERLEAVE.value - except ImportError: - pass + gate_mode = GateMode.INTERLEAVE.value + elif activation_interleave is not None: + gate_mode = ( + GateMode.INTERLEAVE.value + if activation_interleave + else GateMode.SEPARATED.value + ) return rocm_aiter_ops.fused_moe( hidden_states, @@ -458,6 +471,7 @@ class AiterExperts(mk.FusedMoEExpertsModular): MoEActivation.SILU, MoEActivation.GELU, MoEActivation.SWIGLUOAI, + MoEActivation.SWIGLUOAI_UNINTERLEAVE, ] @staticmethod diff --git a/vllm/model_executor/layers/fused_moe/layer.py b/vllm/model_executor/layers/fused_moe/layer.py index 2254843858..e92cb7cad0 100644 --- a/vllm/model_executor/layers/fused_moe/layer.py +++ b/vllm/model_executor/layers/fused_moe/layer.py @@ -105,6 +105,7 @@ def FusedMoE( top_k: int, hidden_size: int, intermediate_size: int, + intermediate_pad: int | None = None, params_dtype: torch.dtype | None = None, renormalize: bool = True, use_grouped_topk: bool = False, @@ -311,6 +312,7 @@ def FusedMoE( experts_per_token=top_k, hidden_dim=hidden_size, intermediate_size=intermediate_size, + intermediate_pad=intermediate_pad, num_local_experts=expert_map_manager.local_num_experts, num_logical_experts=logical_num_experts, moe_parallel_config=moe_parallel_config, diff --git a/vllm/models/minimax_m3/amd/model.py b/vllm/models/minimax_m3/amd/model.py index 4f3528806c..f01ed45dd6 100644 --- a/vllm/models/minimax_m3/amd/model.py +++ b/vllm/models/minimax_m3/amd/model.py @@ -309,6 +309,7 @@ class MiniMaxM3MoE(nn.Module): top_k=config.num_experts_per_tok, hidden_size=config.hidden_size, intermediate_size=config.intermediate_size, + intermediate_pad=0, scoring_func=config.scoring_func, e_score_correction_bias=self.e_score_correction_bias, renormalize=True,