This is actually one of the reasons why we built PyTorch RPC, i.e., you don’t need to serialize tensors into json/string before passing it through communication. The native PyTorch RPC will serialize actor_params into a binary payload + a list of tensors, so that tensor storage/contents are kept as-is. Then the TensorPipe backend can directly send those tensors to the destination.
RPC API: Distributed RPC Framework — PyTorch master documentation 10
Toy RL tutorial: Getting Started with Distributed RPC Framework — PyTorch Tutorials 1.8.0 documentation 6
More tutorials: PyTorch Distributed Overview — PyTorch Tutorials 1.8.0 documentation 3