Post-Training Quantization
Inference quantization reduces the precision of parameters and values during serving, which can reduce memory footprint and improve computation speed, but reduced precision does not always reduce latency because of format conversion overhead.
Testing the Belief That Fewer Bits Means Faster
A common first reaction to quantization is that storing a model with fewer bits must make it faster. Fewer bits means less data to move, less memory to fill, and, it seems, less arithmetic to perform. That reasoning is partly right, which is exactly why it is easy to over-trust. This article starts from that belief, tests it, and then builds up the more accurate picture that the rest of the topic depends on.
What do you think happens?
If a model's weights are stored in fewer bits, will it always produce answers faster?
Reveal answer
No, the speed depends on more than the number of bits
Reduced precision can speed things up, but it does not always reduce latency. Converting values between formats takes time, and that conversion overhead can cancel out the gain from moving fewer bits.
What Reducing Precision Changes in Stored Values
Inference quantization means reducing the precision of a model's parameters and values while the model is being served. Serving is the stage where a trained model is used to answer inputs, as opposed to the stage where it is learned.
In the early days of deep learning, models were trained and served using 32-bit floating-point values, written FP32. Since the late 2010s it has become increasingly common to serve models at 16 bits and below. The motivation is that quantization can improve computation speed and reduce the memory footprint of the model. The memory footprint is the amount of storage the model's values occupy while it runs.
Once you reach 8 bits and below, the choice of number format becomes more delicate. One option is to keep values as floats in a minifloat format, such as FP8 with 8 bits or FP4 with 4 bits. The more common option is to convert parameter values into an integer format, such as INT8 or INT4. The table below lists the formats mentioned in the source material, ordered from widest to narrowest.
| Format | Bits | Kind of value |
|---|---|---|
| FP32 | 32 | Floating-point |
| 16-bit formats | 16 | Floating-point, reduced width |
| FP8 | 8 | Minifloat |
| INT8 | 8 | Integer |
| FP4 | 4 | Minifloat |
| INT4 | 4 | Integer |
Number formats named in the source, from widest to narrowest
Reducing the width of stored values changes what each value can represent. The diagram below shows the change in stored parameter values. Before quantization, a parameter occupies a wide floating-point slot. After quantization, the same parameter is held in a narrower integer slot. The values are not identical after conversion, which is the central trade-off of this topic.
The diagram is an illustration of the general idea rather than a specific format. A value between two levels is assigned to one of them, so the stored result is an approximation. Each conversion can shift values slightly. Values that fall outside a format's range are a more serious problem, because they can become infinity or an arbitrary value. For that reason, quality has to be checked after quantization rather than assumed.
Why Fewer Bits Can Speed Up Inference
Reduced precision helps in two linked ways. First, a smaller footprint allows a larger batch size, so the model can process more inputs in parallel. Second, reduced precision speeds up the computation itself, which lowers inference latency. Latency is the time it takes to produce a response for one request. The arithmetic argument is easiest to see with a bit-by-bit model of addition, which is why the source uses it as the starting point for the mechanism.
Tracing one parameter through a quantized serving step
A parameter is stored as a wide floating-point value and then converted to a narrower integer format for serving. Follow what happens to its value and where the cost appears.
- 1Start with the stored value
The parameter begins as a value in a wide floating-point slot, such as FP32. It holds a fine-grained number, for example 0.62.
- 2Map it to a narrower format
Quantization converts the value into a narrower integer slot, such as INT8. The value is snapped to the nearest representable level, so the stored result is an approximation rather than the exact original.
- 3Move less data
Because each stored value is narrower, the parameter occupies less memory and less data has to move. This is the source of the footprint and bandwidth benefit.
- 4Convert before computing
The compute unit may need the value in a different format from the one it is stored in. The conversion step takes time, and this is the cost that can offset the savings from moving fewer bits.
Fewer bits reduce data movement and memory use, but the value changes slightly, and any conversion needed before computing adds time back. Whether the net effect is faster depends on that balance.
Where Format Conversion Adds Time Back
Reduced precision does not always reduce latency. The reason is format conversion overhead in the inference path. The pipeline below follows a stored low-precision weight from memory to the compute unit. Each step that changes the format is a place where time can return, even though the stored values are smaller.
The two conversion steps in the pipeline are where the gain can be lost. Moving fewer bits is a real saving, but a conversion before the arithmetic and a conversion after it can consume that saving. This is why the simple rule that fewer bits means faster does not hold in every case. The benefit has to be measured on the actual serving path, not inferred from the bit width alone.
Four Ways to Use Lower Precision
Post-training quantization is only one of several ways lower precision enters the model lifecycle. The table below sets the four approaches side by side. The key question for each is at what stage reduced precision is applied, and whether it is aimed at inference quality, training cost, or both.
| Approach | Where reduced precision applies | Main goal |
|---|---|---|
| Post-training quantization (PTQ) | Only at inference, after training in higher precision | Lower serving cost and speed up computation |
| Quantization-aware training (QAT) | Simulated during training while computing in high precision | Good quality when the model is later run in low precision |
| Mixed precision training | Different precisions for weights, gradients, and activations | Reduce training cost while keeping sensitive values precise |
| Training directly in lower precision | Throughout training itself | Reduce training time and cost; harder to get right |
Where each approach applies reduced precision
Quantization during training is less common than PTQ, but it is gaining traction. It has two distinct goals, and a given technique may serve one, both, or neither. The subsections below take each approach in turn.
How 1-Bit and 1.58-Bit Weights Work
Quantization has a limit. A value cannot use fewer than 1 bit, and several efforts have tried 1-bit representations, including BinaryConnect, Xnor-Net, and BitNet. In 2024, Microsoft researchers declared the era of 1-bit LLMs by introducing BitNet b1.58, a transformer-based language model that requires only 1.58 bits per parameter.
The number 1.58 is not a bit pattern that a single stored bit can hold. It describes information content: a weight that can take one of three values, such as -1, 0, or +1, carries $\log_2 3 \approx 1.58$ bits of information. The diagram below shows the three states. A few states, arranged across a whole weight matrix, are what allow the representation to approximate full-precision weights.
The reported performance of BitNet b1.58 is comparable to 16-bit Llama 2 up to 3.9B parameters. A benchmark comparison with Llama models at several sizes is the source's evidence for this claim. Read it with care: the comparison is about benchmark scores, not about speed, and the gap varies from benchmark to benchmark. A benchmark result does not, by itself, show that the model runs faster.
Mistakes Beginners Make About Lower Precision
Common mistake Assuming fewer bits always means faster inference
What it looks likeA model is quantized to a narrower format, and its latency is expected to drop by the same ratio as its bit width.
Why it failsFormat conversion can add time back, and the conversion steps may consume the gain from moving fewer bits.
Do this insteadMeasure latency on the actual serving path rather than inferring it from the bit width.
Common mistake Assuming quantized values are identical to the originals
What it looks likeA parameter stored as a wide float is assumed to keep exactly the same value after being stored in an integer slot.
Why it failsEach conversion can shift values slightly, so the stored result is an approximation.
Do this insteadCheck output quality after quantization.
Common mistake Confusing QAT with a way to train faster
What it looks likeQuantization-aware training is adopted expecting shorter training runs.
Why it failsQAT simulates low-precision behavior while computing in high precision, so it does not reduce training time.
Do this insteadUse QAT to improve low-precision inference quality, and use other approaches if the goal is cheaper training.
Common mistake Believing low-precision training is always the easier option
What it looks likeTraining directly in lower precision is assumed to be a simple cost reduction.
Why it failsBackpropagation is more sensitive to lower precision, so the learning signal can be disturbed.
Do this insteadExpect extra difficulty and validate training behavior carefully.
Common mistake Treating a 1.58-bit weight as a stored 1.58-bit field, rather than a value with three states
Applying the Ideas to a Deployment Decision
A team has a model trained in FP32 and wants to serve it on an edge device that only supports quantized inference. Which approach matches this situation, and what must they check before shipping? Explain your answer in terms of when reduced precision is applied and what could change in the outputs.
Hints
- Ask whether the reduction happens before, during, or only after training.
- Consider what the edge device requires and what changes when values are converted.
- Think about whether quality must be re-checked after the change.
Key Takeaways
- Inference quantization reduces the precision of a model's parameters and values during serving, which can shrink the memory footprint and speed up computation.
- Reduced precision does not always reduce latency, because format conversion can add time back and each conversion can shift values.
- Post-training quantization applies reduced precision after training; quantization-aware training simulates low precision during training to improve low-precision inference quality without reducing training time; mixed precision assigns different precisions to weights, gradients, and activations.
- 1-bit and 1.58-bit models are possible because a few discrete states can approximate weights, but a value cannot use fewer than 1 bit, and benchmark quality is not the same as speed.