liveBook · Manning

Mixed precision

As explained in Domain-Specific Small Language Models

Using reduced-precision numeric formats for some computations or weights to reduce memory use, often with limited loss in performance.

Mixed precision uses lower-precision formats for some computations while retaining higher precision for others. In training, this can reduce memory use and speed computation without the numerical risks of using only 16-bit arithmetic. section 6.1

A typical mixed-precision training workflow:

  • Convert weights to lower precision for faster computation and calculate gradients at lower precision. section 6.1
  • Convert gradients back to higher precision for numerical stability, then update the original weights using scaled gradients. section 6.1

For inference, pure FP16 can use less memory but may degrade performance. Combining FP16 and FP32 uses more memory than pure FP16, but less than pure FP32, with comparable or sometimes slightly better performance. section 6.1

Estimating inference memory

A 2.7-billion-parameter GPT-Neo model is estimated to require 12.96 GB in FP32 and 5.4 GB in FP16. These estimates show how precision choice affects whether a model fits available GPU memory. section 4.2

How Domain-Specific Small Language Models covers it

How deep it goes
Details floating-point formats and a mixed-precision training workflow, then compares inference tradeoffs without specifying implementation steps.
Examples
Compares GPT-Neo inference memory estimates in FP32 and FP16 and describes mixed-precision weight, gradient, and update operations.
What it assumes
Defines sign, exponent, and mantissa before describing precision formats and mixed-precision workflows.
What you can do after
Operate within GPU memory limits by choosing FP16 for a pretrained model when needed.
How it connects
Connects FP16 and FP32 arithmetic with BF16 and quantization as related approaches to reducing model memory use.

Also explained in

Compare how 3 books explain mixed precision →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.