Attach 'send' autograd function to the autograd graph as part of RPC.#24876
Attach 'send' autograd function to the autograd graph as part of RPC.#24876pritamdamania87 wants to merge 8 commits intogh/pritamdamania87/2/basefrom
Conversation
This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/)
This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/) ghstack-source-id: 88585551 Pull Request resolved: #24876
torch/csrc/distributed/autograd/context/DistAutogradContext.cpp
Outdated
Show resolved
Hide resolved
…art of RPC." This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. GitHub Issue: #23110 Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/)
Pull Request resolved: #24876 This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. ghstack-source-id: 88696420 Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/)
|
When you get a chance please rebase past master failures |
|
@pritamdamania87 , how are we going to do this when the object containing the tensor is a python object? |
|
@aazzolini As we discussed offline, when we pickle python objects, we can hook into the pickler and whenever we see tensors, we can attach them to the |
…art of RPC." This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. GitHub Issue: #23110 Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/)
Pull Request resolved: #24876 This contains very basic functionality of adding 'send' autograd function to our autograd graph. The purpose of this change is to validate the basic structure proposed here makes sense. Once this makes sense, we can build upon this to address more complicated scenarios. At a high level we've added the following functionality: 1) Define a very simple 'SendRpcBackwards' autograd function. 2) Attach this function to appropriate tensors when we call an RPC. 3) Store the send function in our distributed autograd context. ghstack-source-id: 88916065 Differential Revision: [D16903255](https://our.internmc.facebook.com/intern/diff/D16903255/)
How do we actually validate this? |
| op->schema(), args, kwargs, c10::nullopt); | ||
|
|
||
| auto& autogradContainer = DistAutogradContainer::getInstance(); | ||
| if (autogradContainer.hasValidContext()) { |
There was a problem hiding this comment.
Hmm. So if there is no current valid context, we just silently don't attach any autograd edges. That doesn't sound right to me: if there is no valid context, we had better error if we try to backpropagate.
Basically, if I don't do a context, and then I attend to rpc and backward through it, what error message do I get? That's something you should be testing for.
There was a problem hiding this comment.
We can raise an appropriate error as part of our new backward() and optimizer() API. Basically, when the user calls torch.distributed.backward(), either that API takes a context_id as input (then the user is forced to use the with wrapper). Or that API can use the current context id and it will fail if it doesn't find one.
torch/csrc/distributed/autograd/context/dist_autograd_container.cpp
Outdated
Show resolved
Hide resolved
torch/csrc/distributed/autograd/context/dist_autograd_container.cpp
Outdated
Show resolved
Hide resolved
torch/csrc/distributed/autograd/context/dist_autograd_container.cpp
Outdated
Show resolved
Hide resolved
| if (current_context_id_ == context_id) { | ||
| // Reset the thread_local current context id, since it is no longer valid. | ||
| current_context_id_ = -1; | ||
| } |
There was a problem hiding this comment.
Not part of this PR per se, but do we have a C++-side RAII guard for allocating and releasing thread local context? It seems like a logical thing that should be part of the C++ API.
There was a problem hiding this comment.
Do you think we should have support for a user facing C++ API? I feel we can invest there once there is a need. It is quite an overhead to maintain two APIs with good docs and tutorials.
There was a problem hiding this comment.
C++ API is non-goal for now, but let's add a TODO here in case we forgot.
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90403466 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90478263 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interfaces to ensure we have a RpcBase class which all RPC messages inherit from. This is useful since we create a RpcWithAutograd message which can wrap regular RPC messages and augment them with additional autograd information. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interfaces to ensure we have a RpcBase class which all RPC messages inherit from. This is useful since we create a RpcWithAutograd message which can wrap regular RPC messages and augment them with additional autograd information. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90545822 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90623247 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90877831 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Pull Request resolved: #25527 Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. ghstack-source-id: 90989582 Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/)
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
…uiltin operators RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
… RPC." Master GH issue: #23110. This change builds upon #24876 and provides all the autograd hooks needed for a forward pass with distributed rpc for builtin operators. This change does not address distributed rpc for python UDFs and that will be addressed in follow up PRs. Summary of changes: 1. Attach send autograd functions when a request is sent from the client and response is sent from the server. 2. Attach receive autograd functions when a request is received on the server and a response is received on the client. 3. Generate a globally unique autograd_message_id for each send/recv autograd function pair to uniquely identify them. 4. Major re-work of the RPC interface to support autograd seamlessly: * Ensure all RPC messages inherit from a base class `RpcCommandBase`. * `RpcCommandBase` allows us to build a wrapper class `RpcWithAutograd` which basically holds a `RpcCommandBase` object and some additional autograd information. * Added a `RequestCallback` interface which we need to implement to handle RPCs. The abstract class `RequestCallback` performs operations that would be common across all implementations. * Moved PythonUDF handling to an appropriate class which can plug into the `RpcCommandBase` interface. This would allows us to easily attach autograd information to PythonUDF calls. Differential Revision: [D17148077](https://our.internmc.facebook.com/intern/diff/D17148077/) [ghstack-poisoned]
Stack from ghstack:
This contains very basic functionality of adding 'send' autograd
function to our autograd graph. The purpose of this change is to validate the
basic structure proposed here makes sense. Once this makes sense, we can build
upon this to address more complicated scenarios. At a high level we've added
the following functionality:
GitHub Issue: #23110
Differential Revision: D16903255