New Tools for Peak Memory Scheduling

Ce Jin, Manish Purohit, Zoya Svitkina, Erik Vee, Joshua R. WangarXiv 2023 · DOI

Abstract

Minimizing peak memory usage is a critical challenge for deploying large-scale deep learning models on resource-constrained hardware. This paper introduces the "dominant schedule" framework, proving that for any Directed Acyclic Graph (DAG), there exists a schedule that is memory-optimal at every execution step. We leverage this to develop a fixed-parameter tractable (FPT) algorithm for series-parallel graphs. Conversely, we demonstrate that even simple structures like out-trees and "pumpkin" graphs are NP-hard to schedule optimally, highlighting the inherent complexity of the problem.

Introduction

As deep learning models continue to scale, fitting them into the limited memory of hardware—particularly mobile and edge devices—has become a significant bottleneck. This problem is often modeled as scheduling a Directed Acyclic Graph (DAG) to minimize peak memory consumption, a variant of the classical "one-shot black pebbling game." While finding an optimal schedule is NP-hard for general graphs, machine learning computation graphs often exhibit recursive, structured properties. This work seeks to exploit these structures to find exact solutions more efficiently than previous general-purpose methods.

The Node Sum Model and Dominant Schedules

To analyze memory usage mathematically, the authors employ a "node sum" model. In this model, each node is assigned a weight: positive weights represent memory allocation, while negative weights represent memory freed when data is no longer required.

Example of a computation graph in the node sum model.

A central contribution of this work is the definition of a dominant schedule. Unlike a standard optimal schedule that merely minimizes the global peak, a dominant schedule consumes less or equal memory than any other schedule at every single step of execution. The authors prove that such a schedule exists for any DAG (Theorem 3.1), a non-trivial result that suggests memory-optimal scheduling does not require trading off peak memory for lower "valleys" elsewhere in the execution.

Algorithmic Approaches for Structured Graphs

The paper introduces "linearization," a recursive technique where complex, isolated subgraphs are replaced by single directed paths representing their dominant schedules. This allows for the simplification of graphs piece-by-piece without losing the path to a global optimum. For Series-Parallel (SP) graphs—a class common in ML architectures—the authors design an FPT algorithm with a runtime of $2^{O(d \log d)} \cdot \text{poly}(n)$, where $d$ is the maximum out-degree. For simpler "pumpkin" graphs (parallel chains), the complexity is further reduced to $O(2^d \cdot \text{poly}(n))$.

Complexity and Hardness Results

Despite the positive results for SP graphs, the paper establishes strong hardness boundaries. It proves that minimizing peak memory is strongly NP-complete even for highly restricted cases, such as out-trees and pumpkin graphs. These results justify the exponential dependence on out-degree ($d$) in the proposed algorithms, as $d$ appears to be a fundamental driver of complexity. Additionally, the authors show that if an "oracle" exists to find a peak-minimizing schedule, a dominant schedule can be found using only a linear number of calls to that oracle.

Discussion and Future Work

While this work provides powerful new tools for memory scheduling, several challenges remain. The current FPT algorithms are sensitive to nodes with high out-degrees (e.g., broadcast nodes). Furthermore, most real-world ML graphs are "nearly" series-parallel, containing a few "cross-edges" that break the formal definition; these may require heuristic extensions. Finally, the focus on "one-shot" pebbling does not account for "rematerialization"—the re-computation of nodes to save memory—which is a common technique in actual ML frameworks like PyTorch or JAX.

Summary updated

BibTeX
@misc{jin2023new,
  author = {Ce Jin and Manish Purohit and Zoya Svitkina and Erik Vee and Joshua R. Wang},
  title = {{New Tools for Peak Memory Scheduling}},
  year = {2023},
  eprint = {2312.13526},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.13526},
}
Figure