AMD XDNA NPU 编程用开源编译工具:FlashAttention 案例研究
Programming AMD XDNA NPUs with Open-source Compiler Tools: A FlashAttention Case Study
想了解如何用开源工具优化 AMD XDNA NPU 上大模型的性能,这篇论文用 FlashAttention 做了详细案例,对比了不同设计,还给出了具体优化策略。
本文通过 FlashAttention 模型在 AMD XDNA 1 和 XDNA 2 芯片上的测试,对比了四种参考设计,发现将三个注意力阶段融合成一个内核的设计在 XDNA 2 上性能最好,达到 3.62 TFLOP/s,是 IRON 设计的两倍,且能处理十二种 LLM 配置,从 BERT 到 DeepSeek,长度可达 128K tokens。
Programming AMD XDNA NPUs with Open-source Compiler Tools: A FlashAttention Case Study
Spatial NPUs such as AMD XDNA place compute tiles beside small local memories and leave data movement between them to software. Mapping a multi-stage workload onto such a device is largely a question of where the intermediate tensors live. We report what we learned making those choices for FlashAttention with the open-source IRON and MLIR-AIR flows. We compare four reference designs on XDNA 1 and XDNA 2: one runs each operator separately, two stream between operators on chip, and one fuses all three attention stages into a single kernel. The fused kernel holds the $\boldsymbol{QK}^{\mathsf T}$ scores in compute-tile local memory and reduces partial results over the cascade interconnect, so the scores never return to shared MemTile memory. On XDNA 2, it reaches 3.62 TFLOP/s over complete end-to-end execution, twice the IRON design, with 5.3 to 7.2 times the energy efficiency of the integrated GPU on the same chip at 2K tokens and above. It covers twelve LLM configurations, from BERT to DeepSeek, up to 128K tokens. Roofline analysis at each memory level explains this result and shows when to stop. XDNA 1 has lower ridge points, so streaming on chip already reaches the compute-bound regime: the same fusion that doubles throughput on XDNA 2 is nearly wasted on XDNA 1. Comparing a mapping's operational intensity against each level's ridge point predicts which case applies before writing any code. Fuse until the mapping clears that ridge point, then stop. We release the reference designs as maintained open source.
本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」「中美大模型技术代差与商业化对照」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:FlashAttention、AMD XDNA、提示词工程、微调,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。
信源核验说明:本文原始信息发布自一手权威信源「arXiv: DeepSeek」(Tier-1 一手发布),具备高确定性参考价值。