NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Device Placement Optimization with Reinforcement Learning

Azalia Mirhoseini, Hieu Pham, Quoc V. Le, Benoit Steiner, Rasmus Larsen, Yuefeng Zhou, Naveen Kumar, Mohammad Norouzi, Samy Bengio, Jeff Dean

As deep learning models grow in size and complexity, they frequently exceed the memory and computational limits of a single device. To train these massive models, researchers rely on heterogeneous distributed environments—clusters containing a mix of CPUs and various GPUs.

The core challenge in these environments is device placement: deciding which specific operation (e.g., a matrix multiplication or a convolution) should run on which hardware device. Traditionally, human experts rely on simple heuristics, such as placing an entire layer on a single GPU. However, as models become more complex with intricate dependencies (like Neural Machine Translation) or branching architectures (like Inception), human intuition struggles. It fails to account for hardware-specific nuances like PCIe bus contention, memory bandwidth, and communication overhead. Existing algorithmic solvers also fall short, often relying on oversimplified mathematical models that do not reflect real-world performance.

This paper introduces a Reinforcement Learning (RL) approach to automatically distribute neural network operations across a mix of devices. By using a sequence-to-sequence model to predict placements and leveraging actual execution time as a reward signal, the system discovers non-intuitive configurations that outperform human-designed heuristics by up to 20%.

Learning to Place with Reinforcement Learning

The authors propose an RL-based framework that learns the optimal placement through trial and error on actual hardware.

The Policy Model

The core of the system is a sequence-to-sequence (seq2seq) model equipped with an attention mechanism.

Seq2Seq Policy Model
  • Encoder: The model takes a sequence of operations from a computational graph (like a TensorFlow graph) as input. Each operation is represented by an embedding that captures its type (e.g., MatMul), output shapes, and adjacency information.
  • Decoder: The decoder then predicts the device assignment for each operation group sequentially.

Optimization and Reward Signal

Unlike previous methods that use proxy metrics or static cost models, the "reward" for this RL agent is based on the square root of the actual execution time (wall-clock time) of the predicted placement. This ensures the model optimizes for what truly matters: speed. The model parameters are updated using the REINFORCE algorithm, aiming to minimize the expected execution time.

To handle modern graphs with tens of thousands of operations, the authors use co-location heuristics to group related operations (e.g., an operation and its gradients). This reduces the decision space from thousands of individual operations to hundreds of groups. Furthermore, to accelerate the search, they employ a distributed setup with multiple controllers and workers that sample and test placements asynchronously.

Key Insights and Performance Gains

The method was evaluated on three major deep learning architectures: an RNN Language Model (RNNLM), Neural Machine Translation (NMT), and Inception-V3. The hardware environment consisted of a single machine with one Intel Haswell CPU and either 2 or 4 Nvidia Tesla K80 GPUs.

Discovering Non-Intuitive Parallelism

Because the RL agent relies on real-world feedback, it can discover hidden hardware bottlenecks and devise placements that humans would rarely consider.

NMT Device Placement

For example, in Neural Machine Translation, the RL agent learned to offload computationally "cheap" but memory-intensive operations (like embedding lookups) to the CPU, keeping the GPUs free for heavy matrix math. It also discovered a way to balance the workload across four GPUs that accounted for both the forward and backward passes, leading to a much more even distribution of labor than the standard "one layer per GPU" approach.

Benchmark Results

The RL-based placements consistently outperformed both human experts and traditional algorithmic solvers:

  • Neural Machine Translation (NMT): Achieved a 20.6% speedup over the best human-designed placement on 4 GPUs.
  • Inception-V3: Achieved a 19.0% speedup over the standard data-parallel approach on 4 GPUs.
  • RNNLM: The RL agent correctly identified that putting everything on a single GPU was the fastest configuration to avoid communication overhead, matching the best possible human decision.
  • Vs. Traditional Solvers: Algorithmic solvers like Scotch often produced placements that were up to 3x slower than the RL-based ones because they failed to accurately model inter-device communication costs.

Additionally, the authors utilized a "failing signal." Since many random placements simply fail (e.g., due to out-of-memory errors), they assigned a high constant penalty to these failures. This helped the model quickly learn to avoid invalid configurations early in training.

Limitations and Future Work

While highly effective, the approach has a few limitations:

  • Search Time: Finding the optimal placement is computationally expensive, taking between 12 to 27 hours of RL training for a single model. This makes the approach most suitable for models that will be trained for weeks or deployed at a massive scale where the upfront cost pays off.
  • Generalization: The current model is trained for a specific computational graph. Significant changes to the model architecture require re-running the RL search. Future work could explore "transfer learning" to adapt placements across different architectures.
  • Static Graphs: The approach assumes a static graph structure and does not yet account for dynamic graphs where the number of operations might change per input.

Summary updated

BibTeX
@inproceedings{mirhoseini2017device,
  author = {Azalia Mirhoseini and Hieu Pham and Quoc V. Le and Benoit Steiner and Rasmus Larsen and Yuefeng Zhou and Naveen Kumar and Mohammad Norouzi and Samy Bengio and Jeff Dean},
  title = {{Device Placement Optimization with Reinforcement Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2017},
  url = {https://openreview.net/forum?id=SkEx9jWdWr},
}
Figure