Send and receive tensor with indefinite length

Hello, I am doing some work about gradient sparsification and compression in model training. After compress, tensor size may be different among workers. Now I have to send tensor size to others at first and then send the compressed tensor. However it looks ugly. I want to send and receive tensor with indefinite length in one communication, any ideas?

Unfortunately, with ProcessGroup send/recv, this needs to be done in two comms (size and data) for now. We are building a new RPC API which could simplifies it a bit at the API level, but internally it still uses ProcessGroup send/recv currently until we have a better comm primitive for that.