-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[EASY] used guard_or_false instead of guard_sizes_oblivious in pointless_view #154154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/154154
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1d41da8 with merge base 413664b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced May 23, 2025
bobrenjc93
approved these changes
May 23, 2025
Collaborator
|
Starting merge as part of PR stack under #154234 |
2 similar comments
Collaborator
|
Starting merge as part of PR stack under #154234 |
Collaborator
|
Starting merge as part of PR stack under #154234 |
pytorchmergebot
pushed a commit
that referenced
this pull request
May 26, 2025
…154164) This was added in #149637, torch._check can handle unbacked there is no need for size oblivious reasoning here. Note this does not make is_nonzero unbacked friendly. but that is a different story. I ran the test added in #149637 for veirfication. Pull Request resolved: #154164 Approved by: https://github.com/aorenste, https://github.com/bobrenjc93 ghstack dependencies: #154154
pytorchmergebot
pushed a commit
that referenced
this pull request
May 26, 2025
…nt (#154167) This is a short circuit, that we should not fail on. Before this PR we would not fail on u0, u0+u1, only if they are size like. but we will fail on u0-u1.. etc for no need. guard_or_false seems appropriate for that reason. This was added in #122145 there was no unit tests for me to verify why it was added, i could not repo using the associated issue , the example does not work. Pull Request resolved: #154167 Approved by: https://github.com/bobrenjc93 ghstack dependencies: #154154, #154164
pytorchmergebot
pushed a commit
that referenced
this pull request
May 26, 2025
…ce (#154172) This was added in #119562 the idea in this loop seems to be the following. ``` if (TORCH_GUARD_SIZE_OBLIVIOUS(size.sym_eq(1))) { // NB: we could short circuit this once needs_reduce is true but there's // no point since the reduction function will guard on this anyway if (!c10::guard_or_false(size.sym_eq(target), __FILE__, __LINE__)) { needs_reduce = true; } } else { if (!size.sym_eq(target).expect_true(__FILE__, __LINE__)) { fail(); } } ``` 1. if we know size ==1 1.1 : if we know for sure size == target --> no reduce needed. 1.2 : we know for sure that size != target --> we do reduction. 1.3: we could not tell if size == target or not --> we do reduction. 2. if we do now know if size ==1 or not we add a runtime assertions that size ==target and we fail at runtime if size is not equal to target. We could have simplified 1.1 and always do reduction under 1.1, since doing 1.3 without runtime checks implies that it is safe, but i feel the reason could be perf here? idk. anyway using TORCH_GUARD_OR_FALSE instead of TORCH_GUARD_SIZE_OBLIVIOUS here is appropriate. there is really no clear reason for size oblivious reasoning. or for this logic not to apply when size is not size like size is always >=0 anyway. but bad reasoning can make us not able to infer that although we know its true here. python test/dynamo/test_misc.py -k test_validate_outputs_unbacked Pull Request resolved: #154172 Approved by: https://github.com/bobrenjc93 ghstack dependencies: #154154, #154164, #154167
pytorchmergebot
pushed a commit
that referenced
this pull request
May 26, 2025
this was added in #141659, the current change keep the same intention "i do not want to fail here if i cant tell if the size is zero or not" i am not familiar enough in the code to know if we need here a runtime check, but looking at current impl it seems that guard_or_false is appropriate to match current behaviour and have the same effect of guard_size_oblivious here. Pull Request resolved: #154234 Approved by: https://github.com/bobrenjc93 ghstack dependencies: #154154, #154164, #154167, #154172
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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):
The change is direct and clear, the optimizations removes pointless_view iff it all sizes are the same if not we want to return false, there is no need for size oblivious reasoning.
this was added in #139136, run existing tests that are added in that PR.
cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov