Make sliding window size inclusive in eager attention (#29519)

* Make sliding window size inclusive in eager attention

* Fix tests
This commit is contained in:
Jonatan Kłosko
2024-03-08 13:53:17 +01:00
committed by GitHub
parent f386c51ad9
commit 608fa5496c
2 changed files with 4 additions and 4 deletions

View File

@@ -1673,7 +1673,7 @@ class AttentionMaskTester(unittest.TestCase):
def compute_num_context_mask(self, kv_len, context, q_len):
# This function computes the # of attention tokens that are added for
# the sliding window
c_mask_len = kv_len - context
c_mask_len = kv_len - context - 1
num_mask_triangle = c_mask_len * (c_mask_len + 1) // 2
cut_mask_len = max(c_mask_len - q_len, 0)
num_cut_mask = cut_mask_len * (cut_mask_len + 1) // 2