Adapter Methods & Parameter-Efficient Fine-Tuning
LoRA, QLoRA, AdaLoRA, prefix tuning, prompt tuning, (IA)3, and the theory of low-rank adaptation: why PEFT works, rank selection, and when to use which method.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- LoRA: Low-Rank Adaptation
- QLoRA: Quantized LoRA
- AdaLoRA: Adaptive Rank
- Prefix Tuning
- Prompt Tuning
- (IA)3: Few-Parameter Adaptation
- Choosing the Right Method
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Derive LoRA from the low-rank hypothesis of weight updates.
- Explain QLoRA's memory savings via NF4 quantization.
- Compare prefix tuning, prompt tuning, and adapter methods.
- Analyze when full fine-tuning outperforms PEFT.
- Select the optimal PEFT method for a given scenario.
Notation
- — LoRA decomposition ()
- — rank (LoRA rank)
- — LoRA scaling factor
Core Intuition
Full fine-tuning updates all parameters (billions) but typically changes each weight by only a small amount. This suggests the weight UPDATE has low rank — it lies in a low-dimensional subspace. PEFT methods exploit this by parameterizing the update efficiently: LoRA uses rank- matrices, prefix tuning adds learnable tokens, prompt tuning modifies the input embedding.
Adapter Methods Comparison
LoRA: Low-Rank Adaptation
Forward pass:
where is frozen, initialized from , initialized to zero.
Parameters: per adapted layer vs for full fine-tuning. For : 131K vs 16.8M (128x reduction).
Applied to: Typically in attention. Optionally FFN layers.
Merging: After training, merge: . No inference overhead.
QLoRA: Quantized LoRA
Innovation: Combine 4-bit quantization of base model with LoRA adapters:
- Quantize to NF4 (4-bit NormalFloat).
- Add FP16 LoRA adapters on top.
- Backpropagate through the quantized weights to update LoRA.
Memory: 70B model: 35 GB (NF4) + tiny LoRA adapters. Fits on single 48GB GPU.
Double quantization: Even the quantization constants (scales) are quantized to FP8, saving additional memory.
AdaLoRA: Adaptive Rank
Problem: Not all layers need the same rank. Important layers benefit from higher rank; less important ones need minimal adaptation.
Solution: Parameterize adapters with SVD and prune small singular values:
Rank is allocated adaptively based on importance (measured by sensitivity of the loss to that component).
Prefix Tuning
Add learnable "virtual tokens" to keys and values:
where are learned prefix embeddings ( = prefix length).
Parameters: per layer. For : 5.2M total.
Advantage: Modular — different prefixes for different tasks, swappable at inference.
Prompt Tuning
Simplest PEFT: Only add learnable embeddings at the input layer:
Parameters: total (80K for ).
Performance: Competitive with full fine-tuning only for very large models (above 10B). For smaller models, insufficient expressiveness.
(IA)3: Few-Parameter Adaptation
Learned rescaling vectors for keys, values, and FFN:
Parameters: Only per layer (400K total for a 7B model). Extremely lightweight.
Performance: Surprisingly effective for classification tasks. Less effective for generation.
Choosing the Right Method
- Full fine-tuning: When you have enough compute and data, and need maximum quality.
- LoRA (–): Default choice for instruction tuning and domain adaptation.
- QLoRA: When GPU memory is the constraint (single GPU for large models).
- Prefix tuning: When you need multiple task-specific modules (swappable at runtime).
- Prompt tuning: For very large models with minimal parameter budget.
- (IA)3: For classification/NLU tasks with extreme parameter efficiency.
Common Pitfalls
Pitfall 1. Using too low rank for complex tasks. works for simple classification; instruction tuning often needs –.
Pitfall 2. Only applying LoRA to attention layers. For best results, also adapt FFN layers (up and down projections).
Pitfall 3. Not tuning the LoRA ratio. This controls the effective learning rate for the adapter. Default works but isn't always optimal.
Summary
- LoRA: Low-rank weight update; 128x fewer parameters; no inference overhead after merging.
- QLoRA: LoRA on 4-bit base model; enables 70B fine-tuning on single GPU.
- AdaLoRA: Adaptive rank allocation based on layer importance.
- Prefix/Prompt tuning: Learnable virtual tokens; modular and task-swappable.
- (IA)3: Minimal parameters (rescaling only); good for classification.
- Choice depends on: quality needs, memory budget, modularity requirements.
Exercises
Exercise 1. For LoRA with on all attention layers of a 7B model (): compute total trainable parameters and percentage of full model.
Exercise 2. Derive the gradient of the loss with respect to LoRA matrix (showing it flows through frozen ).
Exercise 3. Compare memory requirements for QLoRA () vs full fine-tuning of a 13B model with AdamW.
Exercise 4. Design an experiment to determine the optimal rank for fine-tuning on a specific task.
Exercise 5. Explain why LoRA with initialized to zero ensures the model starts at the pre-trained weights.