arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2301.12017cs.CLcs.LG
收藏

理解Transformer模型的INT4量化:延迟加速、可组合性与失败案例

Understanding INT4 Quantization for Transformer Models: Latency Speedup, Composability, and Failure Cases

Microsoft(微软)

Xiaoxia Wu, Cheng Li, Reza Yazdani Aminabadi, Zhewei Yao, Yuxiong He

AI总结:

本文研究INT4权重和激活量化在Transformer语言模型中的可行性,发现其对编码器类模型几乎无损但对仅解码器模型损失显著,并提出端到端W4A4编码器推理流水线,相比FP16最高加速8.5倍、相比SOTA BERT INT8最高提升1.7倍。

摘要:

由于基于Transformer的语言模型具有较高的计算和内存成本,提高其部署效率一直具有挑战性。虽然INT8量化最近已被证明能够在保持模型准确性的同时有效降低内存成本和延迟,但能否利用INT4(其峰值硬件吞吐量翻倍)来进一步改善延迟仍不清楚。在本研究中,我们探索了为语言模型采用INT4权重和激活(W4A4)量化的可行性。我们的研究结果表明,对于仅编码器模型和编码器-解码器模型,W4A4量化几乎不会引入准确率下降,但对于仅解码器模型则会导致显著的准确率下降。为了利用W4A4实现性能提升,我们开发了一个高度优化的端到端W4A4编码器推理流水线,支持不同的量化策略。与FP16推理相比,我们的INT4流水线在面向延迟的场景中快8.5倍,在面向吞吐量的场景中最高快3倍,并且将FasterTransformer的最先进BERT INT8性能最高提升了1.7倍。我们针对将W4A4应用于仅解码器模型时的失败案例提供了分析见解,并进一步探索了INT4量化与剪枝和层数缩减等其他压缩方法的兼容性。

英文摘要:

Improving the deployment efficiency of transformer-based language models has been challenging given their high computation and memory cost. While INT8 quantization has recently been shown to be effective in reducing both the memory cost and latency while preserving model accuracy, it remains unclear whether we can leverage INT4 (which doubles peak hardware throughput) to achieve further latency improvement. In this study, we explore the feasibility of employing INT4 weight and activation (W4A4) quantization for language models. Our findings indicate that W4A4 quantization introduces no to negligible accuracy degradation for encoder-only and encoder-decoder models, but causes a significant accuracy drop for decoder-only models. To materialize the performance gain using W4A4, we develop a highly optimized end-to-end W4A4 encoder inference pipeline supporting different quantization strategies. Our INT4 pipeline is $8.5\times$ faster for latency-oriented scenarios and up to $3\times$ for throughput-oriented scenarios compared to the inference of FP16, and improves the SOTA BERT INT8 performance from FasterTransformer by up to $1.7\times$. We provide insights into the failure cases when applying W4A4 to decoder-only models, and further explore the compatibility of INT4 quantization with other compression methods, like pruning and layer reduction.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑