diff --git a/vllm/model_executor/layers/fused_moe/oracle/fp8.py b/vllm/model_executor/layers/fused_moe/oracle/fp8.py index d3c70d2d0a..4420bb3873 100644 --- a/vllm/model_executor/layers/fused_moe/oracle/fp8.py +++ b/vllm/model_executor/layers/fused_moe/oracle/fp8.py @@ -471,6 +471,12 @@ def convert_to_fp8_moe_kernel_format( w2_input_scale=w2_input_scale, is_trtllm=(fp8_backend == Fp8MoeBackend.FLASHINFER_TRTLLM), ) + elif fp8_backend == Fp8MoeBackend.XPU: + from vllm.model_executor.layers.fused_moe.xpu_fused_moe import ( + prepare_fp8_moe_layer_for_xpu, + ) + + w13, w2 = prepare_fp8_moe_layer_for_xpu(w13, w2) else: if fp8_backend not in [ Fp8MoeBackend.TRITON, diff --git a/vllm/model_executor/layers/fused_moe/xpu_fused_moe.py b/vllm/model_executor/layers/fused_moe/xpu_fused_moe.py index 9cc0ade288..e10be4af86 100644 --- a/vllm/model_executor/layers/fused_moe/xpu_fused_moe.py +++ b/vllm/model_executor/layers/fused_moe/xpu_fused_moe.py @@ -24,6 +24,13 @@ if current_platform.is_xpu(): from vllm_xpu_kernels.fused_moe_interface import xpu_fused_moe +def prepare_fp8_moe_layer_for_xpu( + w13: torch.Tensor, + w2: torch.Tensor, +) -> tuple[torch.Tensor, torch.Tensor]: + return w13.transpose(-1, -2).contiguous(), w2.transpose(-1, -2).contiguous() + + class XPUExperts(mk.FusedMoEExpertsModular): def __init__( self, diff --git a/vllm/model_executor/layers/quantization/fp8.py b/vllm/model_executor/layers/quantization/fp8.py index 4473bb8b2c..0dc8907248 100644 --- a/vllm/model_executor/layers/quantization/fp8.py +++ b/vllm/model_executor/layers/quantization/fp8.py @@ -1019,10 +1019,6 @@ class Fp8OnlineMoEMethod(Fp8MoEMethod): layer.w2_weight[expert, :, :] ) - if current_platform.is_xpu(): - w13.data = w13.transpose(-1, -2).contiguous() - w2.data = w2.transpose(-1, -2).contiguous() - # Shuffle weights to runtime format and setup kernel. self._setup_kernel( layer,