- Key idea
- Heavy tails, outlier features and massive activations; clipping vs rounding error; calibration by percentile, MSE or KL
- Real world
- Scaling a chart of household incomes so a single billionaire fits on it squashes everyone else into one bar. Cutting the axis at a sensible point (and labelling the billionaire separately) shows the rest of the population.
- In an LLM
- From about 6.7 billion parameters, a handful of hidden-state channels hold values 20–100× larger than the rest, in nearly every token. Quantize those activations to int8 with one scale per token and the other 4,000 channels get almost no resolution.
Heavy tails
If weights and activations were neatly bell-shaped, a grid stretched to the largest value would be fine. They aren’t. Their distributions have heavy tails: almost all values are small, but a few are very far out. The absmax scale is set by those few, so the grid is coarse exactly where most of the values are.
There are two kinds of outliers in LLMs:
- Weight outliers: scattered individual weights much larger than their neighbours. Small groups (granularity) contain them well.
- Activation outliers: whole channels (the same feature dimension, in almost every token) with values tens of times larger than the rest. Dettmers et al., 2022 found they appear abruptly in models around 6.7B parameters and grow with scale. A few tokens (often the first token, or a full stop) also carry massive activations thousands of times larger than typical. Activation outliers are the main reason activations are harder to quantize than weights.
Clip, or stretch the grid?
There are two errors to balance:
- Rounding error for values inside the range, proportional to the grid step. A wider range means a coarser step and more rounding error.
- Clipping error for values outside the range, which are flattened to the edge. A narrower range means more clipped values.
Clipping at the very largest value has zero clipping error but maximum rounding error. Clipping too tightly does the reverse. Somewhere in between is the minimum total error.
Try it
Plot the incomes of a town of 4,000 people where one resident is a billionaire. If the axis runs to £1 billion, everyone else is a sliver at the bottom. Cut the axis at £300,000 and mark the billionaire “off the chart”: you lose the exact figure for one person, and gain a readable picture of everyone else. Clipping makes the same trade.
A token’s hidden state has 4,096 values. 4,090 of them are between −2 and 2; six channels are around 60. Per-token int8 with absmax sets . Every ordinary value now lands on one of about 9 grid points (−2 to 2 in steps of 0.47): effectively a 3-bit grid for 99.9% of the values. Clipping at 2 would destroy the six outlier channels, which turn out to matter a great deal: removing them collapses the model’s quality. So neither stretching nor clipping works, and LLM.int8() and SmoothQuant were invented for exactly this.
Calibration
For activations, the range has to be chosen in advance from sample data: run a few hundred examples through the model, record the values each layer sees, and pick a clipping range. This is calibration. Common rules:
- Min–max: no clipping. Safe, often too coarse.
- Percentile: clip at the 99.9th or 99.99th percentile of magnitudes.
- MSE: choose the range that minimises the mean squared error between original and quantized values, as in the widget.
- KL divergence: choose the range that keeps the quantized histogram closest to the original (used by TensorRT for int8).
For weights, no calibration data is needed for the range itself, since the weights are known; but the better LLM methods (GPTQ, AWQ) still use calibration data to learn which weights matter most.
Where this shows up
- Containing weight outliers with small groups: granularity.
- Handling activation outliers: LLM.int8() and SmoothQuant.
- Spreading outliers out with rotations: rotations.
The clipping trade-off
For clipping threshold and bits, with step , the expected squared error is approximately
The first term grows with ; the second shrinks as grows, faster for light-tailed distributions. For a Gaussian at 4 bits the optimal is about , far below the maximum of a large sample. For heavy-tailed (Laplace or Student-t) data it is relatively even tighter compared with the max, and the gain from clipping is larger.
In papers
- Outlier features: Dettmers et al., 2022 (LLM.int8()).
- Activation outliers and difficulty migration: Xiao et al., 2022 (SmoothQuant).
- Calibration methods for PTQ: Nagel et al., 2021.