DistIR: An Intermediate Representation and Simulator for Efficient Neural Network Distribution

Keshav Santhanam, Siddharth Krishna, Ryota Tomioka, Tim Harris, Matei ZahariaarXiv 2021

Abstract

The rapidly growing size of deep neural network (DNN) models and datasets has given rise to a variety of distribution strategies such as data, tensor-model, pipeline parallelism, and hybrid combinations thereof. Each of these strategies offers its own trade-offs and exhibits optimal performance across different models and hardware topologies. Selecting the best set of strategies for a given setup is challenging because the search space grows combinatorially, and debugging and testing on clusters is expensive. In this work we propose DistIR, an expressive intermediate representation for distributed DNN computation that is tailored for efficient analyses, such as simulation. This enables automatically identifying the top-performing strategies without having to execute on physical hardware. Unlike prior work, DistIR can naturally express many distribution strategies including pipeline parallelism with arbitrary schedules. Our evaluation on MLP training and GPT-2 inference models demonstrates how DistIR and its simulator enable fast grid searches over complex distribution spaces spanning up to 1000+ configurations, reducing optimization time by an order of magnitude for certain regimes.

Introduction

As deep learning models like GPT-3 grow to hundreds of billions of parameters, they no longer fit on a single GPU. To train or run inference on these models, engineers must use various distribution strategies, including Data Parallelism (splitting data across devices), Tensor Parallelism (splitting individual layers across devices), and Pipeline Parallelism (splitting the model into stages that process micro-batches in sequence).

The challenge lies in the "combinatorial explosion" of combining these strategies into a massive D/T/P (Data/Tensor/Pipeline) search space. Finding the optimal configuration for specific hardware (e.g., an NVIDIA DGX node) typically requires expensive trial-and-error on real clusters. Existing tools often lack the expressiveness to represent complex schedules or are too slow to simulate thousands of potential configurations accurately.

The DistIR Framework

The authors introduce DistIR, an expressive, SSA-based (Static Single Assignment) intermediate representation specifically tailored for distributed computing.

The DistIR system architecture, showing the flow from a standard computation graph to per-rank programs via the DistIR representation and search-based simulator.

DistIR differs from standard computation graphs (like ONNX) by using an ordered list of operations, making it easier to simulate device occupancy. It assumes synchronous semantics across participating devices to simplify communication modeling. A key technical feature is its mixed abstract/concrete interpretation: the simulator tracks both tensor shapes (abstract) and specific values (concrete) simultaneously to resolve dynamic dependencies (like Reshape ops) without executing heavy computations. The simulator's cost model combines analytic math for simple operations with empirical linear regression models for complex operations like MatMul and AllReduce, calibrated to the target hardware.

Evaluation and Key Insights

The framework was evaluated on an NVIDIA DGX-2 node using MLP training (1B to 103B parameters) and GPT-2 inference (up to 175B parameters) workloads. The search space included over 1,000 configurations per model.

A critical insight is that for optimization, ranking is more important than absolute accuracy. DistIR achieves a Spearman correlation of 0.84 to 0.99, meaning its predicted performance rankings match real-world results very closely. Furthermore, the results demonstrate that common heuristics—such as always maximizing tensor parallelism—are not always optimal. In some regimes, activation memory dominates, making hybrid configurations (D/T/P) the most efficient.

Key Results

DistIR provides a massive speedup in optimization. For a 1B parameter MLP, a real-world grid search would take 150 minutes. DistIR found the optimal strategy in just 20 minutes—a 7.5x speedup—by simulating over 1,000 configurations on a single CPU and only running the top 10 candidates on real hardware.

Throughput vs. Peak Memory for various MLP model sizes and distribution strategies. The plots illustrate the complex trade-offs between different parallelism types (D, T, P, and hybrids).

As shown in the performance plots, different model sizes and batch sizes favor different distribution strategies. DistIR successfully navigates this trade-off space, identifying high-throughput configurations that stay within memory limits. The simulator's performance scales linearly with the number of operations, ensuring viability for future, even larger models.

Limitations and Future Work

Currently, DistIR assumes synchronous operations, which limits its ability to model fine-grained overlapping of computation and communication (e.g., double buffering). Additionally, it predicts peak memory based on tensor shapes but does not account for framework-level memory fragmentation. Future work includes integrating DistIR with frameworks like DeepSpeed and exploring advanced search algorithms such as MCMC or Reinforcement Learning.

Summary updated

BibTeX
@misc{santhanam2021distir,
  author = {Keshav Santhanam and Siddharth Krishna and Ryota Tomioka and Tim Harris and Matei Zaharia},
  title = {{DistIR: An Intermediate Representation and Simulator for Efficient Neural Network Distribution}},
  year = {2021},
  eprint = {2111.05426},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.05426},
}
Figure