Abstract
Vision Transformers (ViTs) offer superior global context modeling but suffer from quadratic computational complexity, making them difficult to deploy on resource-constrained mobile devices. This paper introduces MobileViTv2, which utilizes a novel separable self-attention mechanism. By replacing expensive batch-wise matrix multiplications with element-wise operations, MobileViTv2 achieves linear complexity $O(k)$ relative to the number of tokens. Experimental results on ImageNet-1k demonstrate that MobileViTv2 is 3.2x faster than its predecessor while maintaining higher accuracy, effectively bridging the latency gap between ViTs and efficient CNNs.
Introduction
Vision Transformers have revolutionized computer vision by enabling global context learning through Multi-Headed Self-Attention (MHA). However, MHA presents two significant hurdles for mobile deployment: quadratic complexity $O(k^2)$ and a heavy reliance on batch-wise matrix multiplications (BMM). While GPUs are optimized for BMM, mobile CPUs and DSPs often experience high latency and memory overhead. MobileViTv2 addresses these challenges by rethinking the attention mechanism to be both computationally efficient and hardware-friendly.
Methods: Separable Self-attention
The core innovation of MobileViTv2 is the Separable Self-attention layer. Unlike standard MHA, which computes a full $k \times k$ attention matrix, this method introduces a "latent token" approach:
- Input Branching: Each input token is mapped to a scalar value to determine its relative importance.
- Context Scoring: The model calculates context scores to determine how much each token contributes to a global summary.
- Global Context Vector: A single global context vector is produced by taking a weighted sum of all tokens.
- Element-wise Propagation: This global information is distributed back to all tokens using simple element-wise multiplication and summation.
By utilizing this intermediary latent representation, the model avoids direct token-to-token interactions in a massive grid. This shift reduces complexity to linear $O(k)$ and replaces slow BMM operations with efficient element-wise operations, significantly reducing latency on mobile hardware.
Key Insights
- Latency-Aware Design: The authors argue that reducing Floating Point Operations (FLOPs) is insufficient for mobile optimization. Previous models like Linformer reduced FLOPs but remained slow due to continued reliance on BMM. MobileViTv2 focuses on actual hardware latency.
- Single Latent Token Sufficiency: Interestingly, the research found that using multiple latent tokens (analogous to multiple "heads") yielded negligible accuracy gains for mobile tasks, allowing for a simpler, faster single-token design.
- Superior Scaling: Due to its linear complexity, MobileViTv2 scales more efficiently than standard ViTs or CNNs as input resolution increases.
Key Results
MobileViTv2 was evaluated on ImageNet-1k, MS-COCO, and ADE20k benchmarks.
- Inference Speed: MobileViTv2-1.0 is 3.2x faster than the original MobileViT on an iPhone 12.
- Classification Accuracy: It achieves 75.6% top-1 accuracy on ImageNet-1k with only 3 million parameters, outperforming the original MobileViT by approximately 1%.
- Downstream Tasks: On MS-COCO object detection, it achieved 24.6 mAP using SSDLite, surpassing MobileNetV2 and V3. It also demonstrated competitive performance in semantic segmentation on the ADE20k dataset while using fewer parameters than ResNet-50 based alternatives.
Conclusion
MobileViTv2 demonstrates that vision transformers can be made highly efficient for mobile devices without sacrificing accuracy. By moving from quadratic to linear complexity and optimizing for hardware-friendly operations, the proposed separable self-attention mechanism provides a scalable path for deploying advanced transformer architectures on the edge. Future work remains in optimizing downstream task "heads" (like those in PSPNet) which currently remain a bottleneck for mobile vision pipelines.
Summary updated