diff --git a/python/sglang/srt/models/qwen2_moe.py b/python/sglang/srt/models/qwen2_moe.py index d2b744a68..fb879a689 100644 --- a/python/sglang/srt/models/qwen2_moe.py +++ b/python/sglang/srt/models/qwen2_moe.py @@ -68,6 +68,7 @@ from sglang.srt.layers.moe.utils import ( RoutingMethodType, filter_moe_weight_param_global_expert, is_deepep_class_backend, + uses_per_rank_fused_shared_slots, ) from sglang.srt.layers.quantization.base_config import QuantizationConfig from sglang.srt.layers.radix_attention import RadixAttention @@ -249,6 +250,20 @@ class Qwen2MoeSparseMoeBlock(nn.Module): self.num_shared_experts > 0 and can_fuse_shared_expert(config, quant_config) ) + if ( + self.enable_shared_expert_fusion + and uses_per_rank_fused_shared_slots() + and get_parallel().moe_ep_size > 1 + ): + logger.warning_once( + "Disabling Qwen shared-expert fusion: it uses a single global " + "shared slot with a per-token gate, which is incompatible with " + "per-rank EP shared-slot backends (e.g. DeepEP/MoRI) at " + "moe_ep_size=%d. Using the separate shared-expert MLP instead.", + get_parallel().moe_ep_size, + ) + self.enable_shared_expert_fusion = False + if self.enable_shared_expert_fusion: self.num_fused_shared_experts = self.num_shared_experts