[NPU] Adapt cann 8.5: use sfa and lightning indexer op from cann and CI update (#17615)
Co-authored-by: Kelon <kelonlu@163.com>
This commit is contained in:
@@ -546,7 +546,7 @@ class AscendAttnBackend(AttentionBackend):
|
||||
actual_seq_qlen_prev, actual_seq_qlen_next = actual_seq_qlen
|
||||
actual_seq_lengths_kv_prev, actual_seq_lengths_kv_next = actual_seq_lengths_kv
|
||||
|
||||
attn_out_prev = torch.ops.custom.npu_sparse_flash_attention(
|
||||
attn_out_prev, _, _ = torch_npu.npu_sparse_flash_attention(
|
||||
query=q_nope_prev,
|
||||
key=k_nope,
|
||||
value=k_nope,
|
||||
@@ -565,8 +565,10 @@ class AscendAttnBackend(AttentionBackend):
|
||||
layout_query="TND",
|
||||
layout_kv="PA_BSND",
|
||||
sparse_mode=3,
|
||||
attention_mode=2,
|
||||
return_softmax_lse=False,
|
||||
)
|
||||
attn_out_next = torch.ops.custom.npu_sparse_flash_attention(
|
||||
attn_out_next, _, _ = torch_npu.npu_sparse_flash_attention(
|
||||
query=q_nope_next,
|
||||
key=k_nope,
|
||||
value=k_nope,
|
||||
@@ -585,6 +587,8 @@ class AscendAttnBackend(AttentionBackend):
|
||||
layout_query="TND",
|
||||
layout_kv="PA_BSND",
|
||||
sparse_mode=3,
|
||||
attention_mode=2,
|
||||
return_softmax_lse=False,
|
||||
)
|
||||
return torch.cat([attn_out_prev, attn_out_next], dim=0)
|
||||
|
||||
@@ -675,7 +679,7 @@ class AscendAttnBackend(AttentionBackend):
|
||||
actual_seq_lengths_kv,
|
||||
)
|
||||
else:
|
||||
attn_out = torch.ops.custom.npu_sparse_flash_attention(
|
||||
attn_out, _, _ = torch_npu.npu_sparse_flash_attention(
|
||||
query=q_nope,
|
||||
key=k_nope,
|
||||
value=k_nope,
|
||||
@@ -694,6 +698,8 @@ class AscendAttnBackend(AttentionBackend):
|
||||
layout_query="TND",
|
||||
layout_kv="PA_BSND",
|
||||
sparse_mode=3,
|
||||
attention_mode=2,
|
||||
return_softmax_lse=False,
|
||||
)
|
||||
|
||||
return attn_out
|
||||
|
||||
@@ -92,14 +92,6 @@ def init_npu_backend():
|
||||
assert _is_npu, "NPU backend initialization called on non-NPU device."
|
||||
|
||||
import sgl_kernel_npu # noqa: F401
|
||||
|
||||
try:
|
||||
import custom_ops # noqa: F401
|
||||
except ImportError:
|
||||
logger.warning(
|
||||
f"custom_ops not found, dsv3.2 requires this package, which includes the npu_lightning_indexer and npu_sparse_flash_attention operators."
|
||||
)
|
||||
|
||||
import torch_npu
|
||||
from torch_npu.contrib import transfer_to_npu # noqa: F401
|
||||
|
||||
|
||||
Reference in New Issue
Block a user