LIVEยทThe trends shaping tomorrow's world.
AI

What Is LoRA and QLoRA?

LoRA fine-tunes a frozen model by training two small matrices per layer; QLoRA does it on a 4-bit base. How both work, what they save and their limits.

LoRA (Low-Rank Adaptation) is a way to fine-tune a large model without changing its original weights. It freezes the pretrained model and trains two small matrices per adapted layer, whose product becomes the weight update [1]. QLoRA applies the same idea to a base model that has been compressed to 4 bits, which cut memory needs far enough for its authors to fine-tune a 65-billion-parameter model on a single 48 GB GPU [2].

This piece explains the mechanism. If you're still deciding whether to fine-tune at all, start with our guide to fine-tuning vs prompt engineering, and for adding knowledge rather than behavior, see RAG vs fine-tuning.

Why full fine-tuning is expensive

Training a neural network means computing a gradient for every trainable weight and, with the common Adam optimizer, keeping extra optimizer state for each of them (our explainer on training vs inference covers the loop). Full fine-tuning updates every weight, so the memory bill scales with the whole model.

The LoRA authors used GPT-3 175B as the cautionary example. Each fully fine-tuned copy has 175 billion parameters, so deploying a separate copy for each task is, in their words, "prohibitively expensive" [1].

How LoRA works

The core idea: the update is low-rank

Take one weight matrix inside a transformer, call it Wโ‚€, with d rows and k columns. Fine-tuning learns some change ฮ”W, so the adapted weight is Wโ‚€ + ฮ”W.

LoRA's bet is that ฮ”W doesn't need all d ร— k degrees of freedom. The authors hypothesized that weight updates during adaptation have a low "intrinsic rank," building on earlier work showing pretrained language models can learn well inside a much smaller subspace [1]. So instead of learning ฮ”W directly, LoRA writes it as the product of two thin matrices:

  • B, with d rows and r columns;
  • A, with r rows and k columns;
  • where the rank r is much smaller than d or k [1].

During training, Wโ‚€ gets no gradient updates; only A and B learn. Both paths see the same input x, and their outputs are added: h = Wโ‚€x + BAx [1]. In practice the update is scaled by a constant ฮฑ/r, which the authors say reduces the need to retune hyperparameters when you change r [1].

Two details that matter

It starts as a no-op. A is initialized with random Gaussian values and B with zeros, so BA is zero at the start and training begins from the unchanged base model [1]. Hugging Face's PEFT library defaults to a similar scheme (Kaiming-uniform for A, zeros for B), which it describes as an identity transform [3].

It can disappear at inference. After training you can compute W = Wโ‚€ + BA once and serve that merged matrix like any other. That is why the paper says LoRA adds no inference latency "by construction" [1]. To switch tasks, subtract BA and add a different pair [1].

How much it saves

A quick piece of arithmetic shows the scale. For a 4,096 ร— 4,096 matrix, a full update has about 16.8 million values. A rank-8 LoRA update has 8 ร— (4,096 + 4,096) = 65,536, about 0.4% as many.

The paper's own measurements on GPT-3 175B, compared with full fine-tuning using Adam [1]:

  • trainable parameters fell by about 10,000 times;
  • training memory (VRAM) fell from 1.2 TB to 350 GB;
  • with rank 4 on just the query and value projections, the saved checkpoint shrank from 350 GB to 35 MB;
  • training ran about 25% faster, because most gradients no longer had to be computed.

Quality held up. The authors reported LoRA performing on par with or better than full fine-tuning on RoBERTa, DeBERTa, GPT-2 and GPT-3 [1]. They also found very small ranks often sufficed on GPT-3; in some experiments a rank of one worked well when adapting both query and value matrices [1].

Many tasks, one base model

Because the base stays frozen, one copy can serve many adapters. The paper's example: storing 100 adapted GPT-3 models takes roughly 350 GB plus 100 ร— 35 MB, about 354 GB, versus about 35 TB for 100 full copies [1]. PEFT's documentation makes the same point, calling LoRA adapters "lightweight and portable" [3].

How QLoRA works

QLoRA, published in 2023 by Tim Dettmers and colleagues at the University of Washington, asks a follow-up question: if the base model is frozen anyway, why store it at full precision? [2]

The method backpropagates through a frozen, 4-bit quantized base model into LoRA adapters [2]. (Our explainer on model quantization covers the general idea of storing weights in fewer bits.) It adds three memory-saving pieces [2]:

  1. 4-bit NormalFloat (NF4). A new 4-bit data type built for weights that are roughly normally distributed, which the authors describe as information-theoretically optimal for that case. It beat 4-bit integers and 4-bit floats in their tests.
  2. Double Quantization. Quantization needs small scaling constants; QLoRA quantizes those too, saving about 0.37 bits per parameter, or roughly 3 GB on a 65B model.
  3. Paged Optimizers. These use NVIDIA unified memory to avoid the memory spikes that occur when a mini-batch contains long sequences.

One subtlety: QLoRA doesn't do its math in 4 bits. Weights are stored in NF4 and dequantized to BFloat16 whenever a layer runs, so each matrix multiply happens in 16-bit [2].

What QLoRA achieved

The headline: fine-tuning a 65B model, which the authors say would normally need more than 780 GB of GPU memory, in under 48 GB, while preserving the task performance of full 16-bit fine-tuning [2]. Their Guanaco model family reached 99.3% of ChatGPT's level on the Vicuna benchmark after 24 hours of fine-tuning on one GPU [2]. Treat that comparison as a 2023 snapshot on a benchmark the authors themselves questioned (more on that below).

Two practical findings from the paper are still useful:

  • Put adapters everywhere. The authors found that the number of LoRA adapters was the most critical LoRA setting, and that adapters on all linear transformer layers were needed to match full fine-tuning. The rank r mattered much less in their tests [2].
  • Data quality beats data size. A 9,000-example dataset (OASST1) outperformed a 450,000-example subsample of FLAN v2 for chatbot performance [2].

LoRA vs QLoRA vs full fine-tuning


Full fine-tuning

LoRA

QLoRA

What trains

Every weight

Small A and B matrices per adapted layer

Same as LoRA

Base model in memory

Full precision, plus gradients and optimizer state for all weights

Full or half precision, frozen

4-bit NF4, frozen, dequantized per layer

Output file

A full model copy

A small adapter (35 MB in the paper's GPT-3 example) [1]

A small adapter

Inference latency

Baseline

None added once merged [1]

None added once merged, but merging into quantized weights adds rounding error (see below) [4]

Typical reason to choose

Maximum flexibility, large budget

Cheaper training, many task variants on one base

Fitting the biggest possible base onto limited GPU memory

What the settings mean in practice

Most open-source LoRA work runs through Hugging Face's PEFT library, so its LoraConfig vocabulary is worth knowing [3]:

  • r: the rank. Lower means fewer trainable parameters.
  • lora_alpha: the scaling factor in ฮฑ/r. PEFT also offers rank-stabilized scaling (use_rslora=True), which divides by โˆšr instead of r [3].
  • target_modules: which layers get adapters. PEFT notes LoRA is "typically applied to attention blocks only," but for QLoRA-style training it recommends target_modules="all-linear", matching the paper's finding [3][4].
  • init_lora_weights: initialization. For quantized base models, PEFT suggests LoftQ, which initializes the adapters to offset quantization error [3][4].

To reproduce QLoRA's recipe, PEFT's guide loads the base model with load_in_4bit=True, bnb_4bit_quant_type="nf4", double quantization switched on and BFloat16 as the compute type [4].

When you're done, merge_and_unload() folds the adapter into the base so it runs as a standalone model [3]. With quantized bases, be careful: merging dequantizes, adds the adapter and re-quantizes, so unmerging doesn't restore the original weights exactly and repeated cycles can accumulate rounding error [4].

Where LoRA shows up

  • Open-weight model customization. PEFT supports LoRA on top of several quantization schemes, including bitsandbytes 4-bit and 8-bit and GPTQ [4]. That combination is the route most teams take to fine-tune an open-weight model on their own hardware.
  • Managed cloud tuning. Google's Vertex AI documentation describes parameter-efficient "adapter tuning" for Gemini models and says its reinforcement-learning fine-tuning option updates "a parameter-efficient LoRA adapter" [5].

Limitations and risks

  • Batching across adapters. If you merge an adapter into the weights to avoid latency, you can't easily mix requests for different adapters in one batch. The paper notes you can keep adapters unmerged and pick them per request when latency matters less [1].
  • It changes behavior more readily than knowledge. LoRA is a fine-tuning method, so it inherits fine-tuning's limits; for facts that change, retrieval usually fits better. See RAG vs fine-tuning.
  • Adapters can memorize. The 2026 OWASP Top 10 for LLM Applications warns that fine-tunes and LoRA adapters can memorize training data, and that narrow adapters can reproduce rare examples with high fidelity [6]. Don't train an adapter on data you couldn't tolerate leaking. Our guide to AI data privacy and security covers the controls.
  • Benchmarks can mislead. The QLoRA authors found that strong MMLU scores didn't imply strong chatbot scores, and concluded that chatbot benchmarks of the time weren't trustworthy [2]. Evaluate on your own task; see AI benchmarking and model evaluation.

How to choose

  1. Try prompting and retrieval first. Both Google and OpenAI document a workflow that starts with prompts and evaluations and treats fine-tuning as optional [5][7].
  2. If you do fine-tune an open-weight model, default to LoRA. It keeps the base model intact and the output small.
  3. Reach for QLoRA when memory is the constraint, for example to fit a larger base model onto the GPU you have.
  4. Target all linear layers and keep the rank modest, then spend your effort on data quality, following the QLoRA findings [2].
  5. Check your platform's status. As of November 2026, OpenAI is winding down its self-serve fine-tuning platform: new jobs stop for all organizations on December 15, 2026 (earlier cutoffs already applied to inactive organizations), though existing fine-tuned models keep running until their base models are retired [7][8].

Frequently asked questions

What does "low-rank" mean in LoRA?

A matrix's rank is roughly how many independent directions it contains. LoRA forces the weight update to be the product of a d ร— r and an r ร— k matrix, so it can have at most rank r. The bet, supported by the paper's experiments, is that useful fine-tuning updates live in a small number of directions [1].

Does LoRA make the model slower?

Not if you merge it. Once training ends you can add BA into Wโ‚€ and serve a single matrix, so there's no extra computation at inference [1]. Keeping adapters separate adds a small cost but lets you swap tasks quickly.

Is QLoRA worse than LoRA?

Not on the benchmarks its authors tested. They report that QLoRA preserved the task performance of full 16-bit fine-tuning [2]. The trade-off is engineering complexity, plus some care when merging adapters into quantized weights [4].

What rank should I use?

Small ranks often work. The LoRA paper found ranks as low as one or four effective on GPT-3, and QLoRA found rank mattered less than putting adapters on every linear layer [1][2]. Start small and test on your own evaluation set.

Can I use LoRA with closed models like GPT or Gemini?

Only through whatever the provider offers. Google documents parameter-efficient adapter tuning on Vertex AI [5]. OpenAI's self-serve fine-tuning is closing to new jobs on December 15, 2026 [8]. Open-weight models give you direct control over LoRA.

Sources

  1. Hu, E. et al. "LoRA: Low-Rank Adaptation of Large Language Models." arXiv:2106.09685, v2, October 2021. https://arxiv.org/abs/2106.09685
  2. Dettmers, T., Pagnoni, A., Holtzman, A., Zettlemoyer, L. "QLoRA: Efficient Finetuning of Quantized LLMs." arXiv:2305.14314, May 2023. https://arxiv.org/abs/2305.14314
  3. Hugging Face. "LoRA" (PEFT conceptual guide). https://huggingface.co/docs/peft/main/en/conceptual_guides/lora
  4. Hugging Face. "Quantization" (PEFT developer guide). https://huggingface.co/docs/peft/main/en/developer_guides/quantization
  5. Google Cloud. "Introduction to tuning" (Vertex AI generative AI documentation). https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/tune-models
  6. OWASP GenAI Security Project. "LLM02:2026 Sensitive Information Disclosure." OWASP Top 10 for LLM Applications 2026, published August 4, 2026. https://raw.githubusercontent.com/GenAI-Security-Project/GenAI-LLM-Top10/main/2026/final/LLM02_SensitiveInformationDisclosure.md
  7. OpenAI. "Model optimization." https://developers.openai.com/api/docs/guides/model-optimization
  8. OpenAI. "Deprecations." https://developers.openai.com/api/docs/deprecations