GenAI Systems Lab Open interactive version →
AI Engineering 11 min read

LoRA → How a 2021 Paper Made Fine-Tuning Affordable for Everyone

Hu et al. introduced Low-Rank Adaptation as a way to fine-tune giant models by training a tiny fraction of parameters. What LoRA does mathematically, why it works, and how QLoRA, AdaLoRA, and LoRA+ evolved it for production use.

In 2021, Edward Hu and colleagues at Microsoft published 'LoRA: Low-Rank Adaptation of Large Language Models.' The paper proposed fine-tuning large models by training a small set of additional low-rank matrices rather than updating all model weights. At the time, fine-tuning GPT-3 required hundreds of billions of parameter updates. LoRA reduced the trainable parameter count by 10,000x.

LoRA became the standard method for fine-tuning open-source models. Understanding how it works — and what QLoRA, AdaLoRA, and LoRA+ add — tells you what's actually happening when you fine-tune Llama or Mistral today.

How LoRA works

The key insight is that weight updates during fine-tuning tend to be low-rank. When you fine-tune a model for a specific task, you're not changing the model's general knowledge — you're making small, structured adjustments. Those adjustments can be captured by two small matrices rather than a full weight update.

For a weight matrix W with shape d×k, LoRA adds a bypass: instead of updating W directly, it trains two matrices A (d×r) and B (r×k) where r is the rank, typically 4–64. The effective weight update is W + αBA, where α is a scaling hyperparameter. During inference, you can either merge the LoRA weights back into W (zero inference overhead) or keep them separate (allows swapping adapters).

LoRA trains only A and B — typically 0.1%–1% of total model parameters. For a 7B parameter model, you might train 5–50M parameters instead of 7B. This makes fine-tuning on consumer hardware actually possible.

Which layers to apply LoRA to

The original paper applies LoRA to the attention weight matrices (Q, K, V projections). In practice, applying it to both attention and feedforward layers consistently improves results. The choice of rank (r) is a key hyperparameter: lower rank = fewer trainable parameters but lower expressivity. r=8 or r=16 works for most tasks; r=64 for harder adaptation tasks.

QLoRA: making it fit on consumer GPUs

Dettmers et al. (2023) combined LoRA with 4-bit quantization to create QLoRA. The base model weights are stored in 4-bit NormalFloat (NF4), with dequantization happening on-the-fly during training. LoRA adapters train in BFloat16. The result: fine-tuning a 65B parameter model on a single A100 GPU with full-dataset quality. QLoRA made open-source model fine-tuning accessible to researchers without data-center hardware.

What production fine-tuning looks like today

Adapter merging and switching

One underappreciated feature of LoRA: you can serve multiple fine-tuned models from a single base model by keeping adapters separate and swapping them per-request. This is the foundation of multi-tenant fine-tuned model serving — S-LoRA and similar systems serve hundreds of fine-tuned adapters simultaneously on shared base model weights.

Interactive lab:

Try it interactively

GenAI Systems Lab is a free platform for AI engineers — configure real failure modes, break things, and build the judgment that gets you hired.

Open GenAI Systems Lab →