Activation recomputation (checkpointing) is a memory-for-computation trade-off technique where selected intermediate activations from the forward pass of neural network training are deliberately discarded and later recalculated during the backward pass to compute gradients. This strategy dramatically reduces the peak memory required to store the computational graph's state, enabling the training of deeper models or larger batch sizes on memory-constrained hardware like NPUs and GPUs. The compiler strategically selects which activations to checkpoint to minimize the recomputation overhead.
Glossary
Activation Recomputation (Checkpointing)

What is Activation Recomputation (Checkpointing)?
Activation recomputation, also known as gradient checkpointing, is a fundamental memory optimization technique in neural network training.
The technique is implemented during graph compilation by inserting special checkpointing operators. During execution, the forward pass stores only these checkpointed tensors. In the backward pass, the system recomputes the non-checkpointed activations in segments, starting from the nearest stored checkpoint. This approach is critical for large language model (LLM) training and is a key component of hardware-aware model optimization, allowing frameworks to adapt to specific accelerator memory hierarchies.
Key Characteristics of Activation Recomputation
Activation recomputation (checkpointing) is a memory-for-compute trade-off technique used during neural network training. It strategically discards intermediate activation tensors in the forward pass and recalculates them during the backward pass to compute gradients.
Memory-for-Compute Trade-off
The core principle of activation recomputation is a direct trade: it reduces peak memory consumption at the cost of increased computational FLOPs. Instead of storing all intermediate activations for the entire forward pass, only a subset (checkpoints) is saved. The discarded activations are recomputed on-demand during backpropagation from the nearest checkpoint. This is critical for training very large models that would otherwise exceed GPU or NPU memory limits.
Selective Checkpoint Placement
Not all layers are checkpointed. Optimal placement is determined by a cost model that analyzes:
- Tensor Size: Larger activations are prime candidates for discarding.
- Recomputation Cost: The FLOPs required to recompute the subgraph.
- Memory Budget: The target peak memory reduction.
Common strategies include checkpointing every N layers or placing checkpoints at the boundaries of memory-intensive operations (e.g., after large matrix multiplications).
Subgraph Recomputation
When the backward pass reaches a point where a needed activation has been discarded, the compiler re-executes a segment of the forward pass. This is not a full model rerun but a targeted recomputation of a subgraph defined between two checkpoints. The compiler must manage this execution context, ensuring inputs are available and the recomputed tensors are identical to the original forward pass values for correct gradient calculation.
Compiler-Driven Automation
Modern ML compilers (e.g., PyTorch's torch.utils.checkpoint, XLA) automate activation recomputation. The compiler:
- Analyzes the computational graph to identify candidate regions.
- Inserts checkpoint and recompute nodes into the IR.
- Schedules the forward/backward/recompute operations to ensure correctness and minimize overhead.
This allows developers to apply the technique with minimal code changes, often via a simple decorator or context manager.
Impact on Training Throughput
The primary trade-off is increased wall-clock time per training iteration. The recomputation of forward segments can add 20-30% overhead. However, this is often preferable to the alternative: model parallelism or offloading to CPU RAM, which can introduce even greater latency due to communication. The technique enables batch size scaling within fixed memory, which can sometimes offset the recomputation cost by improving gradient signal.
Relation to Graph Fusion & Memory Planning
Activation recomputation interacts closely with other graph compilation strategies:
- Graph Fusion: Recomputation boundaries can affect fusion opportunities. Fused kernels that span a checkpoint may need to be split.
- Memory Planning: The compiler's memory allocator must manage the lifetime of checkpointed tensors and the temporary buffers for recomputation. Advanced planning can reuse memory between discarded activations and recomputation buffers.
- Operator Reordering: Independent ops may be reordered to create more favorable subgraphs for recomputation.
Activation Recomputation vs. Alternative Memory Optimization Techniques
This table compares activation recomputation (checkpointing) with other major techniques for reducing memory footprint during neural network training, highlighting trade-offs in compute, memory, and implementation complexity.
| Feature / Metric | Activation Recomputation (Checkpointing) | Gradient Accumulation | Model Parallelism | Mixed-Precision Training (FP16) |
|---|---|---|---|---|
Primary Optimization Target | Peak activation memory | Batch size memory | Model parameter memory | Activation & parameter memory |
Mechanism | Discards & recomputes selected activations during backward pass | Accumulates gradients over multiple micro-batches before updating weights | Distributes model layers across multiple devices | Uses lower numerical precision (e.g., FP16) for weights and activations |
Memory Reduction (Typical) | 30-70% | Linear with micro-batch count | Near-linear with device count | ~50% |
Compute Overhead | 30-50% extra FLOPs | < 1% | 5-20% (communication) | 0-5% (with tensor cores) |
Implementation Complexity | High (requires compiler/runtime integration) | Low (framework-level) | Very High (model architecture changes) | Medium (framework support required) |
Communication Overhead | None | None | High (inter-device communication) | None |
Optimal Use Case | Memory-bound training of very large models | Simulating large effective batch sizes | Models too large for a single device | Throughput-optimized training on supported hardware (e.g., NVIDIA Tensor Cores) |
Compiler/Runtime Support Required | ||||
Transparent to Model Code |
Activation Recomputation (Checkpointing)
Activation recomputation, also known as gradient checkpointing, is a memory optimization technique that trades off computation for memory by selectively discarding and later recalculating intermediate activations during the backward pass of training.
Core Mechanism
Activation recomputation works by strategically discarding the outputs (activations) of certain layers during the forward pass of neural network training. During the backward pass, when gradients are needed for those discarded activations, the system re-executes a segment of the forward pass to regenerate them. This creates a fundamental trade-off: reduced memory footprint for storing activations versus increased computational cost due to the extra forward passes.
- Checkpoint Selection: The compiler decides which layers to checkpoint. Common strategies include checkpointing every
n-th layer or using a dynamic cost model. - Recomputation Granularity: Can be performed at the level of individual operators, subgraphs, or entire network segments.
Memory vs. Compute Trade-off
The primary value proposition is trading abundant compute for scarce memory. For a network with L layers, the naive approach stores all L activations, leading to O(L) memory complexity. With optimal checkpointing, peak memory can be reduced to O(√L) while increasing total FLOPs by approximately 30-40%.
- Peak Memory Reduction: Critical for training very large models (e.g., LLMs, diffusion models) that would otherwise exceed GPU VRAM.
- Overhead Calculation: The recomputation overhead is not uniform; it depends on the placement of checkpoints and the computational cost of the recomputed subgraph.
Implementation in Frameworks
Major deep learning frameworks provide APIs and compiler passes to implement activation recomputation automatically or via user annotations.
- PyTorch:
torch.utils.checkpoint.checkpointfunction wraps a network segment. Thetorch.compileAPI withfullgraph=Truecan enable more aggressive, compiler-managed checkpointing. - TensorFlow/JAX: Similar functionality via
tf.recompute_graddecorator orjax.checkpoint(formerlyjax.remat). - Compiler Integration: In graph compilers like XLA (for JAX/TensorFlow) and TorchInductor (for PyTorch), checkpointing decisions are often made during the graph lowering and fusion passes, considering the target hardware's memory hierarchy.
NPU-Specific Optimizations
On Neural Processing Units, activation recomputation must be co-designed with other graph compilation strategies to account for unique hardware constraints.
- Fusion-Aware Checkpointing: The compiler must decide whether to checkpoint before or after a fused kernel. Recomputation a fused kernel is efficient but may regenerate more data than needed.
- Memory Hierarchy Alignment: Checkpoints can be placed to minimize expensive transfers between NPU global memory and on-chip SRAM/cache. The goal is to keep actively recomputed tensors in faster memory.
- Pipeline Interleaving: In training pipelines, recomputation can be scheduled to overlap with other operations (e.g., communication, weight updates) to hide its latency.
Checkpointing Strategies
Different algorithmic strategies determine which activations to save and which to recompute.
- Uniform Checkpointing: Saves activations at regular intervals (e.g., every 5 layers). Simple but often suboptimal.
- Optimal Checkpointing (Chen et al.): A dynamic programming algorithm that minimizes recomputation FLOPs for a given memory budget. It has O(L²) complexity for a graph of L layers.
- Greedy Heuristics: Runtime or compile-time heuristics that estimate the memory cost of saving an activation versus the compute cost of recomputing it.
- Subgraph Checkpointing: Treats a connected subgraph of operators as a single unit for checkpointing, which can be more efficient than per-operator decisions.
Related Compiler Techniques
Activation recomputation interacts closely with other graph compilation passes.
- Operator Reordering: Independent operations may be reordered to create larger, more efficient subgraphs for checkpointing.
- Memory Planning: The compiler's memory allocator must account for the transient buffers needed during recomputation phases.
- Common Subexpression Elimination (CSE): If the same subgraph is recomputed multiple times during backward pass, CSE can cache the result.
- Static vs. Dynamic: Decisions can be made statically at compile time (AOT) or dynamically at runtime (JIT), with static planning allowing for more aggressive global optimization.
Frequently Asked Questions
Activation recomputation, also known as gradient checkpointing, is a critical memory optimization technique in neural network training. It strategically trades increased computation for reduced memory consumption, enabling the training of larger models or the use of larger batch sizes on hardware with limited memory.
Activation recomputation, also known as gradient checkpointing, is a memory optimization technique for training deep neural networks. During the forward pass, it selectively discards (does not store) certain intermediate layer activations in GPU or NPU memory. During the subsequent backward pass, when these discarded activations are required to compute gradients, they are recomputed on-the-fly via a partial re-execution of the forward pass. This creates a fundamental trade-off: it reduces peak memory usage at the cost of increased computational overhead.
For example, in a 100-layer network, a naive implementation stores all 100 layers' activations. With checkpointing, you might store only every 10th layer's activation. To get the activation for layer 95 during the backward pass, the system re-runs the forward pass from the last stored checkpoint (layer 90) up to layer 95.
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
Activation recomputation operates within a broader ecosystem of compiler optimizations designed to maximize hardware efficiency. These related techniques focus on memory, computation, and dataflow transformations.
Memory Planning
A compiler optimization pass that allocates memory buffers for tensors in a computational graph, aiming to minimize peak memory usage. It is the foundational technique that activation recomputation directly complements.
- Objective: Reduce the maximum memory footprint during execution.
- Techniques: Include buffer reuse (aliasing) and in-place operations.
- Relationship to Checkpointing: Memory planning handles static allocation; checkpointing introduces a dynamic trade-off, discarding activations to stay within a planned memory budget.
Graph Fusion
A compiler optimization that merges multiple adjacent operators into a single, compound kernel. This reduces overhead and is often a prerequisite for effective checkpointing.
- Reduces Kernel Launch Overhead: Fewer discrete operations mean less CPU scheduling overhead.
- Minimizes Intermediate Memory: Fused operators pass data via registers or shared memory, not global memory.
- Checkpointing Synergy: Checkpoints are typically placed at the boundaries of fused blocks, as the entire block's intermediate activations are discarded and recomputed as a unit.
Operator Reordering
Changing the execution sequence of independent operators in a graph to improve performance. This can significantly impact the effectiveness of activation recomputation.
- Goal: Improve data locality, enable fusion, or reduce peak memory.
- Impact on Checkpointing: Reordering can create more favorable subgraphs for checkpointing by grouping memory-intensive operations, allowing a single checkpoint to save more memory.
- Example: Moving a large tensor operation closer to its consumer to minimize its lifetime in memory.
Automatic Differentiation (Autodiff)
The compiler technique that generates code to compute derivatives (gradients) from a forward-pass computational graph. Activation recomputation is a memory optimization for the backward pass created by autodiff.
- Forward Mode & Reverse Mode: Reverse-mode autodiff (backpropagation) is standard in deep learning and requires storing intermediate activations for the backward pass.
- The Core Problem: Autodiff creates the need to store activations; recomputation solves the memory bottleneck it introduces.
- Implementation: Modern frameworks (PyTorch, TensorFlow) integrate checkpointing directly into their autodiff engines.
Rematerialization
The general compiler optimization of recomputing a value instead of storing and reloading it. Activation recomputation is a specific, strategic application of rematerialization for neural network training.
- Classical Use: In register-poor architectures, recompute an expression if it's cheaper than spilling to memory.
- In ML Training: The 'value' is a layer's activation tensor. The trade-off is between DRAM storage cost and FLOP recomputation cost.
- Algorithm: Optimal checkpointing strategies solve for the optimal rematerialization schedule across a computational graph.
Static Shape Inference
A compiler analysis that determines the dimensions of all tensors at compile time. This is a critical enabling analysis for planning activation recomputation.
- Prerequisite for Planning: To estimate the memory cost of saving an activation versus recomputing it, the compiler must know the tensor's size.
- Enables Optimization: With known shapes, the compiler can perform cost-benefit analysis to place checkpoints optimally.
- Limitation: Dynamic shapes complicate checkpointing, often requiring conservative heuristics or runtime decisions.

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