arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.14403cs.PL
收藏

NPUEval:利用LLM与开源编译器优化NPU内核

NPUEval: Optimizing NPU Kernels with LLMs and Open Source Compilers

Sarunas Kalade, Graham Schelle

AI总结:

本文提出NPUEval基准,包含102个机器学习算子,用于评估LLM在AMD NPU上生成内核的功能正确性与向量化效率,并揭示即使前沿模型平均得分也仅约10%的挑战。

摘要:

神经处理单元(NPU)在客户端设备等功耗敏感设备中日益受到重视,AI PC正是以其搭载这些专用处理器为特征。在这些设备上高效运行AI工作负载需要经过优化的内核库。创建高效内核要求具备使用向量内建函数的领域特定C++专业知识,以及对目标架构的深入理解。与已有多年发展历史的GPU编程不同,NPU编程尚属新兴领域,跨硬件平台的开发者社区规模更小且更加分散。这种碎片化给利用LLM辅助编写NPU内核带来了挑战,因为领域特定的优化代码示例在LLM预训练数据中代表性不足。本文介绍了NPUEval——一个用于编写和评估NPU内核的基准测试,包含102个机器学习工作负载中的常用算子。我们使用针对AMD NPU的开源编译器工具,基于功能正确性和向量化效率在实际硬件上评估LLM生成的代码。我们评估了一系列最先进的LLM,涵盖专有模型和开放权重模型。最新的推理模型(如DeepSeek R1)展现出有前景的结果,在选定的内核上开箱即用实现了超过50%的向量化。然而,即使提供编译器反馈和向量化内核示例,整个数据集上的平均得分仍约为10%——表明即使对于前沿模型,这也是一个具有挑战性的数据集。该数据集和评估代码将以宽松的开源许可证发布,为推进代码生成和NPU内核优化研究提供重要的基准测试。

英文摘要:

Neural processing units (NPUs) are gaining prominence in power-sensitive devices like client devices, with AI PCs being defined by their inclusion of these specialized processors. Running AI workloads efficiently on these devices requires libraries of optimized kernels. Creating efficient kernels demands expertise in domain-specific C++ with vector intrinsics and in-depth knowledge of the target architecture. Unlike GPU programming, which has had years to mature, NPU programming is new, with smaller and more fragmented developer communities across hardware platforms. This fragmentation poses a challenge when utilizing LLMs to assist in writing NPU kernels, as domain-specific optimized code examples are underrepresented in LLM pre-training data. In this paper we introduce NPUEval -- a benchmark for writing and evaluating NPU kernels, consisting of 102 common operators for machine learning workloads. We evaluate LLM generated code on actual hardware based on both functional correctness and vectorization efficiency using open source compiler tools targeting the AMD NPU. We evaluate a range of state-of-the-art LLMs with a mix of proprietary and open-weight models. Latest reasoning models like DeepSeek R1, show promising results achieving out-of-the-box 50%+ vectorization on select kernels. However, the average score across the entire dataset remains roughly 10% even with compiler feedback and vectorized kernel examples -- showing that this is a challenging dataset even for frontier models. The dataset and evaluation code will be released with a permissive open source license, providing an essential benchmark for advancing research in code generation and NPU kernel optimization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑