用大模型指导编译优化,显著提升效率并减少尝试次数。
REASONING COMPILER: LLM-Guided Optimizations for Efficient Model Serving
- 用大模型生成优化建议,结合蒙特卡洛树搜索进行智能决策。
- 在少于现有方法的样本数下实现显著加速,性能提升明显。
- 适合关注模型部署效率、编译器优化的研究者与工程师。
模型服务虽已释放空前能力,但大规模模型的高昂部署成本仍是普及与快速创新的主要障碍。传统编译优化虽能显著提效,但面对神经网络工作负载时,因变换空间呈指数级增长且高度耦合,难以有效应用。现有随机搜索方法常样本效率低下,且无法利用编译决策背后的结构上下文。本文探索:无需重训练的大语言模型(LLM)能否通过上下文感知推理,显著提升编译优化的样本效率?为此,我们提出新型编译框架——REASONING COMPILER,将优化视为由大语言模型引导的序列化、上下文感知决策过程,并结合结构化蒙特卡洛树搜索(MCTS)。LLM充当提议机制,基于当前程序状态与累积性能反馈生成硬件感知的变换建议。MCTS融合这些提议,在探索与利用间取得平衡,实现对庞大编译优化空间的结构化、上下文敏感遍历。实验表明,该方法以远少于领先神经编译器的样本数实现了显著加速,验证了大模型引导推理在变革编译优化领域的潜力。
原文摘要 · Abstract (English)
While model serving has unlocked unprecedented capabilities, the high cost of serving large-scale models continues to be a significant barrier to widespread accessibility and rapid innovation. Compiler optimizations have long driven substantial performance improvements, but existing compilers struggle with neural workloads due to the exponentially large and highly interdependent space of possible transformations. Although existing stochastic search techniques can be effective, they are often sample-inefficient and fail to leverage the structural context underlying compilation decisions. We set out to investigate the research question of whether reasoning with large language models (LLMs), without any retraining, can leverage the context-aware decision space of compiler optimizations to significantly improve sample efficiency. To that end, we introduce a novel compilation framework (dubbed REASONING COMPILER) that formulates optimization as a sequential, context-aware decision process guided by a large language model and structured Monte Carlo tree search (MCTS). The LLM acts as a proposal mechanism, suggesting hardware-informed transformations that reflect the current program state and accumulated performance feedback. MCTS incorporates the LLM-generated proposals to balance exploration and exploitation, facilitating a structured, context-sensitive traversal of the expansive compiler optimization space. By achieving substantial speedups with markedly fewer samples than leading neural compilers, our approach demonstrates the potential of LLM-guided reasoning to transform the landscape of compiler optimization.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。