I’d like a fast serialization for a tensor. Right now, I’m using
x = torch.Tensor(...)
serialized = pickle.dumps(x)

The tensor is not guaranteed to live on the CPU and I want to preserve CPU–GPU bandwidth, meaning I can not use
x.numpy().tobytes()

Is there a fast serialization method for torch Tensors?
Notes on research I’ve done so far:

the source for torch.serialization and it relies on pickle.dumps (plus it seems oriented towards files, not speed).
blosc has compress_ptr 9 which could be useful with x.data_ptr

I’ve looked at pyarrow 23 too, but decided to ask here first