Why does QLoRA use NF4 instead of uniform INT4?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Why does QLoRA quantise the frozen base model with NF4 rather than uniform INT4? What assumption does NF4 exploit, and why does that assumption hold for LLM weights?
Trained transformer weights are roughly zero-mean Gaussian, so NF4 places its 16 levels at Normal quantiles. That puts resolution where the mass is and beats uniform INT4 at the same 4 bits.
Picture sorting 16 buckets to catch raindrops, where almost all the rain falls in one small spot. Uniform INT4 spaces the buckets evenly, so most sit in dry corners and waste capacity. NF4 looks at the rain map first and crowds buckets where the drops actually land, near the centre, with just a few out in the dry tails. Trained model weights behave like that rain: tons of values near zero, very few far out. By matching its buckets to the bell-curve shape, NF4 catches the values more precisely than even spacing ever could, using the exact same number of buckets. Same storage budget, smaller average rounding error.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: 16-level budget framing + why weights are Gaussian + Normal-quantile placement + the optimality argument + per-block scale and double quantisation + when NF4 stops being the right choice.
| Aspect | Uniform INT4 | NF4 (NormalFloat-4) |
|---|---|---|
| Level placement | Equal-width grid across the range | Quantiles of a unit Normal distribution |
| Optimal for | Uniformly distributed values | Zero-mean Gaussian values |
| Resolution near zero | Same as everywhere else | Highest, where most weights live |
| Tail handling | Wastes many levels on empty edges | Few levels, matching sparse tails |
| Error on real LLM weights | Higher at the same 4 bits | Lower at the same 4 bits |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Claiming NF4 is just INT4 with better software, or that it works for any data. NF4 is optimal only because it matches the near-Gaussian shape of trained weights.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.