PEFT freezes the pretrained weights and trains a small set of new numbers beside them. LoRA, the default, learns each weight matrix's change as the product of two thin matrices, ΔW = (α/r)BA: training holds about 2 bytes per frozen parameter instead of 16, each task ships as megabytes instead of a copy of the model, and the change folds back into the weights for serving.
What follows from freezing the base, with the numbers:
You need: what a matrix's rank and its singular value decomposition (SVD) are (Linear algebra for ML: vectors to SVD, rank, conditioning, low-rank methods); where Adam's 16 bytes per parameter come from (ZeRO); the post-training stages a LoRA usually runs (Alignment).
Shapes from the config (q_proj is 4,096 × 4,096). derived training state: 16 bytes per trained number (bf16 weight and gradient, fp32 master copy and two Adam moments, the ZeRO accounting) and 2 bytes per frozen one, so 268 MB against 35.7 MB for this matrix at rank 16. B and A are drawn at their true thickness, at least 1.5 px.
Every method answers one question differently: which numbers are trained, and where do they touch the frozen network? The diagram places each on one decoder block; the table below counts them on Llama 3 8B (8.03B parameters).
Why LoRA won. Adapters sit in series, so every token runs extra sequential layers: the LoRA paper measured a forward pass of GPT-2 medium 20.7% to 30.3% slower at batch size 1 and 128 tokens, shrinking to 2.2% to 3.0% at batch 32 and 512 tokens (LoRA Table 1). Soft prompts spend context positions, train less stably and score lower: on LLaMA-7B commonsense reasoning, prefix tuning averaged 64.6 against LoRA's 74.7 (DoRA Table 1, baselines from LLM-Adapters). LoRA sits in parallel and merges away, so it costs nothing at serving time; its descendants each change one thing (QLoRA the base's storage, DoRA magnitude against direction, LoRA-FA and VeRA what is trained, rsLoRA and LoRA+ the scale and learning rates).
Grey boxes are frozen; dashed boxes are new layers in the token's path. Methods in the highlight colour add nothing to the path once merged.
| Method | What is trained | Trainable on Llama 3 8B | Extra cost when serving |
|---|---|---|---|
| Full fine-tuning | Every weight | 8.03B (100%) | None, but one full copy per task |
| Head only | A new output layer | task-sized | None |
| Adapters (Houlsby 2019) | Two bottleneck MLPs per block | 33.8M at m = 64 | Extra sequential layers on every token |
| Prompt tuning | n "virtual token" embeddings | 81,920 at n = 20 | n more tokens of context |
| Prefix tuning, P-tuning v2 | n keys and values per layer | 1.31M at n = 20 | n more cached positions |
| (IA)³ | One scaling vector each for keys, values and the MLP hidden units | 0.52M | None once folded into the weights |
| LoRA | Two thin matrices B, A per adapted matrix | 41.9M at r = 16, all 7 matrices | None once merged |
| LoRA-FA | LoRA with A frozen at its random start; only B trains | 22.0M at r = 16, all | None once merged |
| VeRA | Two scaling vectors per matrix; one random B, A pair shared by all layers and frozen | 1.61M at r = 1,024, all 7 | None once merged |
| QLoRA | LoRA, on a base stored in 4-bit NF4 | as LoRA | Merge needs care (see Memory and QLoRA) |
| DoRA | LoRA for each weight's direction plus one magnitude per output unit | 43.3M at r = 16, all | None once merged |
Counts from the config.json by the page's formulas, identical to the counts the PEFT library itself reports; the Trainable parameters tab recomputes them for any model, rank and target set. (IA)³ scales keys, values and the input of the MLP's down projection, as PEFT does for Llama; VeRA's rank 1,024 on every linear layer is the VeRA paper's instruction-tuning setup (VeRA §4.3). Adapter count from the LoRA paper's formula 2L(2dm + m + d) (LoRA §5.1).
LoRA (Hu et al. 2021) leaves a pretrained matrix W0 frozen and learns its change as the product of two thin matrices. Fig. 2 runs it on a real matrix: the query projection of layer 14 of SmolLM2-135M (576 × 576). For the "after" it uses a real fine-tuning update: the same matrix in SmolLM2-135M-Instruct, which its model card says was made from the base by SFT and then DPO. Full fine-tuning produced that update; LoRA cannot, because it is limited to rank r, so the LoRA steps show the closest rank-r matrix to it (its truncated SVD, the best any rank-r update can do in squared error).
Predict, then watch: what share of this real update can a rank-64 matrix (of a possible 576) hold? Pick r = 64 and look at step 3. (Rank 64 recovers 57% of the update's squared size.)
At rank 16 LoRA's training state for this matrix is 958 KB (2 B per frozen number plus 16 B per trained one), and it ships 37 KB per task.
measured by delta_probe.py from the two published checkpoints (bf16; storing the fine-tuned weights in bf16 can account for well under 0.1% of the update's squared size). Plates show the top-left 16 × 16 corner of each matrix; counters are for the whole matrix. Both updates are drawn at their own scale, 12 times finer than W0's, the same for both plates. Rank 1, 4, 16 and 64 hold 2.3%, 7.8%, 23% and 57% of the update. Bytes: 2 per bf16 number shipped; training state 16 bytes per trained number and 2 per frozen one.
The formula, in the figure's names:
use_rslora=True. Changing r under one convention while keeping α from a recipe written for the other changes the effective learning rate; know which one your library applies.Microsoft's own loralib initialises A Kaiming-uniform, "different than what is described in the paper but should not affect performance". LoRA+ (Hayou et al. 2024) shows that one learning rate for A and B is suboptimal at large width and gives B a larger one: 1 to 2% better and up to about 2 times faster, at the same cost.
The LoRA paper's own animation of a token through LoRA against an adapter, its GPT-3 parameter calculator, and a LoRA you can train in the browser on a task whose true update is known are on the LoRA paper page.
LoRA's bet is that the change fine-tuning needs is low-rank. The LoRA paper supported it with GPT-3, where rank 1 to 4 on the query and value matrices already matched larger ranks on its tasks. Full fine-tuning has no such limit, and its updates are not low-rank: Biderman et al. found full fine-tuning on code and math learns "perturbations with a rank that is 10-100× greater than typical LoRA configurations", rising with more data and higher in the MLP than in attention (LoRA Learns Less and Forgets Less). SmolLM2's real update says the same, first for the matrix of Fig. 2, direction by direction:
measured by delta_probe.py, the same two checkpoints; σ² are the squared singular values of ΔW, so the lit columns' heights add up to the share a rank-r matrix can hold.
Every other matrix of the model, the same way: the heatmap shows all 210 and the table their medians over the 30 layers.
Click or tap a cell.
measured SmolLM2-135M to SmolLM2-135M-Instruct, every layer; medians over the 30 layers in the table (about 200 of 576 directions for 90% of the attention query and output, about 350 for the MLP matrices). Rank shares are of min(din, dout): 576 for q, o and the MLP, 192 for k and v (grouped-query attention). Some single matrices did change in few directions: layer 0's value projection moved by 33% of its size with 90% of that in 22 directions.
The LoRA paper adapted only the attention query and value matrices of GPT-3. Practice has moved to every linear layer, especially the MLP:
Fig. 4 shows why the choice matters for cost: on a dense model most of an all-linear adapter sits in the MLP.
Each matrix costs r(din + dout) per layer: q and o 8,192, k and v 5,120 (8 KV heads), gate, up and down 18,432 each, so 55,296 of the 81,920 numbers per unit of rank per layer are in the MLP. The q and v of the LoRA paper's choice are 16% of an all-linear adapter at the same rank. derived from the config. The Trainable parameters tab breaks any configuration down, including a mixture-of-experts model where the expert matrices dominate.
Training with Adam in mixed precision holds about 16 bytes per trained parameter: the bf16 weight and gradient (2 + 2), an fp32 master weight and two moments (12) (ZeRO). LoRA pays them only for the adapter, and QLoRA (Dettmers et al., 2023) also stores the frozen base in 4 bits. On Llama 3 8B with a rank-16 adapter on every linear layer the three need 128.5 GB, 16.7 GB and 6.4 GB. How the 16 bytes split across GPUs is on Distributed Training.
Predict, then pick LLaMA 65B: does QLoRA's 65B fit one 48 GB card at the QLoRA recipe's rank 64? (Fig. 5 says about 47 GB before activations; the paper measured 45.0 GB at batch 1.)
derived before activations, KV cache and framework overhead: full = 16N; LoRA = 2N + 16P; QLoRA = 4.127/8 × (linear weights) + 2 × (embeddings and norms) + 16P, with P the adapter's count; 4.127 bits = 4 + 8/64 + 32/(64 × 256), NF4 plus double-quantised block constants. Published checks: Biderman et al. put a 7B model at 112 GB with Adam and 15.12 GB with LoRA (Table S14), the same accounting with 7B rounded (112 = 16 × 7) and adapters of about 1% (15.12 = 2 × 7 + 16 × 0.07); QLoRA's "more than 780 GB" for 16-bit fine-tuning of LLaMA 65B reproduces at 12 bytes per parameter (no fp32 master copy: 783 GB), the 16 used here give 1,045 GB. QLoRA's Figure 6 prints 37,074 MB for the 65B model in 4 bits, which does not reproduce: this arithmetic gives 34.46 GB, 2.6 GB less, and the paper does not itemise it; the figure also keeps adapters in bf16 with no master copy (12 rather than 16 bytes each) (QLoRA paper page).
QLoRA backpropagates through the dequantised 4-bit weights into bf16 adapters. That took fine-tuning a 65B model from more than 780 GB of GPU memory to under 48 GB, one GPU, "without degrading the runtime or predictive performance compared to a 16-bit fully finetuned baseline". Three pieces make it work:
QLoRA's recipe put LoRA on every linear layer (r = 64, α = 16). The trade is time: Sebastian Raschka measured 33% less memory for 39% more training time (21.33 GB and 1.85 h with bf16 LoRA against 14.18 GB and 2.79 h with QLoRA, in one of his runs) (Practical tips).
Merging onto a quantised base needs care. The adapter was trained against the dequantised 4-bit weights, so its product is right relative to those. The usual routes: merge into the original 16-bit weights and quantise the result again (which adds a fresh rounding error, so evaluate the merged model); keep the adapter separate at serving time; or train so the merge stays quantised, as QA-LoRA does. Some formats cannot merge at all: the PEFT docs say adapters on AQLM-quantised models "shall be saved separately, as merging them with AQLM quantized weights is not possible" (PEFT quantization guide). LoftQ goes the other way, choosing the LoRA initialisation to cancel part of the quantisation error.
Two careful studies, a year apart, agree more than their titles suggest: LoRA matches full fine-tuning when the data fits in its capacity and it is set up right, and falls behind when the data is pretraining-sized.
Biderman et al. trained Llama-2-7B on code and on math, two ways each: continued pretraining (CPT: StarCoder-Python up to 20B tokens; OpenWebMath, 14.7B tokens) and instruction fine-tuning (IFT: Magicoder-Evol-Instruct-110K, 73M tokens; MetaMathQA, 103M tokens). They scored the target skill (HumanEval for code, GSM8K for math) and, to measure forgetting, the average of HellaSwag, WinoGrande and ARC-Challenge, which the base model already knew.
Predict, then look: on code CPT, which run ends highest, and which forgets most? Then switch Fig. 6 to code IFT, where LoRA at rank 256 matches or beats full fine-tuning at epoch 4 while forgetting far less.
published values from Tables S1 to S8, one run per point; the paper's figures plot the same data. Further right is less forgetting; higher is more learning.
John Schulman and Thinking Machines Lab (29 September 2025) swept learning rates for LoRA and full fine-tuning on Llama 3 and Qwen3 models (including a mixture-of-experts one), with SFT on Tulu3 and OpenThoughts3 and RL on MATH and GSM. When "a few key details" are right, LoRA learns with the same sample efficiency as full fine-tuning:
A 4B model (empero-ai/Qwen3.8-4B-Distill, a third party's distillation of Qwen 3.8 into Qwen 3.5 4B) was taught to write PostgreSQL query plans: SFT on 394 GPT-6 Astra trajectories (440 generated in two rounds of 120 and 320, 40 kept for validation and 6 dropped) through a LoRA of 21.2 million parameters (42.5 MB), then a custom "anchored" GRPO against measured execution time. On 113 join-heavy queries its plans averaged 1.40 times the speed of Postgres's own planner in one search (geometric mean); the headline 1.81 times is the best of three searches, picked by single timings, for $1,200 in total (about $800 of rented 2 × H100 time and $400 of API fees; development on two RTX 3090s) (write-up, 16 September 2026; the evidence judged: our reading).
illustrative one 2-D column moved toward a target turned 60° at the same length, along the straight path each parametrisation takes in its own parameters; not a trained model. Both reach the target: it shows how each moves, not which is more accurate.
DoRA (Liu et al., ICML 2024) starts from a measurement: across training checkpoints, full fine-tuning's changes in each weight column's length and in its direction were negatively correlated (a large turn with a small stretch, or the reverse), while LoRA's were positively correlated, because one low-rank update moves both together. DoRA separates them: it trains each column's length directly and its direction with LoRA.
The results (Table 1): on eight commonsense-reasoning tasks, LLaMA-7B averaged 74.7 with LoRA (0.83% of parameters trained), 78.4 with DoRA (0.84%) and 77.5 with DoRA at half the rank (0.43%); LLaMA3-8B 80.8 against 85.2. Two cautions: the LoRA numbers for LLaMA 7B and 13B are taken from an earlier paper (LLM-Adapters) rather than re-tuned, while DoRA kept LoRA's configuration "adjusting only the learning rate"; and the extra 0.01% is the magnitude vector (the Trainable parameters tab's LLaMA-7B preset reproduces 0.83%, 0.84% and 0.43%). To save memory DoRA treats the norm as a constant in the backward pass, which cut training memory by about 24.4% on LLaMA with a 0.2-point difference in accuracy. Once trained, DoRA merges like LoRA, so serving is free; PEFT enables it with use_dora=True.
One adapter is best merged: the model is the base's shape and speed. Many adapters on one base are a different problem, and LoRA's parallel form answers it with multi-LoRA serving (Fig. 8); routing, adapter limits and engine settings are on LLM serving in production.
S-LoRA is the design of Fig. 8: the adapter pool in host memory, "Unified Paging" for adapter weights and the KV cache, and kernels that batch requests for adapters of different ranks. The merged baseline ran out of memory beyond a handful of adapters, and was 4 times slower even then: derived 8.05 / 2.04 = 3.9 times, and 7.99 / 0.25 = 32 times faster than PEFT, which swaps adapters between batches. Punica introduced the batching kernel for many LoRA models against one copy of the base; vLLM (--enable-lora) and SGLang ("techniques from S-LoRA and Punica") ship it; vLLM's limits (max_loras, max_lora_rank, max_cpu_loras), their defaults and what each costs are on vLLM: inside the default engine, section 5. The memory side of serving (KV cache, paging) is PagedAttention.
Apple's on-device foundation model swaps rank-16 adapters, "10s of megabytes" each, per feature (Apple, June 2024), and Thinking Machines' Tinker fine-tuning service is built on LoRA.
published S-LoRA Table 3: requests per second on one A100 80GB, synthetic workload; OOM is out of memory; "not run" means the paper did not run PEFT there. Settings from its Table 1.
| Situation | Choice | Why |
|---|---|---|
| Post-training on one node, model fits in bf16 | LoRA on all linear layers, r = 16 to 64 (256 for large SFT sets), learning rate about 10 times full fine-tuning's, modest batches; FSDP2 if the base needs sharding | Matches full fine-tuning in the low-regret regime at a fraction of the memory (Distributed Training for sharding) |
| Short of GPU memory, large base | QLoRA (NF4 base, bf16 adapters) | 65B on one 48 GB card; costs training time; evaluate after merging |
| RL fine-tuning (GRPO and its family) | LoRA, low rank (1 to 32) | RL absorbs about a bit per episode (RL for LLMs, Alignment) |
| Domain adaptation on billions of tokens | Full fine-tuning or continued pretraining (Data mixing, section 6) | Exceeds LoRA's capacity; LoRA learns less there |
| Many tenants or tasks on one deployment | One LoRA adapter per task, multi-LoRA serving | One base in memory; S-LoRA-style batching |
| Thousands of adapters where storage dominates | VeRA or (IA)³ | Ten to a hundred times fewer numbers than LoRA; check quality on your task |
How many numbers each method trains, for a model's real shapes (from its config.json), a rank and a set of target matrices. The formulas are below; for the open models they give exactly the counts the PEFT library reports (). This tab extends the Reading tab's methods table; what the counts mean for training memory is the Reading tab's memory calculator (Memory and QLoRA).
Try: the presets reproduce published counts. Then switch targets from all seven matrices to q and v only and watch LoRA shrink about 6 times on Llama 3 8B; pick Qwen3-30B-A3B to see an adapter on every expert reach 844M numbers at rank 16, 20 times the dense Llama 3 8B's adapter at the same rank.
The current LoRA configuration, matrix by matrix: each targeted matrix costs r(din + dout) per layer (per expert in a mixture-of-experts layer).
Configs: . GPT-3 175B shapes from the GPT-3 paper (d = 12,288, 96 layers, MLP 4d, no gate); its total is the published 175B. Library check: peft_counts.py builds each open model empty from its config with PEFT and reads the library's trainable count. Mixture-of-experts LoRA is counted per expert; PEFT wraps transformers' fused expert tensors in its own way and is not compared there.
The careful empirical study of when LoRA matches full fine-tuning: layers, capacity, learning rate, batch size, RL at rank 1. (50 min)
The same findings as runnable SFT and GRPO configurations, with a reproduction on SmolLM3. (30 min)
The standard implementation of every method on this page, with the LoRA developer guide (rsLoRA, DoRA, initialisation options) and the quantization guide. (40 min)
Hyperparameter intuition from many runs: rank, α, which layers, QLoRA's memory against time trade. (30 min)
Code and math, continued pretraining against instruction tuning, the learning and forgetting tables behind this page's chart, and the spectral analysis of full fine-tuning's updates. (45 min)
Unified Paging, heterogeneous batching kernels and the throughput table above. (40 min)
LoRA against an adapter animated, the GPT-3 parameter calculator, a LoRA you train in the browser on a task whose true update is known, every table rebuilt, and Then and now to 2025. (21 min)
NF4 built and measured on real LLaMA weights, double quantisation, the Guanaco evaluations rechecked. (31 min)
Where the 16 bytes per trained parameter come from, and how sharding divides them. (24 min)
The KV-cache paging that S-LoRA's Unified Paging extends to adapter weights. (27 min)
The parent: every stage compared on what it changes, its data, cost and failure; its Machinery section gives bytes per parameter in one paragraph and links here for the calculator. (22 min, plus 22 in closed details)
NF4 among the other formats, and quantisation-aware training against QLoRA-style adapters. (34 min, plus 11 in closed details)
The post-training stages a LoRA usually runs. (33 min, plus 4 in closed details)
FSDP and the other ways to split a model when even the frozen base does not fit. (32 min, plus 5 in closed details)
Continued pretraining (section 6) is the regime where full fine-tuning beats LoRA: billions of tokens of new domain text. (45 min)
The RL algorithms that LoRA matches at rank 1. (53 min)
Serving systems, where multi-LoRA batching lives. (34 min)
Bottleneck adapters: within 0.4% of full fine-tuning on GLUE with 3.6% of the parameters. (30 min)
Soft prompts at every layer and at the input only. (50 min)
The weight-decomposition analysis and the method. (35 min)
The variants, each changing one thing about LoRA or replacing it with vectors; read the abstracts first. (25 min)
The batching kernel for many LoRA models on one base, which SGLang cites with S-LoRA. (30 min)
Times: paper pages give their paper tab's time; migrated knowledge base pages the length of their Reading tab; pages not yet migrated and external resources an estimate.