TL;DR
Activation outliers in Transformer models are a major roadblock for efficient 8-bit quantization. This paper discovers that these outliers are a side effect of attention heads trying to perform a "no-op" (doing nothing), and proposes two simple architectural fixes—clipped softmax and gated attention—that eliminate outliers at the source, enabling seamless INT8 deployment without accuracy loss.
What Problem Does This Paper Address?
Quantization—reducing the precision of weights and activations from 32-bit floating point to 8-bit integers—is essential for running large models on edge devices. However, Transformers are notoriously difficult to quantize because their activations contain massive "outliers": specific values that are orders of magnitude larger than the rest.
Standard quantization methods struggle with this high dynamic range; you either clip the outliers (losing critical information) or use a wide range that destroys the precision of all other values. Previous research treated these outliers as an unavoidable nuisance, suggesting "band-aid" fixes like mixed-precision or specialized hardware. This paper asks a deeper question: Why do these outliers appear in the first place?
Methods
The authors trace the root cause to the softmax function in the attention mechanism. They observe that attention heads often try to learn a "no-op"—a state where they don't update the residual connection for certain tokens. To achieve this, a head must assign near-zero attention weights to all tokens.
Because the standard softmax function can only produce a true zero if its input is negative infinity, the network is forced to push inputs to extreme values during training to get close to zero. These extreme values then propagate through the network, creating the dreaded outliers.
To fix this, the authors propose two architectural modifications:
- Clipped Softmax: A modified softmax that stretches the output range and clips it to $[0, 1]$. This allows the model to output exact zeros (and ones) with finite input values, removing the incentive for values to explode.
- Gated Attention: Adding a simple, learnable sigmoid gate to the output of the attention block. This gives the model a dedicated "volume knob" to nullify updates explicitly, rather than forcing the softmax to do the heavy lifting.
Datasets
The authors validated their methods across three major Transformer variants:
- BERT (Encoder): Pre-trained on BookCorpus and English Wikipedia, then evaluated on the MNLI (GLUE) benchmark.
- OPT (Decoder): Pre-trained on the same corpus, with scalability tests on models up to 1.3 billion parameters.
- ViT (Vision): Trained and evaluated on ImageNet-1K.
Key Insights and Ideas
- The "No-Op" Hypothesis: Outliers aren't random noise; they are concentrated on "uninformative" tokens like
[SEP], periods, or background image patches. These tokens act as "sinks" where attention heads dump their probability mass when they have nothing useful to contribute to a specific layer. - Softmax is the Culprit: The mathematical definition of softmax is fundamentally at odds with the hardware-friendly requirement of bounded activations. By forcing a "soft" function to behave "hard" (outputting zeros), we inadvertently cause activation explosions elsewhere.
- Quantization-Aware Architecture: Instead of fixing models after training, we should design architectures that are "quantizable by design." Both clipped softmax and gated attention are "drop-in" replacements that add negligible compute overhead.
Key Results
The results are striking. By using these modifications, the authors virtually eliminated outliers, measured by a massive drop in activation kurtosis (a measure of "tailedness") and the maximum infinity norm.
- Seamless INT8: Vanilla BERT fails completely under standard INT8 quantization (perplexity jumps from 4.49 to ~1294). With clipped softmax, the INT8 model achieves a perplexity of 4.52—nearly identical to the floating-point original.
- Performance Gains: In several cases, the modified models actually outperformed the vanilla versions in floating-point accuracy, suggesting that helping attention heads "do nothing" makes the overall learning process more efficient.
- Scalability: The gated attention method successfully reduced outliers in OPT models up to 1.3B parameters, proving the approach works for Large Language Models (LLMs).
Limitations and Future Work
- Pre-training Requirement: The primary drawback is that these changes require training a model from scratch (or significant fine-tuning). You cannot easily apply this to an existing, pre-trained "black box" model like GPT-4.
- Hyperparameters: Both methods introduce a new hyperparameter (the clipping threshold $\gamma$ or gate initialization). While the authors show the methods are relatively robust, finding the "perfect" value for a new architecture might require some tuning.
- Extreme Scale: While tested up to 1.3B parameters, the behavior of these modifications in 100B+ parameter models remains an open question for future research.
Summary updated