Skip to content

Commit e8e559e

Browse files
authored
Merge pull request #18 from Mr-Grin/fix-selected-index-k-out-of-range
fix selected index k out of range
2 parents b2d140d + 69c0556 commit e8e559e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

native_sparse_attention_pytorch/native_sparse_attention.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,8 @@ def forward(
675675
fk = k
676676
fv = v
677677

678+
num_selected = min(num_selected, importance_scores.shape[-1] - 1)
679+
678680
if has_selected_kv_for_fine_attn:
679681

680682
# get the top-n kv segments for fine attention

0 commit comments

Comments
 (0)