Homeglossary

Gradient Checkpointing

Gradient checkpointing is a neural network training technique that reduces GPU memory use by saving only selected intermediate results, called activations, during training. It recreates discarded activations when needed during backpropagation, trading memory savings for additional computation time. This makes it useful when a model, batch size, or input sequence would otherwise exceed available GPU memory.

Build AI-powered apps with Emergent.

What Is Gradient Checkpointing?

Gradient checkpointing is a neural network training technique that reduces GPU memory use by saving selected intermediate results, called activations. During backpropagation, it recreates discarded activations when needed, trading memory savings for extra computation. It is also called activation checkpointing.

Each layer creates activations during the forward pass. The backward pass uses them to calculate gradients and update model weights. Saving every activation can require substantial memory in deep models or with larger batches and sequence lengths.

How Gradient Checkpointing Works During Model Training

Instead of retaining every layer output, training saves planned restore points.

  1. Run the forward pass through the model.
  2. Save activations at selected checkpoint layers.
  3. Discard activations between checkpoints to free GPU memory.
  4. During backpropagation, rerun the needed segment from the nearest saved activation.
  5. Use recreated activations to calculate gradients and update the model.

Recomputation must match the original forward pass. Random operations such as dropout need consistent random-number handling, or gradients may be incorrect.

Gradient Checkpointing vs. Related Memory Techniques

These techniques address different training-memory needs and can often be combined.

TechniqueMain targetTrade-offBest use
Gradient checkpointingActivationsMore computationDeep or long-context models
Model checkpointsTraining recoveryStorage and save timeResuming after interruption
Gradient accumulationBatch memoryMore training stepsSimulating a larger batch
Mixed precisionMany tensorsNumerical careModern GPU training
Activation offloadingGPU activationsData-transfer delayGPU memory is tight
Distributed trainingModel and state memoryMore infrastructureVery large workloads

Benefits of Gradient Checkpointing

Benefits depend on the model architecture and checkpoint placement.

  • Lowers peak activation memory on the same GPU.
  • Can make larger models, longer inputs, or larger batches practical.
  • Works with mixed precision, efficient attention, and accumulation.
  • Lets teams test configurations before moving to larger hardware.

Limits and Performance Trade-Offs

Checkpointing saves memory, not time or cost.

  • Repeated forward computations slow training.
  • Extra GPU work can increase energy and compute cost.
  • It helps less when weights or optimizer states dominate memory.
  • Random layers and custom operations can complicate debugging and reproducibility.

When Should You Enable Gradient Checkpointing?

Use it when activation memory is the constraint, not as a default for every run.

  • Enable it after an out-of-memory error during large-model or long-context training.
  • Consider it for fine-tuning language models on a constrained single GPU.
  • First test mixed precision, a smaller batch, and efficient attention where available.
  • Combine methods when those changes still do not fit the workload in memory.

Using Gradient Checkpointing in AI Application Development

Teams may encounter gradient checkpointing when fine-tuning a custom model or running evaluation workflows. It is one infrastructure choice behind an application, alongside the product work covered in app design and development. Emergent is an agentic platform for building, testing, and shipping AI-powered full-stack applications, including projects created with its AI web app builder. The right configuration depends on the model, data, hardware, and reliability requirements.

Start Building
on Emergent today
Start Building