rsLoRA(Tenyx):把 LoRA 缩放因子从 α/r 改成 α/√r,解锁大 rank
📄 A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA
2023-12 · Tenyx(Damjan Kalajdzievski)
一句话:从无穷宽极限的学习动态出发,证明 LoRA 适配器的正确缩放阶数是
📖 论文原文 Abstract(英文)
As large language models (LLMs) have become increasingly compute and memory intensive, parameter-efficient fine-tuning (PEFT) methods are now a common strategy to fine-tune LLMs. A popular PEFT method is Low-Rank Adapters (LoRA), which adds trainable low-rank "adapters" to selected layers. Each adapter consists of a low-rank matrix product, multiplicatively scaled by a rank-dependent factor. This scaling factor, which divides adapters by a factor of the rank, results in slowed learning and stunted performance for LoRA with higher-rank adapters. Consequently, the use of LoRA in practice has generally been limited to very low ranks. In this work, we study the impact of the scaling factor on the learning process and prove that LoRA adapters should be divided by a factor of the square root of the rank. Modifying LoRA with the appropriate scaling factor, which we call the rank-stabilized LoRA (rsLoRA) method, easily provides for a fine-tuning compute/performance trade-off, where larger ranks can be used to trade off increased computational resources during training for better fine-tuning performance, with no change in inference computing cost.
相关:LoRA 总览 · LoRA · QLoRA · LoRA+ · AdaLoRA · DoRA · PiSSA

图源:Kalajdzievski, A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA(arXiv:2312.03732)Figure 1(引自 Hu et al., 2022)——LoRA 适配器示意(用于学习注解,版权归原作者)。
动机与创新点:α/r 把大 rank 掐死了,rsLoRA 用 α/√r 把它救回来
LoRA 的前向是
问题在于:
the setting of the scaling factor
in LoRA is overly aggressive and causes gradient collapse as the rank increases, which slows the learning such that LoRA fine-tuning using larger ranks performs no different than that with very small ranks.
这正是社区普遍观察到的"LoRA 的 rank 收益很快饱和":从
rsLoRA 的洞察是:要让"加 rank 真的有用",缩放因子必须选得让增量
关键创新:
- 理论定阶:把 LoRA 的"缩放-初始化-更新"放进 Yang & Hu 的无穷宽框架分析,给出 Definition 3.1(rank-stabilized)+ Theorem 3.2,证明 rank 稳定当且仅当
。 - 一行改动:把
换成 ,其余初始化、合并方式都与 LoRA 完全一致——这就是 rsLoRA。 - 解锁算力/性能权衡:因为 rsLoRA 不再坍缩,"加 rank → 更好"重新成立,可以把更大的训练算力换成更好的微调效果,而推理零额外开销(合并回基座)。
- 充分实验验证:在 Llama 2、GPT-J 上,跨 AdamW/SGD/Adafactor、跨困惑度/梯度范数,一致复现"LoRA 坍缩、rsLoRA 稳定",并用消融排除"只是变相调大学习率"的解释。
方法:从无穷宽学习动态推出唯一正确的缩放阶数
LoRA 适配器的形式与缩放因子的角色
先把记号摆清楚。一个线性子模块
其中
关键问题就是
举例:把
从 4 加到 2048(512 倍), 只放大约 22.6 倍,但 放大了 512 倍。LoRA 的 等于在大 rank 上额外乘了一个约 的衰减,把新增维度的贡献压没了;rsLoRA 的 恰好抵掉这块多出来的衰减。
Definition 3.1 + Theorem 3.2:rank 稳定 ⟺ Θ(1/√r)
论文先定义什么叫"对 rank 稳定"。直觉是:前向(激活的矩)和反向(梯度的量级)都不应随
Definition 3.1. An adapter
is rank-stabilized if the following two conditions hold:
- If the inputs to the adapter are iid such that the
'th moment is in each entry, then the 'th moment of the outputs of the adapter is also in each entry. - If the gradient of the loss with respect to the adapter outputs are
in each entry, then the loss gradients into the input of the adapter are also in each entry.
这里
Theorem 3.2. Consider LoRA adapters of the form
… In expectation over initialization, all adapters are rank-stabilized if and only if In particular, the above holds at any point in the learning trajectory, and unless
, there is unstable or collapsing learning for sufficiently large values of .
证明思路(附录 A):先对一个适配器做归纳——
于是 rsLoRA 取最简单的代表元:
注意 LoRA 的
实现:只改 scaling 的分母
实现上 rsLoRA 与 LoRA 的唯一区别就是把缩放分母从
import math
# 标准 LoRA: scaling = alpha / r
scaling = alpha / math.sqrt(r) # rsLoRA:唯一改动
h = x @ W0.T + scaling * (x @ A.T) @ B.T在 HuggingFace peft 中开启极其简单——LoraConfig(use_rslora=True),库会自动把缩放分母改成
实验结果:困惑度随 rank 持续下降、梯度不再坍缩
设置
主实验微调 Llama 2,数据用 OpenOrca 指令微调集的 20,000 条样本,AdamW、HuggingFace 默认学习率 0.0005、常数调度,适配器加在所有线性(非 LayerNorm)注意力与前馈 MLP 子模块上。扫
Benchmark 表现(以原文为准)
困惑度(Figure 2):LoRA(铜色梯度)的曲线无论 rank 大小几乎挤成一团、收敛到相近的损失,"larger ranks even performing slightly worse"(更大 rank 甚至略差);rsLoRA(蓝绿色梯度)则 rank 越大困惑度越低,解锁了大 rank 的容量收益。

图源:Kalajdzievski, A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA(arXiv:2312.03732)Figure 2——LoRA 与 rsLoRA 在
下的微调困惑度(用于学习注解,版权归原作者)。
梯度范数(Figure 3):直接验证坍缩机制——

图源:Kalajdzievski, A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA(arXiv:2312.03732)Figure 3——LoRA 梯度随 rank 坍缩、rsLoRA 保持稳定(用于学习注解,版权归原作者)。
左图 LoRA 的梯度范数随 rank 增大逐级下降、跨越约两个数量级,印证"大 rank 学不动";右图 rsLoRA 各 rank 在训练起点就保持相同梯度范数,且全程维持在同一数量级。
消融:排除"只是变相调大学习率"
论文跑了一组消融(附录 B),逐一堵住替代解释:
- 换模型/优化器/数据集:把 GPT-J(6B)在 GSM8k 上用 Adafactor 微调(Figure 5),同样出现"LoRA 各 rank 曲线几乎重叠、rsLoRA 随 rank 解锁更优性能",证明结论可迁移。
- 换 SGD:去掉 AdamW 后梯度范数稳定性模式不变(Figure 4),排除"是自适应优化器带来的稳定"。
- 学习率扫描:对 LoRA 的
扫学习率,怎么调都追不上默认学习率下 rsLoRA 高 rank 的表现——说明 rsLoRA 的增益来自"更大容量真的被用上了",而非 变相充当 learning-rate boost。 - 只加注意力模块:与全模块结果相似。
- 只校正初始化、不改缩放:仅把
的初始化按 缩放、缩放因子仍用 ,大 rank 下训练变得不稳定/次优——证明必须靠重参数化的缩放因子纠正,初始化补不了。
看榜须知:本文是机制性论文而非刷榜,报告的是同一套实验里 LoRA vs rsLoRA 的相对趋势(困惑度、梯度范数),并非跨系统绝对分数对比;关注"rsLoRA 让大 rank 重新有收益"这一定性结论即可。
在 LoRA 谱系里的位置
rsLoRA 在 LoRA 家族里只动缩放因子这一个旋钮,因此与几乎所有其他变体正交、可叠加:
| 维度 | LoRA( | rsLoRA( |
|---|---|---|
| 缩放因子阶数 | ||
| 小 rank(4–16) | 与 rsLoRA 基本无差异 | 基本无差异 |
| 大 rank(≥64) | 收益快速饱和 | 持续受益,效果随 rank 继续提升 |
| 实现成本 | — | 一行改动 |
| 推理开销 | 合并后无 | 合并后无 |
| 需重标定的超参 | — |
小 rank 时两者差距小,因为
- vs LoRA:rsLoRA 是 LoRA 的"缩放因子修正版"——同样的结构与合并方式,只把
改成 ,把 LoRA 论文里被掩盖的"大 rank 收益"重新打开。 - vs QLoRA:rsLoRA 只动缩放、与 QLoRA 的量化基座完全正交,常被一起用——QLoRA 省显存让你能上更大 rank,rsLoRA 让这些 rank 真正发挥作用。
- vs AdaLoRA:AdaLoRA 动态分配各层 rank、但仍沿用 LoRA 的
;本文明确指出 AdaLoRA 在不同 rank 间切换时正受同一个过度衰减缩放之累,"optimizing the selection of … can improve upon AdaLoRA",把 AdaLoRA 建在 rsLoRA 之上有望进一步提升(尤其高 rank 预算)。 - vs LoRA+:LoRA+ 调的是
的学习率比,rsLoRA 调的是整体缩放尺度——两者都涉及"尺度",叠加时建议先固定 rsLoRA 的缩放、再单独标定 LoRA+ 的学习率比,避免两个尺度旋钮互相干扰。 - vs DoRA / PiSSA:DoRA(幅度-方向分解)、PiSSA(用主奇异成分初始化)改的是适配器的参数化/初始化,与 rsLoRA 的缩放修正各管一件事,原则上可组合。
实践经验:
- 换缩放后必须重标定
与学习率:有效尺度变了,别再用 这类与 绑定的经验值;一个实用做法是固定 、把学习率当主旋钮重扫一遍。 - 什么时候值得开:只有当你确实想用大 rank(如
,做较重领域适配或要更大增量容量)时 rsLoRA 才有明显价值;若本来只用 的轻量适配,开不开几乎无差别,没必要额外引入调参负担。