diff --git a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py index 356281ab7..7bd540888 100644 --- a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py +++ b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py @@ -1587,7 +1587,9 @@ class AscendAttnBackend(AttentionBackend): (q.shape[0], layer.tp_q_head_num * layer.v_head_dim) ) else: - attn_output = torch.empty_like(q) + attn_output = torch.empty_like( + q, memory_format=torch.contiguous_format + ) use_gqa = layer.tp_q_head_num != layer.tp_k_head_num @@ -2746,7 +2748,9 @@ class AscendAttnBackend(AttentionBackend): (q.shape[0], layer.tp_q_head_num * layer.v_head_dim) ) else: - attn_output = torch.empty_like(q) + attn_output = torch.empty_like( + q, memory_format=torch.contiguous_format + ) use_gqa = layer.tp_q_head_num != layer.tp_k_head_num