CHOSEN: Compilation to Hardware Optimization Stack for Efficient Vision Transformer Inference

Mohammad Erfan Sadeghi, Arash Fayyazi, Suhas Somashekar, Massoud Pedram · DOI

Vision Transformers (ViTs) have revolutionized computer vision by leveraging self-attention mechanisms to capture global dependencies. However, their deployment on resource-constrained hardware like Field-Programmable Gate Arrays (FPGAs) is hindered by significant memory bottlenecks, the computational cost of non-linear functions, and the vast design space for hardware parameters. This paper introduces CHOSEN, an end-to-end hardware-software co-design framework that automates ViT deployment. By utilizing a multi-kernel architecture, rotating scheduling, and heuristic-based design space exploration, CHOSEN achieves up to a 1.5x throughput improvement over existing state-of-the-art accelerators.

Addressing the Challenges of ViT Deployment

The deployment of ViTs on FPGAs faces three primary hurdles. First, memory bottlenecks arise from massive parameter counts and high-bandwidth data requirements that often exceed on-chip memory limits. Second, computational complexity is high due to non-linear functions like Softmax, GELU, and Layer Normalization, which are expensive to implement precisely in hardware. Finally, design complexity makes finding optimal hardware parameters (such as tiling sizes and parallelism factors) a slow process due to the millions of possible configurations.

The CHOSEN Framework Architecture

The CHOSEN framework (Compilation to Hardware Optimization Stack) employs a layered approach to overcome these challenges. At its core is a multi-kernel hardware architecture designed to maximize external bandwidth.

CHOSEN Multi-Kernel Hardware Architecture

As shown in the architecture diagram, instead of a single monolithic processor, CHOSEN distributes computing kernels across multiple Super Logic Regions (SLRs) on the FPGA (e.g., VU9P). Each kernel is mapped to its own dedicated DDR memory bank. This design allows for parallel data access, directly addressing the memory-wall problem common in transformer accelerators.

Memory Management and Rotating Scheduling

To further optimize data movement, CHOSEN implements a specific matrix storage strategy and a "rotating" scheduling mechanism to prevent hardware idling.

Matrix Storage and Scheduling for Softmax and LayerNorm

The framework stripes the original matrix across four DDR banks. This enables "full burst" memory reads by aligning tile sizes with the FPGA’s 512-bit AXI bus width. For operations like Layer Normalization, which require row-wide data, the rotating schedule ensures that kernels remain busy processing different segments or rows simultaneously. This ensures that while one kernel processes a segment of a row, others are kept busy with different segments, maximizing overall hardware utilization.

Hardware-Friendly Approximations and Heuristic DSE

CHOSEN reduces logic resource consumption (LUTs and FFs) by employing hardware-friendly approximations for non-linear functions. It uses bit-manipulation for inverse square roots and piece-wise linear approximations for the GELU activation function. This shifts the computational burden to Digital Signal Processors (DSPs) optimized for matrix math while keeping Look-Up Table (LUT) usage relatively low.

On the software side, the CHOSEN compiler utilizes a custom heuristic Design Space Exploration (DSE) algorithm. Rather than an exhaustive search through millions of combinations, it uses an adaptive strategy to converge on Pareto-optimal configurations for latency and throughput. This reduces the number of evaluated cases to roughly 2,000–3,700, significantly accelerating the development cycle.

Performance Evaluation and Results

The researchers evaluated CHOSEN using the ImageNet-1K dataset on a Xilinx UltraScale+ VU9P FPGA running at 200 MHz. Key results include:

  • Throughput Gains: Achieved 132 FPS on DeiT-S (a 1.5x improvement over the previous state-of-the-art, ME-ViT) and 37 FPS on DeiT-B (a 1.42x improvement).
  • Resource Efficiency: The design shifted the burden to DSPs for matrix math, allowing for a more balanced and dense hardware design.
  • Compilation Speed: The heuristic DSE algorithm reached optimal solutions significantly faster than exhaustive methods, making the toolchain practical for rapid prototyping.

Conclusion and Future Directions

CHOSEN demonstrates that a co-design approach focusing on memory bandwidth and scheduling can significantly enhance ViT inference on FPGAs. While current results are promising at 200 MHz, future work may explore higher clock frequencies, broader model support (such as Large Language Models), and lower-precision quantization (e.g., 4-bit) to further optimize performance and memory footprint.

Summary updated

BibTeX
@misc{sadeghi2024chosen,
  author = {Mohammad Erfan Sadeghi and Arash Fayyazi and Suhas Somashekar and Massoud Pedram},
  title = {{CHOSEN: Compilation to Hardware Optimization Stack for Efficient Vision Transformer Inference}},
  year = {2024},
  eprint = {2407.12736},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.12736},
}
Figure