Repository navigation
Accumulate generic tile flash attention directly into att_out. - #1065
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
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. - LoadAndMulUpTo8Times2/StoreUpTo8Times2 now use unaligned loads/stores, since att_out rows are caller-provided and not guaranteed aligned. - Document that att_out must be zero-initialized before the first call (tiled_attention.cc already does this); 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. PiperOrigin-RevId: 1003900950
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).
since att_out rows are caller-provided and not guaranteed aligned.
(tiled_attention.cc already does this); 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.