Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/maxtext/layers/attention_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,15 @@ def wrap_flash_attention(
sinks,
indexer_mask,
):
# Splash prefetches the segment ids into SMEM, and SMEM is 1 MB per core.
# This limits the segmented kernel to approximately 524,288 tokens. When
# packing is off there is one segment per example, so the segment ids are
# constant and the non-segmented kernel gives the same result. Drop the
# ids here, before any early return, so every path benefits.
if not self.config.packing:
decoder_segment_ids_q = None
decoder_segment_ids_kv = None

if use_tokamax_ring:
attention_output = tokamax_ring_attention.call_ring_attention(
query,
Expand Down