Abstract
Training large-scale neural networks is often constrained by GPU memory limits. Gradient Checkpointing (GCP) offers a solution by trading computation for memory, but existing methods are largely limited to simple linear architectures. This paper presents the first algorithm capable of finding mathematically optimal gradient checkpoints for any neural network architecture, including complex, non-linear Arbitrary Computation Graphs (ACGs). By decomposing networks into independent segments, the proposed method achieves up to 80% memory reduction with a manageable 30-50% increase in training time.
Introduction
As Deep Neural Networks (DNNs) grow in depth and complexity, training them on standard hardware becomes increasingly difficult. During the forward pass, intermediate activations must be stored in VRAM to compute gradients during the backward pass. For high-resolution images or massive models, this memory requirement often exceeds the physical capacity of modern GPUs.
Gradient Checkpointing (GCP) is a strategy to mitigate this by storing only a subset of intermediate tensors (checkpoints) and recomputing the missing ones as needed. However, selecting which tensors to checkpoint has historically relied on manual selection or heuristics (like the $\sqrt{N}$ rule) that fail on modern, heterogeneous architectures like ResNet or NAS-generated models. This work introduces a systematic, optimal approach for Arbitrary Computation Graphs (ACGs).
The Memory-Computation Trade-off
In regular training, every intermediate state is stored, leading to high memory consumption. The proposed optimal search identifies specific "checkpoints" to store, while others are discarded and re-generated via a "re-forward" pass during backpropagation.
Methodology: Solving for Arbitrary Graphs
The core innovation of this paper is the ability to handle non-linear graphs. The authors define Independent Segments (IS)—subgraphs that can be recomputed in isolation. They prove that any complex graph can be uniquely decomposed into a "Division Tree" consisting of three segment types:
- Linear IS: Simple chains of layers.
- Branch IS: Segments with parallel paths that merge.
- Complicate IS: Highly interconnected subgraphs.
By treating checkpoint selection as a shortest-path problem on an "Accessibility Graph" derived from this Division Tree, the algorithm finds the exact set of checkpoints that minimizes peak memory usage. This search is performed once as a pre-processing step, ensuring no overhead during the actual training iterations.
Experimental Results
The method was evaluated on a diverse set of architectures, ranging from classic linear models (VGG) to complex NAS graphs (AmoebaNet, DARTS).
- Memory Efficiency: The algorithm achieved an 81% memory reduction for ResNet152 and an 85% reduction for DenseNet201.
- Scalability: On a standard 4x RTX 2080Ti setup, the method enabled training ResNet50 with a batch size of 512, doubling the capacity of standard training (256).
- Performance Overhead: The time cost for recomputation typically ranged between 30% and 50%. While this increases total training time, it provides a critical pathway for training models that would otherwise be impossible to fit on available hardware.
Conclusion and Future Work
This research provides the first top-down framework for optimal memory management in non-linear neural networks. By accounting for the heterogeneous memory costs of different layer types (e.g., convolutions vs. pooling), it consistently outperforms previous state-of-the-art heuristics. Future extensions may include optimizing for a specific memory budget (e.g., "fit within 8GB at maximum speed") and integrating with lower-level memory management techniques like CPU/GPU swapping.
Summary updated