AscendKernelGen: 一种针对神经处理单元的LLM基内核生成系统研究
AscendKernelGen: A Systematic Study of LLM-Based Kernel Generation for Neural Processing Units
AI总结:
本文提出AscendKernelGen框架,通过引入Ascend-CoT数据集和KernelGen-LM模型,提升NPU内核生成效率与正确性,实验显示复杂内核编译成功率从0%提升至95.5%。
摘要:
为满足日益增长的计算效率需求,神经处理单元(NPUs)已成为现代AI基础设施中的关键组件。然而,解锁其全部潜力需要开发高性能的计算内核,使用供应商特定的领域特定语言(DSLs),这一任务需要深厚的硬件专业知识且耗时费力。尽管大型语言模型(LLMs)在通用代码生成方面显示出潜力,但它们在NPUs领域中严格的约束和训练数据稀缺性方面表现不佳。我们的初步研究发现,最先进的通用LLMs无法为Ascend NPUs生成功能性复杂的内核,导致接近零的成功率。为解决这些挑战,我们提出了AscendKernelGen,一个集生成与评估于一体的NPU内核开发框架。我们引入了Ascend-CoT,一个高质量的数据集,其中包含从真实世界内核实现中衍生出的链式推理数据,并提出了KernelGen-LM,一个通过监督微调和强化学习与执行反馈训练的领域适应模型。此外,我们设计了NPUKernelBench,一个全面的基准测试,用于评估不同复杂级别下的编译、正确性和性能。实验结果表明,我们的方法显著缩小了通用LLMs与硬件特定编码之间的差距。具体而言,复杂级别2内核的编译成功率从0%提升至95.5%(Pass@10),而功能性正确性达到64.3%,相比基线的完全失败。这些结果突显了领域特定推理和严格评估在自动化加速器感知代码生成中的关键作用。AscendKernGen可在https://huggingface.co/AscendKernelGen和https://github.com/weich97/NPUKernelBench上获取。
英文摘要:
To meet the ever-increasing demand for computational efficiency, Neural Processing Units (NPUs) have become critical in modern AI infrastructure. However, unlocking their full potential requires developing high-performance compute kernels using vendor-specific Domain-Specific Languages (DSLs), a task that demands deep hardware expertise and is labor-intensive. While Large Language Models (LLMs) have shown promise in general code generation, they struggle with the strict constraints and scarcity of training data in the NPU domain. Our preliminary study reveals that state-of-the-art general-purpose LLMs fail to generate functional complex kernels for Ascend NPUs, yielding a near-zero success rate. To address these challenges, we propose AscendKernelGen, a generation-evaluation integrated framework for NPU kernel development. We introduce Ascend-CoT, a high-quality dataset incorporating chain-of-thought reasoning derived from real-world kernel implementations, and KernelGen-LM, a domain-adaptive model trained via supervised fine-tuning and reinforcement learning with execution feedback. Furthermore, we design NPUKernelBench, a comprehensive benchmark for assessing compilation, correctness, and performance across varying complexity levels. Experimental results demonstrate that our approach significantly bridges the gap between general LLMs and hardware-specific coding. Specifically, the compilation success rate on complex Level-2 kernels improves from 0% to 95.5% (Pass@10), while functional correctness achieves 64.3% compared to the baseline's complete failure. These results highlight the critical role of domain-specific reasoning and rigorous evaluation in automating accelerator-aware code generation. AscendKernGen is available at https://huggingface.co/AscendKernelGen and https://github.com/weich97/NPUKernelBench.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。