Gradient checkpointing is a memory-saving technique that selectively discards intermediate neural network activations during the forward pass and recomputes them on-demand during backpropagation. Instead of storing every tensor required for gradient calculation, the system retains only strategic 'checkpoint' nodes, dramatically reducing peak GPU memory consumption at the cost of additional forward-pass computation.
Glossary
Gradient Checkpointing

What is Gradient Checkpointing?
A memory optimization technique that trades compute for memory by discarding intermediate activations during the forward pass and recomputing them during the backward pass, enabling transfer learning on larger 3D volumes.
This trade-off is critical for transfer learning on 3D medical volumes, where high-resolution CT or MRI scans exceed standard GPU memory limits. By applying gradient checkpointing to a pre-trained model's encoder layers, engineers can fine-tune on full volumetric data without resorting to patch-based approximations, preserving spatial context essential for accurate diagnostic inference.
Key Characteristics of Gradient Checkpointing
Gradient checkpointing is a compute-for-memory trade-off that enables training larger models on limited hardware. By strategically discarding and recomputing intermediate activations, it dramatically reduces peak memory usage during backpropagation.
Core Mechanism: Compute-Memory Trade-Off
During a standard forward pass, all intermediate activations are stored in memory for the backward pass. Gradient checkpointing discards the activations of designated layers, keeping only the checkpoint tensors. During backpropagation, when an activation is needed but not stored, it is recomputed from the nearest checkpoint by running a mini-forward pass. This trades additional computation (roughly 20-30% more FLOPs) for a significant reduction in peak memory, often enabling a 4x to 10x reduction in activation memory footprint.
Enabling Larger 3D Volumes in Medical Imaging
Training deep networks on high-resolution 3D CT or MRI volumes is notoriously memory-intensive. A single 512×512×512 voxel input can exhaust GPU memory even on high-end hardware. Gradient checkpointing is critical for transfer learning on 3D medical data because it allows a pre-trained model to be fine-tuned on full volumetric inputs without downsampling or patch-based workarounds. This preserves fine-grained anatomical context and enables end-to-end learning on entire organs or body regions.
Checkpointing Strategies
Not all layers are equal candidates for checkpointing. Effective strategies include:
- Selective checkpointing: Only recompute memory-intensive operations like convolutions and activations, while keeping cheap operations like pooling and normalization in memory.
- Optimal segmentation: Divide the computation graph into segments of roughly equal memory cost to minimize the peak recomputation overhead.
- Recursive checkpointing: Apply the technique hierarchically for extremely deep networks, enabling sublinear memory scaling at the cost of logarithmic recomputation.
Integration with PyTorch and TensorFlow
Modern frameworks provide native APIs for gradient checkpointing:
- PyTorch:
torch.utils.checkpoint.checkpoint()wraps any module or function, marking it for activation recomputation. - TensorFlow:
tf.recompute_grad()in custom gradient tapes achieves the same effect. - Hugging Face Transformers: The
gradient_checkpointing_enable()method applies it to all transformer blocks, a common practice when fine-tuning large vision transformers on medical images. These implementations use non-reentrant checkpointing by default, which is thread-safe and compatible with automatic mixed precision.
Impact on Training Dynamics
Gradient checkpointing is mathematically equivalent to standard backpropagation—the computed gradients are identical. However, practical considerations include:
- Increased training time: The recomputation overhead adds 15-25% to total iteration time, though this is often preferable to reducing batch size or model capacity.
- Randomness handling: Operations like dropout must have their random state saved at checkpoints to ensure deterministic recomputation.
- In-place operation conflicts: Checkpointed regions cannot contain in-place operations that modify saved tensors, as this would corrupt the recomputation.
Comparison with Other Memory-Saving Techniques
Gradient checkpointing is one of several memory optimization strategies, each with distinct trade-offs:
- Gradient accumulation: Simulates larger batches by accumulating gradients over multiple micro-batches, reducing activation memory but not model memory.
- Mixed precision training: Uses FP16 for activations, halving memory with minimal accuracy loss; often combined with checkpointing.
- Model parallelism: Distributes layers across devices, orthogonal to checkpointing which operates within a single device.
- Activation offloading: Moves activations to CPU memory, trading PCIe bandwidth for GPU memory; checkpointing avoids this bandwidth bottleneck.
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.
Frequently Asked Questions
Clear, technical answers to the most common questions about gradient checkpointing, a critical memory-saving technique for training large models on high-resolution 3D medical volumes.
Gradient checkpointing is a memory optimization technique that trades computation for memory by strategically discarding intermediate activations during the forward pass and recomputing them on-demand during the backward pass. Instead of storing every activation tensor for the entire computational graph—which is required for standard backpropagation—the technique saves only a sparse set of 'checkpoint' nodes. During the backward pass, when an activation is needed to compute the gradient but was not stored, it is recomputed by re-running a segment of the forward pass from the nearest available checkpoint. This reduces peak memory consumption from O(n) to O(√n) or O(log n), where n is the number of layers, enabling the training of deeper networks and larger 3D volumes that would otherwise exceed GPU memory limits.
Related Terms
Gradient checkpointing is a critical memory optimization technique that enables training large models on 3D medical volumes. These related concepts form the ecosystem of memory and compute trade-offs essential for transfer learning on hardware-constrained systems.
Activation Recomputation
The core mechanism behind gradient checkpointing. During the forward pass, only a subset of intermediate activations (checkpoints) are stored. During the backward pass, discarded activations are recomputed on-the-fly from the nearest checkpoint. This trades a ~33% increase in FLOPs for an O(√n) reduction in memory, where n is the number of layers. In PyTorch, this is implemented via torch.utils.checkpoint.checkpoint() which wraps arbitrary module segments.
Activation Offloading
A complementary technique that moves intermediate activations from GPU VRAM to CPU RAM during the forward pass, fetching them back during the backward pass. Unlike recomputation, offloading preserves exact values without additional compute but introduces PCIe bandwidth bottlenecks. Frameworks like DeepSpeed ZeRO-Offload combine offloading with gradient checkpointing for extreme memory efficiency, enabling training of models that are 10x larger than GPU memory alone would permit.
Mixed Precision Training
Uses FP16 or BF16 floating-point formats for forward and backward passes while maintaining a master copy of weights in FP32. This halves activation memory and accelerates tensor core throughput. When combined with gradient checkpointing, the memory savings compound: mixed precision reduces per-activation storage by 50%, while checkpointing eliminates storing most activations entirely. Critical for training large 3D U-Nets on consumer GPUs with limited VRAM.
Reversible Layers
An architectural alternative to gradient checkpointing. Reversible residual networks (RevNets) design each layer such that activations can be exactly reconstructed from the subsequent layer's output during the backward pass—eliminating the need to store or recompute them. Unlike checkpointing, reversible layers add no computational overhead during backpropagation but constrain architecture design. Used in Reformer and RevViT architectures for memory-efficient transformers.
Gradient Accumulation
Simulates larger batch sizes by accumulating gradients over multiple micro-batches before performing a single optimizer step. When combined with gradient checkpointing, this enables training with effective batch sizes that would otherwise exceed GPU memory. For example, a desired batch size of 32 on 3D CT volumes may be split into 8 micro-batches of 4, with checkpointing ensuring each micro-batch fits in VRAM. The trade-off is proportionally slower training wall-clock time.
Selective Checkpointing
A policy-based optimization where only specific, memory-intensive operations are checkpointed rather than entire layer blocks. Operations like attention mechanisms and large convolutions are checkpointed, while cheap activation functions (ReLU, GELU) are stored normally. This provides a finer-grained memory-compute trade-off compared to uniform checkpointing. PyTorch's checkpoint function accepts a use_reentrant parameter and can be applied surgically to bottleneck operations in 3D medical segmentation networks.

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