[Paper Review] Quantizable Transformers: Removing Outliers by Helping Attention Heads Do Nothing
The paper introduces two architectural tweaks—clipped softmax and gated attention—to reduce activation outliers in transformers, enabling straightforward INT8 post-training quantization without heavy retraining. It demonstrates quantization-friendly performance gains across BERT, OPT, and ViT.
Transformer models have been widely adopted in various domains over the last years, and especially large language models have advanced the field of AI significantly. Due to their size, the capability of these networks has increased tremendously, but this has come at the cost of a significant increase in necessary compute. Quantization is one of the most effective ways to reduce the computational time and memory consumption of neural networks. Many studies have shown, however, that modern transformer models tend to learn strong outliers in their activations, making them difficult to quantize. To retain acceptable performance, the existence of these outliers requires activations to be in higher bitwidth or the use of different numeric formats, extra fine-tuning, or other workarounds. We show that strong outliers are related to very specific behavior of attention heads that try to learn a "no-op" or just a partial update of the residual. To achieve the exact zeros needed in the attention matrix for a no-update, the input to the softmax is pushed to be larger and larger during training, causing outliers in other parts of the network. Based on these observations, we propose two simple (independent) modifications to the attention mechanism - clipped softmax and gated attention. We empirically show that models pre-trained using our methods learn significantly smaller outliers while maintaining and sometimes even improving the floating-point task performance. This enables us to quantize transformers to full INT8 quantization of the activations without any additional effort. We demonstrate the effectiveness of our methods on both language models (BERT, OPT) and vision transformers.
Motivation & Objective
- Identify why activation outliers hinder quantization in transformers across vision and language models.
- Propose architectural modifications to attention that suppress outliers without harming FP performance.
- Evaluate the impact of these modifications on post-training quantization (PTQ) performance across multiple model families.
Proposed method
- Analyze outlier phenomena in transformer attention heads and their interaction with softmax and residual connections.
- Propose clipped softmax as a drop-in replacement that yields exact zeros and reduces outliers.
- Propose gated attention with a lightweight head-specific gating network to modulate attention output.
- Quantize models post-training to INT8 and compare quantized vs FP performance and outlier metrics.
- Evaluate on BERT-base, OPT-125M, and ViT-S/16 across standard benchmarks.
Experimental results
Research questions
- RQ1What causes strong activation outliers in transformer attention across NLP and CV architectures?
- RQ2Can architectural changes to the attention mechanism suppress outliers and improve quantization without retraining?
- RQ3Do clipped softmax and gated attention preserve or improve FP performance while enabling better PTQ results?
Key findings
- Clipped softmax and gated attention substantially reduce attention-layer output outliers and kurtosis.
- Both methods improve W8A8 quantized performance while maintaining or sometimes improving FP performance across models.
- Gated attention yields the strongest PTQ gains for OPT and ViT in the reported experiments.
- OPT with gated attention achieves markedly lower max infinity norm and kurtosis, improving quantized perplexity.
- BERT and ViT show favorable quantization metrics with both methods, while OPT’s clipped softmax underperformed in this study for some configurations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.