[XPU]remove is_xxx from moe class and bump up kernels (#48079)

Signed-off-by: mayuyuace <qiming1.zhang@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
Qiming Zhang
2026-07-11 09:27:13 +00:00
committed by GitHub
co-authored by Kunshang Ji
parent 4a6440acef
commit 0b6636cbcb
3 changed files with 7 additions and 37 deletions
@@ -62,11 +62,6 @@ class XPUExperts(mk.FusedMoEExpertsModular):
max_num_tokens,
num_dispatchers,
)
self.is_fp8 = False
self.is_int4 = False
self.is_mxfp4 = False
self.is_block_fp8 = False
self.is_mxfp8 = False
self.gemm1_clamp_limit = quant_config.gemm1_clamp_limit
self.fused_moe_impl: XpuFusedMoe | None = None
@@ -149,17 +144,14 @@ class XPUExperts(mk.FusedMoEExpertsModular):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
):
# The kernel takes is_fp8/is_int4/is_mxfp4 as independent booleans.
# In this hierarchy each subclass flips exactly one to True; assert
# the invariant so a future subclass that sets two doesn't silently
# miscompute (kernel-side priority is undocumented).
assert sum([self.is_fp8, self.is_int4, self.is_mxfp4]) <= 1, (
"XPUExperts: at most one of is_fp8, is_int4, is_mxfp4 may be True; "
f"got is_fp8={self.is_fp8}, is_int4={self.is_int4}, "
f"is_mxfp4={self.is_mxfp4}."
)
if self.fused_moe_impl is None:
topk = topk_ids.size(-1)
if (
self.quant_config is not None
and self.quant_config.weight_quant_dtype == "mxfp4"
):
w1 = w1.view(torch.float4_e2m1fn_x2)
w2 = w2.view(torch.float4_e2m1fn_x2)
self.fused_moe_impl = XpuFusedMoe(
w13=w1,
w13_scales=self.w1_scale,
@@ -172,11 +164,6 @@ class XPUExperts(mk.FusedMoEExpertsModular):
num_experts=self.moe_config.num_local_experts,
ep_rank=self.moe_config.ep_rank,
ep_size=self.moe_config.ep_size,
is_fp8=self.is_fp8,
is_int4=self.is_int4,
is_mxfp4=self.is_mxfp4,
is_mxfp8=self.is_mxfp8,
is_block_fp8=self.is_block_fp8,
gemm1_clamp_limit=self.gemm1_clamp_limit,
)
assert self.fused_moe_impl is not None
@@ -202,7 +189,6 @@ class XPUExpertsFp8(XPUExperts):
max_num_tokens,
num_dispatchers,
)
self.is_fp8 = True
@staticmethod
def _supports_quant_scheme(
@@ -231,7 +217,6 @@ class XPUExpertsMxFp8(XPUExpertsFp8):
num_dispatchers,
)
assert quant_config.quant_dtype == "mxfp8"
self.is_mxfp8 = True
@staticmethod
def _supports_quant_scheme(
@@ -259,7 +244,6 @@ class XPUExpertsBlockFp8(XPUExperts):
max_num_tokens,
num_dispatchers,
)
self.is_block_fp8 = True
@staticmethod
def _supports_quant_scheme(
@@ -298,7 +282,6 @@ class XPUExpertsWNA16(XPUExperts):
max_num_tokens,
num_dispatchers,
)
self.is_int4 = True
@staticmethod
def _supports_quant_scheme(
@@ -325,7 +308,6 @@ class XPUExpertsMxFp4(XPUExperts):
max_num_tokens,
num_dispatchers,
)
self.is_mxfp4 = True
@staticmethod
def _supports_quant_scheme(