CODA: 将Transformer模块重写为GEMM-Epilogue程序
阅读原文· arxiv.org论文提出CODA技术,旨在优化Transformer架构的核心计算。其核心思想是将Transformer块中的复杂操作(如注意力机制、前馈网络)统一抽象并重写为“通用矩阵乘法(GEMM)+ 后续操作(Epilogue)”的程序化组合。这种方法能够更高效地映射到现代硬件(如GPU)上执行,通过融合计算、减少内存访问来提升整体效率。该成果已发布于arXiv,并在Hacker News社区获得关注(100点热度),反映了业界对大模型底层计算优化的持续探索。
Computer Science > Machine Learning
Title:CODA: Rewriting Transformer Blocks as GEMM-Epilogue Programs
Abstract:Transformer training systems are built around dense linear algebra, yet a nontrivial fraction of end-to-end time is spent on surrounding memory-bound operators. Normalization, activations, residual updates, reductions, and related computations repeatedly move large intermediate tensors through global memory while performing little arithmetic, making data movement an increasingly important bottleneck in otherwise highly optimized training stacks. We introduce CODA, a GPU kernel abstraction that expresses these computations as GEMM-plus-epilogue programs. CODA is based on the observation that many Transformer operators exposed as separate framework kernels can be algebraically reparameterized to execute while a GEMM output tile remains on chip, before it is written to memory. The abstraction fixes the GEMM mainloop and exposes a small set of composable epilogue primitives for scaling, reductions, pairwise transformations, and accumulation. This constrained interface preserves the performance structure of expert-written GEMMs while remaining expressive enough to cover nearly all non-attention computation in the forward and backward pass of a standard Transformer block. Across representative Transformer workloads, both human- and LLM-authored CODA kernels achieve high performance, suggesting that GEMM-plus-epilogue programming offers a practical path toward combining framework-level productivity with hardware-level efficiency.