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 6626f89aa..d4049b5db 100644 --- a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py +++ b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py @@ -802,7 +802,8 @@ class AscendAttnBackend(AttentionBackend): and _is_dflash_verify(spec_info) and seq_lens_cpu is not None ): - seq_lens_int = seq_lens_cpu[:bs].int() + # seq_lens_cpu may be a CPU tensor; swa_indices is on-device. + seq_lens_int = seq_lens_cpu[:bs].int().to(self.device) else: seq_lens_int = seq_lens[:bs].int() starts = torch.clamp(seq_lens_int - self.sliding_window_size, min=0)