Explain LoRA: what is trained, how rank and alpha matter, where adapters go, and how QLoRA cuts memory further. How would you serve 50 customer-specific adapters?
Theme reported publicly: Mistral AI
Answer
Model answer, written in a candidate's voice
In short
- Frozen base W; learn low-rank ΔW = BA scaled by α/r; B starts at zero so training begins at the base model
- Trainable params typically well under 1%; small optimizer state; rank trades capacity vs overfitting; adapters on attention projections and often MLPs
- QLoRA: 4-bit NF4 base with double quantization and paged optimizers; compute in bf16
- Serving: merge for single-tenant; otherwise batched multi-adapter serving with an adapter cache and enough slots for concurrency; latency overhead
- Per-adapter evaluation and versioning
In full
LoRA keeps the pretrained base weight W frozen and learns a low-rank update ΔW = BA, scaled by α/r, with B initialized to zero so the model starts exactly at the base and only the small adapter matrices are trained. That makes trainable parameters typically well under 1% and the optimizer state small, while rank r trades capacity against overfitting and α controls the effective update scale rather than the rank itself; adapters are usually placed on attention projections and often on MLPs. QLoRA pushes memory lower by keeping the base in 4-bit NF4 with double quantization and paged optimizers, while still computing in bf16. For 50 customer-specific adapters, I would merge the adapter into the base only for a single-tenant deployment; for concurrent multi-tenant serving I would keep one shared base resident, load adapters through a cache, batch by adapter, and provision enough adapter slots for the expected concurrency, accepting extra latency from adapter loads, cache misses, and the added matmuls. Each adapter should be evaluated on its own held-out set and versioned with the base model, data, and hyperparameters so a bad adapter can be rolled back without touching the others.
What a strong answer covers
- Frozen base weight W; learned low-rank update ΔW = BA scaled by α/r; B initialised to zero so training starts at the base model
- Trainable parameters typically well under 1%; small optimiser state; rank trades capacity against overfitting; adapters on attention projections and often MLPs
- QLoRA: 4-bit NF4 base with double quantisation and paged optimisers; compute in bf16
- Serving: merge for single-tenant; otherwise batched multi-adapter serving with an adapter cache (and enough adapter slots for the concurrency); latency overhead
- Per-adapter evaluation and versioning
Common mistakes
- Claiming LoRA makes inference cheaper
- confusing rank with the number of layers adapted