Abstract
Vision Transformers (ViTs) have become a standard for visual representation learning, but they are limited by the quadratic computational complexity of self-attention relative to image resolution. This paper introduces ViG (Vision Gated Linear Attention), a novel backbone architecture that adapts Gated Linear Attention (GLA) for computer vision. By incorporating bidirectional modeling, 2D gating locality injection, and hardware-aware kernel fusion, ViG achieves a global receptive field with linear complexity. Experimental results on ImageNet-1K, COCO, and ADE20K demonstrate that ViG outperforms both standard Transformers and recent State Space Models like Mamba in accuracy and real-world inference speed.
Introduction: The Quadratic Bottleneck
The primary challenge in scaling Vision Transformers to high-resolution tasks—such as medical imaging or 4K video processing—is the $O(N^2)$ complexity of self-attention. While "linear-time" models like Mamba (based on State Space Models) have emerged as potential solutions, they often face two hurdles: underwhelming real-world "wall-time" speed on modern GPUs due to lack of optimization, and a design primarily suited for 1D causal sequences rather than 2D visual data. ViG addresses these issues by adapting the hardware-friendly GLA mechanism for bidirectional visual processing.
Methodology: Adapting GLA for Vision
ViG introduces three core innovations to make Gated Linear Attention effective for computer vision:
- Bidirectional GLA (BiGLA): Unlike unidirectional text processing, visual data requires context from all directions. ViG processes visual sequences in both forward and backward directions, utilizing a direction-wise gating mechanism to adaptively prioritize spatial information.
- 2D Gating Locality Injection: To compensate for GLA's focus on global context, ViG injects local 2D details by incorporating a 3x3 depthwise convolution. A data-dependent gate is used to interleave these local features with the global sequence features.
- Hardware-Aware Kernel Fusion: To bridge the gap between theoretical FLOPs and actual runtime, the authors developed a specialized CUDA kernel. This kernel fuses forward and backward scans into a single operation, maximizing GPU parallelism and minimizing data movement between high-bandwidth memory (HBM) and the processor's SRAM.
Experimental Evaluation
The model was rigorously evaluated across several standard benchmarks:
- ImageNet-1K: For large-scale image classification.
- COCO: For object detection and instance segmentation.
- ADE20K: For semantic segmentation.
Key Results and Insights
ViG demonstrates superior performance-efficiency trade-offs compared to both hierarchical and non-hierarchical state-of-the-art models.
- Efficiency Gains: ViG-S (Small) achieves 81.7% top-1 accuracy on ImageNet-1K, matching the larger DeiT-B while being 2× faster and requiring 5× fewer FLOPs.
- Outperforming Mamba: ViG-S outperforms Vision Mamba (Vim-S) in both accuracy (81.7% vs 80.3%) and speed (1.6× faster).
- Resolution Scaling: The linear complexity of ViG becomes most apparent at high resolutions. At 1024x1024, ViG-T uses 5.2× fewer FLOPs and runs 4.8× faster than a standard DeiT-T.
- Hardware Awareness: A key takeaway is that GLA is inherently more hardware-friendly than Mamba's SISO (single-input-single-output) model because it can be expressed as matrix multiplications, leveraging modern GPU Tensor Cores more effectively.
Conclusion and Future Work
ViG successfully translates the theoretical benefits of linear-complexity attention into practical, high-performance visual backbones. While the current implementation relies on specialized CUDA kernels, which may limit immediate deployment on non-NVIDIA hardware, the efficiency gains at high resolutions are significant. Future research will explore scaling ViG to foundation-model sizes and investigating more sophisticated multi-directional scanning patterns.
Summary updated