Fine-tuning, RLHF & Alignment·Question 14 of 61Intermediate

Which modules do you target with LoRA, how do you pick the rank, and what are the actual memory savings?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Modules: the original paper adapted only q and v projections, but current practice is to target all attention projections (q, k, v, o) plus the MLP matrices (gate/up/down) - at fixed trainable-parameter budget, covering more modules at lower rank generally beats high rank on few modules (this is also QLoRA's finding: adapting all linear layers was needed to match full fine-tuning). Embeddings and the LM head are usually left frozen unless you've added new tokens.

Full worked answer

Modules: the original paper adapted only q and v projections, but current practice is to target all attention projections (q, k, v, o) plus the MLP matrices (gate/up/down) - at fixed trainable-parameter budget, covering more modules at lower rank generally beats high rank on few modules (this is also QLoRA's finding: adapting all linear layers was needed to match full fine-tuning). Embeddings and the LM head are usually left frozen unless you've added new tokens.

Rank: r=8-16 for style/format/persona; r=32-64 for harder behavioral shifts or more capable task learning; beyond 64 you hit diminishing returns for most SFT tasks - if r=64 still underfits, the problem is usually data or the low-rank assumption itself (consider full FT). Practical method: start r=16, alpha=32; if held-out quality plateaus below target and more/better data doesn't move it, double r and compare.

Memory math (7B-class model, hidden 4096, 32 layers, all-linear targeting at r=16): adapter params come to roughly ~40M - ~0.6% of the model. The savings:

  • Full FT with Adam, mixed precision: ~16 bytes/param → ~112 GB for weights+grads+optimizer states.
  • LoRA: frozen base in bf16 ~14 GB (no grads, no optimizer states) + adapters ~40M params with grads and fp32 Adam states → well under 1 GB. Total ~15 GB + activations → fits a 24 GB GPU with gradient checkpointing.
  • QLoRA: base in NF4 ~3.5-4 GB → 7B fine-tunes fit consumer cards.

Going further: follow-up territory

Two caveats that show real experience: activations still scale with batch × sequence length regardless of LoRA (checkpointing is what controls that), and backward passes still flow through the frozen base weights, so compute savings are modest - LoRA saves memory, not FLOPs.

What a good answer covers

  • Modules: the original paper adapted only q and v projections, but current practice is to target all…
  • Embeddings and the LM head are usually left frozen unless you've added new tokens
  • Rank: r=8-16 for style/format/persona; r=32-64 for harder behavioral shifts or more capable task…
  • Practical method: start r=16, alpha=32; if held-out quality plateaus below target and more/better data…
  • Memory math (7B-class model, hidden 4096, 32 layers, all-linear targeting at r=16)

Key terms: Modules · Rank · Memory math

Interviewer follow-ups to expect

  1. Why does low-rank-many-modules beat high-rank-few-modules at equal parameter count?

  2. When would you also train the embedding layer?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep