Paper commentary
QLoRA: Efficient Finetuning of Quantized LLMs
- Problem Regular 16-bit finetuning of a LLaMA 65B model needs more than 780GB of GPU memory, and quantized models have mostly been usable only for inference.
- Method Freezes a 4-bit NF4 base model, compresses its quantization constants with Double Quantization, and trains LoRA adapters while the frozen weights are dequantized to BFloat16.
- Results Guanaco 65B reached 99.3% of ChatGPT's score on the Vicuna benchmark under GPT-4 judging, with a 95% CI of 4.4%.

Figure 3 : Mean zero-shot accuracy over Wino- grande, HellaSwag, PiQA, Arc-Easy, and Arc- Challenge using LLaMA models with different 4-bit data types. The NormalFloat data type significantly improves the bit-for-bit accuracy gains compared to regular 4-bit Floats. While Double Quantization (DQ) only leads to minor gains, it allows for a more fine-grained control over the memory footprint to fit models of certain size (33B/65B) into certain GPUs (24/48GB).
Original paper · CC BY 4.0 · Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, Luke Zettlemoyer · QLoRA: Efficient Finetuning of Quantized LLMs · Original paper figure · Extracted the figure area from page 6 of the original PDF.Why finetuning large models is memory bound
Instruction finetuning turns a pretrained LLM into a chat model, but at 65B parameters regular 16-bit finetuning needs more than 780 GB of GPU memory. Quantization can shrink the weights of a trained model, but the authors point out that such methods serve inference and break down when used for training. QLoRA targets this gap by keeping the frozen base model in 4 bits and training only small adapters on top of it.
The authors report that a 65B model drops from >780GB to <48GB of GPU memory without degrading predictive performance relative to a 16-bit fully finetuned baseline.
Block-wise quantization and the LoRA starting point
Quantization maps values from a representation with more bits to one with fewer bits, and the input is usually rescaled by its absolute maximum so that the full low-bit range is used. For a 32-bit tensor mapped to an Int8 tensor with range [−127, 127], the scaled values are rounded, the quantization constant c records the scale, and dequantization divides by it.
\[ X^{\mathrm{Int8}} = \operatorname{round}\!\left(\frac{127}{\operatorname{absmax}(X^{\mathrm{FP32}})}\,X^{\mathrm{FP32}}\right) = \operatorname{round}(c^{\mathrm{FP32}}\,X^{\mathrm{FP32}}) \]
A single large outlier stretches the scale and leaves many quantization bins empty, so the tensor is cut into blocks that each receive their own constant. A tensor of size b×h is flattened and sliced into n = (b×h)/B contiguous blocks of size B, and each block is quantized independently.
Only L1 and L2 are trained, and gradients pass back through the frozen weights to reach them.
Where the training memory goes
For a 7B LLaMA model trained on FLAN v2 with batch size 1, the LoRA input gradients occupy 567 MB while the LoRA parameters take only 26 MB. Gradient checkpointing lowers the input gradients to an average of 18 MB per sequence, and the 4-bit base model itself takes 5,048 MB.
Because the adapter weights are such a small share of memory, the authors argue that adding more adapters does not raise total training memory much. They tie this to recovering full 16-bit precision performance, which the experiments return to.
Building the NF4 data type
Quantile quantization gives each bin the same number of input values by estimating input quantiles, but exact estimation is expensive and approximate estimators err most on outliers. NF4 avoids per-tensor quantile estimation by assuming pretrained weights are zero-centered normal with a standard deviation that can be rescaled into the fixed range [−1, 1].
The data type is built from the quantiles of a standard normal N(0,1), normalized into [−1, 1], and weights are then rescaled by absolute maximum into the same range. The 2^k values q_i are estimated as follows, where Q_X is the quantile function of N(0,1). \[ q_i = \frac{1}{2}\left(Q_X\!\left(\frac{i}{2^k+1}\right) + Q_X\!\left(\frac{i+1}{2^k+1}\right)\right) \]
A symmetric grid of this kind has no exact zero, which matters for padding and other zero-valued entries, so the authors estimate quantiles separately for the negative and positive parts. They merge the two sets, drop one of the duplicate zeros, and call the result NFk, which gives each bin an equal expected number of values.
Double Quantization and paged optimizer memory
Small blocks are needed for accurate 4-bit quantization, but their constants add memory: 32-bit constants with blocksize 64 add 32/64 = 0.5 bits per parameter. Double Quantization quantizes the first-level constants c2 to 8-bit floats with blocksize 256, after subtracting their mean so that the values center near zero before symmetric quantization.
At blocksize 64 this drops the per-parameter overhead from 0.5 to 0.127 bits, which is the reported reduction of 0.373 bits per parameter, computed as \(8/64 + 32/(64 \cdot 256)\).
Paged optimizers place the optimizer states in NVIDIA unified memory, so pages can move to CPU RAM when the GPU runs short and return at the optimizer update step.
How one QLoRA layer computes its output
For one linear layer, the stored base weight is NF4 with block-wise constants and double-quantized constants, and the forward pass dequantizes it to BFloat16 before the matrix products. \[ Y_{\mathrm{BF16}} = X_{\mathrm{BF16}}\,\mathrm{doubleDequant}(c_1^{\mathrm{FP32}}, c_2^{\text{k-bit}}, W^{\mathrm{NF4}}) + X_{\mathrm{BF16}}\,L_1^{\mathrm{BF16}}L_2^{\mathrm{BF16}} \] The doubleDequant step first recovers the constants from c2 and then uses them to dequantize the 4-bit weight into a BFloat16 weight.
The 4-bit weights receive no gradient, and only the adapter matrices do, yet backpropagating to them needs the derivative with respect to X through the dequantized weight in BFloat16. The base weight is stored as NF4 with blocksize 64, the constants as FP8 with blocksize 256, while the adapter path stays in BFloat16.
QLoRA therefore keeps one low-precision storage type and one 16-bit computation type.
NF4 against 4-bit Float and Int4
This comparison is post-quantization, using zero-shot accuracy and perplexity across OPT, BLOOM, Pythia and LLaMA models.
Figure 3 plots mean zero-shot accuracy against total model bits for LLaMA models, and the authors report that NF4 improves accuracy per bit over regular 4-bit Floats, while double quantization adds small gains.
Does adapter finetuning recover 16-bit accuracy?
GLUE with RoBERTa-large and Super-NaturalInstructions with T5 models place 16-bit, 8-bit and 4-bit adapter methods next to full finetuning. On RoBERTa-large the FP4 variant scored 88.6, equal to the BF16 baseline, and the T5-80M NF4 with DQ run scored 40.4 against 40.1 for BF16.
The authors read this as evidence that accuracy lost to imprecise quantization can be recovered through adapter finetuning after quantization.
The MMLU setup finetunes LLaMA 7B through 65B on Alpaca and FLAN v2 and measures 5-shot accuracy, since full finetuning at 11B and above needs more than one server of high-memory GPUs. Averaged over these models and datasets, NF4 with double quantization reached 53.1, BFloat16 reached 53.0 and Float4 reached 52.2.
Where LoRA adapters must go
The common default applies LoRA to query and value projections, and in the LLaMA 7B Alpaca runs this did not reproduce full finetuning. Adding adapters to all linear transformer block layers matched full finetuning, and the authors identify the number of adapters as the most critical LoRA hyperparameter.
Other LoRA settings such as the projection dimension r did not affect performance.
Paged optimizers were not measured directly, since paging occurs only on long-sequence mini-batches. For 65B models on 48GB GPUs with batch size 16, the authors found that paged optimizers train as fast as regular optimizers, and they list the circumstances of slowdowns as future work.
Training data and chatbot setup
Eight instruction datasets cover crowd-sourced, distilled, aggregated and hybrid sources, including OASST1, HH-RLHF, Alpaca, FLAN v2, Chip2 and Longform. Training uses cross-entropy supervised finetuning without reinforcement learning, and where instructions and responses are clearly separated only the response is trained.
For OASST1 and HH-RLHF the top response at each level of the conversation tree is kept, and the full selected conversation is trained, including the instructions. The authors halve the learning rate and double the batch size for 33B and 65B models.
In the reported comparison a 9k-sample OASST1 dataset outperformed a 450k-sample subsampled FLAN v2 on chatbot performance.
Guanaco against ChatGPT on the Vicuna benchmark
The Vicuna benchmark uses 80 prompts, and GPT-4 scores each response out of ten; a system's overall score is its percentage of ChatGPT's score, with both orders averaged. Guanaco 65B reached 99.3% and Guanaco 33B reached 97.8%, each with a 95% confidence interval of 4.4%.
Guanaco 33B uses 21 GB at 4 bits, while the 16-bit Vicuna 13B at 26 GB scored 94.9%.
Many confidence intervals overlap, which the authors attribute to the lack of a clear meaning for a ten-point scale across scenarios, so they recommend Elo rankings from pairwise judgments.
The authors describe Guanaco as the only top model in their evaluation not trained on proprietary data, since OASST1 collection guidelines forbid the use of GPT models.
GPT-4 and human judges compared
Pairwise comparisons from humans and GPT-4 feed a tournament, with ratings starting at 1,000, K = 32, and the procedure repeated 10,000 times with different random seeds. Each Elo update is proportional to how unexpected the match outcome was.
Under GPT-4 judging, GPT-4 has an Elo of 1348 and Guanaco-65B 1022, while human judgments give 1176 and 1023. The text says Guanaco 33B and 65B outperform every model except GPT-4 on both benchmarks, but in the OA column of Table 7 ChatGPT-3.5 Turbo sits at 1015 above Guanaco-65B at 1008.
System-level agreement between GPT-4 and humans is moderate, with Kendall Tau 0.43 and Spearman rank correlation r = 0.55. At the example level, agreement between GPT-4 and the human majority vote is weaker at Fleiss κ 0.25, while human annotators reach Fleiss κ 0.42 among themselves.
GPT-4 assigned higher scores to its own outputs than humans did, and it showed strong order effects, favoring the system listed first.
Where Guanaco succeeds and fails
The authors searched generations for patterns, then built prompts that trigger each pattern, labelling failures as lemons and successes as cherries, with nucleus sampling at p = 0.9.
Guanaco answers well-known facts correctly, but on obscure HotPotQA prompts it gives a wrong popularizer and a wrong birth year while sounding confident.
It resists some false premises, such as a claim that the earth has been confirmed flat, and it states that it cannot give the current time.
A direct request for the secret word is refused, but a game-style instruction makes it reveal banana.
Mathematics is the weakest area: the model can show accurate work, yet it wrongly factorizes 1833. Its theory-of-mind answers are detailed in one case and presume information transfer in another.
Limitations
Full 16-bit parity at 33B and 65B scale was not established, because the resource costs were too large, and the authors leave this to future work. Other benchmarks such as BigBench, RAFT and HELM were not evaluated.
The authors suggest that benchmark results follow the similarity between finetuning data and the benchmark, with FLAN v2 resembling MMLU but not chatbot benchmarks, and Chip2 behaving the other way.
The responsible-AI check covers only CrowS for Guanaco-65B, which averages 43.5 against 66.6 for LLaMA-65B, and other bias types were left open.
Only LoRA was tested as an adapter method, and 3-bit base models were not tried. Models were trained only with cross-entropy, so the tradeoff with RLHF was not studied, and human agreement was only moderate.
Paper info
- Authors
- Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, Luke Zettlemoyer
- Venue
- arXiv · Preprint
- First published
- 2023-5-23
- Added
- 2026-10-20
- Updated
- 2023-5-23
- Version
- v1
- arXiv
- 2305.14314
- Category
- cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
We present QLoRA, an efficient finetuning approach that reduces memory usage enough to finetune a 65B parameter model on a single 48GB GPU while preserving full 16-bit finetuning task performance. QLoRA backpropagates gradients through a frozen, 4-bit quantized pretrained language model into Low Rank Adapters~(LoRA). Our best model family, which we name Guanaco, outperforms all previous openly released models on the Vicuna benchmark, reaching 99.3% of the performance level of ChatGPT while only requiring 24 hours of finetuning on a single GPU. QLoRA introduces a number of innovations to save memory without sacrificing performance: (a) 4-bit NormalFloat (NF4), a new data type that is information theoretically optimal for normally distributed weights (b) double quantization to reduce the average memory footprint by quantizing the quantization constants, and (c) paged optimziers to manage memory spikes. We use QLoRA to finetune more than 1,000 models, providing a detailed analysis of instruction following and chatbot performance across 8 instruction datasets, multiple model types (LLaMA, T5), and model scales that would be infeasible to run with regular finetuning (e.g. 33B and 65B parameter models). Our results show that QLoRA finetuning on a small high-quality dataset leads to state-of-the-art results, even when using smaller models than the previous SoTA. We provide a detailed analysis of chatbot performance based on both human and GPT-4 evaluations showing that GPT-4 evaluations are a cheap and reasonable alternative to human evaluation. Furthermore, we find that current chatbot benchmarks are not trustworthy to accurately evaluate the performance levels of chatbots. A lemon-picked analysis demonstrates where Guanaco fails compared to ChatGPT. We release all of our models and code, including CUDA kernels for 4-bit training.
Quote from the paper
Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, Luke Zettlemoyer (2023). QLoRA: Efficient Finetuning of Quantized LLMs. arXiv:2305.14314v1. https://arxiv.org/abs/2305.14314v1
BibTeX
@misc{dettmers2023qlora,
title = {{QLoRA: Efficient Finetuning of Quantized LLMs}},
author = {Tim Dettmers and Artidoro Pagnoni and Ari Holtzman and Luke Zettlemoyer},
year = {2023},
eprint = {2305.14314},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2305.14314v1}
}