Fully Quantized Transformer for Machine Translation
Gabriele Prato, Ella Charlaix, Mehdi Rezagholizadeh
TL;DR
This work introduces FullyQT, a uniform 8-bit quantization strategy that fully quantizes the Transformer for machine translation, including weights, activations, and critical components like Q/K/V, attention, and LayerNorm. By employing bucketing and careful zero-handling, it preserves translation quality while enabling efficient inference, achieving equal or superior BLEU scores compared to full-precision models on multiple WMT tasks. Extensive ablation and timing analyses demonstrate robustness, with early quantization generally preferred and 8-bit FullyQT often outperforming FP baselines. The approach also shows promise in language modeling and suggests further gains from selective quantization and broader application to Transformer variants.
Abstract
State-of-the-art neural machine translation methods employ massive amounts of parameters. Drastically reducing computational costs of such methods without affecting performance has been up to this point unsuccessful. To this end, we propose FullyQT: an all-inclusive quantization strategy for the Transformer. To the best of our knowledge, we are the first to show that it is possible to avoid any loss in translation quality with a fully quantized Transformer. Indeed, compared to full-precision, our 8-bit models score greater or equal BLEU on most tasks. Comparing ourselves to all previously proposed methods, we achieve state-of-the-art quantization results.
