Parameter-efficient adaptation
Derive low-rank update dimensions and distinguish trainable-state savings from total model memory.
On this page
The question for today
What you’ll understand
- Compute low-rank adapter parameter counts and update shapes.
- Identify which memory categories freezing parameters actually removes.
- Design an adaptation comparison with controlled targets and budgets.
Adapting a large pretrained model does not always require changing every weight. Parameter-efficient methods constrain the change to a smaller set of trainable parameters, such as inserted bottleneck modules or low-rank updates. This can reduce optimizer state and make many task-specific variants easier to store. It does not make the frozen base model disappear, and it does not guarantee that a restricted update family can express every useful adaptation.
Factor the update, not necessarily the original weight
Use a column-vector convention: a frozen linear map W has output width d_out and input width d_in. A low-rank update is BA, where A maps the input to rank r and B maps that bottleneck to the output. The pretrained weight can remain full rank. It is the learned difference that is constrained. The rank of BA is at most r, even if the two factors together contain more than r numbers.
An update scale controls the contribution of the adapter relative to the base branch. A common initialization makes one factor zero and the other nonzero so the initial update is zero but useful gradients can reach one factor. Setting both factors to zero makes the bilinear update's initial gradients zero. Implementations may use different scaling or initialization rules, so preserve those details when comparing rank choices rather than treating rank as the entire method.
Count the memory categories separately
Low-rank factors need r times the sum of input and output widths parameters rather than their product. Gradients and optimizer moments are then needed only for trainable parameters if the implementation freezes the base correctly. However, the base weights still occupy storage, and backpropagation through frozen layers may still require activations to propagate gradients to adapters. Activation checkpointing and reduced-precision storage address different memory terms.
For a static linear adapter, its update can be merged into the base weight before inference, removing the extra low-rank branch in exact arithmetic. Finite-precision rounding can cause small numerical differences, and keeping multiple task adapters available may favor unmerged execution. Nonlinear bottleneck adapters generally cannot be absorbed into a single fixed linear weight. Quantizing a base model while training adapters adds precision and kernel constraints; it is an additional technique rather than an automatic property of low rank.
Adaptation quality needs controlled evidence
Choose target modules according to the hypothesis. Adapting only attention projections constrains a different part of the model from adapting feed-forward projections or embeddings. A fixed rank in every layer is convenient but does not prove every layer needs the same update capacity. Compare validation quality, trainable parameter count, peak memory, training time, and serving behavior. Include a frozen-model baseline to determine whether adaptation helps at all.
Keep task data, evaluation splits, prompt formats, and tuning budgets aligned when comparing full fine-tuning with adapters. Test forgetting and out-of-domain behavior, because a small parameter update can still cause a large behavioral change. Track the exact base checkpoint and adapter compatibility; matching tensor dimensions does not prove that an adapter belongs to a different base revision. Store adapter metadata as part of the model artifact so loading a compact file does not silently select the wrong computation.
Work it through
Size a rank-eight update
Adapt a 4,096 by 4,096 dense weight with rank eight. Ignore bias and scaling parameters, and store all weights in two bytes per parameter for this illustration.
The base matrix contains 4,096²=16,777,216 parameters, requiring 33,554,432 bytes, or 32 MiB.
The two factors contain 8×(4,096+4,096)=65,536 trainable parameters, requiring 131,072 bytes, or 128 KiB.
The adapter-to-base parameter ratio is 65,536/16,777,216=1/256≈0.3906%. Optimizer memory savings depend on optimizer precision and state count; the 32 MiB base still exists.
A small trainable update can greatly reduce trainable state while leaving base-weight and activation memory substantial.
The living notebook
Explore the model
Interactive lab · vectors
Inspect a constrained direction
The lab displays one two-dimensional vector, controlled by angle and magnitude, and its coordinate projections. Use a fixed angle to imagine a one-direction update family and vary magnitude along it. It does not factor a matrix, train LoRA, or measure singular values; the algebra defines the actual rank constraint.
- x component
- 1.393
- y component
- 0.975
- Magnitude
- 1.7
Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forRestricting update directions can reduce the adaptation search space, but the useful change may require directions the chosen family cannot express.
Pause & reason
Check your understanding
Your turn
Try it yourself
For input width 1,024, output width 2,048, and rank four, compute factor shapes and parameter count. What is the largest possible rank of the update?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use A as rank by input width and B as output width by rank under the column-vector convention.
Compare with the solution
A is 4×1,024 and B is 2,048×4. Together they have 4,096+8,192=12,288 parameters. Their product is 2,048×1,024 and has rank at most four, possibly lower if either factor is rank deficient. This does not constrain the frozen base matrix to rank four.
Keep the idea
Take it with you
- Low-rank adaptation constrains a learned difference rather than the base matrix.
- Trainable-state savings do not remove base weights or every activation.
- Rank, target modules, initialization, and artifact compatibility all affect the result.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.