liveBook · Manning

SmoothQuant

As explained in Domain-Specific Small Language Models

A post-training quantization technique that reduces memory footprint and speeds up inference by smoothing activation and weight ranges.

SmoothQuant is a training-free, post-training quantization technique for large language models. It addresses activation outliers by applying a mathematically equivalent, per-channel scaling transformation that shifts quantization difficulty from activations to weights, enabling INT8 quantization of both weights and activations. section 9.2

SmoothQuant is useful when conventional quantization stops meeting deployment constraints:

  • Targets larger models where systematic activation outliers commonly degrade quantization quality, especially beyond roughly 6–7 billion parameters. section 9.2
  • Avoids the hardware inefficiency of mixed-precision approaches that retain activation outliers in FP16 while using INT8 elsewhere. section 9.2
  • Can reduce memory usage by 50% and increase speed by up to 1.56 times, with minimal accuracy loss in reported experiments. section 9.2
  • Replaces standard linear layers with INT8-capable components rather than requiring additional model training. section 9.5

Quantizing OPT with W8A8

A PyTorch workflow loads the OPT-2.7B model, obtains activation scales from a validation dataset, smooths the model with an alpha value of 0.5, and replaces relevant layers with W8A8Linear modules. On one reported evaluation, naive W8A8 accuracy was 0.423 versus 0.799 after SmoothQuant, compared with 0.798 for the FP16 model. section 9.2

Figure 9.3 A high-level explanation of SmoothQuant

Use the high-level transformation diagram to follow how channel scaling smooths activations before weights and activations are quantized. section 9.2

How Domain-Specific Small Language Models covers it

How deep it goes
Explains activation outliers, channel scaling, layer replacement, and evaluation, but does not derive the transformation mathematically.
Examples
Demonstrates OPT-2.7B, W8A8Linear replacements, activation-scale calibration, and LAMBADA accuracy comparisons.
What it assumes
Assumes familiarity with conventional language-model quantization and introduces advanced methods for cases where those methods fall short.
What you can do after
Apply SmoothQuant through PyTorch and its implementation package to produce and evaluate W8A8 language models.
How it connects
Connects post-training quantization, activation outliers, mixed-precision quantization, INT8 quantization, and PyTorch linear layers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.