MLGO: a Machine Learning Guided Compiler Optimizations Framework

Mircea Trofin, Yundi Qian, Eugene Brevdo, Zinan Lin, Krzysztof Choromanski +1 more
1/13/2021
cs.PLcs.LG

Official code: google/ml-compiler-opt (807 stars, Python, Apache-2.0, last commit 2026-11-16).

Abstract

Leveraging machine-learning (ML) techniques for compiler optimizations has been widely studied and explored in academia. However, the adoption of ML in general-purpose, industry strength compilers has yet to happen.

Show full abstract

We propose MLGO, a framework for integrating ML techniques systematically in an industrial compiler -- LLVM. As a case study, we present the details and results of replacing the heuristics-based inlining-for-size optimization in LLVM with machine learned models. To the best of our knowledge, this work is the first full integration of ML in a complex compiler pass in a real-world setting. It is available in the main LLVM repository. We use two different ML algorithms: Policy Gradient and Evolution Strategies, to train the inlining-for-size model, and achieve up to 7\% size reduction, when compared to state of the art LLVM -Oz. The same model, trained on one corpus, generalizes well to a diversity of real-world targets, as well as to the same set of targets after months of active development. This property of the trained models is beneficial to deploy ML techniques in real-world settings.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Infrastructure for Machine Learning Guided Optimization (MLGO) in LLVM.

807127Python, ShellMay 28, 20202 weeks agoApache-2.0

Similar Papers

Cite this paper

@article{trofin2021mlgo,
  title  = {MLGO: a Machine Learning Guided Compiler Optimizations Framework},
  author = {Mircea Trofin and Yundi Qian and Eugene Brevdo and Zinan Lin and Krzysztof Choromanski and David Li},
  year   = {2021},
  eprint = {2101.04808},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2101.04808}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2101.04808.svg)](https://codeofpaper.com/paper/2101.04808)

Discussion