arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2505.23819cs.PLcs.ARcs.DCcs.PF
收藏

线性布局:利用$\mathbb{F}_2$实现高效张量计算的鲁棒代码生成

Linear Layouts: Robust Code Generation of Efficient Tensor Computation Using $\mathbb{F}_2$

George Mason University(乔治梅森大学);OpenAI

Keren Zhou, Mario Lezcano, Adam Goucher, Akhmed Rakhmati, Jeff Niu, Justin Lebar, Pawel Szczerbuk, Peter Bell, Phil Tillet, Thomas Raoux, Zahi Moudallal

AI总结:

本文提出线性布局方法,利用$\mathbb{F}_2$实现高效张量计算的鲁棒代码生成,通过通用布局定义和转换减少工程工作量并修复Triton布局系统中的错误。

摘要:

高效张量计算是现代深度学习(DL)工作负载的核心,但现有方法在实现张量布局——逻辑张量与硬件资源之间的映射时,难以实现灵活且高效的架构和实现。随着DL算法和硬件复杂性的增加,需要一种通用且系统的方法来处理张量布局。在本文中,我们引入了线性布局,一种新的方法,通过在$\mathbb{F}_2$上使用线性代数来建模张量布局。通过将张量布局表示为作用于硬件表示位上的二进制矩阵,我们的方法使张量布局定义变得通用,而不是传统的逐个案例处理方式,并允许通用的布局到布局转换,消除了现有解决方案中令人困扰的二次爆炸问题。我们将线性布局与Triton集成,并展示了其在优化单个Triton操作符以及用Triton编写内核方面的有效性。我们还表明,线性布局在编译器后端中减少了工程工作量,并修复了Triton传统布局系统中的几个错误。

英文摘要:

Efficient tensor computation is a cornerstone of modern deep learning (DL) workloads, yet existing approaches struggle to achieve flexible and performant design and implementation of tensor layouts -- mappings between logical tensors and hardware resources. The increasing complexity of DL algorithms and hardware demands a generic and systematic approach to handling tensor layouts. In this work, we introduce Linear Layouts, a novel approach that models tensor layouts using linear algebra over $\mathbb{F}_2$. By representing tensor layouts as binary matrices acting on the bits of the hardware representation, our approach enables a generic layout definition -- as opposed to the classical case-by-case approach -- and allows for generic layout-to-layout conversions, eliminating the quadratic explosion that plagues existing solutions. We integrate linear layouts with Triton and demonstrate their effectiveness in optimizing individual Triton operators as well as kernels written in Triton. We also show that linear layouts reduce engineering effort in the compiler backend while fixing several bugs in Triton's legacy layout system.

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

↑