Add then(callback)->Future API to ivalue::Future#37311
Add then(callback)->Future API to ivalue::Future#37311mrshenli wants to merge 24 commits intogh/mrshenli/157/basefrom
Conversation
[ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit d6231bc (more details on the Dr. CI page):
🚧 4 fixed upstream failures:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
| @dist_init | ||
| def test_callback(self): |
There was a problem hiding this comment.
Can we add a few more test cases:
- Test that the callback can be a torchscript function.
- Attach python callback to future returned by:
i) rpc_async within torchscript.
ii) rpc_async calling torchscript function. - Add tests to validate that we receive appropriate exceptions if callback doesn't have appropriate signature.
There was a problem hiding this comment.
Cannot test calling _then in a TorchScript function yet, as that would require making _then torchscrptable.
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
| } | ||
|
|
||
| template<typename R> | ||
| std::shared_ptr<Future<R>> then(std::function<R(const Future<T>& future)> cb) { |
There was a problem hiding this comment.
I am not sure if this is the appropriate API. Since the returned Future represents the completion of the callback, it should also hold the returned value of the callback?
There was a problem hiding this comment.
The signature LGTM, though one question - what's the reason for the CB taking in a future instead of the completed value of the future? Is it so that we can access errors on the future when running the callback (if so see above comment)?
There was a problem hiding this comment.
what's the reason for the CB taking in a future instead of the completed value of the future? Is it so that we can access errors on the future when running the callback (if so see above comment)?
Yep, the return value T might not be available if the callback crashed.
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Differential Revision: [D21247827](https://our.internmc.facebook.com/intern/diff/D21247827) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Pull Request resolved: #38352 Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 103957346 Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/)
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Pull Request resolved: #38352 Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 103983281 Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/)
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Pull Request resolved: #38352 Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 104042479 Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/)
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/) [ghstack-poisoned]
Pull Request resolved: #38352 Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 104086114 Differential Revision: [D21506940](https://our.internmc.facebook.com/intern/diff/D21506940/)
Summary: Pull Request resolved: #38352 Fixes the RPC profiling by using the `then()` API added in #37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 104086114 Test Plan: Re-enabled profiling tests Differential Revision: D21506940 fbshipit-source-id: 35cde22f0551c825c9bc98ddc24cca412878a63a
Summary: Pull Request resolved: pytorch#38045 We are working on fixing these (e.g. pytorch#37311) but a few PRs still need to land before these tests are fixed. Disable them for now to avoid noise ghstack-source-id: 103701518 Test Plan: CI Differential Revision: D21461340 fbshipit-source-id: fbb029a19a93d439c9fce8424be0fb6409b52ff3
Summary: Pull Request resolved: pytorch#37311 Test Plan: Imported from OSS Differential Revision: D21247827 Pulled By: mrshenli fbshipit-source-id: f8fe0617ccb957aa747a78554a000ce2c4a58495
Summary: Pull Request resolved: pytorch#38352 Fixes the RPC profiling by using the `then()` API added in pytorch#37311. Instead of adding a regular callback, we return a new future that completes when the profiling callback is finished. This is transparent to the user as the future still completes with the value of the original future (i.e. the RPC's return value) To make this work for RRef, we add a `_set_profiling_future` to set the profiling future, and `_get_profiling_future` to retrieve this future and wait on it in the tests. Re-enabled profiling tests and stress tested them 1000 times to verify the fix ghstack-source-id: 104086114 Test Plan: Re-enabled profiling tests Differential Revision: D21506940 fbshipit-source-id: 35cde22f0551c825c9bc98ddc24cca412878a63a
Stack from ghstack:
Differential Revision: D21247827