Skip to content
Open
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
6 changes: 4 additions & 2 deletions src/maxtext/layers/attention_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,8 +2111,10 @@ def wrap_flash_attention(
if indexer_mask is not None:
# Convert additive float mask (0.0=attend, negative=masked) to boolean mask for Tokamax splash kernel
indexer_mask = indexer_mask == 0.0
pad_q = mask_shape[0] - indexer_mask.shape[-2]
pad_kv = mask_shape[1] - indexer_mask.shape[-1]
padded_q_len = ((indexer_mask.shape[-2] + sa_config.block_q - 1) // sa_config.block_q) * sa_config.block_q
padded_kv_len = ((indexer_mask.shape[-1] + sa_config.block_kv - 1) // sa_config.block_kv) * sa_config.block_kv
pad_q = padded_q_len - indexer_mask.shape[-2]
pad_kv = padded_kv_len - indexer_mask.shape[-1]
if pad_q > 0 or pad_kv > 0:
pad_width = [(0, 0)] * (indexer_mask.ndim - 2) + [(0, pad_q), (0, pad_kv)]
indexer_mask = jnp.pad(
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/attention_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3480,9 +3480,6 @@ def test_tpu_dot_product_context_parallel_with_indexer(
"indexer_topk": 32,
},
)
@pytest.mark.skip(
reason="Indexer with all-gather context parallelism diverges from the dot_product reference; fix tracked in #4947."
)
@pytest.mark.tpu_only
def test_tpu_flash_attention_context_parallel_with_indexer(
self, context_parallel_load_balance, ici_context_parallelism=2, indexer_topk=256
Expand Down
Loading