Modern LLMs have billions of parameters. Fine-tuning all of them for a new task means:
- Storing full gradient and optimizer states for every parameter (for Adam, that's 2 extra copies of the model's weights)
- Needing enormous GPU memory — a 7B parameter model can require 100+ GB to fully fine-tune
- Producing a completely new copy of the model for every task, which is expensive to store and deploy Most teams and researchers simply don't have the hardware to do this repeatedly. This is the gap LoRA was built to close.
LoRA's Idea: Low-Rank Decomposition of Weight Updates
LoRA (Low-Rank Adaptation), introduced by Hu et al. in 2021, starts from an observation: when you fine-tune a model, the change in weights (ΔW) tends to have a low "intrinsic rank" — meaning it can be well-approximated by a much smaller matrix.
Instead of learning a full ΔW (which is as big as the original weight matrix W), LoRA decomposes it into two much smaller matrices:
ΔW = B × A
Where:
-
Wis the original weight matrix, shape(d × k) -
Ais a new matrix, shape(r × k) -
Bis a new matrix, shape(d × r) -
ris the "rank" — a small number like 4, 8, or 16, far smaller thandorkDuring training: - The original
Wis frozen — never updated - Only
AandBare trained - At inference, the effective weight is
W + BA, or these can even be merged into a single matrix so there's no extra latency Sinceris tiny compared todandk, the number of trainable parameters drops dramatically — often to less than 1% of the original model.

Diagram for an overview on LoRA
The Math and Intuition
Picture W as a 1000 × 1000 matrix — a million parameters. If you set r = 8:
-
Ais8 × 1000= 8,000 parameters -
Bis1000 × 8= 8,000 parameters - Total trainable: 16,000 parameters — about 1.6% of the original
Ais typically initialized randomly (Gaussian), andBis initialized to zero. This means at the very start of training,BA = 0, so the model behaves exactly like the original pretrained model — training starts from a stable, known-good point and gradually learns the adaptation.
Why It Works
The core hypothesis is that fine-tuning doesn't require moving weights in every possible direction — it requires nudging them within a much smaller subspace relevant to the new task. Empirically, this holds up surprisingly well: LoRA models often match or come close to full fine-tuning performance, despite training a tiny fraction of the parameters.
A useful mental model: full fine-tuning is like being allowed to redraw an entire map from scratch. LoRA is like being handed a small set of transparent overlays you can slide around on top of the original map — limited in what you can change, but often exactly enough to redirect the model toward a new task.
QLoRA: Adding Quantization to the Mix
LoRA reduces how many parameters you train. It doesn't address how much memory the frozen base model itself consumes — a 65B parameter model in 16-bit precision still takes over 130GB just to load.
QLoRA (Dettmers et al., 2023) solves this by combining LoRA with quantization:
- The frozen base model is quantized down to 4-bit precision (using a scheme called NF4, designed to preserve accuracy for normally-distributed weights)
- LoRA adapters are added on top, kept in higher precision (like bfloat16)
- Only the LoRA adapters are trained; the quantized base model stays frozen throughout This combination is what made it possible to fine-tune a 65B parameter model on a single 48GB GPU — a task that would otherwise require a multi-GPU cluster.
The key insight is that these two techniques attack different bottlenecks and stack cleanly: quantization shrinks the frozen base model's footprint, while LoRA keeps the trainable portion small.
Practical Trade-offs
A few things matter when applying LoRA in practice:
- Rank (r) choice: Higher rank means more capacity to adapt, but more parameters and memory. Many tasks work well with r = 8 or 16; more complex tasks may benefit from r = 32 or 64.
- Which layers to target: LoRA is often applied only to the attention layers' query and value projection matrices, though applying it more broadly (to all linear layers) can improve performance at some extra cost.
- Alpha scaling: LoRA includes a scaling factor (alpha/r) that controls how much the adapter's output influences the frozen weights — this needs tuning alongside rank.
- Merging vs. keeping separate: For deployment, LoRA weights can be merged into the base model for zero extra inference cost, or kept separate to allow quickly swapping between multiple task-specific adapters on the same base model. ## Conclusion
LoRA reframes fine-tuning as a low-rank optimization problem, letting massive models be adapted with a tiny fraction of the compute and memory that full fine-tuning would need. Paired with quantization in QLoRA, it's become one of the most practical ways to customize large models without needing datacenter-scale hardware.


Top comments (0)