Part 2 of 15 in LLM fine-tuning techniques
QLoRA fine-tunes a large language model by loading its frozen weights in 4-bit precision and training small LoRA adapters on top. University of Washington researchers introduced it in May 2023 and reported that it cut the GPU memory needed to fine-tune a 65B-parameter model from more than 780GB to under 48GB, without losing 16-bit fine-tuning performance in their tests (Dettmers et al., 2023).
What is QLoRA?
QLoRA is a fine-tuning method that "backpropagates gradients through a frozen, 4-bit quantized pretrained language model into Low Rank Adapters (LoRA)", according to its paper. The base model is stored in a new 4-bit data type and never updated; only the LoRA adapters, kept in 16-bit, are trained (QLoRA paper, abstract).
The point is access to hardware. Before QLoRA, quantization worked "only for inference and break[s] down during training", the authors write, and 16-bit fine-tuning of LLaMA 65B needed more than 780GB of GPU memory (Sec. 1). With QLoRA, the paper says, the largest public models of the time became fine-tunable on a single GPU.
How does QLoRA work?
QLoRA keeps two data types: a 4-bit storage type for the frozen weights and a 16-bit computation type, usually BFloat16. Whenever a weight is used, it is dequantized to BFloat16 and the matrix multiply runs in 16-bit; weight gradients are computed only for the LoRA parameters (QLoRA paper, Sec. 3).

The paper adds three pieces on top of LoRA (Sec. 3):
- 4-bit NormalFloat (NF4). Pretrained weights roughly follow a zero-centered normal distribution, so NF4 places its 16 levels at quantiles of a normal distribution, giving each level an equal expected number of values. The paper calls it "information theoretically optimal" for normally distributed data. Weights are quantized in blocks of 64.
- Double Quantization. Each block of 64 weights needs a 32-bit scaling constant, which adds 32/64 = 0.5 bits per parameter. QLoRA quantizes those constants again, to 8-bit floats in blocks of 256, cutting the overhead to 8/64 + 32/(64 × 256) = 0.127 bits: a saving of 0.373 bits per parameter, "approximately 3 GB for a 65B model" (Sec. 1, Sec. 3).
- Paged Optimizers. Optimizer states use NVIDIA unified memory, so they are "automatically evicted to CPU RAM when the GPU runs out-of-memory" and paged back when needed. This handles memory spikes from long sequences during gradient checkpointing (Sec. 3).
The formal definition for one linear layer is Equation 5: Y = X · doubleDequant(c1, c2, W_NF4) + X · L1 · L2, where L1 and L2 are the LoRA matrices in BFloat16 (Sec. 3).
Worked example: weight memory for a 65B model
This is our arithmetic using the paper's bit counts (Sec. 3); it covers the frozen weights only, not activations, adapters or optimizer state.
| Storage format | Bits per parameter | 65B parameters |
|---|---|---|
| 16-bit (BF16/FP16) | 16 | 130 GB |
| 4-bit, 32-bit constants, block 64 | 4 + 0.5 = 4.5 | 36.6 GB |
| 4-bit NF4 + Double Quantization | 4 + 0.127 = 4.127 | 33.5 GB |
The difference between the last two rows, 3.0 GB, matches the paper's "approximately 3 GB" figure (Sec. 1). The paper's full measurement for fine-tuning, including everything else, is under 48GB.
When was QLoRA introduced, and by whom?
QLoRA was introduced in "QLoRA: Efficient Finetuning of Quantized LLMs" by Tim Dettmers, Artidoro Pagnoni, Ari Holtzman and Luke Zettlemoyer of the University of Washington, posted to arXiv on May 23, 2023, and published at NeurIPS 2023 (arXiv 2305.14314; NeurIPS 2023 proceedings).
The authors released their code at github.com/artidoro/qlora and the 4-bit CUDA kernels in bitsandbytes, integrated into Hugging Face Transformers (paper, Sec. 1).
What results did the QLoRA paper report?
The paper's central claim is that 4-bit QLoRA with NF4 matched 16-bit full fine-tuning and 16-bit LoRA on its academic benchmarks. On LLaMA 7B to 65B fine-tuned on Alpaca and FLAN v2, mean 5-shot MMLU accuracy was 53.1 for NF4 with Double Quantization versus 53.0 for BFloat16 and 52.2 for plain 4-bit Float (QLoRA paper, Table 4).
| Data type (LLaMA 7B–65B, LoRA) | Mean 5-shot MMLU |
|---|---|
| BFloat16 (16-bit) | 53.0 |
| Float4 | 52.2 |
| NFloat4 + Double Quantization | 53.1 |
Other results:
- Quantization quality. Mean Pile Common Crawl perplexity across OPT, BLOOM, LLaMA and Pythia models from 125M to 13B: Int4 34.34, Float4 (E2M1) 31.07, Float4 (E3M0) 29.48, NF4 + DQ 27.41; lower is better (Table 2).
- Chatbot. The Guanaco model family, trained with QLoRA, reached 99.3% of ChatGPT's performance on the Vicuna benchmark "while only requiring 24 hours of finetuning on a single GPU" (abstract). The second-best model reached 97.8% and trains "in less than 12 hours on a single consumer GPU" (Sec. 1).
- Elo ratings judged by GPT-4 on the Vicuna benchmark: GPT-4 1348, Guanaco 65B 1022, Guanaco 33B 992, Vicuna 13B 974, ChatGPT 966 (Table 1).
- Small model. Guanaco 7B needs 5GB of memory and beat a 26GB Alpaca model by more than 20 percentage points on the Vicuna benchmark (Sec. 1).
- Scale of study. The authors fine-tuned more than 1,000 models and found that a 9k-sample dataset (OASST1) beat a 450k-sample FLAN v2 subset on chatbot performance: "data quality is far more important than dataset size" (Sec. 1).
What the paper did not show
The authors state a limit plainly: "we did not establish that QLORA can match full 16-bit finetuning performance at 33B and 65B scales" because of cost (Sec. 8). Their comparison with full fine-tuning covers models up to 3B; at 7B to 65B they compared against 16-bit LoRA (Sec. 4). They also did not provide hard measurements for paged optimizers, which only page on long-sequence batches (Sec. 4).
How is QLoRA different from LoRA?
QLoRA uses the same LoRA adapters but stores the frozen base model in 4-bit NF4 instead of 16-bit, and adds Double Quantization and paged optimizers. It also changed the recommended setup: QLoRA's authors found that applying LoRA only to query and value projections, the original LoRA default, did not match full fine-tuning on large models, and that all linear layers were needed (QLoRA paper, Sec. 4).
| LoRA (2021) | QLoRA (2023) | |
|---|---|---|
| Frozen base weights | 16-bit | 4-bit NF4, constants double-quantized |
| Trained weights | LoRA A, B | LoRA adapters in BF16 |
| Default target layers in the paper | Wq, Wv (Sec. 4.2, 7.1) | All linear layers (Sec. 4) |
| Headline memory figure | GPT-3 175B: 1.2TB → 350GB VRAM (Sec. 4.2) | LLaMA 65B: >780GB → <48GB (Sec. 1) |
| Optimizer memory spikes | Not addressed | Paged optimizers (Sec. 3) |
Compared with Adapter Tuning and BitFit, which also freeze most weights, QLoRA is the only one in this group that also compresses the frozen weights.
Which libraries support QLoRA?
QLoRA runs on three Hugging Face pieces: bitsandbytes for 4-bit loading through Transformers' BitsAndBytesConfig, PEFT for the LoRA adapters, and optionally TRL for training. PEFT's quantization guide describes QLoRA as a method that "quantizes a model to 4-bits and then trains it with LoRA" (PEFT quantization guide).
- Transformers bitsandbytes guide:
BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.bfloat16). The page says "You should use NF4 for training 4-bit base models." - PEFT (v0.22.0):
prepare_model_for_kbit_training(), thenLoraConfig(target_modules="all-linear", ...)andget_peft_model(). - TRL
SFTTrainer(v1.19.0): takesquantization_config=andpeft_config=; the docs say to "Combine withpeft_configfor QLoRA training."
How do you use QLoRA in code?
This follows the PEFT quantization guide and the Transformers bitsandbytes page; names were checked on Dec. 4, 2026. The LoRA settings (r = 64, alpha = 16, all linear layers, dropout 0.1) are the paper's own for models up to 13B (QLoRA paper, Appendix B.2).
import torch
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4", # 4-bit NormalFloat
bnb_4bit_use_double_quant=True, # Double Quantization
bnb_4bit_compute_dtype=torch.bfloat16, # BF16 compute type
)
model = AutoModelForCausalLM.from_pretrained(
"mistralai/Mistral-7B-v0.1", quantization_config=bnb_config
)
model = prepare_model_for_kbit_training(model)
lora_config = LoraConfig(
r=64, lora_alpha=16, lora_dropout=0.1,
target_modules="all-linear", # LoRA on every linear layer
bias="none", task_type="CAUSAL_LM",
)
model = get_peft_model(model, lora_config)
model.print_trainable_parameters()
The snippet does not set up paged optimizers; we did not find them documented on the pages above, so check the bitsandbytes docs for your version.
Common pitfalls
- Targeting only q and v. The paper could not match full fine-tuning on LLaMA 7B that way; "LoRA on all linear transformer block layers are required" (QLoRA paper, Sec. 4, Figure 2). PEFT's guide says the same and recommends
target_modules="all-linear"(PEFT). - Using FP4 instead of NF4. Float4 trailed BFloat16 by about one point on MMLU, while NF4 + DQ matched it (Table 4).
- Trying to update the 4-bit weights. The Transformers docs warn that "8 and 4-bit training is only supported for training extra parameters" (bitsandbytes guide).
- Repeated merge/unmerge on quantized weights. PEFT warns that merging dequantizes and re-quantizes, so "repeated merge and unmerge cycles can accumulate rounding error"; reload the base model to get the original weights back (PEFT quantization guide).
- Trusting one benchmark. The authors found strong MMLU did not imply strong Vicuna chatbot scores and vice versa (Sec. 1, Sec. 8).
FAQ
How much GPU memory does QLoRA need?
The paper reports fine-tuning a 65B model in under 48GB, down from more than 780GB for 16-bit fine-tuning (Sec. 1). It also reports a 7B Guanaco model that needs 5GB of memory when deployed (Sec. 1).
Does QLoRA lose accuracy compared to 16-bit?
Not in the paper's tests: NF4 with Double Quantization scored 53.1 mean MMLU versus 53.0 for 16-bit LoRA (Table 4), and matched 16-bit full fine-tuning on GLUE and Super-NaturalInstructions for models up to 3B (Sec. 4). The authors say they did not verify parity with full fine-tuning at 33B and 65B (Sec. 8).
What is NF4?
4-bit NormalFloat, a data type QLoRA introduced. Its levels are quantiles of a normal distribution, matching how pretrained weights are distributed (Sec. 3). In Transformers you select it with bnb_4bit_quant_type="nf4".
What is double quantization?
Quantizing the quantization constants. It reduces their overhead from 0.5 to 0.127 bits per parameter, about 3GB saved on a 65B model (Sec. 1, Sec. 3). In Transformers it is bnb_4bit_use_double_quant=True.
Is QLoRA slower than LoRA?
The paper does not give a general speed comparison. It reports that, for 65B models on 48GB GPUs with batch size 16, paged optimizers gave the same training speed as regular optimizers (Sec. 4).
What LoRA settings did the QLoRA paper use?
r = 64, alpha = 16, LoRA on all linear layers, NF4 with Double Quantization, BF16 compute, LoRA dropout 0.1 up to 13B and 0.05 for 33B and 65B, and a constant learning rate schedule (Appendix B.2).
What is Guanaco?
The chatbot family the authors trained with QLoRA; Guanaco 65B was fine-tuned "on a variant of OASST1" (Sec. 5). Guanaco 65B reached 99.3% of ChatGPT's Vicuna-benchmark score (abstract) and an Elo of 1022 versus ChatGPT's 966 in GPT-4-judged matches (Table 1).
Related techniques
- LoRA: the low-rank adapters QLoRA trains
- Adapter Tuning: bottleneck layers inserted in each block
- BitFit: train only the bias terms
- Distillation, LoRA and GRPO explained
- All 15 LLM fine-tuning techniques
Sources
- Dettmers, T., Pagnoni, A., Holtzman, A., Zettlemoyer, L. "QLoRA: Efficient Finetuning of Quantized LLMs." arXiv, May 23, 2023; NeurIPS 2023. arXiv 2305.14314. Read Dec. 4, 2026.
- NeurIPS 2023 proceedings entry for QLoRA. proceedings.neurips.cc. Checked Dec. 4, 2026.
- Hugging Face PEFT docs, v0.22.0: Quantization guide, LoRA reference. Checked Dec. 4, 2026.
- Hugging Face Transformers docs: bitsandbytes. Checked Dec. 4, 2026.
- Hugging Face TRL docs, v1.19.0: SFT Trainer. Checked Dec. 4, 2026.
- Hu, E. J., et al. "LoRA: Low-Rank Adaptation of Large Language Models." arXiv, June 17, 2021. arXiv 2106.09685. Read Dec. 4, 2026.
Series: ← Prev: LoRA · All 15 techniques · Next: Adapter Tuning →
- #llm-fine-tuning
- #qlora
- #peft
- #quantization
- #lora



