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

如何循环你的Transformer:循环缩放、专业化与并行推理

How to Loop Your Transformer: Loop Scaling, Specialization, and Parallel Inference

FAIR at Meta;MIT(麻省理工学院)

Chanakya Ekbote, Artidoro Pagnoni, Devendra Singh Sachan, Shruti Bhosale, Mike Lewis, Maryam Fazel-Zarandi, Shashank Rajput, Sujan Kumar Gonugondla

AI总结:

该研究探讨Transformer循环的权衡,发现全循环Transformer在固定参数预算下质量最优,中间层循环在训练计算受限时更优,添加循环收益会饱和,提出循环专用低秩适配器提升质量,改进并行循环方案恢复性能。

摘要:

Transformer模型中的循环通过重复应用相同的Transformer或其部分组件来复用权重,使模型在不增加参数数量的情况下变得更深。循环是否有用取决于哪个约束占主导:模型大小、训练计算量或自回归推理效率。我们在从头训练的密集仅解码器Transformer中联合研究这些权衡,改变模型的循环部分、应用的循环次数以及循环间的信息传递方式。我们的实验涵盖参数达10亿、在1550亿token上训练、浮点运算量达1.07×10²¹且循环次数达32次的模型。我们发现,在固定参数预算下,对整个Transformer进行循环通常能获得最强的质量,而当训练浮点运算量受限时,对中间层块进行循环能获得更好的回报。增加循环并非总是有益的:收益最终会饱和、逆转或变得不稳定。这促使我们思考,强制每个循环使用相同的权重是否限制了更深循环的收益。我们通过添加小型循环专用低秩适配器来解决这一问题,随着循环次数增加,收益也更大。循环Transformer还会出现与循环次数成比例的解码减速。并行循环Transformer通过在相邻token位置间传递循环间的隐藏状态,使循环阶段能够并行运行来解决这一问题。然而,在我们的实验中,原始方案并未始终保留普通循环的质量收益。我们发现,保留当前token嵌入并在组合前分别对其和前一个token隐藏状态进行归一化,可在各种模型规模和训练预算下恢复强劲性能。这些结果共同表明,有效的循环需要使设计匹配资源约束和推理设置。

英文摘要:

Looping in transformer models reuses weights by repeatedly applying the same transformer, or parts of it, making the model deeper without increasing its parameter count. Whether looping is useful depends on which constraint dominates: model size, training compute, or autoregressive inference efficiency. We study these trade-offs jointly in dense decoder-only transformers trained from scratch, varying which parts of the model are looped, how many loops are applied, and how information is passed between loops. Our experiments span models with up to 1B parameters, trained on up to 155B tokens with up to $1.07\times10^{21}$ FLOPs and 32 loops. We find that looping the full transformer generally gives the strongest quality at a fixed parameter budget, whereas looping a middle block of layers gives a better return when training FLOPs are constrained. Adding loops is not uniformly beneficial: gains eventually saturate, reverse, or become unstable. This motivates asking whether forcing every loop to use the same weights limits the benefit of deeper looping. We address this by adding small loop-specific low-rank adapters that improve quality, with larger gains as more loops are added. Looped transformers also suffer a decoding slowdown proportional to the number of loops. Parallel Loop Transformers address this by passing hidden states between loops across adjacent token positions, allowing loop stages to run concurrently. However, in our experiments the original formulation does not consistently retain the quality gains of ordinary looping. We find that preserving the current-token embedding and separately normalizing it and the previous-token hidden state before combining them recovers strong performance across model scales and training budgets. Together, these results show that effective looping requires matching the design to the resource constraint and inference setting.

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

↑