Repository navigation
Accumulate generic tile flash attention directly into att_out. - #1065
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_1003900950
branch
from
November 3, 2026 12:27
98d05f0 to
58669ea
Compare
att_out is now an IN/OUT parameter: the generic TileFlashAttentionReturnExpSumsAndMaxLogits kernel uses it directly as the online-softmax accumulator instead of a separate C accumulator buffer. - Remove the C accumulator region from TileFlashAttentionWorkspaceLayout (saves padded_q_count * qkv_dim * 4 bytes of per-worker workspace). - Drop the per-call zero fill of C and the final C -> att_out copy. - Address att_out via Row()/Stride() so padded layouts work. - Document att_out as in-out, like exp_denominator_sums and max_logits: it must be zero-initialized before the first call, and its rows must be aligned to the SIMD vector size (all current callers already satisfy both). Fix the MixedRanges test and the attention benchmark, which passed uninitialized att_out. - Add TestTiledFlashAttentionChainedCalls with a kernel-agnostic helper, CheckChainedCallsMatchSingleCall, verifying that chaining calls over sub-ranges of the KV (carrying att_out, exp_sums and max_logits) matches a single call over the full range, including remainder query groups. The MixedRanges and chaining tests share a TiledFlashAttentionTestSetup. PiperOrigin-RevId: 1012927185
copybara-service
Bot
force-pushed
the
test_1003900950
branch
from
November 3, 2026 13:17
58669ea to
fef595d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accumulate generic tile flash attention directly into att_out.
att_out is now an IN/OUT parameter: the generic
TileFlashAttentionReturnExpSumsAndMaxLogits kernel uses it directly as the
online-softmax accumulator instead of a separate C accumulator buffer.
(saves padded_q_count * qkv_dim * 4 bytes of per-worker workspace).
must be zero-initialized before the first call, and its rows must be
aligned to the SIMD vector size (all current callers already satisfy both).
Fix the MixedRanges test and the attention benchmark, which passed
uninitialized att_out.
CheckChainedCallsMatchSingleCall, verifying that chaining calls over
sub-ranges of the KV (carrying att_out, exp_sums and max_logits) matches a
single call over the full range, including remainder query groups. The
MixedRanges and chaining tests share a TiledFlashAttentionTestSetup.