INT4 stores weights as 4-bit integers with a scale factor, so 16 distinct values must cover the whole weight range. FP4 stores weights as 4-bit floating point values, which gives a wider dynamic range: small values get fine steps and large values get coarse steps, but no value is clamped to the same range. FP4 is the 4-bit data type used by QLoRA under the name NF4, a normal-float format adapted for weights drawn from a normal distribution. Choose by the shape of your weight distribution, not by habit.
What you need
- The model you want to quantize
- Whether you will train on top of the quantized model or only run inference
- A test set of tasks the model must still pass
Step 1: Check the weight distribution
If the weights are roughly evenly spread with few outliers, INT4 is fine and widely supported. If a few weights are far larger than the rest, FP4 handles the range better because its steps grow with magnitude.
Step 2: Match the format to the job
For QLoRA fine-tuning, NF4 is the recommended 4-bit type for training a base model. For inference only, the format matters less than the engine that supports it, so check the engine first.
Step 3: Test quality on your tasks
Quantize the same model both ways where the tool allows it, and compare the answers on your test set. A format that wins on perplexity can still lose on the tasks you care about.
Worked example: synthetic FP4 versus INT4 check
The table below is a synthetic example. It shows the expected result of comparing FP4 and INT4; no model was quantized.
| Format | Outlier handling | Best for |
|---|---|---|
| INT4 | Clamped to one range | Even weights, inference |
| FP4 / NF4 | Wide dynamic range | Outliers, QLoRA training |
| Quality on test set | NF4 wins by 1 task | NF4 chosen |
| Support | Widest | INT4 wins on support |
Expected result (UNTESTED). NF4 wins on the test set for the fine-tuning job, while INT4 wins on engine support, so NF4 is chosen for training. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- NF4 is adapted for weights from a normal distribution; a model whose weights are not normal may behave differently.
- For inference, the bnb_4bit_quant_type does not have a huge impact on performance.
- Going below 4-bit saves more memory but the quality degradation becomes noticeable.
- The larger the model, the more aggressively you can quantize it; small models feel the loss more.
