Skip to main content
QUICK REVIEW

[Paper Review] FQ-ViT: Fully Quantized Vision Transformer without Retraining

Yang Lin, Tianyu Zhang|arXiv (Cornell University)|Nov 27, 2021
Advanced Neural Network ApplicationsComputer Science45 references10 citations
TL;DR

This paper introduces FQ-ViT, a method for fully quantized Vision Transformers that achieves state-of-the-art performance without retraining by proposing Powers-of-Two Scale (PTS) for hardware-friendly normalization and Log-Int-Softmax (LIS) for efficient 4-bit attention map quantization. It attains 85.17% Top-1 accuracy on ImageNet with ViT-L and 51.4 mAP on COCO with Cascade Mask R-CNN (Swin-S), setting a new SOTA for fully quantized Transformers with only ~1% accuracy drop.

ABSTRACT

Network quantization significantly reduces model inference complexity and has been widely used in real-world deployments. However, most existing quantization methods have been developed and tested mainly on Convolutional Neural Networks (CNN), and suffer severe degradation when applied to Transformer-based architectures. In this work, we present a systematic method to reduce the performance degradation and inference complexity of Quantized Transformers. In particular, we propose Powers-of-Two Scale (PTS) to deal with the serious inter-channel variation of LayerNorm inputs in a hardware-friendly way. In addition, we propose Log-Int-Softmax (LIS) that can sustain the extreme non-uniform distribution of the attention maps while simplifying inference by using 4-bit quantization and the BitShift operator. Comprehensive experiments on various Transformer-based architectures and benchmarks show that our methods outperform previous works in performance while using even lower bit-width in attention maps. For instance, we reach 85.17% Top-1 accuracy with ViT-L on ImageNet and 51.4 mAP with Cascade Mask R-CNN (Swin-S) on COCO. To our knowledge, we are the first to achieve comparable accuracy degradation (~1%) on fully quantized Vision Transformers. Code is available at https://github.com/linyang-zhh/FQ-ViT.

Motivation & Objective

  • To address the severe performance degradation observed when applying existing quantization methods to Vision Transformers.
  • To reduce inference complexity in Transformer-based models through hardware-friendly quantization techniques.
  • To enable end-to-end quantization of Vision Transformers without fine-tuning or retraining.
  • To maintain high model accuracy despite extreme non-uniform attention map distributions under low-bit quantization.
  • To achieve state-of-the-art performance in fully quantized Vision Transformers using 4-bit precision for attention maps.

Proposed method

  • Introduces Powers-of-Two Scale (PTS), a method to handle inter-channel variation in LayerNorm inputs by using power-of-two scaling factors, enabling efficient hardware deployment.
  • Proposes Log-Int-Softmax (LIS), a quantization-friendly attention mechanism that uses logarithmic integer approximation and BitShift operations to simplify 4-bit inference.
  • Applies 4-bit quantization to both key-value projections and attention maps, significantly reducing model size and computational cost.
  • Designs a quantization-aware training-free pipeline that maintains model accuracy across diverse Vision Transformer architectures.
  • Uses BitShift operators to accelerate inference by replacing expensive floating-point operations with efficient bit shifts.
  • Employs a symmetric quantization scheme with dynamic range adaptation to preserve attention map distribution characteristics.

Experimental results

Research questions

  • RQ1Can Vision Transformers be fully quantized to 4-bit precision without retraining while maintaining high accuracy?
  • RQ2How can inter-channel variation in LayerNorm inputs be effectively managed under hardware-constrained quantization?
  • RQ3Can a quantization method sustain the extreme non-uniformity of attention maps in Transformers while enabling efficient inference?
  • RQ4What is the performance ceiling of fully quantized Vision Transformers under low-bit precision?
  • RQ5Is it possible to achieve SOTA accuracy in fully quantized Transformers with minimal accuracy degradation?

Key findings

  • FQ-ViT achieves 85.17% Top-1 accuracy on ImageNet using ViT-L with full 4-bit quantization and no retraining.
  • The method attains 51.4 mAP on COCO using Cascade Mask R-CNN with Swin-S, demonstrating strong performance in object detection.
  • The approach achieves comparable accuracy degradation of only ~1% on fully quantized Vision Transformers, setting a new SOTA.
  • Log-Int-Softmax enables efficient 4-bit inference through BitShift operations while preserving attention map quality.
  • Powers-of-Two Scale effectively mitigates inter-channel variation in LayerNorm inputs with minimal computational overhead.
  • The method outperforms prior works in both accuracy and bit-width efficiency across multiple Vision Transformer architectures and benchmarks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.