I’m not sure what “lossless” means in this context. The optimizer stored references to the model parameters, so depending what your modification does, you might delete these references. Generally, you can move models between different devices (and this operation is also differentiable).


I would recommend to create a deepcopy of the state_dict.


Calling half() on the model might work, but could also create NaN/Inf outputs since FP16 can easily overflow. In particular during training we thus recommend to use automatic mixed-precision 2, but your inference use case might also work.
All parameters will be transformed to HalfTensors and back to FloatTensor and will thus lose precision as seen in this example:


x = torch.randn(100)
y = x.half().float()
print((x - y).abs().max())