arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2506.12355cs.LGcs.CL
收藏

QiMeng-Attention: 由SOTA注意力算法生成的SOTA注意力算子

QiMeng-Attention: SOTA Attention Operator is generated by SOTA Attention Algorithm

SKL of Processors, Institute of Computing Technology, CAS(处理器国家重点实验室,计算技术研究所,中国科学院);Intelligent Software Research Center, Institute of Software, CAS(智能软件研究中心,软件研究所,中国科学院);University of Chinese Academy of Sciences(中国科学院大学)

Qirui Zhou, Shaohui Peng, Weiqiang Xiong, Haixin Chen, Yuanbo Wen, Haochen Li, Ling Li, Qi Guo, Yongwei Zhao, Ke Gao, Ruizhi Chen, Yanjun Wu, Chen Zhao, Yunji Chen

AI总结:

针对现有LLM难以生成高性能注意力算子的问题,提出适配LLM的思维语言与两阶段推理工作流,可自动生成多GPU适配的FlashAttention,性能显著超越原生LLM与人工优化库,大幅缩短开发周期。

摘要:

注意力算子仍然是大语言模型(LLM)的关键性能瓶颈,尤其是在长上下文场景下。FlashAttention是目前应用最广泛、效果最好的GPU感知加速算法,但它需要耗时且针对特定硬件的手动实现,限制了其在不同GPU架构间的适配性。现有LLM在代码生成任务上已展现出巨大潜力,但难以生成高性能的注意力代码。核心挑战在于其无法理解注意力算子复杂的数据流与计算过程,也无法利用底层原语挖掘GPU性能。\n为解决上述挑战,我们提出了一种适配LLM的思维语言(LLM-TL),帮助LLM解耦高层优化逻辑的生成与GPU底层实现,增强LLM对注意力算子的理解。结合“TL代码生成-翻译”的两阶段推理工作流,LLM可自动生成适配多种GPU的FlashAttention实现,构建了以注意力为核心的算法中生成高性能注意力算子的自优化范式。在A100、RTX8000和T4 GPU上的验证结果表明,我们的方法性能显著优于原生LLM,加速比最高可达35.16倍。此外,我们的方法不仅在大多数场景下性能超越人工优化的库(cuDNN和官方库),还拓展支持了原本不支持的硬件与数据类型,将开发时间从人类专家所需的数月缩短至数分钟。

英文摘要:

The attention operator remains a critical performance bottleneck in large language models (LLMs), particularly for long-context scenarios. While FlashAttention is the most widely used and effective GPU-aware acceleration algorithm, it must require time-consuming and hardware-specific manual implementation, limiting adaptability across GPU architectures. Existing LLMs have shown a lot of promise in code generation tasks, but struggle to generate high-performance attention code. The key challenge is it cannot comprehend the complex data flow and computation process of the attention operator and utilize low-level primitive to exploit GPU performance. To address the above challenge, we propose an LLM-friendly Thinking Language (LLM-TL) to help LLMs decouple the generation of high-level optimization logic and low-level implementation on GPU, and enhance LLMs' understanding of attention operator. Along with a 2-stage reasoning workflow, TL-Code generation and translation, the LLMs can automatically generate FlashAttention implementation on diverse GPUs, establishing a self-optimizing paradigm for generating high-performance attention operators in attention-centric algorithms. Verified on A100, RTX8000, and T4 GPUs, the performance of our methods significantly outshines that of vanilla LLMs, achieving a speed-up of up to 35.16x. Besides, our method not only surpasses human-optimized libraries (cuDNN and official library) in most scenarios but also extends support to unsupported hardware and data types, reducing development time from months to minutes compared with human experts.

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

↑