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
[functorch] Prevent using for-loop for out-of-place index_fill batch rule #99229
Conversation
…rule [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99229
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b77fce9: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…rule ghstack-source-id: 2d2ba335785096dd17779c48fa8b991624739822 Pull Request resolved: #99229
…fill batch rule" A follow-up PR for #91364 (comment) [ghstack-poisoned]
…rule ghstack-source-id: f31f7166b41d8dca2c6b3bdb94bba4478600ad2b Pull Request resolved: #99229
…fill batch rule" A follow-up PR for #91364 (comment) [ghstack-poisoned]
…rule ghstack-source-id: d7ebf37f89f9117de99198475794f78963aa93ce Pull Request resolved: #99229
self_slice.index_fill_( | ||
dim, | ||
index_slice, | ||
value_bdim.has_value() ? value_.select(0, i) : value_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write this for-loop such that we won't have to check value_bdim
every iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this is the most concise version, and checking value_bdim
would not be costly.
Here are the ways I came up:
- Always ensure
value
has a batch dim and do select in every iteration - costly. - Make copies of the for-loop statement and separate the work out. There are four combinations for
inplace
andvalue_bdim.has_value()
- not concise. - Determine
value_bdim.has_value()
before for-loop and use lambdas to wrap eithervalue_
orvalue_.select(0, i)
- I feel unnecessary tbh. Would it be better?
Or maybe I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, makes sense, plus I would assume that most of the time would be spent in index_fill
so this should be good.
…fill batch rule" A follow-up PR for #91364 (comment) cc zou3519 Chillee samdow soumith kshitij12345 janeyx99 [ghstack-poisoned]
…rule ghstack-source-id: b5feebe0e0d028dac696482ef77c2a5dcc00a6c1 Pull Request resolved: #99229
…fill batch rule" A follow-up PR for #91364 (comment) cc zou3519 Chillee samdow soumith kshitij12345 janeyx99 [ghstack-poisoned]
…rule ghstack-source-id: ad2b76877d4d788d9e5b77bc8c2e40c853d6a331 Pull Request resolved: #99229
…fill batch rule" A follow-up PR for #91364 (comment) cc zou3519 Chillee samdow soumith kshitij12345 janeyx99 [ghstack-poisoned]
…rule ghstack-source-id: 60b5301fc7ae924142a16b044b21a2b90dd1cf24 Pull Request resolved: #99229
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you @qqaatw
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
A follow-up PR for #91364 (comment)
cc @zou3519 @Chillee @samdow @soumith @kshitij12345 @janeyx99