Skip to main content
QUICK REVIEW

[论文解读] Efficient Post-training Quantization with FP8 Formats

Haihao Shen, Naveen Mellempudi|arXiv (Cornell University)|Sep 26, 2023
Advanced Neural Network Applications被引用 4
一句话总结

本论文提出了一种统一且可扩展的后训练量化框架,采用FP8格式(E5M2、E4M3、E3M4),在大型语言模型和视觉任务中,相较于INT8,显著提升了模型准确率和工作负载覆盖率。实验表明,E4M3在自然语言处理任务中表现优异(96.32%覆盖率),E3M4在视觉任务中表现更优(78.95%覆盖率),而混合FP8格式与动态量化进一步提升了准确率。

ABSTRACT

Recent advances in deep learning methods such as LLMs and Diffusion models have created a need for improved quantization methods that can meet the computational demands of these modern architectures while maintaining accuracy. Towards this goal, we study the advantages of FP8 data formats for post-training quantization across 75 unique network architectures covering a wide range of tasks, including machine translation, language modeling, text generation, image classification, generation, and segmentation. We examine three different FP8 representations (E5M2, E4M3, and E3M4) to study the effects of varying degrees of trade-off between dynamic range and precision on model accuracy. Based on our extensive study, we developed a quantization workflow that generalizes across different network architectures. Our empirical results show that FP8 formats outperform INT8 in multiple aspects, including workload coverage (92.64% vs. 65.87%), model accuracy and suitability for a broader range of operations. Furthermore, our findings suggest that E4M3 is better suited for NLP models, whereas E3M4 performs marginally better than E4M3 on computer vision tasks. The code is publicly available on Intel Neural Compressor: https://github.com/intel/neural-compressor.

研究动机与目标

  • 为解决INT8量化在处理异常值和动态范围方面的局限性,尤其是在现代模型(如大语言模型和扩散网络)中的表现。
  • 评估三种FP8格式(E5M2、E4M3、E3M4)在多样化模型架构中的后训练量化有效性。
  • 开发一种通用且可扩展的量化工作流,适用于自然语言处理、计算机视觉及多模态任务。
  • 识别最优的FP8格式及量化策略(如混合格式、动态量化),以最大化准确率与覆盖率。

提出的方法

  • 提出一种统一的FP8格式后训练量化工作流,支持对称与非对称量化,并采用逐通道缩放。
  • 采用三种FP8格式——E5M2(宽动态范围)、E4M3(精度与动态范围平衡)、E3M4(高精度、有限范围),以研究不同权衡。
  • 通过为NLP模型中的激活值分配E4M3、权重分配E3M4,实现混合FP8格式,以降低量化误差。
  • 在校准过程中使用数据增强,以改善BatchNorm统计量与模型准确率,尤其在小校准集下表现更优。
  • 评估静态与动态量化方案,发现动态量化在NLP模型上可提升准确率。
  • 引入基于准确率驱动的自动模型调优,以选择最优量化超参数与格式。
Figure 1: ( left ) Histogram of the tensor $X\sim\mathcal{N}(\mu=0.0,\,\sigma^{2}=0.5)$ , that contains a small number ( 1%) of outliers uniformly distributed between -6.0 to 6.0. ( center ) Distribution of quantized values represented by E5M2, E4M3, E3M4 and INT8 data formats. ( right ) Overall qua
Figure 1: ( left ) Histogram of the tensor $X\sim\mathcal{N}(\mu=0.0,\,\sigma^{2}=0.5)$ , that contains a small number ( 1%) of outliers uniformly distributed between -6.0 to 6.0. ( center ) Distribution of quantized values represented by E5M2, E4M3, E3M4 and INT8 data formats. ( right ) Overall qua

实验结果

研究问题

  • RQ1在多样化深度学习模型中,不同FP8格式(E5M2、E4M3、E3M4)与INT8相比,在模型准确率与工作负载覆盖率方面表现如何?
  • RQ2在后训练量化中,NLP模型与计算机视觉模型的最优FP8格式分别是什么?
  • RQ3混合FP8格式(如激活使用E4M3、权重使用E3M4)是否能超越单一格式方法,进一步提升量化准确率?
  • RQ4在后训练量化中,使用FP8格式时,动态量化与静态量化相比表现如何?
  • RQ5在FP8量化下,何种校准策略(如数据增强)最能保持BatchNorm层的模型准确率?

主要发现

  • FP8量化在75个模型上实现了92.64%的工作负载覆盖率,显著优于INT8的65.87%覆盖率。
  • E4M3在NLP模型上实现96.32%覆盖率,优于E3M4的92.11%,表明其在NLP工作负载中更具优势。
  • E3M4在计算机视觉模型上实现78.95%覆盖率,略高于E4M3的73.68%,在该领域表现更优。
  • 混合FP8格式(激活使用E4M3,权重使用E3M4)在BERT-base(MRPC: 0.9069 vs. 0.9050)与Funnel(MRPC: 0.9233 vs. 0.9207)上均提升了准确率。
  • 动态量化在使用E4M3时,使BERT-Large(RTE)的准确率最高提升+0.98%,证明其对NLP模型的显著优势。
  • 使用3K个经过训练增强的校准样本并结合数据增强,能更好地保持准确率,尤其在BatchNorm层上表现更优,优于仅推理校准或小样本校准。
Figure 2: Standard Quantization Scheme : default configuration for broad set of operations across different workloads, Extended Quantization Scheme : configuration for additional operator coverage (Ex: LayerNorm, BatchNorm & element-wise), mixed FP8 formats, dynamic quantization, BatchNorm Calibrati
Figure 2: Standard Quantization Scheme : default configuration for broad set of operations across different workloads, Extended Quantization Scheme : configuration for additional operator coverage (Ex: LayerNorm, BatchNorm & element-wise), mixed FP8 formats, dynamic quantization, BatchNorm Calibrati

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

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