Quantizable Transformers: Removing Outliers by Helping Attention Heads Do Nothing

要約

Transformer モデルはここ数年、さまざまな分野で広く採用されており、特に大規模な言語モデルは AI の分野を大きく前進させました。
その規模により、これらのネットワークの能力は大幅に向上しましたが、その代償として必要なコンピューティング量が大幅に増加しました。
量子化は、ニューラル ネットワークの計算時間とメモリ消費量を削減する最も効果的な方法の 1 つです。
しかし、多くの研究で、現代の変圧器モデルは活性化の際に強い外れ値を学習する傾向があり、量子化が困難であることが示されています。
許容可能なパフォーマンスを維持するには、これらの異常値が存在する場合は、より高いビット幅でアクティブ化するか、異なる数値形式を使用するか、追加の微調整、またはその他の回避策を行う必要があります。
強い外れ値は、「ノーオペレーション」または残差の部分的な更新を学習しようとするアテンションヘッドの非常に特殊な動作に関連していることを示します。
更新なしのアテンション マトリックスで必要な正確なゼロを達成するために、トレーニング中にソフトマックスへの入力がどんどん大きくなるようにプッシュされ、ネットワークの他の部分で外れ値が発生します。
これらの観察に基づいて、注意メカニズムに対する 2 つの単純な (独立した) 修正、つまりクリップされたソフトマックスとゲートされた注意を提案します。
私たちの方法を使用して事前トレーニングされたモデルは、浮動小数点タスクのパフォーマンスを維持し、場合によっては改善しながら、大幅に小さい外れ値を学習することを経験的に示しています。
これにより、追加の労力を必要とせずに、トランスフォーマーをアクティベーションの完全な INT8 量子化に量子化できるようになります。
言語モデル (BERT、OPT) とビジョン トランスフォーマーの両方に対する手法の有効性を実証します。

要約(オリジナル)

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.

arxiv情報

著者 Yelysei Bondarenko,Markus Nagel,Tijmen Blankevoort
発行日 2023-11-09 14:05:51+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.CV, cs.LG パーマリンク