Low-Rank Adaptation in Depth
Intrinsic dimension, LoRA’s design choices and fine-tuning quantized models.
LoRA freezes the model and trains two thin matrices per weight, and on GPT-3 a rank of one was enough for some tasks. Why should such small updates work, what do they actually learn, how should they be scaled and trained, and what do they give up? This lesson goes from the intrinsic dimension of fine-tuning through LoRA's design choices and its successors to fine-tuning a 4-bit model with QLoRA, and ends with the evidence that LoRA learns less and forgets less.
What you’ll learn
- Define the intrinsic dimension of fine-tuning, interpret its measurements, and state the generalization bound built on it.
- Derive LoRA's gradients at initialization and justify its design choices: zero-initialized , the factor, which matrices to adapt and how small the rank can be.
- Explain rank-stabilized scaling, separate learning rates for and , magnitude–direction decomposition and adaptive ranks.
- Compute the memory budget of QLoRA's 4-bit NormalFloat weights with double quantization.
- Summarize what LoRA learns and forgets compared with full fine-tuning, including intruder dimensions.
How many dimensions does fine-tuning need?
Li, Farkhoor, Liu & Yosinski (2018) asked how many directions training really needs: train only coordinates in a fixed random subspace, , and find the smallest that reaches 90% of full performance (Training in a Tiny Subspace covers training from scratch). Aghajanyan, Gupta & Zettlemoyer (2021) applied the idea to fine-tuning pretrained language models, with the pretrained weights and a fast structured random projection (the Fastfood transform). Their structure-aware variant spends a few of the coordinates on one scale per layer, .
| Model | on MRPC | on QQP |
|---|---|---|
| BERT-Base | 1,608 | 8,030 |
| BERT-Large | 1,037 | 1,200 |
| RoBERTa-Base | 896 | 896 |
| RoBERTa-Large | 207 | 774 |
Two trends stood out. Over the checkpoints of a RoBERTa pretraining run, the intrinsic dimension of downstream tasks fell steadily, although pretraining never saw those tasks: in their words, "pre-training implicitly minimizes intrinsic dimension". And larger models tended to have lower intrinsic dimension after a fixed number of pretraining updates. They also turned the measurement into a compression bound: a model fine-tuned in a -dimensional subspace on examples has a generalization gap of order , independent of the full parameter count. The bound applies to subspace training itself; ordinary fine-tuning by SGD is not shown to stay in such a subspace.
Think first If 200 random directions suffice, why does LoRA learn its low-rank factors instead of using a random projection?
Random subspaces are a measuring device, not an efficient method: to reach full performance they need far more than dimensions, and the projection must be recomputed in every forward pass. LoRA keeps the low-dimensional spirit but learns the subspace, with structure that matches the network: one low-rank factor pair per weight matrix, which costs an extra matrix product during training and nothing at inference once merged.
LoRA’s design, derived
For a frozen weight , LoRA (Hu et al., 2022) computes with , and a scaling factor . starts as a random Gaussian matrix and at zero.
Let be the gradient arriving at the layer's output for one example. The adapter's output is , so by the chain rule
With the model starts exactly at the pretrained one, and only moves on the first step, in the directions picked by the random projection. starts moving once is nonzero. Initializing both at zero would leave both gradients zero forever; initializing both randomly would perturb the pretrained model at step 0.
Why ? Hu et al. note that when optimizing with Adam and a suitably scaled initialization, "tuning α is roughly the same as tuning the learning rate", so they set to the first they try and leave it, which lets be changed without retuning the learning rate, at least for small ranks. The next step shows that this choice is not stable for large .
Which matrices, which rank. On GPT-3 (175 billion parameters) with a fixed budget of 18 million trainable parameters, putting it all into or at rank 8 did markedly worse than spreading it: and together at rank 4 (73.7% on WikiSQL, 91.3% on MultiNLI) and all four attention matrices at rank 2 (73.7%, 91.7%) gave the best results. Applied to and , a rank as small as 1 sufficed on those datasets, with the authors' caveat that tasks far from the pretraining data, such as a new language, may need more. Freezing also removes its gradients and optimizer state: with on and , training memory for GPT-3 fell from 1.2 TB to 350 GB, and a task's checkpoint from 350 GB to 35 MB.
What the update learns. Comparing the learned subspaces at ranks 8 and 64, only the top direction or so was shared, which suggests the remaining directions mostly carry noise. Projecting onto the singular directions of its update (rank 4, layer 48) gave a Frobenius norm of , against for 's own top directions and for random ones: the update is correlated with but does not reinforce its dominant directions. With , it amplifies the directions it picks by a factor of about . Hu et al.'s reading: LoRA amplifies features that pretraining learned but did not emphasize.
LoRA with rank adapts a feed-forward weight matrix of shape (the shape used in LLaMA-7B). How many parameters does it train for this one matrix, in thousands?
Show the answer
241.7 thousand
, against million for the full matrix: about . For a square matrix at it would be against million, about .
Scaling, learning rates and decompositions
With , practitioners found that raising the rank often did not help, as if the extra directions went unused. Kalajdzievski (2023) traced this to the scaling factor.
A one-step calculation shows the mechanism.
Start from and take one gradient step of size on a single example. From the gradient above, , so the adapter's new output on that input is
has coordinates, each a random combination of the input with fixed variance, so grows in proportion to :
With the update shrinks like : higher ranks learn more slowly, which wipes out their benefit. With it is independent of , as the theorem requires along the whole trajectory: rank-stabilized LoRA (rsLoRA), which lets extra rank trade training compute for accuracy at no inference cost. (The theorem is proved for SGD; the paper's main experiments use AdamW, with a separate check under SGD.)
| Variant | Change to LoRA | Motivation and reported effect |
|---|---|---|
| rsLoRA (Kalajdzievski, 2023) | scaling instead of | keeps learning from slowing down at higher ranks |
| LoRA+ (Hayou, Ghosh & Yu, 2024) | a larger learning rate for than for , with | a width-scaling analysis shows equal rates are suboptimal for wide models; up to about faster fine-tuning and 1–2% better results |
| DoRA (Liu et al., 2024) | : a trainable magnitude per column, with LoRA updating only the direction ( is the norm of each column) | brings LoRA's pattern of magnitude and direction changes closer to full fine-tuning's; still mergeable, so no inference overhead |
| AdaLoRA (Zhang et al., 2023) | the update in SVD form , pruning singular values by an importance score | moves the rank budget to the matrices and layers that need it |
Fine-tuning a 4-bit model: QLoRA
LoRA removes the optimizer state of the frozen weights, but the weights themselves still have to sit in memory: 130 GB for a 65-billion-parameter model in 16-bit precision. QLoRA (Dettmers, Pagnoni, Holtzman & Zettlemoyer, 2023) stores the frozen base in 4 bits and backpropagates through it into LoRA adapters. Three ideas make it work:
- 4-bit NormalFloat (NF4). Pretrained weights are roughly normally distributed, so the 16 levels are placed at quantiles of a standard normal, rescaled to ; the two halves are built separately so that zero is exact, giving 7 negative levels, zero and 8 positive levels. Each block of 64 weights is divided by its largest absolute value before quantization. The authors call NF4 "information theoretically optimal for normally distributed weights", since each level is then used about equally often.
- Double quantization. The per-block scales are themselves quantized, to 8-bit floats in blocks of 256, so their overhead drops from bits per parameter to bits.
- Paged optimizers. Optimizer states live in unified memory and move to CPU RAM during memory spikes, such as long sequences with gradient checkpointing.
For each matrix multiplication the 4-bit weights are dequantized to BF16 and multiplied in 16-bit; only the adapters receive gradients. Adapters on all linear layers were needed to match 16-bit full fine-tuning; adapting only the query and value projections, as in the original LoRA, was not enough for large models. The paper's headline: fine-tuning a 65-billion-parameter model on a single 48 GB GPU "while preserving full 16-bit finetuning task performance".
How many gigabytes do the frozen weights of a 65-billion-parameter model take in QLoRA's format, counting 4 bits per weight plus the double-quantized constants ( bits per weight)? Use bytes.
Show the answer
33.5 GB
bytes: GB of 4-bit weights plus about GB of constants (single-level 32-bit constants would have taken about GB, so double quantization saves about GB). That leaves room on a 48 GB card for the adapters, their optimizer state and the activations, against GB for the 16-bit weights alone.
How the 4-bit base compares with other weight-only quantizers such as GPTQ, and why outlier features make low-bit formats hard, is the subject of Quantization in Depth.
What LoRA learns and what it forgets
Matching full fine-tuning on benchmarks like GLUE does not mean LoRA is full fine-tuning. Biderman et al. (2024) compared the two on harder targets, programming and mathematics, in two regimes: instruction fine-tuning on about 100,000 prompt–response pairs and continued pretraining on 20 billion tokens. In standard low-rank configurations LoRA substantially underperformed full fine-tuning on the target domain, especially for continued pretraining, but it better preserved the base model's performance outside that domain: LoRA learns less and forgets less. It reduced forgetting more than weight decay or dropout did, and kept generations more diverse. Their spectral analysis offers a reason for the first half: full fine-tuning learned weight perturbations with ranks 10 to 100 times higher than typical LoRA configurations.
Shuttleworth, Andreas, Torralba & Sharma (2025) looked at the singular value decompositions of the fine-tuned weights. Even when accuracy matched, LoRA introduced intruder dimensions, new singular vectors with large singular values that are nearly orthogonal to those of the pretrained matrix, which full fine-tuning did not. LoRA forgot less overall, but its forgetting was concentrated in those dimensions: scaling their singular values down after training recovered much of the pretraining loss at little cost on the new task, and in sequential fine-tuning they accumulated and hurt.
Think first You must teach a base model a large new domain, continued pretraining on billions of tokens of code, and you care mainly about performance on that domain. Low-rank LoRA or full fine-tuning?
The evidence favors full fine-tuning. Biderman et al. found the gap largest for continued pretraining, where LoRA stayed behind full fine-tuning in every configuration they tried, rank 256 included (higher ranks narrowed the gap without closing it), and full fine-tuning's updates had very high rank. The trade-off reverses if keeping the base model's other abilities matters more than peak performance on the new domain, since low-rank LoRA forgets less.
Key takeaways
- Fine-tuning has a low intrinsic dimension: about 200 random directions bring RoBERTa-Large to 90% of full fine-tuning on MRPC, pretraining lowers the intrinsic dimension, and larger models have lower values.
- LoRA's zero-initialized starts training at the pretrained model, with only moving at first; adapting several matrices at low rank beats one matrix at higher rank, and its updates amplify directions the pretrained weights contain but do not emphasize.
- The factor makes updates shrink with rank; (rsLoRA) fixes it. LoRA+ uses a larger learning rate for , DoRA trains magnitudes separately from directions, and AdaLoRA reallocates rank.
- QLoRA freezes the base in 4-bit NormalFloat with double-quantized constants (about bits per weight, so about 33.5 GB for 65 billion parameters) and trains 16-bit adapters on all linear layers.
- LoRA learns less and forgets less than full fine-tuning, whose updates have far higher rank; its forgetting concentrates in intruder dimensions that accumulate under sequential fine-tuning.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
LoRA initializes randomly and at zero. Which factor receives a nonzero gradient on the very first training step?
- Only , because it multiplies the input
- Both, equally
- Neither, so a warmup step is needed
- Only , since vanishes while
Show the answer
D. Only , since vanishes while
is nonzero because is random; contains and is zero. After the first step and both factors train. The zero factor keeps the model exactly at the pretrained one at step 0.
Why does rank-stabilized LoRA scale the update by instead of ?
- So that the size of the learning updates no longer shrinks as the rank grows, letting higher ranks actually help
- So that the adapter can be merged into the weights
- To reduce the number of trainable parameters
- To make LoRA equivalent to full fine-tuning at every rank
Show the answer
A. So that the size of the learning updates no longer shrinks as the rank grows, letting higher ranks actually help
An update's effect scales like . With that is , so learning slows as the rank rises; with it is rank-independent.
In QLoRA, what does double quantization quantize?
- The LoRA adapters, to 4 bits
- The gradients, to 8 bits
- The per-block scaling constants of the 4-bit weights, cutting their overhead from about 0.5 to about 0.127 bits per weight
- The activations, to NF4
Show the answer
C. The per-block scaling constants of the 4-bit weights, cutting their overhead from about 0.5 to about 0.127 bits per weight
Each block of 64 weights has a 32-bit scale, half a bit per weight. Quantizing those scales to 8 bits in blocks of 256 leaves bits, about 3 GB saved on a 65-billion-parameter model.
Hu et al. projected onto the top singular directions of its LoRA update and got a small norm (), larger than for random directions () but far below 's own top directions (). What do they conclude?
- duplicates the dominant directions of
- amplifies directions that contains but does not emphasize, by a factor of about 21.5
- is unrelated to , like a random matrix
- must be full-rank to work
Show the answer
B. amplifies directions that contains but does not emphasize, by a factor of about 21.5
The update is correlated with (more than random) but not with its top directions; with , the directions it picks are amplified by . Their reading: fine-tuning boosts features pretraining learned but did not stress.
Further reading
- A. Aghajanyan, S. Gupta & L. Zettlemoyer, "Intrinsic dimensionality explains the effectiveness of language model fine-tuning," ACL (2021).
- E. J. Hu, Y. Shen, P. Wallis, Z. Allen-Zhu, Y. Li, S. Wang, L. Wang & W. Chen, "LoRA: low-rank adaptation of large language models," ICLR (2022).
- D. Kalajdzievski, "A rank stabilization scaling factor for fine-tuning with LoRA," arXiv:2312.03732 (2023).
- T. Dettmers, A. Pagnoni, A. Holtzman & L. Zettlemoyer, "QLoRA: efficient finetuning of quantized LLMs," NeurIPS (2023).
- D. Biderman et al., "LoRA learns less and forgets less," Transactions on Machine Learning Research (2024).