[NPU] Update non-vit vision part for cumulative seqlen (#31867)
This commit is contained in:
@@ -803,11 +803,11 @@ class VisionAscendAttention(nn.Module):
|
|||||||
[b * s, h, head_size]
|
[b * s, h, head_size]
|
||||||
"""
|
"""
|
||||||
if forward_metadata is not None:
|
if forward_metadata is not None:
|
||||||
seq_lens = forward_metadata.seq_lens
|
# TND fused attention expects cumulative seqlens (cu_seqlens[1:]),
|
||||||
if seq_lens.is_npu:
|
# not per-sequence lengths in forward_metadata.seq_lens.
|
||||||
seq_lens = seq_lens.to("cpu")
|
cu = forward_metadata.cu_seqlens.to("cpu")
|
||||||
output = torch.empty_like(q)
|
output = torch.empty_like(q)
|
||||||
seq_len_arg = seq_lens.to(torch.int32)
|
seq_len_arg = cu[1:].to(torch.int32)
|
||||||
elif envs.SGLANG_VIT_ENABLE_CUDA_GRAPH.get():
|
elif envs.SGLANG_VIT_ENABLE_CUDA_GRAPH.get():
|
||||||
if "output_ws" not in kwargs:
|
if "output_ws" not in kwargs:
|
||||||
raise RuntimeError("output_ws should be prepared for npu-graph mode")
|
raise RuntimeError("output_ws should be prepared for npu-graph mode")
|
||||||
|
|||||||
Reference in New Issue
Block a user