A weight matrix W0∈R4096×4096 is adapted with LoRA of rank r=8. How many trainable parameters does LoRA add for this matrix, and what fraction of the full matrix is that? If LoRA is applied to the query and value matrices of all 32 layers, how many trainable parameters is that in total?

Sequence models and transformers, Parameter-efficient fine-tuning
Level L2 Elementary. Length Short. Nature Mat Mathematical.

What's being asked

Whether you know the LoRA factorisation ΔW=BA and can count its parameters.

Key idea

LoRA replaces the update ΔW∈Rd×k by BA with B∈Rd×r and A∈Rr×k, so it adds r(d+k) parameters instead of dk.

Steps

  1. Full matrix: 4096×4096=16,777,216 parameters.
  2. LoRA: B is 4096×8 and A is 8×4096, so r(d+k)=8×8192=65,536 parameters.
  3. Fraction: 65,536/16,777,216=1/256≈0.39%.
  4. Two matrices (Wq and Wv) in each of 32 layers: 2×32×65,536=4,194,304≈4.2 million trainable parameters.
  5. The frozen base weights are not counted here, and the adapter can be merged into W0 after training, so inference cost is unchanged.

Common mistakes

How long your answer should be

3–4 lines of arithmetic.

Last checked on 4 December 2026.

Read this

Previous in Sequence models and transformers: A language model gives logits (2,1,0,−1) for four tokens. What are the sampling probabilities at temperature T=1, T=0.5 and T=2? What happens as T→0 and as T→∞?
Next in Sequence models and transformers: A scalar RNN has ht=tanh⁡(w ht−1+u xt) with w=0.5, u=1 and h0=0. For inputs x1=1 and x2=−1, what are h1, h2 and the gradient ∂h2/∂h1?