Pidoku

SmoothQuant (2022)

Module 30 Lesson 30.k 35 min Difficulty 3/5

Prerequisites 10.l, 30.h


Before you start: words you need#

WordPlain meaning
W8A8Both weights (W) and activations (A) in 8-bit integers, so the matrix multiply itself runs on INT8 tensor cores.
ChannelOne column of the activation matrix: the same hidden dimension across all tokens.
Per-tensor / per-token / per-channel scaleOne quantization scale for the whole tensor, one per row (token), or one per column (channel). Per-channel activation scales cannot be used with a fast INT8 GEMM, because the scale would sit inside the sum.
Static vs dynamic quantizationStatic: activation scales fixed in advance from calibration data. Dynamic: computed on the fly for every batch (more accurate, a little slower).
Migration strength (α)SmoothQuant’s knob: how much of the quantization difficulty to move from activations to weights (0 = none, 1 = all).
Mathematically equivalent transformChanging two things so that their product is exactly the same, for example dividing X by s and multiplying W by s.
Zero-shot accuracyAccuracy on standard tasks without examples or fine-tuning.

1. The paper#

  • Title: “SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models”
  • Authors: Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, Song Han (MIT, NVIDIA)
  • Venue: ICML 2023 (arXiv November 2022).
  • Link: arXiv:2211.10438 · code: mit-han-lab/smoothquant

2. The problem#

LLM.int8() (30.h) kept accuracy but ran slower than FP16 because of its mixed-precision split. Weight-only methods like GPTQ (30.i) speed up memory-bound decode but leave the matrix multiply in FP16, so compute-bound prefill gets no faster. To use INT8 tensor cores you need both operands in INT8.

The obstacle is the same outliers LLM.int8() found. In activations, a few channels hold values up to 100× larger than the rest, and those channels are outliers in every token. A per-token scale cannot help (the outlier is in every row), and a per-channel scale would fix it but is not compatible with an INT8 GEMM. Naive W8A8 on OPT-175B drops average zero-shot accuracy from 66.9% to 35.5%.

Weights, on the other hand, are smooth and easy to quantize.


3. The idea#

Move the difficulty from the activations to the weights, with a transform that does not change the layer’s output:

Y = X · W = (X · diag(s)⁻¹) · (diag(s) · W) = X̂ · Ŵ

Divide each activation channel j by a factor s_j, and multiply row j of the weights by the same s_j. Choose s_j large for outlier channels: X̂ becomes flat and easy to quantize, and Ŵ becomes a little bumpier, which weights tolerate.

The factor balances the two with one number α:

s_j = max(|X_j|)^α / max(|W_j|)^(1−α)

α = 0.5 splits the difficulty evenly and works for most models; models with harder activations (the paper names GLM-130B) use 0.75.

The scaling is computed offline from calibration data and folded into the previous layer (the LayerNorm weights, or the previous linear layer), so at run time there is no extra operation at all.

flowchart LR
  C["Calibration: per-channel max of X and W"] --> S["s_j = max|X_j|^α / max|W_j|^(1−α)"]
  S --> FX["Fold 1/s into previous LayerNorm"]
  S --> FW["Multiply weights by s"]
  FX --> Q["Quantize X̂ and Ŵ to INT8"]
  FW --> Q
  Q --> G["INT8 GEMM on tensor cores"]
  class C io
  class S neutral
  class FX,FW memory
  class Q,G compute

4. How it works#

  1. Run 512 random sentences from the Pile through the model to collect each channel’s maximum absolute activation.
  2. Compute s per channel with the chosen α; fold 1/s into the preceding LayerNorm and s into the linear layer’s weights.
  3. Quantize all linear layers to W8A8, and the attention batched matmuls (Q·Kᵀ and P·V) as well. Element-wise operations (softmax, LayerNorm, activation functions) stay in FP16.
  4. Choose one of three settings, from most accurate to fastest:
SettingWeightsActivations
SmoothQuant-O1per-tensorper-token, dynamic
SmoothQuant-O2per-tensorper-tensor, dynamic
SmoothQuant-O3per-tensorper-tensor, static

O3 is the most hardware-friendly: one scale per tensor, known in advance.


5. Results#

Accuracy, OPT-175B, average of 7 zero-shot tasks and WikiText perplexity (Table 3):

MethodAverage accuracyWikiText perplexity
FP1666.9%10.99
Naive W8A8 (per-tensor)35.5%93,080
ZeroQuant35.8%84,648
LLM.int8()66.7%11.10
SmoothQuant-O166.5%11.11
SmoothQuant-O366.8%11.17

The same held for BLOOM-176B, GLM-130B and MT-NLG 530B, and in later versions of the paper for Llama-1/2, Falcon, Mistral and Mixtral (Table 4 and appendix).

Speed and memory:

  • PyTorch implementation, single A100 80 GB: up to 1.51× faster and 1.96× less memory than FP16 on OPT models; LLM.int8() was slower than FP16 in most cases.
  • FasterTransformer integration: up to 1.56× lower latency for OPT-13B and OPT-30B on one GPU, and similar or better latency with half the GPUs for larger models.
  • MT-NLG 530B served within a single 8-GPU node.

6. What held up and what did not#

Held up

  • Migrate difficulty with an equivalent transform. This is the most reused idea in quantization since 2022. AWQ (30.m) scales weight channels using activation statistics; QuaRot and SpinQuant (30.u) replace the diagonal scale with a rotation; FP8 and FP4 recipes in llm-compressor and NVIDIA ModelOpt include a SmoothQuant step.
  • Fold the transform into neighbouring layers so it costs nothing at run time.
  • W8A8 for compute-bound work. It roughly doubles tensor-core throughput over FP16 for prefill and large batches.

Did not, or changed

  • INT8 lost to FP8 on new GPUs. Hopper and Blackwell have FP8 tensor cores; FP8’s exponent handles outliers far better than INT8, so FP8 W8A8 with simple per-tensor or per-channel scales usually needs no smoothing (13.e). SmoothQuant INT8 remains relevant on Ampere (A100, A10) and on hardware without FP8.
  • 4-bit activations need more. Smoothing alone does not get W4A4 accurate; that needed rotations (QuaRot, 30.u) or block-scaled formats such as NVFP4 (13.g).
  • Scaling cannot be folded everywhere — for example where there is no preceding linear or norm to absorb it, as in some gated or residual paths — which limits which layers can be smoothed for free.

7. Where it lives in 2026#

  • Taught in depth: activation quantization and SmoothQuant in 13.d, FP8 and INT8 in 13.e, vLLM’s quantization support in 18.j.
  • llm-compressor has a SmoothQuantModifier used before INT8 W8A8 quantization; vLLM runs the resulting checkpoints with INT8 kernels on GPUs that support them.
  • TensorRT-LLM and ModelOpt include SmoothQuant as an INT8 option.

Checked on 13 November 2026.


8. Questions#

  1. Why can’t per-token scales fix activation outliers? Why can’t per-channel activation scales be used with an INT8 GEMM?
  2. Show that dividing X by s and multiplying W by s leaves X·W unchanged.
  3. What does α control? What happens at α = 0 and α = 1?
  4. Where does the 1/s go at inference time, and why does that make it free?
  5. Compare O1 and O3. Which would you deploy, and why?
  6. Why is SmoothQuant less needed for FP8 on an H100 than for INT8 on an A100?
  7. Why does W8A8 speed up prefill more than decode?

9. Further reading#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in