What is Gradient checkpointing?
Storing only some intermediate forward results and recomputing the rest during backpropagation, trading extra computation for less memory.
Japanese name: 勾配チェックポイント
Storing only some intermediate forward results and recomputing the rest during backpropagation, trading extra computation for less memory.
Japanese name: 勾配チェックポイント
When backpropagation computes the gradient of each layer, it uses the intermediate result that layer produced in the forward pass. These intermediate results are called activations. Ordinary training stores the activations of all layers until backpropagation finishes. Their amount grows in proportion to the number of layers and the batch size. In inference an activation can be discarded once it has been used, but in training it cannot. Gradient checkpointing is a way to cut down this storage.
The model is divided into several segments, and only the results at the segment boundaries are stored. The stored points are called checkpoints. When backpropagation reaches a segment, the forward pass is rerun from the checkpoint just before it. The activations inside the segment are rebuilt, and discarded once the gradients have been computed. Suppose 16 layers are divided into 4 segments of 4 layers each. What is held is the 4 boundaries plus roughly 4 layers' worth for the segment being computed. That is about half of what storing all 16 layers would take.
Each layer is recomputed at most once, so the added computation is about one forward pass. Memory falls, but each training step becomes slower by that amount. It is used when memory is short and a large model or a large batch would not otherwise fit. The gradients obtained are the same as when everything is stored. This assumes, however, that the recomputation gives the same result as the first forward pass. Operations that use random numbers have to be handled so that the same values can be reproduced.
Answer: A. Store only some intermediate forward results and recompute the rest when needed during backpropagation, trading extra computation for less memory
Backpropagation needs each layer's intermediate forward results, but storing them all makes memory grow with layer count and batch size. Gradient checkpointing stores results only every few layers, and when backpropagation reaches a segment it reruns the forward pass from the saved point to regenerate the needed values. At the cost of roughly one extra forward pass, activation memory is greatly reduced.
No, that is a different thing. That kind of checkpoint means saving the weights and other state to a file so that training can be resumed. Gradient checkpointing is a way to save activation memory within a single backward pass.
No. Inference is only a forward pass, and there is no need to store activations for backpropagation. Gradient checkpointing is a method for reducing the memory of training.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.