How much GPU memory do model states take when fine-tuning a 7-billion-parameter model with mixed-precision Adam under (a) full fine-tuning, (b) LoRA with 20 million trainable adapter parameters on an fp16 base, and (c) QLoRA with a 4-bit NormalFloat base? How do NF4, double quantisation and paged optimisers work, and what is the trade-off?

Sequence models and transformers, Parameter-efficient fine-tuning
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can compare the model-state memory footprint of full fine-tuning, LoRA (Low-Rank Adaptation) and QLoRA (Quantised Low-Rank Adaptation), and explain the three mechanisms that make QLoRA work.

Key idea

Full fine-tuning stores 16 bytes per parameter across all 7 billion weights (112 GB). LoRA freezes the base weights in fp16 (14 GB) and trains only small low-rank adapters (≈0.32 GB), while QLoRA compresses the frozen base further to 4-bit NormalFloat (3.5 GB plus small quantisation constants), bringing model states down to roughly 4 GB.

Steps

  1. Full fine-tuning with mixed-precision Adam: every parameter needs 16 B (2 B fp16, 16-bit floating point, weight + 2 B fp16 gradient + 4 B fp32, 32-bit floating point, master weight + 8 B for Adam moments m,v). For 7×109 parameters, model states require 16×7×109 B=112 GB (using 1 GB=109 B).
  2. LoRA on a frozen fp16 (or bf16, 16-bit brain floating point) base: the 7 billion base weights have no gradients or optimiser states, taking 7×109×2 B=14 GB. With 20×106 trainable adapter parameters (counting across adapted layers, covered in LoRA parameter-count questions), adapter states take 20×106×16 B=0.32 GB, for a total of 14.32 GB.
  3. QLoRA with a 4-bit NF4 (4-bit NormalFloat) base: storing 7×109 frozen weights at 4 bits (0.5 B) per parameter takes 3.5 GB. Blockwise quantisation constants add small overhead (reduced to ≈0.11 GB by double quantisation below), plus 0.32 GB for the 16-bit adapter states, giving roughly 3.9–4.0 GB total.
  4. Note excluded activations: these totals count model states only. Activation memory (saved intermediate tensors for backpropagation) grows with batch size and sequence length and often needs gradient checkpointing on single GPUs (graphics processing units).
  5. Explain QLoRA's three techniques: (1) NF4 places its 16 quantisation levels (approximately) at equal-probability quantiles of a standard normal distribution N(0,1), matching pretrained weight distributions better than uniform int4 (4-bit integers); (2) double quantisation quantises the per-block fp32 scaling constants themselves (e.g. into 8-bit floats in blocks of 256), cutting constant overhead from 0.5 bits/param (0.44 GB on 7B) to ≈0.127 bits/param (0.11 GB); (3) paged optimisers use NVIDIA unified memory to page optimiser states between GPU VRAM (video memory) and CPU RAM (host memory) during activation memory spikes.
  6. State the trade-off: when adapters are applied to all linear layers, QLoRA nearly matches 16-bit LoRA and full fine-tuning accuracy, at the cost of slower training throughput because 4-bit base weights must be dequantised to bf16/fp16 on the fly during each forward and backward pass.

Common mistakes

How long your answer should be

3–4 minutes; give the three GB totals, explain NF4, double quantisation and paged optimisers, and note activations and speed trade-offs.

Read this

Previous in Sequence models and transformers: In an encoder–decoder transformer with dmodel=512 and 8 heads, a decoder layer cross-attends to an encoder output of length S=50 while it has T=20 target tokens. What are the shapes of Q, K and V and of the score matrix, which projections cost the most, and why does cross-attention need no causal mask?
Next in Sequence models and transformers: Why is autoregressive LLM decoding at batch size 1 memory-bandwidth bound? For a 7-billion-parameter fp16 model (14 GB) on a GPU with 2 TB/s memory bandwidth and 300 TFLOP/s of fp16 compute, what is the upper bound on tokens/s at batch size 1, what is the arithmetic intensity, and near what batch size does decoding reach the compute ridge point?