Skip to main content
QUICK REVIEW

[论文解读] Q-HyViT: Post-Training Quantization of Hybrid Vision Transformers with Bridge Block Reconstruction for IoT Systems

Jemin Lee, Yongin Kwon|arXiv (Cornell University)|Mar 22, 2023
CCD and CMOS Imaging Sensors被引用 5
一句话总结

该论文提出 Q-HyViT,这是首个专为高效混合视觉Transformer(如 MobileViTv1/2、EfficientFormer)设计的后训练量化方法,解决了四个关键挑战:动态激活范围、桥接模块中的零点溢出、多样化的归一化方式以及小模型尺寸(<5M 参数)。通过引入一种新颖的混合重建误差最小化技术,联合优化缩放因子、量化粒度(通道级/层级)和量化方案(对称/非对称),Q-HyViT 在现有 PTQ 方法基础上实现了平均 8.32%(8 位)和 26.02%(6 位)的准确率提升。

ABSTRACT

Recently, vision transformers (ViTs) have superseded convolutional neural networks in numerous applications, including classification, detection, and segmentation. However, the high computational requirements of ViTs hinder their widespread implementation. To address this issue, researchers have proposed efficient hybrid transformer architectures that combine convolutional and transformer layers with optimized attention computation of linear complexity. Additionally, post-training quantization has been proposed as a means of mitigating computational demands. For mobile devices, achieving optimal acceleration for ViTs necessitates the strategic integration of quantization techniques and efficient hybrid transformer structures. However, no prior investigation has applied quantization to efficient hybrid transformers. In this paper, we discover that applying existing post-training quantization (PTQ) methods for ViTs to efficient hybrid transformers leads to a drastic accuracy drop, attributed to the four following challenges: (i) highly dynamic ranges, (ii) zero-point overflow, (iii) diverse normalization, and (iv) limited model parameters ($&lt;$5M). To overcome these challenges, we propose a new post-training quantization method, which is the first to quantize efficient hybrid ViTs (MobileViTv1, MobileViTv2, Mobile-Former, EfficientFormerV1, EfficientFormerV2). We achieve a significant improvement of 17.73% for 8-bit and 29.75% for 6-bit on average, respectively, compared with existing PTQ methods (EasyQuant, FQ-ViT, PTQ4ViT, and RepQ-ViT)}. We plan to release our code at https://gitlab.com/ones-ai/q-hyvit.

研究动机与目标

  • 为解决高效混合视觉Transformer(HyViTs)缺乏有效后训练量化(PTQ)方法的问题,这些模型结合了卷积与Transformer模块。
  • 识别并解决在量化 HyViTs 时的四个关键挑战:高度动态的激活范围、桥接模块中的零点溢出、多样的归一化技术,以及有限的模型参数量(<5M)。
  • 开发一种统一的端到端 PTQ 框架,联合优化桥接层与非桥接层的量化参数(缩放因子、粒度、方案)。
  • 在无需微调的情况下实现对小型 HyViT 模型(如 MobileViTv1-xxs)的高精度量化,从而实现在资源受限的物联网设备上的高效部署。

提出的方法

  • 提出一种混合重建误差最小化技术,针对桥接模块与非桥接模块采用不同适应策略,实现量化参数的联合优化。
  • 将二阶重建误差最小化方法扩展至包含桥接模块,从而实现对缩放因子与零点的精确校准。
  • 引入双优化策略:对非桥接层采用通道级量化,对桥接层采用层级量化,以缓解零点溢出问题。
  • 采用统一框架,根据激活统计特性动态选择每层的量化粒度与方案(对称/非对称)。
  • 使用小型、未标注的校准数据集计算最优量化参数,无需微调,确保在真实物联网部署中具有高度适用性。
  • 复用并扩展现有的二阶重建误差最小化方法,以处理混合架构中特有的激活分布,特别是在桥接模块中的表现。
Figure 1: Overall quantization process of Q-HyViT on the representative structure of hybrid vision transformers, including local, global, and bridge representation.
Figure 1: Overall quantization process of Q-HyViT on the representative structure of hybrid vision transformers, including local, global, and bridge representation.

实验结果

研究问题

  • RQ1为何现有后训练量化方法在应用于高效混合视觉Transformer时失败,尽管其在纯ViT上表现成功?
  • RQ2桥接模块中的零点溢出如何导致小型HyViT模型的准确率下降?何种量化策略可有效缓解此问题?
  • RQ3在HyViTs中,为最小化重建误差,量化粒度(通道级 vs. 层级)与量化方案(对称 vs. 非对称)之间最优权衡为何?
  • RQ4混合ViTs中多样的归一化技术如何影响后训练量化的鲁棒性?如何在量化过程中实现统一协调?
  • RQ5统一的PTQ框架是否能在无需微调的情况下,显著提升小型HyViT模型(<5M参数)的准确率?其与最先进PTQ方法相比表现如何?

主要发现

  • 在多个混合ViT模型上,Q-HyViT 在 8 位精度量化下,相较现有 PTQ 方法(EasyQuant、FQ-ViT、PTQ4ViT)实现了平均 8.32% 的准确率提升。
  • 在 6 位量化下,Q-HyViT 展现出惊人的 26.02% 平均准确率增益,证明其在低精度场景下的卓越有效性。
  • 通过将通道级量化切换为层级量化,该方法成功缓解了桥接模块中的零点溢出问题,防止负零点值被钳位。
  • 直方图分析表明,桥接模块中采用层级量化可显著提升真实激活与量化激活之间的重叠程度,优于通道级量化。
  • 实验表明,将校准数据集大小从 32 张增至 128 张对准确率影响微乎其微,表明 Q-HyViT 对小规模校准集具有强鲁棒性。
  • 零点溢出导致的准确率下降在小型模型(如 MobileViTv1-xxs)中最为严重,但通过桥接模块的层级量化可有效缓解,即使在 8 位精度下性能下降也极小。
Figure 2: Discrepancy in activation ranges between the calibration and validation datasets in 1st bridge block of MobileViTv2-100
Figure 2: Discrepancy in activation ranges between the calibration and validation datasets in 1st bridge block of MobileViTv2-100

更好的研究,从现在开始

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

无需绑定信用卡

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