[ET-VK][ez] Ensure that attn_weight buffers do not exceed GPU buffer numel limit #15651
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.
Stack from ghstack (oldest at bottom):
Title says it all!
To give a concrete example, Llama3.2-1B-Instruct will have attn weights with size
{1, 32, max_seq_len, max_context_len}. Usuallymax_seq_len == max_context_len, and ifmax_context_len = 2048Then the attention weight tensors will have sizes{1, 32, 2048, 2048}which will contain 134217728 elements. ThemaxStorageBufferRangefor Adreno 750 is also 134217728 (2^27), so using context length of 2048 will produce incorrect results on Adreno 750.In practice, it is unlikely that the prompt sequence length will be equal to the context length, so the solution is to adjust down the
max_seq_lendim of the attention weight tensors to ensure that the GPU buffer numel limit is not hit.Differential Revision: D86443407