How are fp 32 weights converted to fp16 post training?

Can the weights of a model trained in full precision be converted to half precision post-training, with or without loss of accuracy? If so, what is the maths involved behind the conversion?
Thanks

you can do model.half(), and it will be lossy I think. it will just convert the weights, and the operators will dispatch to a fp16 implementation as well, you’ll also need to feed the model a fp16 input.