HackerPapers

arXiv:2309.07062cs.PL

Large Language Models for Compiler Optimization

Chris Cummins, Volker Seeker, Dejan Grubisic, Mostafa Elhoushi, Youwei Liang, Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Kim Hazelwood, Gabriel Synnaeve, Hugh Leather

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

Abstract

We explore the novel application of Large Language Models to code optimization. We present a 7B-parameter transformer model trained from scratch to optimize LLVM assembly for code size. The model takes as input unoptimized assembly and outputs a list of compiler options to best optimize the program. Crucially, during training, we ask the model to predict the instruction counts before and after optimization, and the optimized code itself. These auxiliary learning tasks significantly improve the optimization performance of the model and improve the model's depth of understanding. We evaluate on a large suite of test programs. Our approach achieves a 3.0% improvement in reducing instruction counts over the compiler, outperforming two state-of-the-art baselines that require thousands of compilations. Furthermore, the model shows surprisingly strong code reasoning abilities, generating compilable code 91% of the time and perfectly emulating the output of the compiler 70% of the time.

arXiv comments
Journal reference
DOI
Subjects
cs.PLProgramming Languages cs.AIArtificial Intelligence cs.CLComputation and Language cs.LGMachine Learning

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Jun 2024 to Jun 2024. Found in 3 HN submissions from Sep 2023 to Sep 2023. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments1 thread

    • There are similarities to the approach in this paper (though they trained a model from scratch): https://arxiv.org/pdf/2309.07062 How well would an LLM trained with a huge number of examples do on this test? Essentially with enough attention, Goodhart's law will take over.

      ec109685View on HNParent context

Submitted to Hacker News

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