arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2311.09431cs.LGcs.CL
收藏

条纹注意力:用于因果Transformer的更快环形注意力

Striped Attention: Faster Ring Attention for Causal Transformers

MIT CSAIL(麻省理工学院计算机科学与人工智能实验室);MosaicML(MosaicML公司);MIT EECS(麻省理工学院电气工程与计算机科学系)

William Brandon, Aniruddha Nrusimha, Kevin Qian, Zachary Ankner, Tian Jin, Zhiye Song, Jonathan Ragan-Kelley

AI总结:

针对因果Transformer中环形注意力因三角结构导致的工作负载不均衡,提出条纹注意力,通过均匀分布token子集实现更均衡负载,在A100和TPUv4上分别获得最高1.45倍和1.65倍的吞吐量提升。

摘要:

为应对Transformer模型中对更长序列长度日益增长的需求,Liu等人近期提出了环形注意力(Ring Attention),这是一种精确的注意力算法,能够通过将自注意力分布到多个设备上来克服每设备内存瓶颈。本文研究了在因果Transformer模型这一重要特例中环形注意力的性能特征,并识别出由于因果注意力计算的三角结构而导致的关键工作负载不均衡问题。我们提出了环形注意力的一个简单扩展,称为条纹注意力(Striped Attention),以解决这种不均衡。不同于设备拥有连续子序列,每个设备拥有均匀分布在整个序列中的token子集,我们证明这能带来更均衡的工作负载。在A100 GPU和TPUv4上运行条纹注意力的实验中,在序列长度为256k的因果Transformer训练中,我们实现了相比原始环形注意力算法高达1.45倍的端到端吞吐量提升。此外,在16块TPUv4芯片上,我们在序列长度为786k时实现了1.65倍的加速。我们将实验代码作为开源发布。

英文摘要:

To help address the growing demand for ever-longer sequence lengths in transformer models, Liu et al. recently proposed Ring Attention, an exact attention algorithm capable of overcoming per-device memory bottle- necks by distributing self-attention across multiple devices. In this paper, we study the performance characteristics of Ring Attention in the important special case of causal transformer models, and identify a key workload imbal- ance due to triangular structure of causal attention computations. We propose a simple extension to Ring Attention, which we call Striped Attention to fix this imbalance. Instead of devices having contiguous subsequences, each device has a subset of tokens distributed uniformly throughout the sequence, which we demonstrate leads to more even workloads. In experiments running Striped Attention on A100 GPUs and TPUv4s, we are able to achieve up to 1.45x end-to-end throughput improvements over the original Ring Attention algorithm on causal transformer training at a sequence length of 256k. Furthermore, on 16 TPUv4 chips, we were able to achieve 1.65x speedups at sequence lengths of 786k. We release the code for our experiments as open source

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

↑