FP16

Also known as: Half-precision floating point · half precision · float16

On this page 8

FP16, or half-precision floating point, is a 16-bit number format defined in IEEE 754 that stores each value with 1 sign bit, 5 exponent bits and 10 fraction bits. In AI hardware, FP16 is one of the core reduced-precision formats for training and running neural networks, because it halves memory and bandwidth compared with 32-bit floats and runs much faster on dedicated matrix units.

The format is also called half precision or float16 in software frameworks. Its main limitation is a narrow dynamic range, which is why modern accelerators pair it with techniques such as loss scaling or offer alternatives like bfloat16 and FP8.

How the FP16 bit layout works

FP16 encodes a number as sign, exponent and fraction, exactly like FP32 but with fewer bits in each field. The 5-bit exponent uses a bias of 15, and the 10 stored fraction bits plus an implicit leading one give 11 bits of significand precision, which corresponds to roughly three to four decimal digits.

The largest finite FP16 value is 65,504, and the smallest normal positive value is about 6.1 × 10⁻⁵. Below that, subnormal numbers extend the range down to about 6 × 10⁻⁸ at the cost of precision. Values beyond the maximum overflow to infinity, and values below the subnormal limit underflow to zero.

PropertyValuePractical effect
Total bits16 (1 sign, 5 exponent, 10 fraction)Two bytes per value
Maximum finite value65,504Large activations can overflow
Smallest normal valueAbout 6.1 × 10⁻⁵Small gradients lose precision
Smallest subnormal valueAbout 6 × 10⁻⁸Tinier values become zero
Machine epsilonAbout 9.8 × 10⁻⁴Roughly three decimal digits
Key numeric properties of FP16

FP16 compared with other AI number formats

FP16 sits between full-precision FP32 and the newer 8-bit and 4-bit formats used on recent accelerators. Its closest competitor is bfloat16, which keeps the 8-bit exponent of FP32 and therefore the same dynamic range, but stores only 7 fraction bits. FP16 offers more precision, while bfloat16 offers more range.

The comparison below shows why accelerator designers support several formats side by side rather than choosing a single one.

FormatExponent bitsFraction bitsApproximate maximumTypical role
FP328233.4 × 10³⁸Master weights, reference accuracy
TF328103.4 × 10³⁸Tensor core math on FP32 inputs
FP1651065,504Mixed-precision training, inference
bfloat16873.4 × 10³⁸Large model training without scaling
FP8 (E4M3)43448Inference and scaled training
FP16 and neighboring precision formats

Why accelerators run FP16 faster

FP16 speeds up AI workloads in two independent ways. First, each value occupies half the space of FP32, so the same memory bandwidth moves twice as many numbers, which matters for memory-bound layers. Second, a 16-bit multiplier needs far less silicon than a 32-bit one, so a chip can pack many more multiply-accumulate units into the same area and power budget.

Data-center GPUs execute FP16 matrix multiplications on tensor cores or other matrix multiply units, usually accumulating results in FP32 to avoid rounding drift across long dot products. Depending on the generation, dense FP16 tensor throughput is several times to more than ten times higher than plain FP32 vector throughput on the same chip.

  • Halved model footprint: a 7-billion-parameter model needs about 14 GB of weights in FP16 instead of 28 GB in FP32.
  • Higher arithmetic throughput from dense matrix units built for 16-bit inputs.
  • Better cache and memory use, since more values fit in on-chip buffers.
  • Lower energy per operation, which improves performance per watt.

Mixed-precision training with FP16

Pure FP16 training often fails because small gradients underflow to zero and weight updates become too small to change FP16 weights. Mixed-precision training solves this by computing forward and backward passes in FP16 while keeping a master copy of weights in FP32 for the optimizer update.

The second ingredient is loss scaling. The loss is multiplied by a large factor before backpropagation, which shifts gradients into the representable FP16 range, and the gradients are divided by the same factor before the update. Dynamic loss scaling raises the factor gradually and lowers it whenever an overflow produces infinities.

OperationUsual precisionReason
Matrix multiplications and convolutionsFP16 inputs, FP32 accumulationSpeed with stable sums
Softmax and normalizationFP32Sensitive to range and rounding
Loss computationFP32Avoids overflow on large values
Optimizer state and master weightsFP32Preserves tiny updates
Stored activationsFP16Halves activation memory
Typical precision choices inside a mixed-precision step

When to choose FP16 on current hardware

The right choice of FP16 depends on the model scale, the accelerator generation and the workload phase. Older GPUs and many edge NPUs accelerate FP16 but not bfloat16, which makes FP16 the natural option there. Newer data-center chips support bfloat16 and FP8 as well, so FP16 competes with formats that offer either wider range or higher throughput.

The decision table below reflects common engineering practice rather than a fixed rule, and teams should always validate accuracy on their own data.

SituationRecommended formatReason
Training a small or medium model on older GPUsFP16 with loss scalingOnly fast reduced-precision path
Training a very large language modelbfloat16Wide range avoids overflow
Serving a model with strict quality targetsFP16Near-FP32 accuracy, half the memory
Serving at maximum throughput on new acceleratorsFP8 or INT8Higher speed after calibration
Running on a mobile or edge NPUFP16 or INT8Matches supported hardware paths
Decision guide for FP16 adoption

Limitations and common pitfalls of FP16

The narrow range of FP16 is its main operational risk. Very large language models can produce activation outliers above 65,504, which appear as NaN or infinite losses during training. For this reason, many large-scale training runs moved to bfloat16, which tolerates such values without loss scaling.

  • Overflow in attention scores when logits are not scaled before the softmax.
  • Silent accuracy loss when accumulation also happens in FP16 instead of FP32.
  • Underflow in small gradients if loss scaling is disabled or misconfigured.
  • Limited hardware support on some older or CPU-only systems, where FP16 may be emulated and slower.

For inference, FP16 is usually safe and loses little or no accuracy compared with FP32. It remains a common default serving precision before teams consider further quantization to INT8, FP8 or FP4.

Put simply

Computers store numbers using a fixed number of bits. More bits mean more exact numbers, but they also take more space and more time to process.

FP16 uses only 16 bits per number. It is like writing prices rounded to a few digits instead of to many decimals. The numbers are slightly less exact, but AI chips can handle twice as many of them at once. Neural networks usually do not need extreme exactness, so this trade works well for most tasks.

In practice

A research group fine-tunes an image classification model with 300 million parameters on a single data-center GPU. In FP32, training reaches only a small batch size and takes about nine hours per epoch. The team switches on automatic mixed precision, which runs convolutions in FP16, keeps master weights in FP32 and applies dynamic loss scaling.

Memory use for activations drops by almost half, so the batch size doubles. Each epoch now finishes in about three and a half hours, and final validation accuracy stays within 0.1 percentage points of the FP32 baseline. The outcome is a faster, cheaper run with no measurable loss in model quality.