HackerPapers

arXiv:2101.04808cs.PL

MLGO: a Machine Learning Guided Compiler Optimizations Framework

Mircea Trofin, Yundi Qian, Eugene Brevdo, Zinan Lin, Krzysztof Choromanski, David Li

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

arXiv comments
First two authors are equal contributors
Journal reference
DOI
Subjects
cs.PLProgramming Languages cs.LGMachine Learning

On Hacker News

Linked by 2 identifiable commenters in 4 comments across 3 threads, from Aug 2023 to Jun 2024. Found in 1 HN submission from Aug 2023 to Aug 2023. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments3 threads

    • I would not say we are anywhere close to perfect in compilation. Even just looking at inlining for size, there are multiple recent studies showing ~10+% improvement (https://dl.acm.org/doi/abs/10.1145/3503222.3507744, https://arxiv.org/abs/2101.04808). There is a massive amount…

      boomanaiden154View on HNParent context

    • For function inlining specifically, I'm not sure LLMs are necessarily the right choice. The original MLGO paper [1] demonstrated a big code-size improvement with a ML model for making inlining decisions (7-20% code size wins), but they used tens of engineered features. Maybe a…

      boomanaiden154View on HNParent context

    • What's the benefit of having an LLM do those things in a way that guesstimates? There are big wins to be had in code-size and some wins to be had in performance related to inlining [1][2], but I think the implementation in the references directly tied into the compiler's…

      boomanaiden154View on HNParent context

    • There is a fair amount of academic research on this topic. Eg, MLGO[1], but I don't know of any being used for production work. 1. https://arxiv.org/pdf/2101.04808.pdf

      compiler-guyView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.