Reversible Vision Transformers

Karttikeya Mangalam, Haoqi Fan, Yanghao Li, Chao-Yuan Wu, Bo Xiong, Christoph Feichtenhofer, Jitendra Malik

Introduction

As deep learning models continue to scale in depth and complexity, they are increasingly constrained by a "memory wall." While GPU computational power (FLOPs) has grown rapidly, memory bandwidth and capacity have not kept pace. In standard Vision Transformers (ViTs), training is limited by the need to store intermediate activations from the forward pass to calculate gradients during the backward pass. This memory requirement scales linearly with model depth, often forcing researchers to use extremely small batch sizes for high-resolution images or long video sequences, which destabilizes convergence and slows training.

Reversible Vision Transformers (Rev-ViT and Rev-MViT) address this by decoupling GPU memory consumption from model depth. By recomputing activations on-the-fly during the backward pass, these architectures break the linear dependency between depth and memory, enabling the training of much deeper models on existing hardware.

Methodology: Reversible Architectures

The core innovation lies in the implementation of reversible blocks for both standard ViT and Multiscale ViT (MViT) architectures.

Reversible Blocks and Residuals

Instead of a single processing stream, the model utilizes two residual streams ($I_1$ and $I_2$). The output is calculated such that the input can be mathematically recovered from the output, eliminating the need to cache intermediate activations.

Architectural diagrams of (a) Rev-ViT, (b) Stage-Transition Rev-MViT, and (c) Stage-Preserving Rev-MViT blocks.

A critical discovery during development was that standard internal residual connections within Transformer blocks hindered convergence in deep reversible models. By removing these internal skips and relying on the inherent skip connections of the reversible structure, the authors achieved stable training for very deep architectures.

Adapting for MViT

Unlike the "flat" ViT, MViT changes feature dimensions across stages (downsampling resolution and upsampling channels). To accommodate this, the authors introduced two types of blocks:

  1. Stage-Transition Blocks: These handle dimension changes and require some data caching, making them partially reversible.
  2. Stage-Preserving Blocks: These maintain dimensions and are fully reversible, maximizing memory efficiency within a hierarchical framework.

Key Results and Performance

The reversible design yields massive efficiency gains without sacrificing accuracy across ImageNet-1K (classification), Kinetics-400/600 (video), and MS-COCO (detection).

Massive Memory Savings

Rev-ViT-L (Large) achieves a 15.5× reduction in memory footprint compared to a standard ViT-L. For the hierarchical Rev-MViT, the reduction is a still-impressive 4.5×. This allows for significantly larger batch sizes; for instance, the maximum batch size for a ViT-L on a single V100 GPU increased from 24 to 344.

Comparison of GPU memory consumption vs. model complexity, highlighting the 4.5x and 15.5x reductions for Rev-MViT and Rev-ViT respectively.

Throughput Gains

While recomputing activations involves more math, it reduces the time the GPU spends waiting for memory bandwidth (DRAM). For an 80-layer MViT model, the reversible version demonstrated a 2.3× increase in training throughput compared to the non-reversible version at high resolutions.

Competitive Accuracy

Performance remains robust: Rev-ViT-B matched the 81.8% top-1 accuracy of vanilla ViT-B on ImageNet-1K. Furthermore, reversible architectures appear to have an inherent regularization effect, allowing them to achieve peak performance with lighter data augmentation than their vanilla counterparts.

Conclusion

Reversible Vision Transformers effectively trade a small amount of extra computation for a massive reduction in memory bandwidth requirements. By decoupling depth from memory, this architecture paves the way for scaling vision models to hundreds of layers, making deep-model training more accessible on consumer and mid-tier enterprise hardware.

Summary updated

BibTeX
@inproceedings{mangalam2022reversible,
  author = {Karttikeya Mangalam and Haoqi Fan and Yanghao Li and Chao-Yuan Wu and Bo Xiong and Christoph Feichtenhofer and Jitendra Malik},
  title = {{Reversible Vision Transformers}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure