Abstract
Vision Transformers (ViTs) have significantly advanced the state-of-the-art in computer vision but are often constrained by the quadratic complexity of self-attention. This paper introduces MaxViT, a hierarchical Transformer architecture that achieves a global receptive field with linear complexity relative to the input resolution. By decomposing attention into local "block" and sparse global "grid" mechanisms, MaxViT enables efficient long-range interactions at all stages of the network. Our results demonstrate that MaxViT serves as a powerful, general-purpose backbone, achieving state-of-the-art performance in image classification, object detection, and generative modeling.
1. Introduction
The transition from Convolutional Neural Networks (CNNs) to Vision Transformers (ViTs) has been driven by the Transformer's ability to capture long-range dependencies. However, the standard self-attention mechanism scales quadratically ($O(N^2)$) with the number of pixels, making high-resolution image processing computationally prohibitive. Previous attempts to mitigate this, such as the Swin Transformer, utilized local window attention. While effective at reducing complexity, these methods often sacrifice the global receptive field in the early stages of the network, relying on hierarchical downsampling to eventually capture broader context.
MaxViT addresses this limitation by introducing Multi-Axis Self-Attention (Max-SA). This mechanism allows the model to maintain a global view of the image at every layer while keeping computational costs linear ($O(N)$).
2. Methodology: Multi-Axis Self-Attention
The core of the MaxViT architecture is the Multi-Axis Self-Attention (Max-SA) module, which decomposes dense attention into two sparse, computationally efficient operations:
2.1 Block Attention (Local)
Similar to existing window-based approaches, Block Attention partitions the input image into non-overlapping windows of size $P \times P$. Attention is computed only within these local windows. This captures fine-grained, local spatial relationships and ensures that the complexity remains manageable.
2.2 Grid Attention (Global)
To restore the global receptive field without the quadratic cost, MaxViT introduces Grid Attention. Instead of attending to adjacent pixels, the model partitions the image into a sparse grid by selecting pixels at fixed intervals. For instance, by attending to a grid of pixels distributed across the entire image, a single pixel can interact with the global context in one step.
2.3 The MaxViT Block
The architecture employs a "sandwich" structure within its basic building block:
- MBConv: A mobile convolution layer that provides essential inductive biases, such as translation equivariance and local correlation.
- Block Attention: Captures local dependencies.
- Grid Attention: Captures global dependencies.
Because the window and grid sizes are fixed, the complexity stays linear relative to the number of pixels, allowing the model to process high-resolution images efficiently.
3. Experimental Results
MaxViT was evaluated across a diverse set of vision tasks, demonstrating superior performance and efficiency compared to established backbones like Swin and ConvNeXt.
3.1 Image Classification
On the ImageNet-1K benchmark, MaxViT achieved a top-1 accuracy of 86.5% without the use of external data. The model scales exceptionally well with larger datasets:
- ImageNet-21K: Reached 88.7% accuracy.
- JFT-300M: Achieved a peak performance of 89.53%.
3.2 Efficiency and Scaling
MaxViT demonstrates significant efficiency gains over prior hybrid models. For example, MaxViT-B outperforms CoAtNet-4 while utilizing only 43% of the parameters and 38% of the FLOPs, highlighting the effectiveness of the multi-axis approach in optimizing computational budgets.
3.3 Downstream Tasks and Generative Modeling
Beyond classification, MaxViT proved effective for object detection and segmentation on COCO2017 and aesthetic assessment on the AVA benchmark. Notably, in generative tasks, MaxViT set a new state-of-the-art FID score of 30.77 for unconditional image generation on ImageNet-1K, outperforming specialized architectures like HiT.
4. Discussion and Insights
The success of MaxViT points to several key insights in vision architecture design:
- Global Context Everywhere: By providing a global receptive field even in the initial high-resolution stages, MaxViT captures context that hierarchical models often miss until the final layers.
- Hybrid is King: The combination of MBConv and attention mechanisms suggests that the inductive biases of convolutions remain highly complementary to the flexibility of Transformers.
- Universal Vision Module: The ability of the same block to excel in both discriminative (classification) and generative (GANs) tasks suggests that Max-SA is a robust, general-purpose vision component.
5. Conclusion and Future Work
MaxViT presents a scalable and efficient solution to the quadratic complexity problem in Vision Transformers. While the model achieves state-of-the-art results, the computational requirements for the largest variants (MaxViT-XL) remain high, and some results rely on proprietary datasets like JFT-300M. Future research may explore extending the multi-axis attention mechanism to other domains, such as video processing (adding a temporal axis) or 3D point clouds.
Summary updated