ML-Triton:面向Triton GPU编程的多级编译与语言扩展
ML-Triton, A Multi-Level Compilation and Language Extension to Triton GPU Programming
AI总结:
针对Triton过早降级问题,提出ML-Triton多级编译与语言扩展,通过工作组到warp的渐进降级及用户提示,在Intel GPU上达到专家内核95%以上性能。
摘要:
在LLM时代,GEMM和MHA等密集运算是关键组成部分。这些运算非常适合采用基于分块(tile-based)的方法进行并行执行。虽然传统GPU编程通常依赖CUDA或SYCL等低级接口,但Triton作为一种DSL(领域特定语言)应运而生,通过更高级别的编程提供了更用户友好且可移植的替代方案。当前的Triton从工作组(即线程块)级别开始,直接降级到每线程级别,然后尝试通过一系列pass进行合并和修正,从低级表示中提升信息。我们认为这是基于以下观察的过早降级:1. GPU在物理和逻辑上都具有层次结构。现代GPU通常具有SIMD单元,能够直接在warp或warpgroup基础上对分块进行操作,例如块加载(blocked load)和块MMA(blocked MMA)。2. 多级逐步降级可以通过分离逻辑层间和逻辑层内的考虑,使编译器解耦且清晰。3. 内核开发者通常需要精细控制以在最新硬件上获得良好性能。FlashAttention2倡导在warp之间进行显式数据分区以提升性能。在此背景下,我们提出ML-Triton,其特点是多级编译流程和编程接口。我们的方法从工作组级别开始,逐步降级到warp和内在函数(intrinsic)级别,实现与GPU层次结构一致的多级降级。此外,我们扩展了Triton语言以支持用户设置的编译器提示和warp级编程,使研究人员无需等待编译器更新即可获得良好的开箱即用性能。实验结果表明,在Intel GPU上,我们的方法在几何平均性能上达到了专家编写内核的95%以上。
英文摘要:
In the era of LLMs, dense operations such as GEMM and MHA are critical components. These operations are well-suited for parallel execution using a tilebased approach. While traditional GPU programming often relies on low level interfaces like CUDA or SYCL, Triton has emerged as a DSL that offers a more user-friendly and portable alternative by programming at a higher level. The current Triton starts at the workgroup (aka threadblock) level, and directly lowers to per-thread level. And then attempt to coalesce and amend through a series of passes, promoting information from low-level representation. We believe this is pre-mature lowering based on the below observations. 1. GPU has a hierarchical structure both physically and logically. Modern GPUs often feature SIMD units capable of directly operating on tiles on a warp or warpgroup basis, such as blocked load and blocked MMA. 2. Multi-level gradual lowering can make compiler decoupled and clean by separating considerations inter and intra a logical layer. 3. Kernel developers often need fine control to get good performance on the latest hardware. FlashAttention2 advocates explicit data partition between warps to make a performance boost. In this context, we propose ML-Triton which features multi-level compilation flow and programming interface. Our approach begins at the workgroup level and progressively lowers to the warp and intrinsic level, implementing a multilevel lowering align with the hierarchical nature of GPU. Additionally, we extend triton language to support user-set compiler hint and warp level programming, enabling researchers to get good out-of-the box performance without awaiting compiler updates. Experimental results demonstrate that our approach achieves performance above 95% of expert-written kernels on Intel GPU, as measured by the geometric mean.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。