Limit the precision of weights and gradients

I am in a case where I hope the precision of gradients and weights of a model is low. This means I prefer integer values or 2-bit floats instead of 32-bit floats in training. How could I do it?