MG-ViT: A Multi-Granularity Method for Compact and Efficient Vision Transformers

Yu Zhang, Yepeng Liu, Duoqian Miao, Qi Zhang, Yiwei Shi, Liang Hu

Vision Transformers (ViTs) have revolutionized computer vision, but they come with a heavy "computational tax." Because the self-attention mechanism's complexity grows quadratically with the number of input tokens (patches), processing high-resolution images is incredibly expensive.

Most existing compression methods try to prune or merge tokens, but almost all share a common flaw: they treat the entire image with a single granularity. In reality, images are spatially redundant. A large patch of blue sky doesn't need the same processing power as the intricate features of a bird's wing. A "one-size-fits-all" patch size is inefficient and fails to capture the varying semantic density across an image.

To address this, researchers have introduced MG-ViT, a dynamic, two-stage inference framework that treats different parts of an image with varying levels of detail. By using coarse patches for simple images and only "zooming in" on critical regions for complex ones, it slashes computational costs (FLOPs) by up to 56% on standard Vision Transformers without sacrificing accuracy.

The MG-ViT Framework

The authors propose a framework consisting of two main inference stages and a novel "slimming" module to dynamically allocate compute based on image complexity.

The MG-ViT framework illustrating the Single-Granularity and Multi-Granularity Inference Stages.
  1. Single-Granularity Inference Stage (SGIS): The image is first split into a small number of coarse patches (e.g., a $7 \times 7$ grid). If the model is highly confident in its prediction at this stage (like the simple soccer ball example above), it stops here, saving massive amounts of compute.
  2. Multi-Granularity Inference Stage (MGIS): If the first stage is uncertain (e.g., the more complex image of the cat), the model identifies "important" patches based on attention scores. These specific patches are sub-split into finer grains (e.g., $3 \times 3$ or $2 \times 2$ sub-patches). To maintain context, a Feature Reuse module injects information from the coarse stage into these new fine-grained tokens.
  3. Plug-and-Play Slimming Module (PPSM): To prevent the token count from exploding after sub-splitting, PPSM uses a "three-way decision" mechanism:
  4. Positive tokens: High-importance tokens are kept as-is.
  5. Negative tokens: Low-importance tokens are merged into a single weighted token.
  6. Boundary tokens: Tokens with ambiguous importance are "match-merged"—similar tokens are paired and combined to reduce count while preserving detail.

The authors also extend this approach to Hierarchical ViTs (like PVT) by introducing "proxy tokens" to help the model handle patches of different scales within the same layer.

Key Insights

  • The "Confidence" Exit: Not every image needs a deep, high-res pass. By implementing a threshold-based exit, MG-ViT acts like a "fast and slow" thinking system for computer vision.
  • Attention as a Map: The model uses the class attention scores from the early coarse stage to decide exactly where to "invest" more pixels. This mimics human foveated vision, where we focus detail only on the object of interest.
  • Merging over Pruning: A key observation is that even "unimportant" tokens contain complementary background information. Simply deleting them (pruning) hurts accuracy more than intelligently combining them (merging).
  • Soft Slimming: The "three-way decision" acknowledges that the importance of a token isn't always black and white. Creating a "boundary" zone for merging similar tokens provides a buffer that stabilizes performance.

Performance and Results

The model was evaluated on industry-standard benchmarks including ImageNet-1K (classification), MS-COCO 2017 (object detection/instance segmentation), and ADE20K (semantic segmentation). MG-ViT achieved impressive efficiency gains across different architectures:

  • DeiT-S: Reduced FLOPs by 56% with no loss in accuracy on ImageNet.
  • LV-ViT-S: Reduced FLOPs by 47% while maintaining top-tier performance.
  • Throughput: On an NVIDIA RTX 3090, MG-ViT increased throughput (images processed per second) by up to 1.79x.
  • Downstream Tasks: When applied to hierarchical structures for detection and segmentation, the multi-granularity strategy successfully reduced computational overhead with negligible impact on mIoU and AP scores.

Future Directions

While the results are strong, the authors note that the Hierarchical MG-ViT (used for detection and segmentation) hasn't been fully optimized for peak performance yet. The current implementation serves as a powerful proof-of-concept that multi-granularity can work in complex, multi-stage architectures. Future research will likely focus on refining the "proxy token" mechanism and exploring how to better integrate multi-granularity features in dense prediction tasks where spatial alignment is highly critical.

Summary updated

BibTeX
@inproceedings{zhang2023mg,
  author = {Yu Zhang and Yepeng Liu and Duoqian Miao and Qi Zhang and Yiwei Shi and Liang Hu},
  title = {{MG-ViT: A Multi-Granularity Method for Compact and Efficient Vision Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=Bf6WFWNCUP},
}
Figure