What Is BF16? Choosing Between BF16 and FP16 by Range and Precision
BF16 is a 16-bit format with an FP32-width exponent and a shorter fraction than FP16. It can represent a wider range than FP16, but distinguishes nearby values less precisely. Learn when BF16 is a candidate and how to compare accuracy and performance safely.
What Is BF16? Choosing Between BF16 and FP16 by Range and Precision
BF16 (Brain Floating Point) is a 16-bit floating-point format with an exponent field as wide as FP32 and a shorter fraction. It can represent much larger magnitudes than FP16, but distinguishes nearby values less precisely. Storage per element, actual speed, and accuracy must be considered separately. Choose a format by checking value ranges and measuring task quality.
How BF16, FP16, and FP32 differ
A floating-point number divides its bits among a sign, exponent, and fraction. Normalized numbers have an implicit leading 1, so more fraction bits allow closer representable values around a given magnitude. NVIDIA TensorRT and Transformer Engine describe BF16 as 1/8/7, FP16 as 1/5/10, and FP32 as 1/8/23 sign/exponent/fraction bits.
| Format | Storage per element | Sign / exponent / fraction bits | Effective precision for normalized numbers | Range and trait |
|---|---|---|---|---|
| FP32 | 4 bytes | 1 / 8 / 23 | 24 bits | Reference precision; same exponent width as BF16 |
| BF16 | 2 bytes | 1 / 8 / 7 | 8 bits | Range similar to FP32, lower fraction precision |
| FP16 | 2 bytes | 1 / 5 / 10 | 11 bits | More fraction precision than BF16, but max finite value is 65,504 |
Suppose an FP32 intermediate value can grow to 80,000. That exceeds FP16’s maximum finite value of 65,504, so it cannot remain finite when converted to FP16. BF16’s FP32-width exponent can represent a value of that magnitude, but its shorter fraction rounds to a nearby value. BF16 is therefore a candidate for avoiding this FP16 range overflow, not a guarantee of exact values or model accuracy.
FP16 has three more fraction bits than BF16. If magnitudes stay in a safe range but nearby values matter, FP16 may retain more detail. If activations or gradients vary widely and FP16 overflows or underflows, BF16 may be worth testing. During training, small updates added to larger low-precision weights can also round away in either format; FP32 master weights or a higher-precision path may be needed.
What to try for a given problem
| Observed issue or requirement | Candidate to try first | Also check |
|---|---|---|
| Large intermediate values exceed 65,504 and FP16 produces Inf/NaN | BF16 or FP32 for those operations | Evaluate task error from BF16 fraction rounding |
| Values fit in FP16 range but finer fraction precision is needed | Compare FP16 and the FP32 reference | Check underflow of small values and output sensitivity |
| A layer or loss calculation loses quality after changing dtype | Keep that part in FP32 through mixed precision | Verify the engine used the requested input and accumulation precision |
| Expecting BF16 alone to make execution faster or total memory half as large | Measure first | Gains depend on supported operations, kernels, temporary buffers, and weight copies |
This is a starting point, not a rule that predicts results. BF16 and FP16 both use 2 bytes per element, so equal-sized arrays have the same storage size. Total training memory may differ because a framework can also keep FP32 master weights, optimizer state, or temporary buffers.
A process for applying and validating BF16
**Fix an FP32 baseline.** Save outputs and current quality criteria, such as validation metrics or training loss, using the same model version and representative data.
**Separate range problems from precision problems.** Inf/NaN or values above a format limit can indicate a range issue. Output or loss changes within the representable range, or small updates that do not take effect, can indicate precision limits. Both can occur together.
**Check GPU, framework, and operation support.** Use the support matrix for the exact library version and confirm that the operations in your model have a BF16 path. For example, NVIDIA Transformer Engine 2.21 lists BF16 support for that library at compute capability 8.0 or higher. That is specific to the library, not a promise for every GPU framework or operation.
**Compare BF16 with FP16 and FP32.** With identical inputs and settings, compare output error, task metrics, layer-level Inf/NaN, loss, and gradient behavior. Evaluate mixed precision to keep accuracy-sensitive operations at higher precision where supported.
**Measure on the target device.** Hold batch size, input shape, warm-up, and measurement interval constant while comparing latency, throughput, and actual memory use. If quality fails its criterion, return affected operations to FP32 or try another mixed-precision setup. If quality passes but performance does not improve, reconsider adding complexity.
BF16’s main advantage is a range similar to FP32 in a 16-bit format; its main cost is even lower fraction precision than FP16. If large values are the problem, put BF16 on the candidate list, then verify value distributions, task accuracy, and real performance on the target hardware.
Sources
[NVIDIA TensorRT: Data Format Descriptions](https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/data-format-desc.html) — sign, exponent, and fraction layouts for FP32, BF16, and FP16.
[NVIDIA TensorRT: Accuracy Considerations](https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/accuracy-considerations.html) — range/precision trade-offs, overflow, and mixed-precision guidance.
[NVIDIA TensorRT: Precision Control](https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/precision-control.html) — explicit tensor types and accumulation-precision controls in TensorRT 11.x.
[NVIDIA Transformer Engine 2.21: Training in BF16/FP16](https://docs.nvidia.com/deeplearning/transformer-engine/features/low_precision_training/introduction/introduction.html) — format comparison, mixed precision, and master weights.
[NVIDIA Transformer Engine 2.21: Datatype and Hardware Support Matrix](https://docs.nvidia.com/deeplearning/transformer-engine/support_matrix.html) — GPU architecture support for that library.