-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Allow Future::then to return pre-extracted DataPtrs #58424
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
Conversation
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 5565bab (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
| addCallback([childFut, | ||
| cb = std::move(callback)](Future& parentFut) mutable { | ||
| try { | ||
| guts::if_constexpr<std::is_convertible< |
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.
curious, what's the difference between guts::if_constexpr and if constexpr? Is it because we are not using C++17 yet?
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.
Correct. In fact, guts::if_constexpr will use if constexpr internally if available, but will fall back onto a C++-14-compatible polyfill if not.
aten/src/ATen/core/ivalue_inl.h
Outdated
| guts::if_constexpr<std::is_convertible< | ||
| typename std::result_of<T && (Future&)>::type, | ||
| IValueWithDataPtrs>::value>( | ||
| [&](auto _) { |
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.
any reason for using "_" instead of giving it a name?
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 did it because this was the example in the docstring of guts::if_constexpr. I'll rename it to identity, hopefully that's clearer.
aten/src/ATen/core/ivalue_inl.h
Outdated
| [&](auto _) { | ||
| IValue value; | ||
| std::vector<std::reference_wrapper<const at::DataPtr>> dataPtrs; | ||
| std::tie(value, dataPtrs) = _(cb)(parentFut); |
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.
would I be correct that _(cb) converts the cb type to IValueWithDataPtrs && (Future &)?
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'm not sure about the details, but according to the docstring of guts::if_constexpr we need _ in order to "trick" the compiler into delaying type-checking and thus avoid it complaining about the fact that cb has different types in the two branches. In practice, _ is the identity function, so it should have no effect.
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/) [ghstack-poisoned]
Pull Request resolved: pytorch#58424 In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. ghstack-source-id: 129567044 Differential Revision: [D28474880](https://our.internmc.facebook.com/intern/diff/D28474880/)
|
This pull request has been merged in a0ee299. |
|
This pull request has been reverted by c1a9bef. |
Reland of #58424 In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. Differential Revision: [D28623890](https://our.internmc.facebook.com/intern/diff/D28623890/) [ghstack-poisoned]
Summary: Pull Request resolved: #59207 Reland of #58424 In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. ghstack-source-id: 130202846 Test Plan: Used in next PR. Reviewed By: mrshenli Differential Revision: D28623890 fbshipit-source-id: 468c5308b40774ba0a778b195add0e0845c1929e
…#59207) Summary: Pull Request resolved: pytorch#59207 Reland of pytorch#58424 In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs. Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too. ghstack-source-id: 130202846 Test Plan: Used in next PR. Reviewed By: mrshenli Differential Revision: D28623890 fbshipit-source-id: 468c5308b40774ba0a778b195add0e0845c1929e
Stack from ghstack:
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs.
Note that
markCompletedalready allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to thethenmethod too.Differential Revision: D28474880