Merge updates, not arbitrary factor sums
Check BA orientation, scaling, rank growth, and quantization before treating merged adapters as equivalent execution.
On this page
The question for today
What you’ll understand
- Compute a small scaled BA update and its merged output.
- Explain why summing two low-rank updates can require larger rank.
- Separate exact algebra from finite-precision, dropout, and quantized implementation behavior.
An adapter can run alongside a frozen base or be merged into the base weight for inference when the implementation supports it. The algebra is simple only after orientation and scaling are fixed. Combining multiple adapters adds another issue: adding their factors is generally not the same as adding their update matrices. Check the exact operation, base artifact, and numeric path rather than assuming every merge method is reversible or quality preserving.
One adapter has a clear algebraic merge
Under column-vector convention, standard LoRA computes W₀x+sB(Ax) with s=alpha/r. In exact arithmetic and without dropout or other active adapter behavior, this equals(W₀+sBA)x. The same frozen base and target orientation must be used for both paths. Training-time adapter dropout must be disabled for the simple deterministic equivalence. Additional mechanisms or biases can change the full transformation and need their documented merge semantics.
Floating-point operation order can make the separate and merged paths differ numerically even when the exact-real expressions match. Quantized bases add dequantization and requantization choices;merging into low-bit storage may approximate the update. Repeated merge/unmerge cycles need not restore the original quantized bytes. Preserve an immutable base and adapter artifact rather than using repeated inverse operations as the only rollback mechanism. Test the exact inference dtype and backend used in release.
Multiple updates can exceed one adapter's rank
For two updates s₁B₁A₁ and s₂B₂A₂, their sum can be represented exactly by concatenating appropriately scaled B factors horizontally and stacking A factors vertically. The combined factor width can be r₁+r₂. Compressing it back to a smaller rank is generally an approximation unless additional structure makes the sum lower rank. Quality after that compression must be evaluated rather than inferred from the original adapters' separate scores.
Adding B₁+B₂ and A₁+A₂ creates cross terms B₁A₂ and B₂A₁, so it does not generally equal the desired sum of updates. PEFT 0.17.0 documents multiple merging methods with different assumptions and restrictions;identify the selected method rather than treating a weighted-adapter API name as one universal algebra. Also verify base compatibility and target sets. Two adapters trained from different base revisions cannot automatically be added as if their deltas shared the same reference point.
Validate the final artifact rather than the recipe name
Compare separate-adapter and merged outputs on representative fixed inputs under the same decoding and numeric settings. Include cases near decision boundaries and long context where small logit differences can change generated text. Evaluate each task and retention set after composition because adding updates is not a linear interpolation of model behavior. Record merge weights, algorithm, dtype, quantization configuration, and immutable source hashes. A successful tensor-shape load does not establish the intended base or output equivalence.
The matrix lab is a restricted orientation aid. Reset and set both a=1, b=1, predict its determinant 1 and shear, then Step. It shows only [[a, b], [0,1]], not arbitrary adapter factors or a rank-compression algorithm. Readouts describe the chosen matrix while geometry interpolates. Use it to distinguish an input vector from an output mapping, but calculate the BA example below independently;the sliders cannot express every merged update or forecast its language-model quality.
Work it through
A two-dimensional rank-one update
Let W₀ be the 2×2 identity, A=[1,2], B=[3,4]ᵀ, rank r=1, and alpha=2, so s=2. Use exact arithmetic and x=[1, −1]ᵀ, with dropout disabled.
BA=[[3,6], [4,8]], so the scaled update is[[6,12], [8,16]]. The merged matrix is[[7,12], [8,17]].
The separate path gives Ax=−1, B(Ax)=[−3, −4]ᵀ, and sB(Ax)=[−6, −8]ᵀ. Adding W₀x=[1, −1]ᵀ yields[−5, −9]ᵀ.
The merged product gives[7−12,8−17]ᵀ=[−5, −9]ᵀ, matching the exact expression. Finite-precision or quantized execution requires its own numerical comparison rather than assuming this integer example proves byte-level equivalence.
Orientation and scaling determine the merge. Correct exact algebra is necessary, but deployment equivalence still depends on the numeric implementation.
The living notebook
Explore the model
Interactive lab · matrix
Orientation aid, not an adapter merger
Reset, set a=1, b=1, predict determinant 1 and shear, then Step. This fixed triangular 2 D family cannot express arbitrary BA updates, multiple-adapter composition, or rank compression.
- Area scale · det A
- 1.4
- Singular values · σmax, σmin
- 1.597, 0.876
- Condition number · κ₂(A)
- 1.823
The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. 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 forCompute the actual update matrices and numeric merge path explicitly.
Pause & reason
Check your understanding
Your turn
Try it yourself
Two unit-scaled rank-one updates are Δ₁=[[3,6], [4,8]]and Δ₂=[[0,1], [0,0]]. Add them, compute the determinant, and decide whether their sum is necessarily rank one.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
A nonzero determinant for a 2×2 matrix implies full rank.
Compare with the solution
The sum is[[3,7], [4,8]]. Its determinant is 3×8−7×4=−4, so it has rank two. Each component is rank one, but preserving their sum exactly can require rank two. Compressing that sum to one factor pair of rank one changes the update in general;measure the resulting behavior rather than assuming unchanged quality.
Keep the idea
Take it with you
- A merge needs the same base, orientation, scaling, and deterministic adapter behavior.
- Summed updates can require more rank than either component.
- Floating-point and quantized merge paths need artifact-specific validation and immutable rollback sources.
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.