Mixed Precision Training
Paulius Micikevicius, Sharan Narang, Jonah Alben, et al.2018ICLR 2018
Read it on arxiv.org(opens in a new tab)Why this one
Read this before LLM.int8(), GPTQ, SmoothQuant, AWQ, and the 4-bit inference paper. Those later tricks look like compression, but this one teaches the older lesson: lower precision is mostly a numerics problem before it is a hardware problem. The key idea is not “use fp16 and go faster.” It is that some tensors can be rounded aggressively, while others need a safe place to accumulate small changes, and gradients may need to be lifted into range before they vanish. People get this wrong when they treat mixed precision as a flag in PyTorch instead of a contract between the optimizer, the loss scale, and the accelerator. If you train or serve models, this is worth an evening because it gives you the mental model behind every precision knob you will touch later.
What to take away
- Keep fp32 master weights because fp16 updates can be too small to change stored parameters.
- Loss scaling protects tiny gradients from underflow before backprop stores them in fp16.
- Mixed precision works when each tensor type gets the precision its numerical role requires.
Reads with
- LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
takes the same range and accumulation problem into transformer inference
- SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models
moves activation outliers so lower precision arithmetic stays numerically safe
- GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers
pushes the precision lesson from training tensors into post training weight quantization