ifsheldon:

Is it a way to tell PyTorch or Lightning that my class is just an aggregation of tensors so then they can just automatically implement and call .to() for me?


I don’t know about Lightning, but that’s not possible in PyTorch, but you could create a new custom object and implement the to() method, if you think it’s making the code cleaner somehow.
I still don’t understand the use case, but given your current TensorGroup code snippet, you could try to use a custom nn.Module instead and register the tensors as buffers, which would then push them to the desired device via the to() operation.