[2309.07062] Large Language Models for Compiler Optimization
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.
Authors:Chris Cummins, Volker Seeker, Dejan Grubisic, Mostafa Elhoushi, Youwei Liang, Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Kim Hazelwood, Gabriel Synnaeve, Hugh Leather View PDF HTML (experimental) 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…
saved by
related reading
- A friendly introduction to machine learning compilers and optimizershuyenchip.com
- Composer2.pdfcursor.com
- Productizing Large Language Modelsblog.replit.com
- Planning with Large Language Models for Code Generationcodeaimcts.github.io
- Can LLMs Be Computers?percepta.ai
- Chinchillaarxiv.org
- Program Synthesis with Large Language Modelsarxiv.org
- Getting Caught Up to Modern LLM Research | Samarth Goeldev.samarthgoel.com
- Pathways Language Model (PaLM): Scaling to 540 Billion Parameters for Breakthrouai.googleblog.com
- Large Language Models Reading List | Sebastian Raschka, PhDsebastianraschka.com
- Transformers Inference Optimization Toolset | AstraBlogastralord.github.io
- Optimizing inference · Hugging Facehuggingface.co