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
[dtensor] skip pytree when not necessary #110132
Conversation
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/110132
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 9be485d with merge base 40b83d9 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: f35895d80052e81f37d539a6413e5da3d30378e8 Pull Request resolved: #110132
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: 72f3370dd99e467b9647655f825efa0c1b8d9d35 Pull Request resolved: #110132
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: d622e08c6218bb192d675bae2465cee7a6e0b4f8 Pull Request resolved: #110132
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: 2c399f73c2b056d5dd5e0db22e3a852fa2b14852 Pull Request resolved: #110132
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, it's actually surprising to me that only two ops need treemap here..
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: d506fdc7a843bc094e069316803001ab1abdb298 Pull Request resolved: #110132
Have you tried using optree? |
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: f2947786ac40ae350eb712fbf48c8c7b322fcac2 Pull Request resolved: #110132
Oh just noticed that got landed!! I can try turn that on, is there a flag to turn it on? My feeling is that even if that landed it would still have some overhead exposed (especially optree perf is most amazing on dicts, while operator arguments does not have too many dicts, maybe kwargs is a good try). This PR try to turn pytree/optree off completely for most ops which I thought it would be faster for either case? |
@wanchaol might be a little bit annoying to actually land but the idea was that we would incrementally port usages over incrementally. |
Yeah, see #109684 |
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops [ghstack-poisoned]
pytree is a great tool, but it sometimes considers to be evil for tensor subclasses, it's useful to implement subclass quickly, but it: * exposes non-trival CPU overhead * many ops don't need pytree, only the one with list/dict ops needs * blindly use pytree to re-wrap have semantic issues for inplace/out ops This PR avoid using pytree for most ops during torch_dispatch and only enable it for certain ops ghstack-source-id: dfddc15534ce75369e914b7875511d991b29e762 Pull Request resolved: #110132
@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):
pytree is a great tool, but it sometimes considers to be evil for
tensor subclasses, it's useful to implement subclass quickly, but it:
ops
This PR avoid using pytree for most ops during torch_dispatch and only
enable it for certain ops