Abstract
While Transformer architectures excel at modeling long-range dependencies in vision tasks, the quadratic complexity of softmax-based attention mechanisms imposes a major bottleneck, particularly for high-resolution images. Linear attention offers a promising alternative by reducing complexity from $\mathcal{O}(N^2)$ to $\mathcal{O}(N)$, but often suffers from "low-rank" feature maps due to uniform information compression. We propose Selective Adaptive GAting (SAGA), which introduces input-adaptive learnable gates to selectively modulate information aggregation. By utilizing an efficient Hadamard-product decomposition, SAGA avoids additional memory overhead. Experiments show SAGA achieves a 1.76$\times$ throughput improvement and a 2.69$\times$ reduction in peak GPU memory compared to PVT-T at $1280 \times 1280$ resolution, while improving top-1 accuracy by up to 4.4% on ImageNet.
Introduction
Vision Transformers (ViTs) have revolutionized computer vision, yet their reliance on softmax self-attention presents a significant scaling challenge. The computational complexity of softmax attention grows quadratically, $\mathcal{O}(N^2)$, with the number of tokens $N$. This makes processing high-resolution images—essential for tasks like medical imaging or autonomous driving—prohibitively expensive.
Linear attention offers a solution by reordering operations to achieve $\mathcal{O}(N)$ complexity. In this paradigm, the key-value ($KV$) pairs are aggregated into a global feature map. However, standard linear attention often lags behind softmax in accuracy. This performance gap stems from uniform compression: by treating all tokens equally, the $KV$ feature map becomes redundant and "low-rank," failing to capture the nuanced directional cues necessary for complex visual reasoning.
The SAGA Mechanism
To overcome the low-rank bottleneck, we introduce Selective Adaptive GAting (SAGA). SAGA enhances linear attention through two primary technical contributions:
1. KVGate: Input-Adaptive Filtering
Instead of indiscriminate aggregation, SAGA employs a learnable gating mechanism. Inspired by recurrent neural networks, this gate assigns weights to each token's contribution based on its content. By selectively filtering information before it enters the global $KV$ repository, the model can prioritize salient features and suppress noise, effectively increasing the semantic diversity and rank of the feature map.
2. Hadamard-Product Decomposition
A naive implementation of gating in linear attention would require storing massive intermediate state feature maps, negating the memory benefits of the $\mathcal{O}(N)$ approach. SAGA solves this via a mathematical decomposition: the gating operation is applied directly to the $K$ and $V$ matrices using element-wise (Hadamard) products. This ensures the mechanism remains highly parallelizable and memory-efficient.
Experimental Evaluation
We evaluated SAGA across standard vision benchmarks, including ImageNet-1K for classification, COCO for detection, and ADE20K for segmentation.
Performance and Efficiency
SAGA delivers substantial improvements in both accuracy and hardware utilization. On ImageNet-1K, integrating SAGA into the PVT-T architecture yielded a 4.4% top-1 accuracy boost. Similar gains were observed in DeiT and Swin Transformer backbones.
Crucially, SAGA excels at high resolutions. At $1280 \times 1280$, where standard PVT-T typically encounters memory limits, SAGA-enhanced models achieved a 1.76$\times$ throughput increase and a 2.69$\times$ reduction in peak GPU memory compared to the baseline.
Downstream Tasks
The benefits of SAGA extend to dense prediction tasks. Using SAGA as a backbone for Mask R-CNN on COCO improved object detection by up to 3.9% AP. For semantic segmentation on ADE20K, it achieved an improvement of 4.46% mIoU using Semantic FPN.
Conclusion
SAGA addresses the fundamental limitations of linear attention by introducing selective, input-adaptive gating. By leveraging Hadamard-product decomposition, it achieves superior representational power without sacrificing the efficiency of $\mathcal{O}(N)$ complexity. These results suggest that SAGA is a robust alternative for high-resolution vision tasks and potentially other domains requiring long-sequence modeling.
Summary updated