arXiv:2511.00592cs.PLcs.DC2025-11中稿 · the 34th Internati…被引 5

用大模型自动优化代码循环,无需训练就能提速三倍以上。

Agentic Auto-Scheduling: An Experimental Study of LLM-Guided Loop Optimization

  • 大模型与编译器闭环互动,根据实测反馈迭代改进优化策略。
  • 在PolyBench上平均提速2.66倍(单次运行)和3.54倍(五次最优)。
  • 不需微调即可媲美顶尖优化器,适合想探索AI辅助编译的开发者。

自动代码优化仍是难题,尤其在现代硬件上的复杂循环嵌套。本文研究一种新方法:利用大语言模型(LLMs)通过与编译器的闭环交互来指导优化。我们提出ComPilot实验框架,使用现成的LLM作为优化代理,无需任何任务特定微调。ComPilot建立反馈环:LLM为给定循环嵌套提出变换,编译器尝试执行并返回合法性状态及实测加速比或降速比,LLM据此迭代优化策略。在PolyBench基准测试集上的广泛评估表明该零样本方法有效:相比原始代码,实现2.66倍(单次运行)和3.54倍(最佳五次运行)的几何平均加速。此外,ComPilot性能可媲美最先进的Pluto多面体优化器,在多个案例中表现更优。本实验研究证明,基于编译器反馈的通用型大模型能有效引导代码优化过程,为智能代理在代码优化中的应用开辟了新方向。

原文摘要 · Abstract (English)

Automatic code optimization remains a difficult challenge, particularly for complex loop nests on modern hardware. This paper investigates a novel approach to code optimization where Large Language Models (LLMs) guide the process through a closed-loop interaction with a compiler. We present ComPilot, an experimental framework that leverages off-the-shelf LLMs, without any task-specific fine-tuning, as interactive optimization agents. ComPilot establishes a feedback loop where an LLM proposes transformations for a given loop nest to a compiler. The compiler attempts the transformations, reporting back legality status and measured speedup or slowdown. The LLM utilizes this concrete feedback to iteratively refine its optimization strategy. Our extensive evaluation across the PolyBench benchmark suite demonstrates the effectiveness of this zero-shot approach. ComPilot achieves geometric mean speedups of 2.66x (single run) and 3.54x (best-of-5 runs) over the original code. Furthermore, ComPilot demonstrates competitive performance against the state-of-the-art Pluto polyhedral optimizer, outperforming it in many cases. This experimental study demonstrates that general-purpose LLMs can effectively guide the code optimization process when grounded by compiler feedback, opening promising research directions for agentic AI in code optimization.

代码优化大模型编译器自动调度

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