Gradient checkpointing is a memory-for-compute trade-off technique used during the backward pass of neural network training. Instead of storing all intermediate activations from the forward pass—which consumes memory proportional to network depth—it strategically saves only a subset (checkpoints). The non-saved activations are recomputed on-demand from the nearest checkpoint during backpropagation, dramatically reducing peak memory usage at the cost of extra computation.
Glossary
Gradient Checkpointing

What is Gradient Checkpointing?
Gradient checkpointing is a memory optimization technique for training deep neural networks that trades compute for memory by selectively recomputing intermediate activations during the backward pass instead of storing them all.
This technique is critical for training extremely large models or processing long sequences where memory is the primary constraint. It is often implemented via automatic differentiation frameworks like PyTorch's torch.utils.checkpoint. Related memory optimization paradigms include model parallelism and the Zero Redundancy Optimizer (ZeRO), which address memory redundancy across distributed devices.
Key Characteristics of Gradient Checkpointing
Gradient checkpointing is a memory-for-compute trade-off technique that strategically recomputes intermediate neural network activations during backpropagation to drastically reduce peak memory consumption during training.
Core Trade-Off: Compute for Memory
Gradient checkpointing fundamentally trades increased computation for reduced memory. Instead of storing all intermediate activations from the forward pass for the backward pass, it selectively stores only a subset (checkpoints). The non-stored activations are recomputed on-demand during backpropagation from the nearest checkpoint. This reduces peak memory usage from O(n) to O(√n) for a chain of n layers, where n is the sequence length or depth.
Strategic Checkpoint Placement
The efficiency of gradient checkpointing depends heavily on where checkpoints are placed. Common strategies include:
- Uniform Placement: Placing checkpoints at regular intervals (e.g., every k layers).
- Optimal Dynamic Programming: Using an algorithm to find the placement that minimizes total recomputation cost for a given memory budget.
- Manual Placement for Model Architecture: Targeting memory-intensive operations (e.g., after large convolutional blocks or attention layers in transformers). Poor placement can lead to excessive recomputation with minimal memory savings.
Implementation in Modern Frameworks
Gradient checkpointing is a standard feature in deep learning frameworks, abstracting the complex recomputation logic.
- PyTorch:
torch.utils.checkpoint.checkpointfunction wraps a segment of the model. It runs the segment twice: once without storing intermediates (forward) and once with gradients enabled (for recomputation during backward). - TensorFlow:
tf.recompute_graddecorator or theGradientTapewithpersistent=Falsecan be used to trigger similar behavior. - JAX: The
jax.checkpoint(formerlyjax.remat) transformation is a first-class citizen, allowing flexible checkpointing policies ('none', 'max', 'min' memory).
Primary Use Case: Training Very Large Models
This technique is critical for overcoming hardware memory limits when training massive models.
- Long Sequence Transformers: Enables training language models with context windows longer than what would fit in GPU memory if all activations were stored.
- Large-Scale Vision Models: Allows training of high-resolution image models (e.g., diffusion models, large CNNs) by checkpointing within the U-Net or residual blocks.
- Scientific Models: Facilitates training of deep physics-informed neural networks (PINNs) or other models with exceptionally deep or wide architectures.
Performance and Overhead Profile
The overhead is predictable but non-negligible.
- Memory Reduction: Can reduce activation memory by 50-90%, depending on the model and checkpointing strategy.
- Compute Increase: Typically increases total training computation by 20-40% due to the second forward pass (recomputation) within checkpointed segments.
- Wall-Clock Time: Training time increases, but the alternative (model parallelism or offloading) often has higher communication overhead. It enables training larger batches or models on existing hardware.
Relationship to Other Memory Techniques
Gradient checkpointing is often combined with other optimizations in a memory reduction stack:
- With Activation Offloading (CPU RAM): Checkpoints can be stored on CPU, further reducing GPU memory pressure.
- With Model Parallelism: Used within individual model-parallel devices to handle layers that are still too large.
- Complementary to Quantization/Pruning: Checkpointing targets activation memory during training, while quantization and pruning primarily target parameter memory for inference. They address different parts of the memory problem.
- Contrast with KV Caching: KV caching optimizes inference memory for transformers. Gradient checkpointing optimizes training memory for any autograd-based model.
Frequently Asked Questions
Gradient checkpointing is a critical memory optimization technique for training large neural networks. This FAQ addresses its core mechanisms, trade-offs, and practical applications in modern AI engineering.
Gradient checkpointing is a memory optimization technique for training deep neural networks that trades compute for memory by selectively recomputing intermediate activations during the backward pass instead of storing them all. During the standard forward pass, the network computes and typically stores every layer's output (activation) to use later for calculating gradients. With checkpointing, only a strategically chosen subset of these activations (the checkpoints) are stored. During the backward pass, when gradients for a non-checkpointed layer are needed, the network re-executes the forward pass for that segment of the model, starting from the nearest stored checkpoint, to regenerate the required activations on-the-fly. This process reduces peak memory consumption from O(n) to O(√n) (where n is the number of layers) at the cost of approximately one additional forward pass per backward pass.
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
Gradient checkpointing is one of several critical techniques for managing the memory footprint of large-scale AI systems. These related methods span model training, inference, and data storage.

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