arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2502.07563cs.LGcs.AIcs.CL
收藏

LASP-2:重新思考线性注意力及其混合模型的序列并行性

LASP-2: Rethinking Sequence Parallelism for Linear Attention and Its Hybrid

Shanghai AI Laboratory(上海人工智能实验室);South China University of Technology(华南理工大学);The Chinese University of Hong Kong(香港中文大学)

Weigao Sun, Disen Lan, Yiran Zhong, Xiaoye Qu, Yu Cheng

AI总结:

针对现有序列并行方法在处理线性注意力Transformer模型超长序列时的并行性和可扩展性问题,提出LASP-2,通过重新设计通信-计算工作流减少通信需求,提升并行性及其重叠度,并扩展到混合模型LASP-2H,在Linear-Llama3上实现显著速度提升。

摘要:

线性序列建模方法(如线性注意力)在序列长度方面具有线性时间训练和恒定内存推理等优势。然而,现有的序列并行(SP)方法要么未针对线性注意力的“右乘优先”特征进行优化,要么采用环形通信策略,导致计算并行性较低,限制了其在分布式系统中处理更长序列时的可扩展性。本文提出LASP-2,一种新的SP方法,用于在训练具有超长输入序列的线性注意力Transformer模型时增强通信和计算并行性。与之前的工作LASP相比,LASP-2重新思考了线性注意力层上SP的最小通信需求,重新组织了LASP的整个通信-计算工作流。通过这种方式,仅需对中间内存状态执行一次AllGather集合通信,而中间内存状态的大小与序列长度无关,从而显著提升了通信和计算并行性及其重叠度。此外,我们将LASP-2扩展到LASP-2H,通过对标准注意力模块应用类似的通信重新设计,为融合线性和标准注意力层的混合模型提供了高效的SP解决方案。我们在Linear-Llama3模型(Llama3的变体,用线性注意力替代标准注意力)上的评估证明了LASP-2和LASP-2H的有效性。具体而言,在64个GPU上处理2048K序列长度时,LASP-2比LASP实现了15.2%的训练速度提升,比Ring Attention提升了36.6%。代码已作为https://github.com/OpenSparseLLMs/Linear-MoE的一部分发布。

英文摘要:

Linear sequence modeling approaches, such as linear attention, provide advantages like linear-time training and constant-memory inference over sequence lengths. However, existing sequence parallelism (SP) methods are either not optimized for the right-product-first feature of linear attention or use a ring-style communication strategy, which results in lower computation parallelism, limits their scalability for longer sequences in distributed systems. In this paper, we introduce LASP-2, a new SP method to enhance both communication and computation parallelism when training linear attention transformer models with very-long input sequences. Compared to previous work LASP, LASP-2 rethinks the minimal communication requirement for SP on linear attention layers, reorganizes the whole communication-computation workflow of LASP. In this way, only one single AllGather collective communication is needed on intermediate memory states, whose sizes are independent of the sequence length, leading to significant improvements of both communication and computation parallelism, as well as their overlap. Additionally, we extend LASP-2 to LASP-2H by applying similar communication redesign to standard attention modules, offering an efficient SP solution for hybrid models that blend linear and standard attention layers. Our evaluation on a Linear-Llama3 model, a variant of Llama3 with linear attention replacing standard attention, demonstrates the effectiveness of LASP-2 and LASP-2H. Specifically, LASP-2 achieves training speed improvements of 15.2% over LASP and 36.6% over Ring Attention, with a sequence length of 2048K across 64 GPUs. The Code is released as a part of: https://github.com/OpenSparseLLMs/Linear-MoE.

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

↑