BIM: Block-Wise Self-Supervised Learning with Masked Image Modeling

Yixuan Luo, Mengye Ren, Sai Qian ZhangarXiv 2023 · DOI

Introduction

Masked Image Modeling (MIM) has emerged as a dominant paradigm for self-supervised learning in computer vision. By training models to reconstruct missing image patches, frameworks like Masked Autoencoders (MAE) have achieved state-of-the-art performance. However, these successes come at a significant "memory tax." Standard end-to-end (E2E) training requires hardware to store intermediate activations for every layer during the forward pass to compute gradients during the backward pass. For large-scale Vision Transformers (ViTs) and high batch sizes, this often leads to peak memory consumption that exceeds the capacity of modern GPUs, making high-level research prohibitively expensive.

To address this, we present BIM (Block-Wise Masked Image Modeling), a novel training framework designed to slash memory and computational barriers without sacrificing accuracy.

The BIM Framework

BIM departs from the traditional E2E approach by introducing three core innovations: block-wise local learning, once-for-all training, and incremental masking.

Block-Wise Local Learning

Instead of performing a single, massive backward pass across the entire network, BIM divides the ViT backbone into several independent blocks. Each block is paired with its own "local decoder." Gradients are calculated and applied within each block independently. Once a block is updated, its activations are immediately cleared from memory, preventing the cumulative memory "pile-up" characteristic of E2E training.

Comparison of conventional MIM (a), BIM (b), and BIM with incremental masking (c). Note the significant reduction in memory usage variation in the BIM variants.

As shown in the architectural comparison above, BIM significantly stabilizes memory usage compared to conventional MIM, where memory pressure builds up linearly with depth. The process follows a sequential step-by-step execution where each block completes its own forward and backward pass before moving to the next, as illustrated below:

The step-by-step execution of the BIM local learning process, showing how gradients are isolated within specific encoder-decoder blocks.

Once-for-all Training and Incremental Masking

Because blocks are trained independently, a single training run naturally produces multiple usable models of varying depths (e.g., 3-block, 6-block, or 12-block versions). This "once-for-all" capability allows for flexible deployment across different hardware constraints.

Furthermore, BIM employs an incremental masking ratio. Recognizing that deeper layers can handle more challenging tasks, the percentage of masked patches increases as data moves deeper into the network. This not only improves feature quality by increasing task difficulty but also reduces the number of visible tokens processed by the most computationally expensive layers, leading to significant savings in FLOPs.

Key Results and Insights

BIM demonstrates that the perceived trade-off between memory efficiency and accuracy is a myth. By isolating objectives locally, BIM achieves results comparable to global backpropagation.

  • Memory Efficiency: BIM reduces peak GPU memory consumption by 25% for ViT-Base, 41% for ViT-Large, and 48% for ViT-Huge compared to standard MAE. This allows for training massive models on hardware that would otherwise trigger "Out of Memory" (OOM) errors.
  • Performance Parity: Fine-tuning accuracies remain within 0.1% of standard E2E models. In linear probing evaluations, BIM often outperforms the baseline, suggesting that local objectives are highly effective for driving quality representation learning.
  • Computational Savings: The combination of once-for-all training and incremental masking results in training cost savings of up to 87.8% when compared to training multiple backbones of different sizes individually.

Conclusion

BIM proves that MIM is uniquely suited for local learning because the task of patch reconstruction is inherently local. By breaking the dependency on global backpropagation, BIM democratizes the training of large-scale Vision Transformers. Future work will explore extending this block-wise approach to other architectures like CNNs and different modalities such as video and audio, potentially paving the way for more efficient foundation models.

Summary updated

BibTeX
@misc{luo2023bim,
  author = {Yixuan Luo and Mengye Ren and Sai Qian Zhang},
  title = {{BIM: Block-Wise Self-Supervised Learning with Masked Image Modeling}},
  year = {2023},
  eprint = {2311.17218},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.17218},
}
Figure