Checkmate: Breaking the Memory Wall with Optimal Tensor Rematerialization

Paras Jain, Ajay Jain, Aniruddha Nrusimha, Amir Gholami, Pieter Abbeel, Kurt Keutzer, Ion Stoica, Joseph GonzalezMLSys 2019

Abstract

Checkmate is a system designed to overcome the "memory wall" in deep learning training by optimally trading off computation for memory. By formalizing tensor rematerialization as a Mixed Integer Linear Program (MILP), Checkmate automatically generates training schedules that support significantly larger batch sizes and input resolutions with minimal computational overhead.

The Memory Wall in Deep Learning

Training state-of-the-art Deep Neural Networks (DNNs) is increasingly bottlenecked by the "memory wall"—the limited capacity of high-bandwidth memory on GPUs and TPUs. While model parameters are often small, the intermediate activation tensors generated during the forward pass (and required for backpropagation) can consume tens of gigabytes.

Comparison of RAM usage between retaining all activations and rematerialization.

When these activations exceed available RAM, researchers are forced to use smaller batch sizes, which can hurt model convergence and hardware efficiency, or lower-resolution inputs. Prior solutions, often called "checkpointing," used simple heuristics to discard and recompute some activations. However, these heuristics typically only work for simple linear chains of layers and fail on modern architectures with complex skip connections, such as ResNets or U-Nets.

Methods: Optimal Rematerialization

Checkmate treats rematerialization as a constrained optimization problem, moving beyond simple heuristics to find the mathematically optimal schedule for a given memory budget.

The Checkmate system workflow from architecture specification to optimized training.
  1. MILP Formalization: The system represents the training schedule as a Mixed Integer Linear Program. The objective is to minimize total computation time subject to a hard memory limit. Unlike prior work, this model supports arbitrary Directed Acyclic Graphs (DAGs).
  2. Hardware-Aware Cost Modeling: Checkmate profiles the actual execution time and memory footprint of each operation on the target hardware. This is crucial because, in architectures like VGG19, the most expensive layer can be six orders of magnitude more costly to compute than the cheapest.
  3. Optimization Efficiency: To make the optimization tractable for deep networks, the authors introduce "frontier-advancing stages" to partition the search space. For extremely large graphs, a two-phase rounding approximation solves a relaxed Linear Program (LP) to produce valid, near-optimal schedules in seconds.

Key Results and Insights

Checkmate was evaluated across a diverse suite of architectures, including VGG, ResNet, MobileNet, U-Net, and Transformers. The evaluation focused on the memory-to-overhead tradeoff, as the rematerialization logic is independent of specific data values.

  • Increased Batch Size: Checkmate enabled training with 5.1× larger batch sizes for MobileNet and 3.8× larger for U-Net compared to standard training.
  • Lower Overhead: On a U-Net architecture with a 16GB memory budget, Checkmate achieved a 1.2× speedup over the best existing baseline (linearized greedy) and a 1.38× speedup over the common √n heuristic.
  • Practicality: For most standard models, Checkmate finds the optimal schedule in under a minute. Because DNN training is highly repetitive, spending this time upfront pays for itself quickly over days of training.

Limitations and Future Work

Checkmate currently targets static computation graphs, such as those in TensorFlow or compiled PyTorch. Adapting this to purely "eager" execution environments where the graph changes dynamically remains a challenge. Additionally, while the current model assumes a simplified memory pool, future iterations could account for hardware memory fragmentation or extend to handle distributed training and CPU-GPU offloading.

Summary updated

BibTeX
@misc{jain2019checkmate,
  author = {Paras Jain and Ajay Jain and Aniruddha Nrusimha and Amir Gholami and Pieter Abbeel and Kurt Keutzer and Ion Stoica and Joseph Gonzalez},
  title = {{Checkmate: Breaking the Memory Wall with Optimal Tensor Rematerialization}},
  year = {2019},
  eprint = {1910.02653},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.02653},
}
Figure