NLP Lineage

23 May 2023 · Efficiency and infrastructure

QLoRA

QLoRA: Efficient Finetuning of Quantized LLMs

T. Dettmers, A. Pagnoni, A. Holtzman, L. Zettlemoyer

Date
23 May 2023
What the date marks
arXiv submission
Kind
Technique
Organisation
University of Washington
Access
MIT
Other dates
NeurIPS 2023
Threads
In the guided tour
Chapter 9. Making it run anywhere
Learning phases
5. Fine-tuning; 6. Local models and deployment

Notable: no later milestone in the data is documented as descending from it. How levels are decided

Drafted with Claude from the paper on 15 October 2026; reviewed by Zeeshan Arif. Read from arxiv.org (arXiv version 1 (May 2023), a preprint under review; the paper was later published at NeurIPS 2023).

What it changed

It made it possible to fine-tune a 65 billion-parameter model on a single 48 GB GPU, by storing the frozen model in 4 bits and training only small adapters, with no loss against normal 16-bit fine-tuning in the authors’ tests.

The problem before it

Fine-tuning improves a language model and can add or remove behaviours. But regular 16-bit fine-tuning of LLaMA 65B needs more than 780 GB of GPU memory, which means many expensive GPUs.

Two partial fixes existed. LoRA trains only small added matrices and keeps the original weights frozen, but the frozen weights still fill memory in 16 bits. Quantisation stores weights in fewer bits, as in LLM.int8(), but the authors note that such methods worked for running a model, not for training it, and broke down during training.

The idea

The mechanism. QLoRA combines the two. It stores the frozen model in 4 bits and trains low-rank adapters on top in 16 bits. Each time a weight is used, it is turned back into a 16-bit number for the calculation. Gradients pass through the frozen 4-bit model into the adapters, and only the adapters change.

Three new parts save memory without losing quality:

The authors also found that LoRA’s usual setting, with adapters only on the attention layers, does not match full fine-tuning on large models. Adapters must go on every linear layer of each Transformer block.

The notation. For one layer, QLoRA computes Y = X · doubleDequant(c1, c2, W_NF4) + X · L1 · L2. W_NF4 is the frozen 4-bit weight matrix, c2 are its 8-bit scale numbers and c1 the 32-bit scales of those. L1 and L2 are the small trainable adapter matrices, kept in 16-bit BrainFloat. Only L1 and L2 get weight gradients.

What it showed

Reported in the paper. We read version 1 of the arXiv paper, a preprint under review. The paper was later published at NeurIPS 2023. The authors trained more than 1,000 models.

Limits, and what came later

The limits come from the paper:

The data does not yet record later milestones that build directly on QLoRA.

What to know first

How to read it

The main text is 16 pages.

  1. Read section 1 with Figure 1, which compares the memory needs of full fine-tuning, LoRA and QLoRA.
  2. Read section 2 for block-wise quantisation and LoRA, then section 3 for NF4, double quantisation and paged optimisers.
  3. Read section 4 with Tables 3 and 4, the evidence that 4 bits lose nothing.
  4. Read section 5.3 with Table 6, then section 8 for the authors’ own limits.

The NF4 formula in section 3 can be skimmed. Expect about 1.5 hours for the parts above (an estimate).

In brief, from the research data

Before it

LoRA made fine-tuning cheap, but the frozen base model still had to fit in memory at 16-bit.

The problem

A 65B base model needs hundreds of gigabytes, so the adapters did not help enough.

What it introduced

Quantize the frozen base to 4-bit with a data-type suited to normal weights, and backpropagate through it into the adapters. 65B on one 48GB GPU.

Why it matters

It put fine-tuning of large models within reach of individuals, and the resulting models were competitive.

What modern models inherit

Quantized base plus small trainable adapters, the standard cheap fine-tune.

What came next

The open fine-tuning ecosystem as it exists now.

To understand it

Learn

  • Low-rank adapters
  • 4-bit NormalFloat quantization
  • Why the frozen base model dominates memory

Helpful first

LoRA and 8-bit quantization.

Before and after

The milestones it descends from, and the milestones that descend from it. Work developed alongside it is not counted. Weak links are left out unless you include them.

Before: where it came from

QLoRA has 38 documented ancestors across 8 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 14 turning points among them.

QLoRA has 38 documented ancestors across 8 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

QLoRA has 39 recorded ancestors, including indirect ones, across 8 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 14 turning points among them.

QLoRA has 39 recorded ancestors, including indirect ones, across 8 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

  1. 2023QLoRAThis milestone.
  2. 2023LLaMA Turning pointQLoRA built directly on thisChapter 8. The weights get out
  3. 2022LLM.int8()QLoRA built directly on thisChapter 9. Making it run anywhere
  4. 2022OPT-175BLLM.int8() was influenced by thisChapter 8. The weights get out
  5. 2022Chinchilla Turning pointLLaMA built directly on thisChapter 5. Scale becomes a science
  6. 2021GopherChinchilla built directly on thisChapter 5. Scale becomes a science
  7. 2021LoRAQLoRA built directly on thisChapter 9. Making it run anywhere
  8. 2021RoPE Turning pointLLaMA built directly on thisChapter 10. Reading more than you remember
  9. 2020The PileOPT-175B built directly on thisChapter 5. Scale becomes a science
  10. 2020GPT-3 Turning pointLoRA built directly on thisChapter 5. Scale becomes a science
  11. 2020Scaling laws Turning pointGPT-3 was influenced by this
    Chinchilla built directly on this
    Chapter 5. Scale becomes a science
  12. 2019C4 Turning pointThe Pile was influenced by thisChapter 4. Pretrain once, use everywhere
  13. 2019Megatron-LMOPT-175B was influenced by thisChapter 4. Pretrain once, use everywhere
  14. 2019Sparse Transformer Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  15. 2019GPT-2 Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  16. 2019WebTextGPT-2 was influenced by thisChapter 4. Pretrain once, use everywhere
  17. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  18. 2018BERT Turning pointMegatron-LM was influenced by thisChapter 4. Pretrain once, use everywhere
  19. 2018GPT-1GPT-2 built directly on thisChapter 4. Pretrain once, use everywhere
  20. 2018ELMoBERT was influenced by thisChapter 4. Pretrain once, use everywhere
  21. 2018ULMFiTBERT was influenced by thisChapter 4. Pretrain once, use everywhere
  22. 2017Mixed precisionMegatron-LM was influenced by thisChapter 9. Making it run anywhere
  23. 2017CoVeELMo was influenced by thisChapter 3. Attention, then only attention
  24. 2017Transformer Turning pointLoRA built directly on thisChapter 3. Attention, then only attention
  25. 2016Layer normTransformer built directly on thisChapter 3. Attention, then only attention
  26. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  27. 2015LM pretraining Turning pointBERT was influenced by this
    GPT-1 was influenced by this
    Chapter 2. Words become vectors
  28. 2015BPE tokenizationLLaMA built directly on thisChapter 2. Words become vectors
  29. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  30. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  31. 2014GloVeELMo built directly on thisChapter 2. Words become vectors
  32. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  33. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  34. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  35. 2013word2vecELMo was influenced by thisChapter 2. Words become vectors
  36. 2011NLP from scratchELMo was influenced by thisChapter 1. Language as probability
  37. 2003Neural LMNLP from scratch was influenced by this
    word2vec was influenced by this
    Chapter 1. Language as probability
  38. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  39. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability
  1. 2023QLoRAThis milestone.
  2. 2023LLaMA Turning pointQLoRA built directly on thisChapter 8. The weights get out
  3. 2022LLM.int8()QLoRA built directly on thisChapter 9. Making it run anywhere
  4. 2022OPT-175BLLM.int8() was influenced by thisChapter 8. The weights get out
  5. 2022Chinchilla Turning pointLLaMA built directly on thisChapter 5. Scale becomes a science
  6. 2021GopherChinchilla built directly on thisChapter 5. Scale becomes a science
  7. 2021LoRAQLoRA built directly on thisChapter 9. Making it run anywhere
  8. 2021RoPE Turning pointLLaMA built directly on thisChapter 10. Reading more than you remember
  9. 2020The PileOPT-175B built directly on thisChapter 5. Scale becomes a science
  10. 2020GPT-3 Turning pointLoRA built directly on thisChapter 5. Scale becomes a science
  11. 2020Scaling laws Turning pointGPT-3 was influenced by this
    Chinchilla built directly on this
    Chapter 5. Scale becomes a science
  12. 2019C4 Turning pointThe Pile was influenced by thisChapter 4. Pretrain once, use everywhere
  13. 2019Megatron-LMOPT-175B was influenced by thisChapter 4. Pretrain once, use everywhere
  14. 2019Sparse Transformer Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  15. 2019GPT-2 Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  16. 2019WebTextGPT-2 was influenced by thisChapter 4. Pretrain once, use everywhere
  17. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  18. 2018BERT Turning pointMegatron-LM was influenced by thisChapter 4. Pretrain once, use everywhere
  19. 2018GPT-1GPT-2 built directly on thisChapter 4. Pretrain once, use everywhere
  20. 2018ELMoBERT was influenced by this
    GPT-1 was influenced by this (indirect influence)
    Chapter 4. Pretrain once, use everywhere
  21. 2018ULMFiTBERT was influenced by this
    GPT-1 was influenced by this (indirect influence)
    Chapter 4. Pretrain once, use everywhere
  22. 2017Mixed precisionMegatron-LM was influenced by thisChapter 9. Making it run anywhere
  23. 2017CoVeELMo was influenced by thisChapter 3. Attention, then only attention
  24. 2017Transformer Turning pointLoRA built directly on thisChapter 3. Attention, then only attention
  25. 2017ConvS2STransformer was influenced by this (indirect influence)Chapter 3. Attention, then only attention
  26. 2016Layer normTransformer built directly on thisChapter 3. Attention, then only attention
  27. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  28. 2015LM pretraining Turning pointBERT was influenced by this
    GPT-1 was influenced by this
    Chapter 2. Words become vectors
  29. 2015BPE tokenizationLLaMA built directly on thisChapter 2. Words become vectors
  30. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  31. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  32. 2014GloVeELMo built directly on thisChapter 2. Words become vectors
  33. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  34. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  35. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  36. 2013word2vecELMo was influenced by thisChapter 2. Words become vectors
  37. 2011NLP from scratchELMo was influenced by thisChapter 1. Language as probability
  38. 2003Neural LMNLP from scratch was influenced by this
    word2vec was influenced by this
    Chapter 1. Language as probability
  39. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  40. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability

After: what it led to

No documented descendants are recorded for QLoRA without weak links.

No documented descendants are recorded for QLoRA without weak links.

No recorded descendants are recorded for QLoRA.

No recorded descendants are recorded for QLoRA.

Direct links and their sources

Where it came from

Built directly on

What it led to

None recorded in the sources used.

Terms