Automatic Mixed Precision (AMP) is a library feature, such as in PyTorch's torch.cuda.amp or NVIDIA's Apex, that dynamically manages the casting of tensors between different numerical precisions—primarily FP16 and FP32—during neural network training. It aims to accelerate computation and reduce memory usage by performing operations in faster, lower-precision FP16 where possible, while automatically maintaining critical operations in higher-precision FP32 to preserve numerical stability and model accuracy.
Glossary
Automatic Mixed Precision (AMP)

What is Automatic Mixed Precision (AMP)?
A technique to accelerate deep learning training by automatically managing numerical precision.
The core mechanism involves two components: automatic type casting and loss scaling. The system automatically selects the appropriate precision for each operation, keeping master weights in FP32. To prevent gradient underflow, where small FP16 gradient values become zero, AMP applies a loss scaling factor before backpropagation and unscales the gradients before the optimizer step. This allows training to leverage the speed of tensor cores in modern GPUs and NPUs while maintaining convergence comparable to full FP32 training.
Key Features and Components of AMP
Automatic Mixed Precision (AMP) is a library feature that accelerates neural network training by automatically managing numerical precision. It combines FP16 for speed with FP32 for stability through several core mechanisms.
Automatic Tensor Casting
The core function of AMP is to automatically manage data types during the forward and backward passes of training. It identifies operations that can safely use FP16 (half-precision) for computation—like matrix multiplications in linear and convolutional layers—and keeps other operations, such as reductions and loss computations, in FP32 (single-precision). This eliminates the need for manual to(dtype) calls, reducing boilerplate code and potential errors. For example, in a standard ResNet-50 training loop, AMP would cast the input tensors and weights of convolutional layers to FP16 for the forward pass.
Loss Scaling
A critical technique to prevent gradient underflow in FP16. Gradients for some layers can have magnitudes smaller than the minimum positive value representable in FP16 (~5.96e-8), causing them to become zero. AMP applies dynamic or static loss scaling:
- The computed loss is multiplied by a scale factor (e.g., 128, 1024) before backpropagation.
- This shifts gradient values into the FP16 representable range.
- After the backward pass, gradients are unscaled before the optimizer step.
- Dynamic scaling automatically adjusts the scale factor by monitoring for gradient overflow (NaN/Inf values).
Master Weights
AMP maintains a copy of the model's parameters in FP32 precision, known as the master weights. During each training iteration:
- Weights are cast from FP32 to FP16 for the forward pass.
- Gradients are computed in FP16.
- Gradients are cast back to FP32.
- The FP32 master weights are updated by the optimizer using the FP32 gradients. This ensures the high-precision weight accumulation necessary for stable convergence, as the small updates from stochastic gradient descent can be lost in FP16. The master weights are the source of truth for the model state.
FP16 Safe Ops & Whitelist/Blacklist
AMP uses internal policy engines to decide which operations to cast. A whitelist contains operations proven numerically safe and beneficial in FP16 (e.g., torch.mm, torch.conv2d). A blacklist contains operations that require FP32 for stability, typically those involving reductions (e.g., torch.sum, torch.softmax) or sensitive functions like torch.exp for large values. All other operations fall into a graylist and use FP16 if input types are FP16, or FP32 otherwise. This policy-based approach ensures critical numerical stability is not compromised for speed.
Gradient Histories & Checkpointing
When using AMP, saving and loading model checkpoints requires handling both the FP32 master weights and the optimizer state (which may also be in FP32). Frameworks like PyTorch's torch.cuda.amp integrate with checkpointing utilities to automatically save and restore this additional state. The optimizer state often includes momentum buffers that must remain in FP32 for correctness. Loading an AMP checkpoint without the proper context will typically restore the model to a standard FP32 mode, requiring re-initialization of the AMP scaler for continued mixed-precision training.
AMP vs. Manual Mixed-Precision Training
A feature-by-feature comparison of automatic and manual approaches to mixed-precision training, highlighting trade-offs in development complexity, control, and performance.
| Feature / Metric | Automatic Mixed Precision (AMP) | Manual Mixed-Precision Training |
|---|---|---|
Implementation Overhead | Low | High |
Primary Use Case | General-purpose training acceleration | Research, custom architectures, maximum optimization |
Loss Scaling Management | Automatic (dynamic or static) | Manual (requires tuning) |
Precision Casting Control | Automatic (op whitelist/blacklist) | Explicit (developer-controlled per operation) |
Gradient Clipping Integration | Automatic (scales gradients before clipping) | Manual (must unscale before clipping) |
Framework Support | Native in PyTorch ( | Framework-agnostic but requires custom implementation |
Typical Speedup (vs. FP32) | 1.5x - 3x | 1.5x - 3.5x (potential for higher with expert tuning) |
Risk of Numerical Instability | Low (managed by automatic loss scaling) | Medium to High (depends on manual implementation quality) |
Debugging Complexity | Low (standard precision context managers) | High (requires tracking casts and scaling across code) |
Optimal For | Production training pipelines, rapid prototyping | Novel research, hardware-specific optimizations, educational purposes |
Frequently Asked Questions
Automatic Mixed Precision (AMP) is a critical technique for accelerating neural network training on modern hardware. These questions address its core mechanisms, implementation, and relationship to other optimization methods.
Automatic Mixed Precision (AMP) is a library feature that automatically manages the casting of tensors between different numerical precisions during neural network training to accelerate performance while preserving model accuracy. It works by executing most operations, particularly matrix multiplications and convolutions, in FP16 (half-precision) to leverage the faster compute and reduced memory bandwidth of modern GPUs and NPUs. Critical operations, such as weight updates and loss function calculations, are kept in FP32 (single-precision) to maintain numerical stability. A key component is loss scaling, where the loss value is multiplied by a factor (e.g., 128, 256) before backpropagation to prevent FP16 gradient values from underflowing to zero; the resulting gradients are then unscaled before the FP32 optimizer step.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Automatic Mixed Precision (AMP) exists within a broader ecosystem of techniques for optimizing numerical representation. These related concepts define the precision formats, conversion processes, and hardware considerations that AMP automates.
Mixed-Precision Training
The foundational technique that AMP automates. It strategically uses multiple numerical formats (e.g., FP16 for activations/gradients, FP32 for master weights) during neural network training. The goal is to accelerate computation and reduce memory usage while maintaining model convergence and final accuracy. AMP provides a library to manage this casting automatically, handling the complexities of maintaining a stable training process.
FP16 (Half-Precision)
A 16-bit floating-point format defined by the IEEE 754 standard. It is the primary lower-precision type used in AMP for compute-intensive operations. Key characteristics:
- Halves memory footprint and bandwidth compared to FP32.
- Enables faster computation on hardware with native FP16 support (e.g., NVIDIA Tensor Cores, modern NPUs).
- Has a limited dynamic range (≈ 5.96e-8 to 65504), which can lead to numerical underflow for small gradient values—a primary challenge AMP's loss scaling addresses.
BF16 (Brain Floating-Point)
An alternative 16-bit format that uses an 8-bit exponent (like FP32) and a 7-bit mantissa. It is increasingly common in AMP frameworks for training. Advantages over FP16:
- Preserves the dynamic range of FP32, drastically reducing underflow risk for gradients.
- Sacrifices mantissa precision for this range, which is often less critical for deep learning robustness.
- Supported natively by hardware like Google TPUs, Intel AMX, and NVIDIA Hopper GPUs, making it a robust choice for automatic precision selection.
Loss Scaling
A critical technique integrated into AMP to prevent gradient underflow in FP16. The process:
- The computed loss value is multiplied by a scaling factor (e.g., 128, 1024) before backpropagation.
- This scales up the entire gradient chain, keeping small values within FP16's representable range.
- Gradients are unscaled before the weight optimizer step to apply the correct update. AMP typically implements dynamic loss scaling, which automatically adjusts the scale factor by monitoring for gradient overflow.
Quantization-Aware Training (QAT)
A more aggressive precision-reduction technique that AMP can complement. While AMP dynamically manages FP16/FP32 during training, QAT simulates INT8 or lower integer precision throughout the forward pass. This allows the model to learn to compensate for quantization error. AMP and QAT can be staged: use AMP for faster initial training, then apply QAT to prepare a model for ultra-efficient integer-only inference on NPUs or edge devices.
Numerical Underflow/Overflow
The core numerical instability risks that AMP is designed to mitigate.
- Underflow: When a value is smaller than the smallest positive number representable in a format (e.g., a gradient < ~5.96e-8 in FP16). It becomes zero, halting learning. AMP uses loss scaling to combat this.
- Overflow: When a value exceeds the maximum representable number (e.g., > 65504 in FP16). This leads to saturation or infinity. AMP's dynamic loss scaling also detects and reduces the scale factor if overflow occurs, ensuring training stability.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us