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

Learning to Optimize Tensor Programs

Tianqi Chen, Lianmin Zheng, Eddie Q. Yan, Ziheng Jiang, Thierry Moreau, Luis Ceze, Carlos Guestrin, Arvind Krishnamurthy

TL;DR

AutoTVM introduces a learning-based framework that automates the performance tuning of deep learning operators across diverse hardware. By using statistical cost models to guide a search through billions of possible program implementations, it achieves performance that rivals or exceeds state-of-the-art hand-tuned libraries like cuDNN, while drastically reducing the engineering effort required to support new chips.

What Problem Does This Paper Address?

Deep learning models rely heavily on "tensor operators"—mathematical building blocks like matrix multiplication and high-dimensional convolutions. To make these run fast, engineers traditionally write hand-optimized libraries (e.g., NVIDIA's cuDNN or Intel's MKL) tailored to specific hardware architectures.

However, this manual approach has three major flaws:

  1. Scalability: Manually tuning code for every new GPU, mobile processor, or AI accelerator is an enormous and unsustainable engineering burden.
  2. Rigidity: Hand-tuned libraries only support a narrow range of standard operators. They struggle to handle "operator fusion" (combining multiple computational steps into one), which is a key technique for speeding up modern neural networks.
  3. Search Complexity: For a single operator, there are billions of ways to order loops, cache memory, and manage threads. Finding the "best" version manually is like finding a needle in a haystack.

Methods

The authors propose AutoTVM, a system that learns how to optimize these programs automatically.

Overview of the AutoTVM framework architecture.

The core components of the framework include:

  • A Rich Search Space: Instead of writing one static implementation, programmers define a space of possible transformations (schedules) like loop tiling, unrolling, and vectorization.
  • Statistical Cost Models: Rather than running every single variant on real hardware (which is prohibitively slow), AutoTVM builds a machine learning model to predict how fast a program will be. They tested two types of models:
  • GBT (Gradient Boosted Trees): Uses domain-specific features extracted from the program's structure, such as memory access patterns and loop characteristics.
  • TreeGRU: A recursive neural network that "reads" the program's abstract syntax tree (AST) to learn its performance characteristics directly from the code structure.
  • Exploration with Simulated Annealing: The system uses the cost model to quickly "screen" millions of candidates. It picks the most promising ones to actually compile, run, and measure on hardware, using the results to continuously update the cost model.
  • Transfer Learning: The framework can take data learned from optimizing one task (e.g., a specific convolution in ResNet) and apply it to a new, similar task, significantly speeding up the search process.

Datasets and Evaluation

The researchers evaluated their framework using representative deep learning workloads and hardware:

  • Workloads: Standard models including ResNet-18, MobileNet, LSTM, Deep Q-Network (DQN), and DCGAN.
  • Hardware Targets: NVIDIA TITAN X (server-class GPU), ARM Cortex-A53 (low-power embedded CPU), and ARM Mali-T860 (mobile GPU).
  • Baselines: They compared against top-tier libraries: cuDNN v7, TensorFlow Lite, and the ARM Compute Library.

Key Insights and Ideas

  • Learning Beats Black-Box Search: The statistical cost models allowed the system to find optimal implementations significantly faster than traditional "black-box" methods like genetic algorithms or random search.
Comparison of optimization methods over number of trials.
  • Relative Rank Matters More Than Absolute Time: The authors found that training the model to predict the relative order of program speeds (Rank Loss) was more effective than trying to predict the exact execution time in milliseconds.
  • The Power of Invariance: By using the low-level AST as a representation, the model learns features that are "transferable." A model trained on one set of convolutions can provide a "warm start" for a completely different operator, accelerating optimization by $2\times$ to $10\times$.
  • Unlocking Fusion: Because AutoTVM is automated, it can optimize custom "fused" operators that don't exist in manual libraries, leading to significant end-to-end system speedups.

Key Results

  • End-to-End Speedup: AutoTVM improved total model performance by $1.2\times$ to $3.8\times$ over existing frameworks like MXNet and TensorFlow.
  • Hardware Versatility: It delivered performance competitive with (and sometimes better than) NVIDIA’s cuDNN on GPUs and ARM’s own optimized libraries on mobile hardware.
  • Efficiency: Through transfer learning, the system could find near-optimal configurations for new workloads in a fraction of the time required for a "from-scratch" search.

Limitations and Future Work

  • Search Space Definition: While the search is automated, the search space (the set of possible transformations) is still manually defined by experts. Automating the generation of this space is a logical next step.
  • Uncertainty Estimation: The authors noted that standard Bayesian optimization techniques (like using Expected Improvement) didn't provide a significant boost in this specific domain, suggesting that the choice of "acquisition function" for program optimization needs more research.
  • Broader Hardware: While they covered CPUs and GPUs, extending this to specialized AI accelerators (TPUs, NPUs) remains an area for future exploration.

Summary updated

BibTeX
@inproceedings{chen2018learning,
  author = {Tianqi Chen and Lianmin Zheng and Eddie Q. Yan and Ziheng Jiang and Thierry Moreau and Luis Ceze and Carlos Guestrin and Arvind Krishnamurthy},
  title = {{Learning to Optimize Tensor Programs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=Hy-IlOZ_ZH},
}
Figure