Abstract
Vision Transformers (ViTs) have achieved state-of-the-art performance in computer vision tasks but face significant deployment challenges due to their high computational complexity. This paper presents a hardware-algorithm codesign framework that optimizes ViT inference by combining static weight pruning with dynamic token pruning. By leveraging the reconfigurable nature of FPGAs, the proposed architecture addresses the irregular computation patterns inherent in dual-pruning strategies. Experimental results on the ImageNet dataset using DeiT-Small demonstrate that this approach achieves up to a 12.8× speedup over high-end CPUs and a 3.2× speedup over modern GPUs, while maintaining a competitive accuracy profile through knowledge distillation.
Introduction
Vision Transformers (ViTs) have revolutionized computer vision by applying the transformer architecture to image patches. However, their Multi-head Self-Attention (MSA) mechanism introduces a "computational tax" that scales quadratically with the number of input tokens. This makes real-time deployment on resource-constrained edge devices or even high-performance servers difficult.
To mitigate these costs, researchers typically employ two strategies: weight pruning (removing redundant model parameters) and token pruning (discarding less informative image patches). While effective individually, combining these techniques creates highly irregular data access and computation patterns. Standard processors, such as CPUs and GPUs, are optimized for dense, predictable workloads and often experience significant performance degradation when faced with such sparsity. This paper introduces a specialized hardware-algorithm codesign that enables efficient dual-pruning on Field-Programmable Gate Arrays (FPGAs).
Methodology
The proposed solution rests on a two-pillar approach: optimizing the model structure for hardware friendliness and designing a custom hardware architecture to handle the resulting sparsity.
1. Algorithmic Innovations
To ensure the pruned model remains performant on hardware, the authors implemented three key algorithmic strategies:
- Static Block-Pruning: Rather than pruning individual weights at random, which leads to fine-grained sparsity that hardware cannot easily accelerate, the authors prune weights in structured blocks. This maintains a level of regularity that allows for efficient parallel processing.
- Dynamic Token Pruning: The researchers integrated a Token Dropping Module (TDM). This module evaluates attention scores during inference to identify and fuse "inattentive" tokens. By discarding redundant tokens on the fly, the model significantly reduces the workload for subsequent layers.
- Knowledge Distillation: To compensate for the potential accuracy loss associated with aggressive pruning, a "teacher-student" training regime was employed. A full-sized, pre-trained ViT (the teacher) guides the training of the pruned model (the student), helping it retain critical features.
2. Hardware Architecture (FPGA)
The flexibility of FPGAs allows for a customized data path that can handle the irregularities of dual-pruning. The hardware design includes:
- Multi-level Parallelism Compute Array (MPCA): A custom compute engine designed to manage the non-linear data access patterns caused by block-pruning.
- Dynamic Load Balancing: Because different parts of the weight matrix have varying levels of sparsity, the hardware dynamically redistributes tasks across processing elements. This ensures high utilization (over 85%) and prevents bottlenecks where some units are idle while others are overloaded.
- Token Dropping Hardware Module (TDHM): This specialized unit handles the sorting and reordering of tokens in real-time. This is a critical component, as the shuffling and management of dynamic tokens is a task where traditional GPUs typically struggle due to fixed pipeline constraints.
Experimental Results
The framework was evaluated using the DeiT-Small model on the ImageNet dataset, which consists of 1.2 million images across 1,000 categories.
Performance and Efficiency
The hardware-algorithm codesign yielded substantial improvements in inference speed and efficiency:
- Latency: The FPGA implementation achieved a 12.8× speedup compared to an AMD EPYC CPU and a 3.2× speedup over an NVIDIA RTX 6000 Ada GPU.
- Compression: The approach reduced overall computational complexity by 3.4× and achieved a model compression ratio of 1.6×.
- Accuracy: These efficiency gains were achieved with a manageable accuracy trade-off, resulting in approximately a 3% drop from the baseline model.
Discussion and Future Work
The "aha moment" of this research lies in the synergy between the algorithm and the hardware fabric. While GPUs rely on rigid, high-throughput pipelines, the FPGA's ability to implement a specific "shuffling engine" allows it to handle dynamic token pruning without the latency penalties that usually negate the benefits of pruning on other platforms.
One identified limitation is the training duration; the models were trained for only 30 epochs. The authors suggest that longer training cycles could further bridge the accuracy gap, as pruned models typically require more time to converge.
Looking forward, the team aims to develop a design automation framework. This tool would allow users to input a specific ViT model and a target FPGA, automatically generating the optimal pruning configuration and hardware bitstream, thereby democratizing high-performance ViT inference for non-specialists.
Summary updated