arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.18524cs.LG
收藏

关于循环Transformer的残差缩放:稳定性和可迁移性

Loop-$μ$P: Residual Scaling and Hyperparameter Transfer in Looped Transformers

Tsinghua University(清华大学)

Shaowen Wang, Bingrui Li, Tansheng Zhu, Ge Zhang, Wenhao Huang, Shen Yan, Jian Li

AI总结:

针对循环Transformer,提出残差缩放因子应为1/N而非1/√L,并推导出多层的分解参数化,实现超参数从少循环到多循环的迁移。

摘要:

循环(权重共享)Transformer 将共享残差块应用 N 次(h ← h + ε f(h),每一步使用相同的 f),在不增加参数的情况下增加有效深度。先前的深度缩放分析建议深度为 L 的残差网络使用 ε = 1/√L。我们证明这对于循环架构是不够的:权重共享使得残差更新在迭代间相关,需要更强的缩放 ε = 1/N。对于多层块(L 个独特层循环 N 次),我们推导出一个分解参数化 ε = λ/(N√L),将两种增长源分开:1/N 控制层内循环相关性,1/√L 控制层间方差。一个关键结果是,最优学习率仅取决于独特层数 L,而非循环次数 N,从而实现了从小的 N 到大的 N 的直接超参数迁移,无需重新调整。在循环 Transformer 上的实验证实,1/N 缩放相比 1/√N 缩放提高了可训练性,并在不同循环次数下获得更优的损失。

英文摘要:

Looped Transformers have drawn growing attention because looping improves multi-step reasoning and increases the executed depth of a model without adding parameters. They achieve this by reusing a stack of $L$ layers for $N$ loops. However, increasing the loop count $N$ not only destabilizes training but also shifts the best hyperparameters, so they must be searched again for every loop count. Inspired by Depth-$μ$P (Yang et al., 2024), which multiplies each residual branch by $L^{-1/2}$ for depth $L$ so that a learning rate tuned on a shallow untied network transfers to a deep one, we study how the residual branches and the learning rate should scale with the loop count $N$. We find that loops cannot simply be treated as extra depth, because the loops share weights. At initialization, distinct layers add nearly uncorrelated increments to the residual stream, so their sum grows as $\sqrt{L}$, whereas a shared layer adds positively correlated increments at every loop, so their sum grows linearly in $N$. For a single layer looped $N$ times, we show in the infinite-width limit that multiplying the residual branch by $1/N$ and keeping the learning rate independent of $N$ is the only parameterization with both a stable forward pass and maximal residual-stream updates. We then generalize the analysis to a stack of $L$ distinct layers looped $N$ times to obtain a parameterization we call Loop-$μ$P, in which the loop factor $1/N$ combines with the depth factor $L^{-1/2}$. Empirically, we find in language modeling that the base learning rate tuned on the smallest model stays best under Loop-$μ$P for loop counts up to $8$ and executed depths up to $384$ layers. These results make Loop-$μ$P a practical recipe for scaling looped Transformers.

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

↑