[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:
co-authored by
Kunshang Ji
parent
4a6440acef
commit
0b6636cbcb
@@ -18,4 +18,4 @@ torchvision
|
|||||||
torchcodec >= 0.14 # Required for the torchcodec video decoding backend
|
torchcodec >= 0.14 # Required for the torchcodec video decoding backend
|
||||||
|
|
||||||
auto_round_lib>=0.14.0
|
auto_round_lib>=0.14.0
|
||||||
vllm_xpu_kernels @ https://github.com/vllm-project/vllm-xpu-kernels/releases/download/v0.1.10.1/vllm_xpu_kernels-0.1.10.1-cp38-abi3-manylinux_2_28_x86_64.whl
|
vllm_xpu_kernels @ https://github.com/vllm-project/vllm-xpu-kernels/releases/download/v0.1.11/vllm_xpu_kernels-0.1.11-cp38-abi3-manylinux_2_28_x86_64.whl
|
||||||
|
|||||||
@@ -2277,18 +2277,6 @@ def topk_sigmoid(
|
|||||||
e_score_correction_bias: torch.Tensor | None = None,
|
e_score_correction_bias: torch.Tensor | None = None,
|
||||||
routed_scaling_factor: float = 1.0,
|
routed_scaling_factor: float = 1.0,
|
||||||
) -> None:
|
) -> None:
|
||||||
if current_platform.is_xpu():
|
|
||||||
# xpu doesn't support routed_scaling_factor currently, will revert
|
|
||||||
# in next vllm-xpu-kernels bumpup
|
|
||||||
torch.ops._moe_C.topk_sigmoid(
|
|
||||||
topk_weights,
|
|
||||||
topk_ids,
|
|
||||||
token_expert_indices,
|
|
||||||
gating_output,
|
|
||||||
renormalize,
|
|
||||||
e_score_correction_bias,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
torch.ops._moe_C.topk_sigmoid(
|
torch.ops._moe_C.topk_sigmoid(
|
||||||
topk_weights,
|
topk_weights,
|
||||||
topk_ids,
|
topk_ids,
|
||||||
|
|||||||
@@ -62,11 +62,6 @@ class XPUExperts(mk.FusedMoEExpertsModular):
|
|||||||
max_num_tokens,
|
max_num_tokens,
|
||||||
num_dispatchers,
|
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.gemm1_clamp_limit = quant_config.gemm1_clamp_limit
|
||||||
self.fused_moe_impl: XpuFusedMoe | None = None
|
self.fused_moe_impl: XpuFusedMoe | None = None
|
||||||
|
|
||||||
@@ -149,17 +144,14 @@ class XPUExperts(mk.FusedMoEExpertsModular):
|
|||||||
expert_tokens_meta: mk.ExpertTokensMetadata | None,
|
expert_tokens_meta: mk.ExpertTokensMetadata | None,
|
||||||
apply_router_weight_on_input: bool,
|
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:
|
if self.fused_moe_impl is None:
|
||||||
topk = topk_ids.size(-1)
|
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(
|
self.fused_moe_impl = XpuFusedMoe(
|
||||||
w13=w1,
|
w13=w1,
|
||||||
w13_scales=self.w1_scale,
|
w13_scales=self.w1_scale,
|
||||||
@@ -172,11 +164,6 @@ class XPUExperts(mk.FusedMoEExpertsModular):
|
|||||||
num_experts=self.moe_config.num_local_experts,
|
num_experts=self.moe_config.num_local_experts,
|
||||||
ep_rank=self.moe_config.ep_rank,
|
ep_rank=self.moe_config.ep_rank,
|
||||||
ep_size=self.moe_config.ep_size,
|
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,
|
gemm1_clamp_limit=self.gemm1_clamp_limit,
|
||||||
)
|
)
|
||||||
assert self.fused_moe_impl is not None
|
assert self.fused_moe_impl is not None
|
||||||
@@ -202,7 +189,6 @@ class XPUExpertsFp8(XPUExperts):
|
|||||||
max_num_tokens,
|
max_num_tokens,
|
||||||
num_dispatchers,
|
num_dispatchers,
|
||||||
)
|
)
|
||||||
self.is_fp8 = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _supports_quant_scheme(
|
def _supports_quant_scheme(
|
||||||
@@ -231,7 +217,6 @@ class XPUExpertsMxFp8(XPUExpertsFp8):
|
|||||||
num_dispatchers,
|
num_dispatchers,
|
||||||
)
|
)
|
||||||
assert quant_config.quant_dtype == "mxfp8"
|
assert quant_config.quant_dtype == "mxfp8"
|
||||||
self.is_mxfp8 = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _supports_quant_scheme(
|
def _supports_quant_scheme(
|
||||||
@@ -259,7 +244,6 @@ class XPUExpertsBlockFp8(XPUExperts):
|
|||||||
max_num_tokens,
|
max_num_tokens,
|
||||||
num_dispatchers,
|
num_dispatchers,
|
||||||
)
|
)
|
||||||
self.is_block_fp8 = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _supports_quant_scheme(
|
def _supports_quant_scheme(
|
||||||
@@ -298,7 +282,6 @@ class XPUExpertsWNA16(XPUExperts):
|
|||||||
max_num_tokens,
|
max_num_tokens,
|
||||||
num_dispatchers,
|
num_dispatchers,
|
||||||
)
|
)
|
||||||
self.is_int4 = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _supports_quant_scheme(
|
def _supports_quant_scheme(
|
||||||
@@ -325,7 +308,6 @@ class XPUExpertsMxFp4(XPUExperts):
|
|||||||
max_num_tokens,
|
max_num_tokens,
|
||||||
num_dispatchers,
|
num_dispatchers,
|
||||||
)
|
)
|
||||||
self.is_mxfp4 = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _supports_quant_scheme(
|
def _supports_quant_scheme(
|
||||||
|
|||||||
Reference in New Issue
Block a user