Skip to main content
QUICK REVIEW

[论文解读] Efficient 8-Bit Quantization of Transformer Neural Machine Language Translation Model

Aishwarya Bhandare, Vamsi Sripathi|arXiv (Cornell University)|Jun 3, 2019
Topic Modeling参考文献 14被引用 57
一句话总结

本文将训练好的 Transformer 翻译模型量化为在 Intel CPU 上使用 INT8/VNNI 的 8 位整数,BLEU 损失小于 0.5,净加速高达 1.5 倍于 FP32,并包含若干图优化和流水线优化。

ABSTRACT

In this work, we quantize a trained Transformer machine language translation model leveraging INT8/VNNI instructions in the latest Intel$^\circledR$ Xeon$^\circledR$ Cascade Lake processors to improve inference performance while maintaining less than 0.5$\%$ drop in accuracy. To the best of our knowledge, this is the first attempt in the industry to quantize the Transformer model. This has high impact as it clearly demonstrates the various complexities of quantizing the language translation model. We present novel quantization techniques directly in TensorFlow to opportunistically replace 32-bit floating point (FP32) computations with 8-bit integers (INT8) and transform the FP32 computational graph. We also present a bin-packing parallel batching technique to maximize CPU utilization. Overall, our optimizations with INT8/VNNI deliver 1.5X improvement over the best FP32 performance. Furthermore, it reveals the opportunities and challenges to boost performance of quantized deep learning inference and establishes best practices to run inference with high efficiency on Intel CPUs.

研究动机与目标

  • 证明将训练好的 FP32 Transformer 翻译模型量化为 INT8,BLEU 损失最小化。
  • 研究 8 位量化对 Transformer 自注意力与非线性组件的影响。
  • 开发校准与图优化技术,在加速推理的同时尽量保持精度。
  • 通过优化 MatMul 内核、数据流和在 Intel CPU 上的并行分批,提升推理吞吐量。

提出的方法

  • 用 INT8/UINT8 运算数与 INT32 汇编的 QuantizedMatMul 替换 FP32 MatMul。
  • 使用 KL 散度对齐来最小化 FP32 与 INT8 张量分布之间的差异,从而校准量化阈值。
  • 调优 Intel MKL/BLAS 内核以利用 VNNI 指令执行加速的 8 位 MatMul。
  • 对计算图进行重新排序和裁剪以减少冗余操作和开销(如 GatherNd、去量化)。
  • 将输入句子按标记长度排序并应用并行批处理,以在推理期间最大化 CPU 利用率。)

实验结果

研究问题

  • RQ1一个训练好的 Transformer 翻译模型能否以 INT8 量化且 BLEU 分数下降小于 0.5 点?
  • RQ2哪种校准策略和张量分布在 INT8 量化过程中能最好地保持精度?
  • RQ3哪些图级和系统级优化能为 INT8/VNNI 推理带来最大吞吐提升?
  • RQ4MatMul 和非线性组件(Softmax、LayerNorm)如何影响 Transformer 模型的量化可行性?
  • RQ5与 FP32 相比,在 Intel CPU 上,INT8/VNNI 量化推理的可实现加速是多少?

主要发现

  • INT8/VNNI 量化将 BLEU 损失维持在 0.5 点以下。
  • MKL INT8/GEMM 内核结合 VNNI 实现显著的相对于 FP32 的加速——MatMul 可达高达 3.7x,INT8 MatMul 相对于 AVX512 提升 2.3x。
  • 使用对称阈值的 KL 散度校准在所测试的模式中带来最佳精度(27.30–27.33 BLEU 区间)。
  • 对 GatherNd 的优化和操作融合减少数据移动和执行时间,提升吞吐量。
  • 按标记数量对输入排序并应用并行批处理提高 CPU 利用率,推动总体吞吐量较最佳 FP32 设置提升至 1.5x。
  • 总体而言,该方法使量化模型相对于最佳 FP32 性能实现净吞吐量提升 1.5x。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。