---
title: "SmoothQuant — paper by Xiao et al. (2022) — summary and ideas"
description: "SmoothQuant rescales weights and activations after training so large language models can run fast integer matrix operations with little loss in…"
canonical: "https://research.elamur.ai/free/en/papers/xiao-2022-smoothquant-accurate-efficient-post-training/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/xiao-2022-smoothquant-accurate-efficient-post-training/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2022](https://md.research.elamur.ai/free/en/papers/2022/) / SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models

# SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models

Paper · 2022 · Guangxuan Xiao, Ji Lin, Mickael Seznec et al.

**Authors:** [Guangxuan Xiao](https://md.research.elamur.ai/free/en/authors/guangxuan-xiao/), [Ji Lin](https://md.research.elamur.ai/free/en/authors/ji-lin/), Mickael Seznec, [Hao Wu](https://md.research.elamur.ai/free/en/authors/hao-wu/), [Julien Demouth](https://md.research.elamur.ai/free/en/authors/julien-demouth/) and [Song Han](https://md.research.elamur.ai/free/en/authors/song-han/) · **Year:** 2022 · **Venue:** arXiv:2211.10438 · **Licence:** [CC BY 4.0 (arXiv)](http://creativecommons.org/licenses/by/4.0/)

[Cited by **597** papers in our library of the 163,136 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/xiao-2022-smoothquant-accurate-efficient-post-training/cited-by/) · [licence](http://creativecommons.org/licenses/by/4.0/)

- [PDF](https://arxiv.org/pdf/2211.10438)
- [arXiv 2211.10438](https://arxiv.org/abs/2211.10438)

## Summary

Serving a large language model takes memory for its learned weights and computing time for the matrix operations that apply those weights to incoming text. Storing the weights as smaller numbers helps with memory. Getting the main matrix operations to run in integer arithmetic also requires changing the activations, the intermediate values produced as text passes through the network. That is where simple conversion runs into trouble. In the large networks studied in SmoothQuant, a few activation channels carry values much larger than the rest. If all channels share a numerical scale, the largest values set the spacing between representable numbers. Many smaller values then get rounded to the same few levels. [Large language models](https://md.research.elamur.ai/free/en/concepts/large-language-models/)

SmoothQuant takes advantage of where those large values occur. Their magnitudes vary strongly from channel to channel, but the same channels tend to have large values across tokens. The authors use calibration text to estimate the range of each channel. They divide each activation channel by a fixed factor and multiply the corresponding part of the weight matrix by that same factor. Before rounding, the changes cancel in the matrix product. After rounding, the smaller spread in the activations makes them easier to represent. The weights absorb some of the variation and can generally tolerate it. A setting called migration strength controls how much variation moves across, with the aim of keeping both sides suitable for integer arithmetic.

The conversion takes place after training, without updating the network through another round of learning. SmoothQuant uses INT8, a signed integer format, for the weights and activations in the main matrix multiplications, a configuration called W8A8. The paper tests settings that trade finer numerical scaling at inference time for lower runtime overhead. On OPT-175B, the authors report accuracy comparable to FP16, their floating-point baseline, even with the most aggressive setting. BLOOM-176B and GLM-130B retain accuracy most closely with finer settings. Tests on MT-NLG 530B, the Llama families, Falcon, Mistral and Mixtral provide evidence across more architectures and sizes, with the later families evaluated through perplexity on WikiText-2.

The systems tests measure how much those numerical changes matter in practice. In PyTorch, SmoothQuant reaches a context-processing speedup of 1.51× and a peak GPU memory saving of 1.96× in the reported single-GPU tests. In FasterTransformer, it reaches a context-stage speedup of 1.56× and nearly halves memory use relative to FP16. The FasterTransformer deployment of OPT-175B uses 4 GPUs in place of 8. For MT-NLG 530B, the required GPU count goes from 16 to 8 at similar latency, allowing the quantized network to run on one node. These outcomes depend on the tested workload and implementation. They show how changing the numerical representation can make an otherwise similar inference job fit on fewer devices.

## Deep dive: SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models

SmoothQuant rescales weights and activations after training so large language models can run fast integer matrix operations with little loss in accuracy. · about 32 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Memory, data movement and arithmetic

The paper concerns inference, the work a trained network does when it receives an input or generates text. At this point, the weights have already been learned. The system must store them, make them available to the processor and use them in calculations that produce increasingly processed representations of the input. The cost is substantial even before considering how many requests a service should handle at once. The authors use GPT-3 as an example. The paper puts the minimum memory needed to store and run its 175B parameters in FP16 at 350GB. The example illustrates how a single inference deployment can require several accelerators.

Accommodating those parameters is a capacity problem. Reading them and moving intermediate values are bandwidth problems. Computing the transformations is an arithmetic problem. A deployment spread across devices also has communication to manage. These costs matter in different proportions for different workloads. A change that reduces parameter storage can determine whether a deployment fits. A change that speeds up matrix multiplication can reduce the time spent processing a request. SmoothQuant is designed to address both storage and the execution of the principal matrix operations. [Efficient models & compression](https://md.research.elamur.ai/free/en/topics/efficient-models/)

The arithmetic target comes from the structure of a Transformer. A linear layer applies the same learned matrix to a representation of each token. A token is a unit of the text representation, and its activation vector records the values computed for it at that point in the network. A linear layer can process the vectors together through general matrix multiplication, or GEMM. Attention also uses batched matrix multiplication, or BMM, which carries out several matrix products as a group. These operations offer large, regular stretches of arithmetic for an accelerator to execute. [Transformer and attention](https://md.research.elamur.ai/free/en/concepts/transformer/)

Quantization replaces a range of floating-point values with a finite set of representable values. In this paper the main target is INT8, with 8 bits per integer. FP16 is the floating-point format used as the reference. Representing the learned matrix in INT8 reduces its storage. Supplying both operands in INT8 also makes it possible to run the central matrix product through an integer kernel. A kernel is the implementation of an operation that runs on the accelerator. Whether a representation saves time depends in part on how directly it maps to such kernels. [GPU & parallel computing](https://md.research.elamur.ai/free/en/topics/gpu-parallel-computing/)

#### Why the activation is the harder operand

The weights are available before inference, so their numerical ranges can be inspected directly. Activations depend on the text entering the network. They also have a different distribution from weights. The paper presents a linear layer in OPT-13B where the weights are fairly even in magnitude, while several activation channels have magnitudes greater than 70. Across the authors’ analysis, activation outliers can be on the order of 100× larger than most values. A channel is one feature position in the vector for a token. An unusually large channel can therefore affect how an entire matrix of token vectors is represented. [OPT](https://md.research.elamur.ai/free/en/papers/zhang-2022-opt-open-pre-trained-transformer/)

A uniform quantizer uses evenly spaced levels. To represent the extremes without clipping, its spacing has to grow with the largest magnitude in the group being quantized. That choice can preserve the magnitude of an outlier while making the much more numerous small values hard to distinguish. The paper notes that some ordinary channels can effectively have only 2-3 levels available under a shared scale. An integer representation can therefore lose detail even when every value sits inside its nominal range. The useful question is how much of that range the typical values in a given channel occupy.

The outliers have a structure that suggests where to intervene. Across the feature positions of one token, magnitudes can vary widely. Down the rows for different tokens, a particular feature position tends to have a more consistent magnitude. In the authors’ analysis, channels that contain outliers keep appearing as large channels across the sequence. Giving each token its own scale cannot undo that pattern. Each row has its own range, but the large feature positions still influence the spacing used for the rest of the row.

Giving each activation channel a separate quantization scale directly addresses the distribution. The small values of a small channel receive a scale suited to that channel. The difficulty is that an input channel indexes terms that are added together during matrix multiplication. A scale that changes across those terms must normally be accounted for before the sum finishes. Efficient INT8 kernels can postpone row and output-column scaling until after the integer arithmetic. Scaling individual terms within the sum disrupts the regular computation that gives the kernel its throughput.

#### Where earlier approaches put the cost

The authors describe quantization as already effective in convolutional networks and smaller Transformers. Earlier methods also changed the distribution of weights. Weight equalization and channel splitting, for example, addressed unusually large values in the learned parameters. Here the large values are concentrated in activations. The challenge is to deal with that distribution while keeping both inputs to the computationally dominant matrix products in an accelerator-friendly format. The paper builds on the uniform integer formulation used in earlier work on neural-network quantization. [Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference](https://md.research.elamur.ai/free/en/papers/jacob-2017-quantization-training-neural-networks-efficient/)

ZeroQuant uses scales derived at runtime for each token’s activation and separate scales for groups of weights. This gives it finer control than a single scale for each complete tensor. The related work also describes nuQmm in connection with per-token and grouped quantization and specialized CUDA kernels. These schemes address the size of the numerical groups and the cost of applying their scales. The persistent activation channels explain why choosing groups alone may leave the hardest numerical problem in place.

LLM.int8() targets those channels using mixed precision. It keeps the outlier contribution in FP16 and uses INT8 for the remaining part. This protects values that are difficult to represent and gives the common part of the calculation access to integer arithmetic. It also leaves a full matrix operation with separate precision paths to handle. Outlier Suppression takes another route, using a form of LayerNorm without its usual learned scaling and using token-wise clipping. The authors describe it in the context of smaller systems such as BERT and BART. [BART](https://md.research.elamur.ai/free/en/papers/lewis-2020-bart-denoising-sequence-sequence-pre/)

Weight-only quantization tackles a different combination of costs. GPTQ compresses the learned parameters and, in the implementation discussed in the paper, converts them back to floating point as needed for multiplication. Loading compact weights can help when fetching them takes much of the time. SmoothQuant asks how to deal with the activations as well, so that both operands are ready for a standard integer matrix kernel. The distinction matters because retaining the accuracy of the original network, reducing the stored size and accelerating the full computation are separate achievements. [GPTQ](https://md.research.elamur.ai/free/en/papers/frantar-2022-gptq-accurate-post-training-quantization/)

### The method, step by step

#### Make the numbers easier to round

Consider the activation entering a linear layer as a rectangle. Rows are tokens and columns are input channels. If a few columns tend to contain large values, the straightforward response is to divide those columns by relatively large amounts. That makes their values closer in magnitude to the rest of the rectangle. Applied by itself, however, the division changes the contribution those features make to every output. SmoothQuant compensates by multiplying the matching rows of the weight matrix by the same amounts. Each activation value is then multiplied by a weight that has received the inverse change.

The order matters. The authors first change the floating-point representation of the computation. Only after doing that do they round the transformed operands to integers. The first change has an algebraic guarantee for the linear product. The second introduces approximation. SmoothQuant relies on the transformed operands being easier to round together, and the experiments establish how well that expectation holds. A network can compute the same linear function before rounding even when the distributions of the two operands have changed considerably.

The method also uses two kinds of scale. A smoothing factor changes the relative magnitudes of input channels and is absorbed into the transformed network where possible. A quantization step is the distance between adjacent representable numerical values. The latter controls rounding and how the integer result is interpreted. SmoothQuant can use a smoothing factor for every input channel while choosing a much coarser quantization step. This distinction allows the transformation to address a channel-specific problem without requiring an input-channel scale inside the integer kernel.

How SmoothQuant prepares and runs integer matrix products The steps in order.

#### Define the integer representation

The paper uses uniform quantization and presents the symmetric case, where zero is the center of the numerical range. For the group of values being quantized, it defines the step as follows.

```
Δ = max(|X|) / (2^(N − 1) − 1)
```

Here Δ is the distance between adjacent levels. X is the floating-point tensor or the portion of it sharing that step. The bars take the absolute value of its entries, and max selects the largest of those magnitudes. N is the bit width, 8 in the paper’s INT8 setting. The caret denotes exponentiation. The denominator is the largest positive integer used by the symmetric quantizer, so the largest observed magnitude determines the step.

```
X̄ᴵᴺᵀ⁸ = round(Xᶠᴾ¹⁶ / Δ)
```

Here Xᶠᴾ¹⁶ is the floating-point input. X̄ᴵᴺᵀ⁸ is its integer representation, and Δ is the quantization step for its group. Division and round are applied entry by entry. The round operation selects the nearest integer. The superscripts indicate storage formats. In the symmetric formulation, the scale connects an integer entry to the floating-point magnitude it represents. The authors point out that an asymmetric version can use a zero-point to shift how the integer codes correspond to floating-point values.

The same quantization rule can use statistics collected at different times. In static quantization, the authors estimate the step from activations observed in calibration and reuse it during inference. This avoids recalculating a range for each input. In dynamic quantization, the current activations determine their own step at runtime. Dynamic quantization adapts to the actual input distribution, with additional work to obtain the statistic. The choice affects how well the scale fits a particular input and how much effort the implementation spends preparing the matrix operands.

Granularity specifies which values are grouped under a step. Per-tensor quantization uses one step for the whole array. Per-token activation quantization uses a separate step for each token row. For weights, per-channel quantization can give each output column a separate step. Group-wise quantization assigns a step to a group of channels. These choices describe how elements share rounding levels. Granularity and when to calculate the statistics are independent in principle. The authors compare settings that combine them to different effect.

The paper gives an estimate of the available levels in an activation channel under a scale shared across the matrix.

```
effective levels for channel i = 2^8 · mᵢ / m
```

Here i identifies the channel, mᵢ is the maximum magnitude in that channel and m is the maximum magnitude across the activation matrix. The caret denotes exponentiation, 8 is the bit width and the centered dot denotes multiplication. The expression is a way to reason about resolution. A channel spanning only a small part of the matrix’s total range can make use of only a small part of the integer grid. A token-specific grid can still have poor resolution across small channels if the same token also contains a large outlier.

#### Put the scale on the correct axis

The authors use the linear product below with the batch dimension omitted.

```
Y = X · W
```

X is the matrix of input activations, with T token rows and Cᵢ input columns. W is the weight matrix, with Cᵢ input rows and Cₒ output columns. Y contains one row per token and one column per output channel. T is the number of tokens, Cᵢ is the number of input channels and Cₒ is the number of output channels. The centered dot denotes matrix multiplication.

Each output entry collects contributions from all input channels. A step shared by an entire activation row can be applied once to every output in that row. A separate weight step for each output column can likewise be applied to the corresponding output column. The matrix product in the middle can be computed directly on its integer inputs. With these choices, the paper writes the scaled output as follows.

```
Y = diag(Δₓᶠᴾ¹⁶) · (X̄ᴵᴺᵀ⁸ · W̄ᴵᴺᵀ⁸) · diag(Δ𝑤ᶠᴾ¹⁶)
```

Here Y is the reconstructed output of the quantized layer. X̄ᴵᴺᵀ⁸ contains the quantized activation entries and W̄ᴵᴺᵀ⁸ contains the quantized weight entries. Δₓᶠᴾ¹⁶ is the vector of floating-point activation steps along the token axis, and Δ𝑤ᶠᴾ¹⁶ is the vector of floating-point weight steps along the output axis. The superscripts identify the formats. The function diag puts a vector’s entries on the diagonal of a matrix, so multiplication on the left scales rows and multiplication on the right scales columns. The dots are matrix multiplication, and the parentheses identify the integer product. Comparison with the original floating-point Y can reveal differences caused by rounding.

A step that varies by input channel behaves differently. Even within one output entry, the terms in the sum would have different steps. Multiplying the finished output by a single factor could no longer reproduce the intended contribution of every input channel. The paper argues that inserting conversions or floating-point arithmetic into the sequence of integer operations would undermine the use of the high-throughput kernel. The smoothing factors solve this particular problem through a change made before quantization, with a compensating action on the weight matrix.

#### Transfer variation while preserving the product

The transformation divides the input columns by channel-specific factors and multiplies the matching weight rows by those factors. In the paper’s matrix notation, this is the following identity.

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

Here Y is the result of the original linear product. X and W are its original floating-point operands. The vector s has a smoothing factor for each of the Cᵢ input channels. The diag function forms a diagonal matrix, and the inverse indicated by ⁻¹ places reciprocal factors on the diagonal. X̂ is the smoothed activation, produced by dividing each column of X by its factor. Ŵ is the adjusted weight matrix, produced by multiplying the corresponding row of W by that factor. The dots denote matrix multiplication.

A contribution through a given channel therefore enters the sum with a division on its activation value and a multiplication by the same factor on its weight. The cancellation happens regardless of the other channels’ factors. This makes it possible to change each channel by a different amount without changing the unquantized product. It also explains why a fixed estimate based on calibration gives a valid transformation for later inputs. A new input may have a different range and prove harder to round, but the cancellation in the floating-point product does not depend on how well the calibration predicted that range.

How far to move the variation is a separate question. If the factor for every channel equals that channel’s activation maximum, the calibration activations become completely aligned by their maximum magnitudes. The corresponding weight rows then absorb all of the original channel-to-channel scale differences. The paper finds that the weights can become hard to quantize in this case. At the other extreme, choosing the reciprocal of each weight row’s maximum aligns the weight ranges and can leave the activation side difficult to represent. Both extremes preserve the floating-point function. Their differing quantized behavior motivates an intermediate choice.

The authors call the parameter that controls that choice migration strength.

```
sⱼ = max(|Xⱼ|)^α / max(|Wⱼ|)^(1 − α)
```

Here j identifies an input channel, and sⱼ is that channel’s smoothing factor. Xⱼ consists of the activations observed in the channel on calibration inputs. Wⱼ contains the weights in the associated input row. Absolute value is indicated by the bars, max selects the largest magnitude, and the carets indicate exponentiation. The parameter α governs how much the activation range determines the factor. The exponent 1 − α governs the complementary role of the weight range. Division combines those two contributions.

When α increases, the method aims to move more of the burden onto the weights. The paper illustrates α = 0.5, which uses the same exponent for both range statistics. For the calibration maxima in a corresponding pair of channels, the division on the activation side and the multiplication on the weight side bring those maxima into balance. That balance concerns the range of the transformed operands. The rest of their distributions, and their importance to task performance, can still differ. An empirical check is needed to see whether the new ranges work for the chosen quantizer.

#### Calibrate once and reuse the transformation

The authors choose α by a quick grid search on part of the Pile validation set. They report α = 0.5 as generally suitable for the OPT and BLOOM families and choose α = 0.75 for GLM-130B, where the activation outliers are more extensive. The adaptive choice is at the level of preparing a particular network. It does not ask the running system to choose a new α from incoming text. The weights supply one set of maxima directly, and a forward pass on calibration text supplies the activation statistics.

The procedure uses 512 randomly selected sentences from the Pile, which the paper describes as pretraining data, to obtain the smoothing factors and the steps for static quantization. The resulting quantized configuration is then reused across downstream tasks. GLM-130B has a further calibration choice. The authors clip the top 2% of tokens when estimating static steps, following the procedure they cite from Outlier Suppression. This clipping pertains to setting the static quantizer. It is distinct from dividing an activation channel by a factor and compensating in the weights.

Because the factors are fixed, they can often be included in the parameters of the operation that produces the activation. If a linear operation or a normalization layer produces the vector, its output parameters can be adjusted to provide the rescaled values. The consuming matrix multiplication then receives the smoothed activation directly and stores the adjusted weights. Where the input comes from adding a residual connection, the paper describes adding scaling on that branch. The reason to move the scaling upstream is to avoid a separate computation for it wherever it can be fused.

The practical precision plan assigns INT8 inputs to the linear layers and the batched matrix multiplications inside attention. By default, smoothing is applied to inputs of the self-attention and feed-forward layers. The authors leave activations in FP16 for lighter operations such as ReLU, Softmax and LayerNorm. This puts the lower precision where the paper expects the largest arithmetic benefit. It also lets operations between matrix products use the floating-point format the implementation already provides.

The paper calls the efficiency settings O1, O2 and O3. The progression goes from finer, dynamic activation quantization toward coarser quantization and finally the per-tensor static O3 configuration. Per-token dynamic scaling can respond to the range of each current token. Dynamic per-tensor scaling uses a single range for the tensor at runtime. Static per-tensor scaling uses a range fixed during calibration. The same smoothing idea makes each of those operating points possible. The paper reports implementation code in the `mit-han-lab/smoothquant` repository.

### Experiments and results

#### Measuring accuracy after conversion

The quality experiments compare each quantized network with its own FP16 reference. This controls for the capabilities it already had before conversion. The question is how much benchmark performance changes when its numerical representation changes. The paper uses task accuracy for the zero-shot evaluations, where the converted network is applied to the benchmark without task-specific retraining. It also reports perplexity for language modeling. Lower perplexity corresponds to the network assigning greater probability to the observed text, as measured by the language-modeling evaluation. Accuracy and perplexity show different aspects of the change. [Evaluation & benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/)

For OPT and BLOOM, the broader zero-shot suite includes HellaSwag, OpenBookQA, RTE and COPA. The other tasks are WinoGrande, PIQA and LAMBADA. The authors also use WikiText for a language-modeling evaluation. They run these experiments with lm-eval-harness. In the family comparison, the reported mean for OPT-175B and BLOOM-176B uses the narrower set of WinoGrande, HellaSwag, PIQA and LAMBADA. The set of tasks matters when interpreting a score called average accuracy. The broad benchmark and the family comparison answer related questions using different groupings. [WinoGrande](https://md.research.elamur.ai/free/en/papers/sakaguchi-2019-winogrande-adversarial-winograd-schema-challenge/) [PIQA](https://md.research.elamur.ai/free/en/papers/bisk-2019-piqa-reasoning-about-physical-commonsense/) [LAMBADA](https://md.research.elamur.ai/free/en/papers/paperno-2016-lambada-dataset-word-prediction-requiring/) [WikiText](https://md.research.elamur.ai/free/en/papers/merity-2016-pointer-sentinel-mixture-models/)

The GLM-130B evaluation instead uses LAMBADA, MMLU, MNLI and QNLI, and is run using the official GLM-130B evaluation code. The authors choose this suite because some benchmarks used for OPT and BLOOM had appeared in GLM-130B’s training data. The family-comparison table consequently supports measuring the effect of changing precision within GLM-130B. Differences between its aggregate scores and those of OPT or BLOOM mix changes in networks with changes in datasets. The paper’s focus is the pair of scores before and after quantization for each tested system. [GLM-130B](https://md.research.elamur.ai/free/en/papers/zeng-2022-glm-130b-open-bilingual-pre/) [MMLU](https://md.research.elamur.ai/free/en/papers/hendrycks-2020-measuring-massive-multitask-language-understanding/) MNLI [GLUE](https://md.research.elamur.ai/free/en/papers/wang-2018-glue-multi-task-benchmark-analysis/)

The post-training accuracy baselines are naive W8A8 quantization, ZeroQuant, LLM.int8() and Outlier Suppression. They represent different ways of spending precision and computational effort. The naive baseline quantizes the operands without smoothing. ZeroQuant changes which values share a scale. LLM.int8() gives the outlier contribution its own higher-precision path. Outlier Suppression changes how activations are handled using its own transformation and clipping approach. The comparison tests whether SmoothQuant’s particular redistribution of channel magnitudes works at sizes where activation quantization is difficult.

#### How different families respond

OPT-175B provides the strongest contrast between successful and unsuccessful conversions in the paper. SmoothQuant approaches the FP16 accuracy across the evaluation datasets with all its quantization settings, including O3. LLM.int8() also retains accuracy, using floating point to handle outliers. The authors describe the naive W8A8, ZeroQuant and Outlier Suppression results on this network as close to random performance. A variant of ZeroQuant that leaves the input to self-attention in FP16 and quantizes the remaining operations also fails to recover OPT-175B’s accuracy. Keeping that input in higher precision was a targeted change derived from the earlier GPT-NeoX-20B procedure.

BLOOM-176B responds differently. The naive dynamic per-tensor W8A8 baseline reduces average accuracy by 4% in the paper’s family comparison on WinoGrande, HellaSwag, PIQA and LAMBADA. The authors report that SmoothQuant O1 and O2 retain the FP16 accuracy. The static per-tensor O3 setting reduces the same average by 0.8%. They attribute the remaining loss to differences between the activation statistics collected for the static scales and those encountered during evaluation. This is an example in which smoothing is compatible with several quantization schemes, while the choice of scheme still affects the measured outcome. [BLOOM](https://md.research.elamur.ai/free/en/papers/workshop-2022-bloom-176b-parameter-open-access/)

Average accuracy loss for BLOOM-176B on WinoGrande, HellaSwag, PIQA and LAMBADA SmoothQuant with static scales loses less average accuracy than naive dynamic quantization.

**The numbers**

| System or setting | average accuracy loss % |
| --- | --- |
| Naive W8A8 with dynamic per-tensor scales | 4 |
| SmoothQuant O3 with static per-tensor scales (this paper) | 0.8 |

GLM-130B is the more difficult quantization case in the authors’ comparison. The procedure uses higher migration strength and the clipping adjustment for static calibration. On LAMBADA, MMLU, MNLI and QNLI, SmoothQuant O1 reaches accuracy comparable to the FP16 reference. O3 reduces the reported mean accuracy by 1%, while outperforming the baselines. Read alongside BLOOM and OPT, the GLM result shows why the paper presents a range of configurations. The method for redistributing magnitudes transfers across families. The granularity and static calibration choices that give the best practical outcome can differ.

The authors also compare different sizes within OPT. Their model-size analysis reports that O3 retains FP16-level accuracy for the sizes tested, including networks smaller than those in the main large-scale comparison. This supports using the transformation at several OPT scales and helps separate its value from the particular requirements of OPT-175B. The study of OPT-IML-30B changes another part of the setup by using an instruction-tuned network. Its evaluations on WikiText-2 and LAMBADA show preserved performance after SmoothQuant conversion, while the baselines in that comparison show deterioration. The evidence covers those two benchmarks for the tested instruction-tuned system.

For LLaMA, the paper reports initial experiments using a WikiText-2 sequence length of 512. SmoothQuant uses per-token activation quantization with α = 0.8 and yields only a small change in perplexity. The authors describe the activation outlier problem they observed in these experiments as less severe than for OPT and BLOOM. The use of a different setting shows that the extension tests the smoothing method on a new family with settings chosen for that evaluation. [LLaMA](https://md.research.elamur.ai/free/en/papers/touvron-2023-llama-open-efficient-foundation-language/)

Further experiments extend the same general approach to Llama-2, Falcon, Mistral and Mixtral. This group uses WikiText-2 perplexity with a sequence length of 2048, per-token activation scales and per-channel weight scales. The paper reports minimal performance loss. Mixtral adds a mixture-of-experts architecture to the test coverage, with the quantization evaluated on the same language-modeling metric as the other families in this group. These perplexity results broaden the list of networks on which the approach has been tested. The different sequence lengths and precision schemes in the two Llama-related experiments are important conditions on comparisons across them. [Llama 2](https://md.research.elamur.ai/free/en/papers/touvron-2023-llama-2-open-foundation-fine/)

#### Timing the context and decoding stages

The speed tests address a separate question from benchmark accuracy. The paper uses NVIDIA A100 80GB GPU servers and measures O3 in two backends. PyTorch with Hugging Face serves as a proof of concept and FasterTransformer represents a more optimized serving implementation. Both replace the existing floating-point linear and batched matrix multiplication implementations with ones built on CUTLASS INT8 kernels. The timing results reflect the combination of a numerical scheme and concrete implementations of its operators.

In the context stage, the system computes the hidden states for the input sentences. The benchmark times the complete pass for a batch of 4 sentences and records peak GPU memory for the process, aggregating across devices where appropriate. This workload processes an input sequence together. Its measurement is useful both for applications that use the resulting representations directly and for the initial processing that precedes autoregressive generation. In the timing comparison with a quantized baseline, the authors select LLM.int8() because it preserves accuracy across the sizes under consideration.

The PyTorch comparison uses a single GPU and covers OPT-6.7B, OPT-13B and OPT-30B. The authors explain that this implementation does not use model parallelism through Hugging Face. SmoothQuant O3 is faster than the FP16 baseline in the reported context experiments. On OPT-30B with a sequence length of 256, it reaches a speedup of 1.51×. The best reported peak-memory saving in the single-GPU PyTorch tests is 1.96×. LLM.int8() also brings peak memory close to half of FP16 in these experiments, but usually takes longer than FP16. The authors attribute the timing cost to the mixed-precision treatment of activations.

FasterTransformer gives the authors access to tensor parallelism, which distributes parts of the matrix computations across accelerators. They use OPT-13B, OPT-30B, OPT-66B and OPT-175B to evaluate a mixture of single-device and multi-device configurations. On a single GPU, O3 brings a context-stage speedup of up to 1.56× over the FasterTransformer FP16 implementation in the smaller-network tests. The authors report that FasterTransformer is already more than 3× faster than the PyTorch implementation for OPT-30B. The speedup from smoothing and quantization in FasterTransformer therefore uses a different FP16 timing reference from the one in the PyTorch chart. [Megatron-LM](https://md.research.elamur.ai/free/en/papers/shoeybi-2019-megatron-lm-training-multi-billion/)

For OPT-66B the FasterTransformer comparison moves from 2 GPUs in FP16 to 1 with SmoothQuant. For OPT-175B it moves from 8 to 4. Across these comparisons, the paper reports similar or better context latency and a memory requirement close to half of the FP16 figure. This experiment changes both the precision and the number of devices. It answers the deployment question of how much hardware is needed to maintain the time to process the input. A same-device comparison, such as the smaller OPT tests, answers the complementary question of whether the quantized execution is faster given the same device count.

Decoding is the stage where each new token depends on the text available so far. The decoding benchmark reports latency per generated token. SmoothQuant reaches a speedup of up to 1.42x over FP16 in this stage and the paper reports roughly half the inference memory footprint. The decoding and context speedups are separate measurements. A full generation request includes both kinds of work, in proportions that depend on the input and output. The paper measures each stage so that an improvement in one need not stand in for the performance of the other. [Text generation](https://md.research.elamur.ai/free/en/topics/text-generation/)

#### Fitting MT-NLG 530B on one node

At the largest scale in the paper, the authors run MT-NLG 530B after W8A8 conversion. They report negligible accuracy loss and similar latency using 8 GPUs where the FP16 deployment used 16. The quantized configuration fits on a single node with 8 A100 80GB GPUs. The main quantitative result here is how many devices are needed to serve the network, with latency checked alongside the device reduction. The smaller-network timing maxima concern different experiments. [MT-NLG 530B](https://md.research.elamur.ai/free/en/papers/smith-2022-using-deepspeed-megatron-train-megatron/)

GPU count for the MT-NLG 530B serving benchmark on A100 80GB devices The quantized deployment fits on one node while retaining similar latency.

**The numbers**

| System or setting | GPUs |
| --- | --- |
| FP16 | 16 |
| SmoothQuant W8A8 (this paper) | 8 |

Fitting on one node is a practical threshold. A deployment that needs more accelerator memory than one node provides must distribute its work more widely. In the reported setup, the smaller memory requirement moves the network across that threshold. The authors also check accuracy after making the change. A smaller hardware allocation is valuable here because the paper finds that it still supports the measured task performance and a comparable time to execute the workload.

### What the ablations show

#### How much variation to move

The migration-strength ablation varies α on OPT-175B and evaluates the resulting quantized system on LAMBADA. This is a controlled test of the trade between activation error and weight error. For each setting, the change to the floating-point operands still cancels. What varies is the distribution presented to the quantizers. The experiment links the observed task performance to where the burden of rounding is placed.

Below α = 0.4, the authors find that the activations remain hard to quantize. Too little of the difference across channels has moved into the weights. Using a scale that is shared across those channels still leaves many small activation values with low resolution. Above α = 0.6, the adjustment leaves the weights difficult to quantize. The weight rows have been changed enough to bring their own large discrepancies into the quantization problem. The paper identifies 0.4-0.6 as the range where the two operands can both be quantized with small errors in this ablation and where LAMBADA performance is maintained.

The experiment gives a reason to keep the operation symmetric in form and moderate in effect. Smoothing the activation as much as possible would move the error to the other operand, whose values are used for every token in the linear product. At the opposite end, protecting the weights by leaving too much variation in the activation side preserves the difficulty that the method was designed to address. The successful region shows that the original distribution leaves room for a reallocation from which both operands can benefit jointly.

The range from the OPT-175B ablation describes that particular experiment. GLM-130B uses α = 0.75 because the authors found its activations harder to quantize. The paper describes outliers in that family as affecting about 30% in its discussion of why stronger migration helps. The LLaMA evaluation also uses a different migration strength and a finer activation quantizer. Taken together, the experiments support a balancing procedure whose preferred setting depends on the network and the rounding scheme. The evidence for the shape of the tradeoff is strongest in the OPT-175B sweep.

#### Which grouping explains the accuracy problem

An earlier diagnostic holds OPT-175B as the test case and compares ways of assigning activation scales. It reports mean accuracy across WinoGrande, HellaSwag, PIQA and LAMBADA. The shared per-tensor and the per-token activation quantizers both give low accuracy. Simulated per-input-channel activation quantization comes close to the FP16 reference. This comparison isolates a key distinction in the paper’s explanation. The issue is how much activation ranges differ along the input-channel dimension. Giving each token a scale still groups together the outlying and ordinary channels inside that token.

The simulation serves as a numerical control. It shows how much accuracy can be recovered by matching scales to the structure of the activations. Its result concerns what happens when those channel scales are allowed in the computation. The inner dimension restriction explains why the authors do not implement that simulated setting as the production path. SmoothQuant’s results show that changing the input representation can recover the relevant accuracy while keeping the run-time scales on axes that efficient matrix kernels can handle.

The OPT-13B visualization offers a related diagnostic at the level of one linear layer. Before smoothing, a few activation channels stand out, with their magnitudes persisting across tokens. The weights are comparatively even. After smoothing, the activation extremes are reduced and the weight distribution can still be quantized effectively. The visualization makes clear what the α sweep varies. It changes the amount of scale variation visible in the operands, while the task evaluation tests whether the modified distributions survive rounding throughout the quantized network.

#### What static scaling saves

The quantization-scheme ablation compares GPU latency in the PyTorch implementation at batch size 4. Coarser configurations run faster in the reported comparisons. Changing dynamic scales to static scales yields an additional speed benefit because it removes the need to calculate the quantizer step from the current activations. SmoothQuant is faster than FP16 under each of the tested settings, and LLM.int8() is usually slower than FP16 in the same comparison. This contrast supports the practical value of preparing the operands for a shared INT8 path.

The latency study and the accuracy evaluations give complementary criteria for choosing a setting. Coarse static scales minimize some of the per-request work. A finer or dynamic scheme can better accommodate input ranges that depart from calibration. O3 preserves the reported accuracy on OPT-175B, where the latency benefit comes without a substantial measured quality cost. BLOOM-176B and GLM-130B show some loss with O3, so the payoff from a coarser configuration can come with a measurable accuracy tradeoff. That is the basis for the authors’ preference for a coarser scheme when its accuracy is acceptable.

### Limitations

#### Limits the authors state

The authors explicitly acknowledge that activation ranges depend on the input and that static scales come from calibration. Their explanation of the BLOOM-176B O3 result is a concrete example. The statistics of evaluation activations can differ from those measured offline. This affects the usefulness of a given fixed quantization step. The smoothing identity remains valid for the floating-point product under a new input, while the quality after rounding depends on how well the prepared ranges accommodate that input.

The paper also treats differences between network families as an open issue. It connects GLM-130B’s quantization difficulty to its more pronounced activation outliers and adjusts the procedure accordingly. It uses a stronger transfer to the weights and clips high values in setting the static steps. The authors report results under those choices and call attention to the possible role of architecture and training in determining quantization difficulty. The experiments establish that the procedure can be adapted to several families. The reported α values are empirical settings for those families.

The appendix explains why the authors leave out a direct speed comparison with GPTQ. The low-bit GPTQ kernel they considered targets OPT-175B and supports generation at batch size 1, whereas the FasterTransformer evaluation covers context processing and batched execution. Kernel support and framework optimization would both affect a direct timing comparison. The authors suggest that weight-only quantization could have an advantage when the number of processed tokens is small and weight loading dominates. Their own evidence supports a benefit from W8A8 in the settings they tested.

The authors also point to memory associated with the key-value cache, which retains attention state during generation. They cite an example where it matters substantially when context length and batch size are large. Activation quantization could help reduce that part of memory use. This discussion identifies a motivation and the importance of the workload. The core deployment experiments demonstrate the complete W8A8 implementation under their tested conditions. The appendix also raises the possibility of combining GPTQ’s method for weights with smoothing to pursue W4A4, which the authors leave for future study.

#### Limits of the experimental design

The accuracy evidence describes agreement on measured tasks. Matching FP16 benchmark accuracy can coexist with changes in individual predictions, probabilities or generated continuations. Likewise, a small difference in perplexity on WikiText-2 establishes closeness on that particular aggregate measure. It leaves open how closely the two precision settings track each other on different styles of input or different forms of generation. The instruction-tuned result offers evidence on WikiText-2 and LAMBADA, so its reach is set by those evaluations.

The coverage also varies across families. The OPT and BLOOM suite provides a broader combination of task accuracy and language modeling. GLM-130B uses a different suite to account for benchmark overlap with its training data. Tests on Llama-2, Falcon, Mistral and Mixtral extend the architecture coverage through perplexity. The experiments support within-system comparisons before and after conversion. They provide less scope for ranking how much quality any two families lose under an identical workload and quantization scheme. The calibration choices and evaluation conditions are part of each result.

The hardware evidence comes from NVIDIA A100 80GB servers, two software backends and the kernels implemented for them. The quantization design is compatible with the standard INT8 matrix multiplication pattern described in the paper. The observed latency depends on the performance of that kernel relative to other work in each backend. A different platform, different sequence lengths or a different mix of requests could change that balance. The upper reported speedups are measurements at favorable points in the benchmark. The multi-GPU tests additionally change device count, so those outcomes characterize deployments at different precisions and allocations.

Finally, the paper gives a focused treatment of why smoothing works. It identifies stable channel structure, shows the effect of finer activation scales, sweeps migration strength and compares latency across quantization schemes. Those analyses leave room for variation in calibration data. The reported procedure uses the Pile to fit the scales, and the article’s conclusions about other inputs rest on the downstream results with that calibration. The experiment that uses static scales on BLOOM-176B illustrates why robustness to a broader change in input distribution would require its own evaluation.

### What came after

#### Quantization as a problem of calibration and representation

One line of later citing work pursues the same general objective of lower-precision arithmetic through different controls. [OmniQuant](https://md.research.elamur.ai/free/en/papers/shao-2023-omniquant-omnidirectionally-calibrated-quantization-large/) takes calibration as its focus. The connection to SmoothQuant is the importance of preparing the numerical representation before inference. In SmoothQuant the preparation is a particular channel transformation based on maxima and a migration parameter. OmniQuant’s title places calibration itself at the center of the method. The citation establishes the relationship between these lines of work, while the scope of the title leaves the exact calibration procedure and any reuse of the smoothing formula open.

[QuaRot](https://md.research.elamur.ai/free/en/papers/ashkboos-2024-quarot-outlier-free-4-bit/) addresses the outlier problem through rotation and targets 4-bit inference. SmoothQuant changes the scale of each feature while leaving the underlying axes in place. A rotation changes the representation across feature directions. The common question is how to express an existing computation in coordinates that are more suitable for limited numerical precision. QuaRot’s stated target also makes contact with the more aggressive precision the SmoothQuant authors raise in their appendix, through a different transformation.

[OWQ](https://md.research.elamur.ai/free/en/papers/lee-2023-owq-outlier-aware-weight-quantization/) makes weight quantization explicitly outlier-aware for both fine-tuning and inference. That puts the compression decision on the operand that SmoothQuant uses to absorb some of the activation variation. The two titles identify different scopes for intervention within the larger problem of outliers and precision. [LLM-QAT](https://md.research.elamur.ai/free/en/papers/liu-2024-llm-qat-data-free-quantization/) places quantization in training and makes the absence of training data part of its stated setup. SmoothQuant’s experiments, by comparison, use post-training conversion with calibration sentences. The distinction brings out separate choices about using data, changing the trained representation and incorporating quantization into learning.

[Atom](https://md.research.elamur.ai/free/en/papers/zhao-2023-atom-low-bit-quantization-efficient/) frames low-bit quantization directly as a serving problem, with both accuracy and efficiency in its stated objective. This follows the systems question that motivates SmoothQuant. A numerical representation has to preserve quality and deliver a practical benefit when implemented for serving. The cited work’s stated scope connects it to both questions. Its title alone establishes neither the mechanism it uses to obtain the tradeoff nor an ordering between its serving results and the measurements in SmoothQuant.

#### Different parts of a serving workload

Other citing work makes the cache itself the object of quantization. [KVQuant](https://md.research.elamur.ai/free/en/papers/hooper-2024-kvquant-towards-10-million-context/) pursues long-context inference through key-value cache quantization. [KIVI](https://md.research.elamur.ai/free/en/papers/liu-2024-kivi-tuning-free-asymmetric-2bit/) focuses on tuning-free asymmetric 2bit quantization of that cache. Their stated targets develop the memory issue that SmoothQuant raises in its appendix. A serving system needs space both for the network’s parameters and for state retained as context grows. Compact matrix operands and a compact cache therefore address distinct pieces of memory demand, even though both involve choosing a numerical representation for values used in inference.

A separate group of citations concerns where serving time or memory goes at the level of the workload. [FlexGen](https://md.research.elamur.ai/free/en/papers/sheng-2023-flexgen-high-throughput-generative-inference/) focuses on high-throughput generation with a single GPU. This shares SmoothQuant’s interest in making inference feasible with a constrained device allocation, while emphasizing throughput in its stated objective. [SARATHI](https://md.research.elamur.ai/free/en/papers/agrawal-2023-sarathi-efficient-llm-inference-piggybacking/) uses chunked prefills with decodes, making the scheduling relationship between context processing and token generation central. [Sarathi-Serve](https://md.research.elamur.ai/free/en/papers/agrawal-2024-taming-throughput-latency-tradeoff-llm/) frames that serving problem through throughput and latency. These links put SmoothQuant’s separate context-stage and decoding-stage measurements in a wider set of questions about operating a service.

[LLMLingua](https://md.research.elamur.ai/free/en/papers/jiang-2023-llmlingua-compressing-prompts-accelerated-inference/) compresses prompts to accelerate inference. Its stated intervention changes the input a system has to process. SmoothQuant changes how the matrix products for that input are represented. [Medusa](https://md.research.elamur.ai/free/en/papers/cai-2024-medusa-simple-llm-inference-acceleration/) focuses on acceleration using multiple decoding heads. Its connection is to the generation stage, where SmoothQuant measures elapsed time per token after changing the arithmetic. These cited directions locate acceleration at different parts of the request, from preparing the input to organizing the work of generation.

The compression literature also includes [SparseGPT](https://md.research.elamur.ai/free/en/papers/frantar-2023-sparsegpt-massive-language-models-accurately/), whose stated contribution is accurate one-shot pruning at large scale. Pruning changes which parameters are retained in the computation, while SmoothQuant changes the precision with which values are represented. Both address how to begin with a trained network and reduce the resources needed to use it. [A Survey on Model Compression for Large Language Models](https://md.research.elamur.ai/free/en/papers/zhu-2024-survey-model-compression-large-language/) brings these kinds of work into the broader topic of compression. For these later citations, the documented topics support connections among the problems each work tackles. They establish where SmoothQuant enters the discussion, with direct adoption of its scaling procedure requiring evidence beyond a citation.

## Cite

Cite as Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth and Song Han. 2022. SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models. arXiv:2211.10438.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.2211.10438](https://doi.org/10.48550/arxiv.2211.10438) · [arXiv 2211.10438](https://arxiv.org/abs/2211.10438)

```bibtex
@misc{xiao2022smoothquant,
  title = {{SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models}},
  author = {Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth and Song Han},
  year = {2022},
  doi = {10.48550/arxiv.2211.10438},
  eprint = {2211.10438},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2211.10438}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
