代理自调度:LLM引导循环优化的实验研究
Agentic Auto-Scheduling: An Experimental Study of LLM-Guided Loop Optimization
AI总结:
本文提出ComPilot框架,利用LLM与编译器闭环交互实现代码优化,实验表明其在循环优化中效果优于现有方法。
摘要:
自动代码优化仍是一个具有挑战性的任务,特别是对于现代硬件上的复杂循环嵌套。本文研究了一种新的代码优化方法,其中大型语言模型(LLMs)通过与编译器的闭环交互来引导整个过程。我们提出了ComPilot,一个实验框架,利用现成的LLMs,无需任何任务特定的微调,作为交互式优化代理。ComPilot建立了一个反馈回路,其中LLM为给定的循环嵌套提出转换建议给编译器。编译器尝试这些转换,并报告回合法性状态和测量的速度提升或下降。LLM利用这种具体的反馈来迭代地改进其优化策略。我们对PolyBench基准套件的广泛评估证明了这种零样本方法的有效性。ComPilot在原始代码上的几何平均速度提升为2.66倍(单次运行)和3.54倍(最佳5次运行)。此外,ComPilot在许多情况下表现出与最先进的Pluto多面体优化器竞争性的性能。这项实验研究证明了通用目的LLMs在编译器反馈的引导下可以有效引导代码优化过程,为代码优化中的代理AI研究开辟了有前途的研究方向。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。