Mapping floats onto integers
- : the scale, the size of one integer step.
- : the zero point, which integer represents exactly zero.
The whole method is choosing and well, because the rounding error is bounded by half a step and the step is set by the range.
Why it speeds up generation
Decoding reads every weight to produce one token, so it is bound by memory rather than arithmetic.
Halving the bytes nearly halves the time, and the arithmetic saving is a secondary benefit that only appears if the hardware has integer units to use.
Prefill is compute-bound, so it gains less.
That is why quantisation helps generation far more than it helps processing a long prompt.
Symmetric, asymmetric, and where the range comes from
Symmetric quantisation is cheaper because the zero point disappears from the arithmetic, and it wastes half the range on a distribution that is not centred.
A single scale for a whole tensor is ruined by one outlier. A scale per output channel, or per group of 64 or 128 weights, keeps the resolution where the values are.
Finer granularity costs a little storage for the scales, and it is the difference between 4-bit quantisation working and not.
Post-training versus quantisation-aware
- Load the trained model and a few hundred calibration samples.
- Record the range of activations at every layer.
- Choose scales and zero points from those ranges.
- Convert the weights, keeping sensitive layers in higher precision.
- Measure on a real evaluation, not on perplexity alone.
That is post-training quantisation, and at 8 bits it typically costs under a point of accuracy.
Quantisation-aware training inserts fake quantisation into the forward pass so the weights adapt to it, using a straight-through estimator for the gradient since rounding has none.
It recovers most of the loss at 4 bits and below, and it costs a full training run.
What breaks first
In large language models a few channels carry values dozens of times larger than the rest, and those channels alone destroy a per-tensor activation scale.
The practical methods all handle this explicitly: separate the outlier channels, or shift the difficulty from activations into weights before quantising.
GPTQ, AWQ and NF4 are the common methods.
Weight-only quantisation is the common case, since activations are produced fresh per token and weights are read constantly.
Compressing the weights buys the bandwidth and leaves the harder distribution alone.