大規模言語モデルを用いたアセンブリコードの性能向上:強化学習によるアプローチ
Improving Assembly Code Performance with Large Language Models via Reinforcement Learning
May 16, 2025
著者: Anjiang Wei, Tarun Suresh, Huanmi Tan, Yinglun Xu, Gagandeep Singh, Ke Wang, Alex Aiken
cs.AI
要旨
大規模言語モデル(LLM)は、幅広いプログラミングタスクにおいて優れた性能を発揮しているが、コード最適化における可能性はまだ十分に探求されていない。本研究では、LLMがアセンブリコードの性能を最適化できるかどうかを調査する。アセンブリコードでは、実行に対するきめ細かい制御が可能であり、高級言語では表現が難しい改善が実現できる。本論文では、Proximal Policy Optimization(PPO)を用いてLLMを訓練する強化学習フレームワークを提案する。このフレームワークでは、テストケースを通じて検証される機能的正確性と、業界標準コンパイラであるgcc -O3に対する実行性能の両方を考慮した報酬関数がガイドとして使用される。本研究を支援するため、8,072の実世界のプログラムからなるベンチマークを導入した。我々のモデル、Qwen2.5-Coder-7B-PPOは、96.0%のテスト合格率と、gcc -O3ベースラインに対して平均1.47倍の高速化を達成し、Claude-3.7-sonnetを含む他の20のモデルを全て上回った。これらの結果は、強化学習がLLMの潜在能力を引き出し、アセンブリコードの性能を効果的に最適化するツールとして活用できることを示している。
English
Large language models (LLMs) have demonstrated strong performance across a
wide range of programming tasks, yet their potential for code optimization
remains underexplored. This work investigates whether LLMs can optimize the
performance of assembly code, where fine-grained control over execution enables
improvements that are difficult to express in high-level languages. We present
a reinforcement learning framework that trains LLMs using Proximal Policy
Optimization (PPO), guided by a reward function that considers both functional
correctness, validated through test cases, and execution performance relative
to the industry-standard compiler gcc -O3. To support this study, we introduce
a benchmark of 8,072 real-world programs. Our model, Qwen2.5-Coder-7B-PPO,
achieves 96.0% test pass rates and an average speedup of 1.47x over the gcc -O3
baseline, outperforming all 20 other models evaluated, including
Claude-3.7-sonnet. These results indicate that reinforcement learning can
unlock the potential of LLMs to serve as effective optimizers for assembly code
performance.