HiViT: Hierarchical Vision Transformer Meets Masked Image Modeling

Xiaosong Zhang, Yunjie Tian, Wei Huang, Qixiang Ye, Qi Dai, Lingxi XiearXiv 2022 · DOI

Introduction

Masked Image Modeling (MIM) has emerged as a powerful self-supervised pre-training paradigm in computer vision, where models learn robust representations by reconstructing missing image patches. However, a significant architectural divide exists in the current landscape. Plain Vision Transformers (ViT) are highly efficient for MIM because they treat images as sequences of tokens, allowing masked patches to be discarded at the input layer. In contrast, Hierarchical Vision Transformers (like Swin) typically offer superior performance due to their multi-resolution "pyramid" structure but are roughly 2× slower to train. This inefficiency stems from their reliance on local inter-unit operations, such as windowed attention or convolutions, which require a fixed 2D grid and prevent the simple removal of masked tokens.

HiViT (Hierarchical ViT) is designed to bridge this gap, offering the performance benefits of a hierarchical structure with the training efficiency of a plain ViT.

The HiViT Architecture

The core innovation of HiViT lies in its surgical removal of "local inter-unit operations" that necessitate a rigid spatial grid. The authors categorized transformer operations into three types: intra-unit (MLP), global inter-unit (global attention), and local inter-unit (window attention and patch merging).

Comparison of Swin-B, HiViT-B, and ViT-B architectures, highlighting the removal of window attention and the simplified stage structure.

To achieve efficiency, HiViT makes several key structural modifications:

  1. Removal of Local Attention: Windowed attention in the early stages is replaced with simple MLPs. This removes the dependency on local 2D neighbors.
  2. Stage Simplification: The typical four-stage hierarchy is reduced to three. The blocks from the final stage are merged into the third stage, maintaining the FLOP count while simplifying the data flow.
  3. Global Main Stage: Global attention is reserved exclusively for the "main stage" (Stage 3).
  4. Token Serialization: By eliminating operations that depend on strict 2D spatial relationships, HiViT can "serialize" tokens. This allows the model to discard masked patches at the input layer, just like a plain ViT, enabling high-speed Masked Autoencoder (MAE) style pre-training.

Experimental Results

HiViT was evaluated on ImageNet-1K for both supervised and self-supervised tasks, as well as on COCO and ADE20K for downstream transfer learning.

Pre-training Efficiency and Accuracy

In an MAE pre-training setup, HiViT-B demonstrates a significant Pareto improvement over existing models. It achieves a 1.9× speedup over Swin-B while using substantially less memory.

Fine-tuning accuracy on ImageNet-1K versus pre-training time (minutes per epoch), showing HiViT's superior efficiency-performance trade-off.

On ImageNet-1K, HiViT-B reached 84.2% top-1 accuracy after MIM pre-training, outperforming plain ViT-B by +0.6% and Swin-B (using SimMIM) by +0.2%. In fully-supervised settings, HiViT-B (83.8%) consistently outperformed both Swin-B (83.5%) and ViT-B (81.8%).

Downstream Performance

The hierarchical nature of HiViT translates well to dense prediction tasks. It achieved 49.5% AP on COCO for object detection and 48.3% mIoU on ADE20K for semantic segmentation, surpassing several state-of-the-art competitors and proving that the simplified architecture does not sacrifice generalization capability.

Conclusion

HiViT demonstrates that the primary driver of performance in hierarchical models is the multi-scale feature map structure itself, rather than complex local attention mechanisms. By stripping away unnecessary local operations, HiViT achieves the "best of both worlds": the high accuracy of hierarchical models and the extreme training efficiency of plain ViTs. While current designs use a fixed masking unit size tied to the main stage, future work may explore more flexible masking strategies and low-level kernel optimizations to further enhance speed.

Summary updated

BibTeX
@misc{zhang2022hivit,
  author = {Xiaosong Zhang and Yunjie Tian and Wei Huang and Qixiang Ye and Qi Dai and Lingxi Xie and Qi Tian},
  title = {{HiViT: Hierarchical Vision Transformer Meets Masked Image Modeling}},
  year = {2022},
  eprint = {2205.14949},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.14949},
}
Figure