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

具有硬件高效训练的门控线性注意力 Transformers

Gated Linear Attention Transformers with Hardware-Efficient Training

Massachusetts Institute of Technology(麻省理工学院);MIT-IBM Watson AI Lab(麻省理工学院-IBM沃森人工智能实验室)

Songlin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, Yoon Kim

AI总结:

本文提出硬件高效的线性注意力算法 FLASHLINEARATTENTION 及其门控变体 GLA Transformer,在中等规模语言建模中性能媲美 LLaMA、RetNet 和 Mamba,且在长度泛化和训练吞吐量上表现优异。

摘要:

具有线性注意力的 Transformers 允许高效的并行训练,同时可以表示为具有 2D(矩阵值)隐藏状态的 RNN,从而享有线性时间的推理复杂度。然而,线性注意力通常表现不如普通的 softmax 注意力。此外,当前的线性注意力实现缺乏 I/O 感知,因此比高度优化的 softmax 注意力实现更慢。这项工作描述了一种用于线性注意力的硬件高效算法,该算法在内存移动和并行性之间进行权衡。由此产生的实现被称为 FLASHLINEARATTENTION,作为独立层,即使在较短的序列长度(例如 1K)下,也比 FLASHATTENTION-2 (Dao, 2023) 更快。然后,我们将此算法推广到具有数据依赖门控的更具表达力的线性注意力变体。当用作 Transformers 中标准注意力层的替代时,由此产生的门控线性注意力(GLA)Transformer 在中等规模语言建模实验中,与 LLaMA 架构 Transformer (Touvron et al., 2023) 以及最近的线性时间推理基准(如 RetNet (Sun et al., 2023a) 和 Mamba (Gu & Dao, 2023))相比,表现出具有竞争力的性能。GLA Transformer 在长度泛化方面特别有效,使得在 2K 上训练的模型能够泛化到超过 20K 的序列,而不会出现显著的困惑度下降。在训练速度方面,GLA Transformer 比同等规模的 Mamba 模型具有更高的吞吐量。

英文摘要:

Transformers with linear attention allow for efficient parallel training but can simultaneously be formulated as an RNN with 2D (matrix-valued) hidden states, thus enjoying linear-time inference complexity. However, linear attention generally underperforms ordinary softmax attention. Moreover, current implementations of linear attention lack I/O-awareness and are thus slower than highly optimized implementations of softmax attention. This work describes a hardware-efficient algorithm for linear attention that trades off memory movement against parallelizability. The resulting implementation, dubbed FLASHLINEARATTENTION, is faster than FLASHATTENTION-2 (Dao, 2023) as a standalone layer even on short sequence lengths (e.g., 1K). We then generalize this algorithm to a more expressive variant of linear attention with data-dependent gates. When used as a replacement for the standard attention layer in Transformers, the resulting gated linear attention (GLA) Transformer is found to perform competitively against the LLaMA-architecture Transformer (Touvron et al., 2023) as well recent linear-time-inference baselines such as RetNet (Sun et al., 2023a) and Mamba (Gu & Dao, 2023) on moderate-scale language modeling experiments. GLA Transformer is especially effective at length generalization, enabling a model trained on 2K to generalize to sequences longer than 20K without significant perplexity degradations. For training speed, the GLA Transformer has higher throughput than a similarly-sized Mamba model.

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

↑