VAQF: Fully Automatic Software-hardware Co-design Framework for Low-bit Vision Transformer

Mengshu Sun, Haoyu Ma, Guoliang Kang, Yifan Jiang, Tianlong Chen, Xiaolong Ma, Zhangyang Wang, Yanzhi WangarXiv 2022

Introduction

Vision Transformers (ViTs) have set new benchmarks in computer vision, often surpassing traditional Convolutional Neural Networks (CNNs) in accuracy. However, their massive parameter counts and high computational complexity pose significant challenges for deployment on resource-constrained edge devices like FPGAs. While quantization is a common solution, applying it to ViTs is difficult due to the dense information in image patches and the "design gap" between software accuracy and hardware throughput.

VAQF (ViT Automatic Quantization Framework) addresses these challenges by providing the first fully automatic software-hardware co-design framework. It bridges the gap by combining extreme weight binarization with an automated search for optimal hardware parameters.

The VAQF Framework

The core of VAQF is an automated pipeline that translates high-level model specifications into optimized hardware bitstreams based on user-defined performance targets.

Overview of the VAQF automatic software-hardware co-design flow.

Unlike traditional methods that quantize a model and then measure performance, VAQF employs an "inverse procedure." The user provides a target Frame Rate (FPS), and the framework automatically searches for the activation precision (e.g., 6-bit or 8-bit) and hardware configurations—such as loop tiling and parallelism factors—that satisfy the requirement while maximizing accuracy.

Software Innovation: Progressive Binary Training

To achieve extreme compression, VAQF binarizes weights to 1-bit (+1 or -1), reducing the model size by 32x. To mitigate the accuracy loss typically associated with such aggressive quantization, the authors introduce Progressive Binary Training. This strategy starts with a full-precision model and gradually increases the proportion of binarized weights during training. This allows the model to adapt slowly to the steep loss landscape of binary weights, preserving high accuracy.

Hardware Architecture and Compute Engine

The hardware component of VAQF is a general-purpose engine designed for FPGAs that efficiently handles both Fully-Connected (FC) layers and Multi-Head Self-Attention (MHSA).

Hardware implementation details including tiling strategies and the compute engine logic.

As shown in the hardware details, the system utilizes sophisticated tiling strategies to manage data movement between memory and the compute engine. Because the weights are binary, the compute engine replaces resource-intensive multiplications with simple additions and subtractions implemented in Lookup Tables (LUTs). This significantly reduces the hardware footprint and power consumption. Furthermore, VAQF employs data packing to maximize memory bandwidth by fitting multiple low-precision values into a single 64-bit data bus.

Experimental Results

The framework was evaluated using the DeiT-base model on a Xilinx ZCU102 FPGA, utilizing ImageNet-1K for primary benchmarking.

  • Accuracy and Precision: The weight-binarized (W1) model proved surprisingly resilient. With 32-bit activations (W1A32), it achieved 79.5% top-1 accuracy. Even when activations were reduced to 6-bit (W1A6), the model maintained a respectable 76.5% accuracy.
  • Throughput and Efficiency: VAQF achieved real-time performance, reaching 24.8 FPS with 8-bit activations and 31.6 FPS with 6-bit activations. In terms of energy efficiency, the W1A6 design demonstrated a 27.0x improvement in FPS/Watt over an Intel i7-9800X CPU and a 5.7x improvement over an NVIDIA TITAN RTX GPU.
  • Automation Speed: The automated search for hardware parameters completes in minutes to hours, drastically reducing the manual engineering effort typically required for FPGA deployment.

Conclusion and Future Work

VAQF demonstrates that large Vision Transformers can be effectively deployed on edge hardware through extreme quantization and automated co-design. While the framework excels with larger models like DeiT-base, smaller models (e.g., DeiT-tiny) remain more fragile under binarization. Future work will explore mixed-precision strategies—applying higher bit-widths only to sensitive layers—and extending the framework to other transformer architectures and NLP tasks.

Summary updated

BibTeX
@misc{sun2022vaqf,
  author = {Mengshu Sun and Haoyu Ma and Guoliang Kang and Yifan Jiang and Tianlong Chen and Xiaolong Ma and Zhangyang Wang and Yanzhi Wang},
  title = {{VAQF: Fully Automatic Software-hardware Co-design Framework for Low-bit Vision Transformer}},
  year = {2022},
  eprint = {2201.06618},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.06618},
}
Figure