Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/paddle/nn/functional/flash_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,9 @@ def flashmask_attention(
has_end = False
elif startend_row_indices.shape[-1] == 4:
has_end = True
raise NotImplementedError(
"ending row index is not implemented yet."
)
else:
raise ValueError(
f"Invalid shape of startend_row_indices, when causal is False, the last dimension should be either 2 or 4 but got {startend_row_indices.shape[-1]}"
Expand Down
7 changes: 3 additions & 4 deletions test/legacy_test/test_flash_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def setUp(self):
self.enable_mem_efficient = False


class TestFlashAttenionWithMaskAPITest(TestFlashAttentionWithMaskAPI):
class TestFlashAttentionWithMaskAPITest(TestFlashAttentionWithMaskAPI):
def setUp(self):
self.place = paddle.CUDAPlace(0)
self.shape = (8, 1024, 16, 128)
Expand Down Expand Up @@ -861,7 +861,6 @@ def generate_mask_matrix_from_mask_indices(start_rows):
for j in range(seq_len):
start_row = start_rows[bz_idx, head_idx, j]
matrix[bz_idx, head_idx, start_row:, j] = -np.inf
matrix[bz_idx, head_idx, j, j] = 0.0
return matrix


Expand Down Expand Up @@ -937,7 +936,7 @@ def test_dot_scale_product(self):
np.testing.assert_allclose(out.numpy(), out_, rtol=5e-03, atol=1e-03)


class TestFlashAttenionWithSparseMaskAPITest(
class TestFlashAttentionWithSparseMaskAPITest(
TestFlashAttentionWithSparseMaskAPI
):
def setUp(self):
Expand All @@ -948,7 +947,7 @@ def setUp(self):
self.causal = True


class TestFlashAttenionWithSparseMaskBF16APITest(
class TestFlashAttentionWithSparseMaskBF16APITest(
TestFlashAttentionWithSparseMaskAPI
):
def setUp(self):
Expand Down