用编译器视角分层诊断LLM生成的Triton内核性能瓶颈。
Compiler-Grounded Hierarchical Diagnosis for LLM-Based Triton Kernel Optimization

- 从编译器反馈逐步深入,定位性能差的根本原因。
- 在昇腾950上实现4.35倍几何平均加速,22个超过2倍。
- 适合研究NPU优化或想理解编译器如何影响性能的人。
大语言模型(LLMs)已能自动生成和优化计算内核,但现有方法多依赖编译反馈和性能指标等表面信号,仅能发现内核运行慢,却无法解释后端编译器为何未能实施有效优化,尤其在新兴加速器如NPUs上。为此,我们提出将内核优化建模为跨层渐进式诊断问题,将运行时症状与IR结构及编译器行为关联,再进行源码重写。基于此,我们构建了面向Triton内核的编译器根基、分层优化框架。系统从轻量模式匹配与性能诊断开始,仅在需要更深层证据时才推进到IR归因和编译器分析阶段,最终生成有依据的源码改写。我们在昇腾NPUs上的Triton实现该系统,并在基于NPUKernelBench的37个成功转换的Ascend 950基准测试中评估。整体几何平均加速达4.35×,中位加速2.73×;其中22/37超过2×,13/37超过5×。结果分布从接近基线到显著提升,揭示了当前系统的适用范围与局限性,强调透明报告的重要性。
原文摘要 · Abstract (English)
Recent advances in large language models (LLMs) have enabled automated kernel generation and optimization, but most existing approaches rely on surface signals such as compilation feedback and profiling metrics. These signals reveal that a kernel is slow, but not why the backend compiler fails to realize a profitable optimization, especially on emerging accelerators such as NPUs. We therefore formulate kernel optimization as a progressive cross-layer diagnosis problem that links runtime symptoms to IR structure and compiler behavior before rewriting source. Based on this insight, we present our system, a compiler-grounded and hierarchical optimization framework for Triton kernels. the system escalates from lightweight pattern triage and profiling diagnosis to IR attribution and compiler-grounded analysis only when deeper evidence is needed, then proposes evidence-backed source-level rewrites. We implement the system on Triton for Ascend NPUs and evaluate it on 37 successfully converted entries from a standardized NPUKernelBench-derived Ascend 950 benchmark. Across these entries, the system attains a geometric-mean speedup of 4.35$\times$ and a median speedup of 2.73$\times$ from the initial to optimized Triton kernel; 22/37 exceed 2$\times$ and 13/37 exceed 5$\times$. The complete distribution ranges from near-baseline entries to large wins, motivating transparent reporting of the current system's scope and limitations.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。