about
MLGO: A Machine Learning Guided Compiler Optimizations Framework (2021) (arxiv.org)
1 point by compiler-guy on Aug 1, 2023 | hide | past | pdf | discuss on HN

In plain words: It swaps the compiler's hand-written rules for deciding which functions to merge (inline) and shrink program size with a machine-learned model. Built into LLVM, it cut code size up to 7% versus the best hand-tuned settings, and kept working on new codebases months later.

Abstract · MLGO: a Machine Learning Guided Compiler Optimizations Framework

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. 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.

Mircea Trofin, Yundi Qian, Eugene Brevdo, Zinan Lin, Krzysztof Choromanski, David Li
arXiv:2101.04808 · cs.PL, cs.LG · submitted Jan 13, 2021
abstract · pdf · html · First two authors are equal contributors

add comment on HN