arXiv:2506.15701cs.LGcs.AI2025-06NeurIPS被引 14

用强化学习让大模型自动优化编译器,指令数平均减少8.46%。

Compiler-R1: Towards Agentic Compiler Auto-tuning with Reinforcement Learning

  • 用强化学习驱动大模型生成编译优化序列
  • 在7个数据集上平均减少8.46%的中间表示指令数
  • 首个专为编译器调优设计的高质推理数据集与训练框架

编译器自动调优旨在通过优化中间表示(IR)的指令数量等性能指标提升程序效率。尽管近期基于大语言模型(LLMs)的方法在自动化编译调优方面展现出潜力,但仍面临两大挑战:缺乏高质量的推理训练数据集,以及与编译环境交互能力有限。本文提出Compiler-R1,首个基于强化学习(RL)的框架,专门增强大模型在编译器自动调优中的能力。该框架包含一个精心构建的高质量推理数据集和一种新颖的两阶段端到端强化学习训练流程,支持通过基于结果的奖励机制实现高效环境探索与学习。在7个数据集上的大量实验表明,Compiler-R1相比opt -Oz平均减少8.46%的IR指令数,验证了强化学习训练的大模型在编译优化中的巨大潜力。代码与数据集已公开于https://github.com/Panhaolin2001/Compiler-R1。

原文摘要 · Abstract (English)

Compiler auto-tuning optimizes pass sequences to improve performance metrics such as Intermediate Representation (IR) instruction count. Although recent advances leveraging Large Language Models (LLMs) have shown promise in automating compiler tuning, two significant challenges still remain: the absence of high-quality reasoning datasets for agents training, and limited effective interactions with the compilation environment. In this work, we introduce Compiler-R1, the first reinforcement learning (RL)-driven framework specifically augmenting LLM capabilities for compiler auto-tuning. Compiler-R1 features a curated, high-quality reasoning dataset and a novel two-stage end-to-end RL training pipeline, enabling efficient environment exploration and learning through an outcome-based reward. Extensive experiments across seven datasets demonstrate Compiler-R1 achieving an average 8.46% IR instruction count reduction compared to opt -Oz, showcasing the strong potential of RL-trained LLMs for compiler optimization. Our code and datasets are publicly available at https://github.com/Panhaolin2001/Compiler-R1.

编译优化强化学习大模型自动调优

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。