FP4 vs NF4, pick the answer that captures the actual structural difference
FP4 uses 16 uniformly-spaced floating-point buckets; NF4 uses 16 non-uniform quantile buckets calibrated to a unit normal, so it captures more signal on bell-shaped weight tensors.
Imagine you have to pick exactly 16 height labels to describe everyone in a city. One approach spaces the labels uniformly from 4 feet to 7 feet, every 2.4 inches. That works, but most people cluster around 5'5" so half your labels are wasted on heights almost nobody has. The other approach looks at the actual height distribution first and places more labels in the crowded middle of the range and fewer in the rare extremes. The second approach loses less information about typical people because it puts its precision where the density is. NF4 is the second approach for transformer weights, which cluster around zero in a bell shape. FP4 is the first approach, spacing buckets evenly without knowing the data shape.
Detailed answer & concept explanation~5 min readEverything 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. 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: establish both formats are 4-bit, contrast uniform versus quantile codebook layouts, explain why the normal prior fits pretrained weights, then cover the block-scaling interaction and the FP4 default override.
Real products, models, and research that use this idea.
- Hugging Face TRL and Unsloth default to bnb_4bit_quant_type='nf4' for QLoRA fine-tuning Llama 4 Maverick on consumer GPUs.
- The QLoRA paper benchmarks NF4 versus FP4 across dozens of model families and shows NF4 wins consistently on perplexity for the same 4-bit budget.
- DeepSeek V4 community QLoRA recipes use NF4 to fit the 70B base into 4xH100 setups with room for LoRA training overhead.
- Qwen 3.5 fine-tunes on 24GB consumer cards rely on NF4 quantization of the frozen base to leave enough memory for activations and LoRA gradients.
- bitsandbytes still exposes FP4 as an option for compatibility but its documentation recommends NF4 as the default for pretrained LLM weights.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is NF4 only a small win over FP4 in practice rather than the dramatic win the information-theoretic argument suggests?
QIf transformer weights were uniformly distributed instead of normally distributed, would FP4 or NF4 win?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming NF4 stores more bits per weight than FP4. Both are exactly 4 bits per value; the difference is where the 16 representable values are placed within the range.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.