ProTuner: Tuning Programs with Monte Carlo Tree Search

Ameer Haj-Ali, Hasan Genc, Qijing Huang, William S. Moses, John Wawrzynek, Krste Asanovic, Ion StoicaarXiv 2020

Abstract

Finding optimal schedules for high-performance programs is a complex combinatorial challenge. ProTuner introduces a novel approach using Monte Carlo Tree Search (MCTS) to replace traditional greedy search methods. By leveraging look-ahead evaluations and a learned cost model, ProTuner achieves significant performance gains across a wide range of benchmarks.

Introduction

In high-performance computing, the separation of algorithm and schedule—popularized by languages like Halide—allows developers to optimize code for specific hardware without changing the underlying logic. However, the search space for an optimal schedule (encompassing tiling, vectorization, and threading) is enormous. Traditional auto-schedulers rely on beam search guided by learned cost models, but these methods often fall into local optima due to their greedy nature and the inaccuracy of cost models on partial programs.

Methodology: MCTS for Program Tuning

ProTuner addresses these limitations by formulating the scheduling problem as a Markov Decision Process (MDP) and employing Monte Carlo Tree Search (MCTS).

The ProTuner architecture integrates MCTS with a learned cost model to navigate the complex schedule search space.

The core innovation lies in Look-ahead Evaluation. Unlike beam search, which evaluates incomplete program states, MCTS performs "rollouts" to reach terminal states—fully scheduled programs. This allows the learned cost model to evaluate complete code, where its predictions are significantly more accurate. To balance the search, ProTuner uses the Upper Confidence Bound (UCB) formula, ensuring a healthy mix of exploration (trying new paths) and exploitation (refining known good schedules).

Evaluation and Benchmarks

The system was evaluated against 16 real-world benchmarks, including:

  • Image Processing: bilateral_grid, nl_means, lens_blur, harris, max_filter, unsharp, interpolate, iir_blur, and bgu.
  • Deep Learning & Linear Algebra: resnet50, conv_layer, and mat_mul.
  • General Stencils: stencil_chain.

Key Results and Insights

ProTuner consistently outperformed state-of-the-art beam search methods. Across the benchmark suite, it achieved a geometric mean execution time improvement of 1.06x to 1.36x.

Performance speedups across the 16 evaluated benchmarks, comparing different search strategies.

Notable results include:

  • Peak Performance: A maximum speedup of 3.25x was observed in the interpolate benchmark.
  • Search Resilience: MCTS proved more resilient to cost model noise by focusing on long-term expected rewards rather than immediate, potentially misleading gains.
  • Efficiency: By utilizing random rollouts, ProTuner reduces the overhead of feature computation, which previously accounted for 92% of the overhead in beam-based systems, allowing for more extensive exploration of the search space.

Conclusion and Future Directions

ProTuner demonstrates that MCTS is a powerful alternative to greedy search for program optimization. By focusing on "meaningful" (complete) programs during the search process, it bridges the gap between theoretical models and actual hardware performance. Future work includes expanding the search space to include more complex optimizations and targeting a wider variety of hardware, such as GPUs and specialized AI accelerators.

Summary updated

BibTeX
@misc{hajali2020protuner,
  author = {Ameer Haj-Ali and Hasan Genc and Qijing Huang and William S. Moses and John Wawrzynek and Krste Asanovic and Ion Stoica},
  title = {{ProTuner: Tuning Programs with Monte Carlo Tree Search}},
  year = {2020},
  eprint = {2005.13685},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2005.13685},
}
Figure