Great question! Your recommendation here is actually quite close. prepare
doesn’t work with raw tensors, so you do need to change the device on that one manually. You can ensure it will always work by setting it to accelerator.device
rather than loss.device
2 Likes