Lower as_strided_copy use fast path with slice #8734
Merged
Conversation
83b4643 to
2c006e8
Compare
pgmoka
reviewed
Feb 24, 2025
tengyifei
requested changes
Feb 25, 2025
pgmoka
reviewed
Feb 26, 2025
tengyifei
requested changes
Feb 26, 2025
tengyifei
requested changes
Feb 26, 2025
| if (stride_mul != stride[j]) { | ||
| if (skip_dim == -1) { | ||
| skip_dim = i; | ||
| K = stride[j] / stride_mul; |
Collaborator
There was a problem hiding this comment.
Should we check that stride[j] can be evenly divided by stride_mul and exit if the remainder is not 0?
Member
Author
There was a problem hiding this comment.
It doesn't need to be 'evenly divided' for stride[j] as long as all indexes before j of stride matches with the cumulative product of tensor dim.
tengyifei
reviewed
Feb 26, 2025
tengyifei
reviewed
Feb 26, 2025
tengyifei
reviewed
Feb 26, 2025
tengyifei
reviewed
Feb 26, 2025
zpcore
commented
Feb 26, 2025
33daabf to
2357253
Compare
tengyifei
approved these changes
Feb 27, 2025
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.
When we execute the following two code snippets regarding
flash attention kernelin custom_kernel.py, they suppose to produce the same result.a.
b.
Both will be lowered through
xla/torch_xla/csrc/aten_xla_type.cpp
Line 882 in 1acc987
strideandsizewill be one element fewer in code a compared with code b. With such argument difference, code a will be fallback intoaten::takeand this can trigger the following error when we call with SPMD:I plan to check in
test_as_stride_use_slice.pyin this PR.Note 1. Failing test
test_scan_layer_aotis not enabled until #8742 is resolved.2. Failing test
test_scan_weight_layer_aotis not enabled unti #8753 is resolved