Course contentsShow
← Machine Learning and Deep Learning
Lesson 2769 of 3,53860. Distributed Training: Model Parallelism and Mixed PrecisionFree lesson

Understanding Floating Point Precision in Neural Networks

Learn the differences between FP32, FP16, and BF16 formats and their impact on memory and computation.

Understanding Floating Point Precision in Neural Networks

What you'll learn: How different floating-point formats (FP32, FP16, BF16) trade precision for memory and speed in neural network training.

The Precision Spectrum

When training neural networks, every weight, gradient, and activation is stored as a floating-point number. The format you choose determines how much memory each number consumes and how quickly your hardware can process it.

Think of floating-point precision like photograph resolution: a high-resolution image captures more detail but takes up more storage space. Similarly, higher precision formats capture more numerical detail but require more memory.

The Three Main Formats

FP32 (Single Precision)

The traditional standard uses 32 bits per number. It offers high precision with a wide range of representable values. This is your "safe default" — stable training, but memory-hungry.

FP16 (Half Precision)

Uses only 16 bits per number, cutting memory usage in half. Specialized hardware (like Tensor Cores) can compute FP16 operations 2-8× faster. However, its narrow range (~±65,000) and limited precision can cause numerical instability, especially with small gradients that "underflow" to zero.

BF16 (Brain Float 16)

Google's clever compromise: 16 bits like FP16, but allocates more bits to the exponent (range) and fewer to the mantissa (precision). It matches FP32's range (~±3.4×10³⁸) while halving memory. This makes it more stable than FP16 for most training scenarios, though slightly less precise.

Impact on Training

  • Memory: FP16/BF16 halve memory consumption, enabling larger models or batch sizes
  • Computation: Modern GPUs accelerate FP16/BF16 math significantly
  • Stability: FP32 is most stable; BF16 is more robust than FP16 for gradient updates

Key Takeaway: FP32 offers maximum precision, FP16 maximizes speed but risks instability, and BF16 provides the best balance of efficiency and training stability for modern distributed training.