Mixed precision
Mixed precision is a computational technique that uses different numerical precisions for values or operations within a computation.
Build a DeepSeek Model (From Scratch)
Mixed precision is a computation technique that uses multiple numerical precisions to reduce resource use while maintaining training effectiveness.
- How it is used
- Uses mixed precision to reduce training memory and computation while protecting numerically sensitive operations and state.
- How deep it goes
- Explains precision allocation through a linear layer and provides an autocast training configuration and loop.
- Examples
- Uses a DeepSeek FP8 linear layer and a PyTorch training loop for a roughly 130-million-parameter MiniDeepSeek model.
- What you can do after
- Apply mixed precision via PyTorch autocast in a training loop with device-dependent dtype selection.
Read how Build a DeepSeek Model (From Scratch) explains mixed precision →
Quantization and Fast Inference
Mixed precision uses different numerical precisions for different tensors or operations within a computation.
- How it is used
- Preserves LLM inference quality while reducing memory through outlier-aware INT8 quantization.
- How deep it goes
- Explains threshold-based outlier routing, split matmuls, reconstruction error, and threshold sweeps.
- Examples
- Compares OPT-6.7B reconstruction error and WikiText-2 perplexity, memory, and threshold settings.
- What you can do after
- Apply LLM.int8() with bitsandbytes by configuring 8-bit loading and an outlier threshold.
Read how Quantization and Fast Inference explains mixed precision →
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.
- How it is used
- Reduces model memory use and computation costs while balancing numerical stability, performance, and hardware limits.
- 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 you can do after
- Operate within GPU memory limits by choosing FP16 for a pretrained model when needed.
Read how Domain-Specific Small Language Models explains mixed precision →
Deep Learning with R, Third Edition
Mixed-precision training is model training that uses numerical values with different floating-point precisions to balance computational efficiency and numerical accuracy.
- How it is used
- Speeds model training on GPUs or TPUs while preserving precision-sensitive weight updates.
- How deep it goes
- Explains dtype roles, unstable operations, loss scaling, and Keras configuration without deriving hardware-level implementation details.
- Examples
- Uses a mixed_float16 mini-GPT configuration, float32 layer opt-outs, and fixed or automatic optimizer loss scaling.
- What you can do after
- Operate/configure Keras mixed precision and protect training with float32 exceptions or loss scaling.
Read how Deep Learning with R, Third Edition explains mixed precision →
CUDA for LLMs
Mixed-precision training uses multiple numerical precisions during model training to reduce resource requirements while maintaining useful numerical behavior.
- How it is used
- Uses lower-precision forward and backward computation with higher-precision weights and gradient accumulation to balance training throughput and numerical stability.
- How deep it goes
- Explains input and accumulator precisions, tensor-core gains, and GEMM constraints, but stops short of a complete mixed-precision training workflow.
- Examples
- Uses a 4096 × 4096 FP16 GEMM analysis and a WMMA example with FP16 inputs and an FP32 accumulator.
- What you can do after
- Evaluate tensor-core GEMM precision tradeoffs by relating lower-precision inputs and higher-precision accumulation to throughput and stability.
Deep Learning with Python, Third Edition
A training technique that uses lower-precision numeric types for some computations while keeping others in higher precision to balance speed, memory use, and numerical stability.
- How it is used
- Uses lower-precision computation to speed GPU or TPU training while preserving full precision for stability-sensitive updates.
- How deep it goes
- Explains layer dtypes, gradient casting, unstable operations, and loss scaling, but does not derive floating-point behavior mathematically.
- Examples
- Demonstrates Keras dtype policies, float32 opt-outs, fixed or automatic loss scaling, and a mini-GPT configuration.
- What you can do after
- Apply mixed precision in Keras, configure loss scaling, and protect numerically unstable layers with float32.
Read how Deep Learning with Python, Third Edition explains mixed precision →
Also covered in
What to know first
- float16float16 is a 16-bit floating-point format, commonly IEEE 754 binary16, with less precision and range than 32-bit floating-point formats.
- attentionAttention is a neural-network mechanism that computes input-dependent relevance weights to combine information from representations for a context-dependent computation.
- bfloat16bfloat16 is a 16-bit floating-point format with one sign bit, eight exponent bits, and seven fraction bits, providing a wide numerical range with reduced precision.
- gradientA gradient is the vector of partial derivatives of a scalar function with respect to its variables, indicating its local rate and direction of change.
Related concepts
- float16uses · float16 is a 16-bit floating-point format, commonly IEEE 754 binary16, with less precision and range than 32-bit floating-point formats.
- Tensor Coreused by · A Tensor Core is a specialized NVIDIA GPU execution unit designed to accelerate high-throughput matrix and tensor arithmetic.
- FP32uses · FP32 is a 32-bit single-precision floating-point format for representing approximate real numbers.
- bfloat16uses · bfloat16 is a 16-bit floating-point format with one sign bit, eight exponent bits, and seven fraction bits, providing a wide numerical range with reduced precision.
Questions about mixed precision
What is mixed precision?
Mixed precision is a computational technique that uses different numerical precisions for values or operations within a computation.
Which Manning books explain mixed precision?
Build a DeepSeek Model (From Scratch), Quantization and Fast Inference, Domain-Specific Small Language Models, Deep Learning with R, Third Edition, CUDA for LLMs and Deep Learning with Python, Third Edition.
What should I know before learning mixed precision?
Manning books that teach mixed precision usually introduce float16, attention, bfloat16 and gradient first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





