AdaLoRA › Worked Example: Step-by-Step AdaLoRA Pruning
Language AI HandbookAll chapters AdaLoRA › Worked Example: Step-by-Step AdaLoRA PruningOne section · Sections in this chapter5 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
To build concrete intuition for how AdaLoRA's pruning decisions unfold, let's work through a small numerical example from first principles. We will consider a toy model with just two adapted weight matrices, each initialized at rank 3, with a target budget of 3 total triplets (meaning we need to prune half the components).
Setup: Two weight matrices and , each with initial rank . Total initial budget: triplets. Target budget: triplets. We are at some training step after the warmup period.
Step 1: Read current singular values and gradients.
For matrix , suppose the current singular values and their gradients are:
- Triplet : ,
- Triplet : ,
- Triplet : ,
For matrix :
- Triplet : ,
- Triplet : ,
- Triplet : ,
Step 2: Compute instantaneous sensitivities.
For :
For :
Notice that triplet (the second component of ) has the highest sensitivity despite not having the largest magnitude. This is because its gradient is large in magnitude (), showing the loss is sensitive to this component's value. Triplet has a larger magnitude but smaller gradient, suggesting it has already settled near a good value.
Step 3: Update exponential moving averages (assuming previous smoothed estimates).
Suppose the previous smoothed estimates were and :
For :
For :
Step 4: Compute final importance scores. For simplicity, assume the orthonormality constraint is well-satisfied so that and , and assume all layers have the same dimensions so the normalization factor is the same for all. The importance score simplifies to .
Step 5: Global ranking and pruning. Sorting all six triplets by importance score in descending order:
- Triplet : (keep)
- Triplet : (keep)
- Triplet : (keep)
- Triplet : (prune)
- Triplet : (prune)
- Triplet : (prune)
With a budget of 3, we keep triplets 1, 2, and 4 (the top 3 by importance) and mask the rest by setting their values to zero. The resulting effective rank distribution is: gets rank 2 (keeps triplets 1 and 2), gets rank 1 (keeps triplet 4 only).
Step 6: Interpretation. This allocation shows the data-driven discovery that is more important for this task than : it receives twice the parameter budget. Within , the first two triplets both have importance scores above 0.11 and are kept, while the third has an importance score near zero and is discarded. Within , only the first triplet has a real importance score; the second and third are pruned.
Notice something interesting about the pruning decision for triplet versus : triplet has a much larger magnitude ( versus ) but is still pruned, while triplet is also pruned. What matters is the combined importance score: even 's smallest triplet ranks 5th overall with , just barely above triplet . A layer-by-layer approach that independently pruned within each matrix might make a different decision, but the global competition yields an allocation where total budgeted importance is maximized.