[XPU]fix: add XPU platform guards to DeepSeek-V4 ops (#42950)

Signed-off-by: Ma Jian <jian1.ma@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
Ma Jian
2026-05-23 06:29:45 +08:00
committed by GitHub
co-authored by Kunshang Ji
parent 4e2eba28be
commit 8de5cabeb7
6 changed files with 31 additions and 18 deletions
+5 -5
View File
@@ -1153,7 +1153,7 @@ class DeepseekV4DecoderLayer(nn.Module):
x = self.ffn(x, input_ids)
return x, residual, post_mix, res_mix
def _forward_rocm(
def _forward_native(
self,
x: torch.Tensor,
positions: torch.Tensor,
@@ -1193,8 +1193,8 @@ class DeepseekV4DecoderLayer(nn.Module):
) -> tuple[
torch.Tensor, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None
]:
if current_platform.is_rocm():
return self._forward_rocm(
if current_platform.is_rocm() or current_platform.is_xpu():
return self._forward_native(
x, positions, input_ids, post_mix, res_mix, residual
)
@@ -1228,10 +1228,10 @@ class DeepseekV4Model(nn.Module):
# DeepseekV4MultiHeadLatentAttentionWrapper.attn_gemm_parallel_execute
# (compressor kv_score, indexer.weights_proj, indexer.compressor
# kv_score). fused_wqa_wkv stays on the default stream.
# Disable them on ROCm because of hang issues.
# Disable them on ROCm / XPU because of hang issues / no overlap.
aux_stream_list = (
None
if current_platform.is_rocm()
if current_platform.is_rocm() or current_platform.is_xpu()
else [torch.cuda.Stream() for _ in range(3)]
)