arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.07062cs.PLcs.AIcs.CLcs.LG
收藏

Large Language Models 用于编译器优化

Large Language Models for Compiler Optimization

Meta AI;UC San Diego(加州大学圣地亚哥分校)

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

AI总结:

研究提出从零训练的 7B 参数 transformer 模型,通过预测指令计数和优化代码等辅助任务优化 LLVM assembly,在减少指令计数上超越基线 3.0%,展现出强大的代码推理能力。

摘要:

我们探索了 Large Language Models 在代码优化中的新颖应用。我们提出了一个 7B 参数的 transformer 模型,从零开始训练以针对代码大小优化 LLVM assembly。该模型以未优化的 assembly 作为输入,并输出编译器选项列表以最佳地优化程序。关键在于,在训练期间,我们要求模型预测优化前后的指令计数以及优化后的代码本身。这些辅助学习任务显著提升了模型的优化性能,并加深了模型的理解深度。我们在大量测试程序套件上进行了评估。我们的方法在减少指令计数方面比编译器提升了 3.0%,优于需要数千次编译的两个 state-of-the-art 基线。此外,该模型展现出惊人的代码推理能力,91% 的情况下生成可编译代码,70% 的情况下完美模拟编译器的输出。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑