QLoRA

On this page 7

QLoRA (quantized low-rank adaptation) is a parameter-efficient fine-tuning method that freezes a pretrained model in 4-bit precision and trains small LoRA adapter matrices in higher precision on top of it. Gradients flow through the quantized weights into the adapters, so the model learns a new task while its base weights stay compressed and unchanged.

In training within artificial intelligence, QLoRA matters because it makes fine-tuning large language models feasible on a single GPU. Introduced in 2023, it showed that a model with about 65 billion parameters could be fine-tuned on one 48 GB card with quality close to 16-bit fine-tuning, which shifted adaptation from data centers to ordinary workstations.

How QLoRA combines quantization and low-rank adapters

QLoRA builds on two neighboring techniques. Quantization stores each base weight in 4 bits instead of 16, cutting weight memory by roughly a factor of four. LoRA adds to selected weight matrices a trainable update expressed as the product of two thin matrices with a small rank r, so only a fraction of a percent of parameters is trained.

During the forward pass, each 4-bit weight block is dequantized on the fly to a 16-bit compute type, multiplied with the input, and added to the adapter output. During backpropagation, gradients pass through the frozen dequantized weights but only the adapter weights are updated. The base model therefore never needs full-precision copies or optimizer states.

The original method introduced three specific components, summarized below.

ComponentWhat it doesBenefit
4-bit NormalFloat (NF4)Quantization levels matched to normally distributed weightsLower error than plain 4-bit integers
Double quantizationQuantizes the per-block scaling constants tooSaves about 0.4 bits per parameter
Paged optimizersMoves optimizer state to CPU memory on spikesAvoids out-of-memory crashes
The three innovations that define QLoRA

Key QLoRA parameters and typical values

QLoRA configuration combines quantization settings for the frozen base and adapter settings for the trainable part. The values below are common starting points; the best choice depends on model size, task difficulty and dataset size.

ParameterCommon rangeEffect
Quantization typeNF4 or FP4Accuracy of the frozen base weights
Compute dtypeBF16 or FP16Precision of matrix multiplications
Block size64 weights per blockGranularity of scaling constants
LoRA rank r8 to 64Adapter capacity and size
LoRA alpha16 to 64, often 2rScale of the adapter update
LoRA dropout0.0 to 0.1Regularization of adapters
Target modulesAll linear layersWhere adaptation happens
Learning rate0.0001 to 0.0003Speed and stability of training
Typical QLoRA settings and what they control

A frequent finding is that applying adapters to all linear layers, including the feed-forward projections, matters more than raising the rank. Attention-only adapters with a high rank often underperform broader coverage with a moderate rank.

QLoRA compared with other fine-tuning approaches

QLoRA sits between full fine-tuning and plain LoRA on the memory and fidelity spectrum. The table compares approximate memory requirements for a model with about 7 billion parameters; real figures vary with sequence length, batch size and implementation.

ApproachTrainable shareApproximate GPU memoryQuality relative to full tuning
Full fine-tuning100%Above 100 GB with AdamReference
LoRA on 16-bit baseUnder 1%About 16 to 24 GBClose on most tasks
QLoRA on 4-bit baseUnder 1%About 6 to 12 GBClose on most tasks
Prompt tuningWell under 0.1%Similar to inferenceWeaker on complex tasks
Fine-tuning approaches for a 7-billion-parameter model

QLoRA is complementary to other training methods rather than a replacement. A model can be adapted with QLoRA for supervised fine-tuning and then aligned with DPO or RLHF using the same adapter approach, while distillation pursues a different goal of transferring knowledge into a smaller model.

Deploying a QLoRA-trained model

After training, the adapter is a small separate file, often tens to a few hundred megabytes. Teams then choose how to serve it, and each option has consequences for speed and accuracy.

OptionHow it worksConsideration
Serve adapter on 4-bit baseLoad base and adapter separatelyMatches training conditions exactly
Merge into 16-bit baseAdd adapter to dequantized weightsFast inference, larger memory use
Merge then requantizeMerge, then quantize againSmall accuracy drift possible
Multi-adapter servingOne base, many swappable adaptersEfficient for many customers or tasks
Deployment options after QLoRA training

Merging the adapter into a 16-bit copy of the base and then quantizing again can introduce a small mismatch compared with the training setup, so the merged model should be re-evaluated on the task benchmark before release.

Limitations and common mistakes

QLoRA reduces memory, not compute time or data requirements. Dequantization adds overhead, so training steps are often slower than LoRA on a 16-bit base, and the quality ceiling is still set by the data.

  • Expecting new knowledge from small data: adapters change behavior and format well but add factual knowledge unreliably.
  • Mismatched chat templates: training and inference must use the same prompt format, or quality drops sharply.
  • Overfitting small datasets: a few hundred examples over many epochs can degrade general abilities.
  • Skipping baseline evaluation: without comparing to the untuned model, gains or regressions remain invisible.
  • Ignoring license terms: the base model license also governs the fine-tuned derivative.

In everyday language

Teaching a large AI model a new skill normally requires very expensive hardware, because the whole model must be held in memory at full detail. QLoRA shrinks the model to save space and then trains only a small set of extra settings attached to it.

It is a bit like keeping a huge reference book in compact paperback form and adding sticky notes for your own field. The book itself never changes, but the notes teach it new habits. The result is a customized model that can be built on a single graphics card.

Seen in the real world

A legal technology team wants a model that drafts contract clause summaries in its firm’s house style. It has about 5,000 reviewed examples and one workstation with a 24 GB GPU, which is far too little for full fine-tuning of an 8-billion-parameter model.

The team loads the base model in NF4 with double quantization, attaches LoRA adapters with rank 16 and alpha 32 to all linear layers, and trains for two epochs at a learning rate of 0.0002. Training takes several hours, and the adapter file is under 200 megabytes.

On a held-out set of 300 clauses, reviewers rate the tuned model’s summaries as clearly more consistent with house style than the base model’s output. The team serves the adapter on the quantized base, matching the training setup exactly.