Learning Efficient Vision Transformers via Fine-Grained Manifold Distillation

Zhiwei Hao, Jianyuan Guo, Ding Jia, Kai Han, Yehui Tang, Chao Zhang, Han Hu, Yunhe Wang

Vision Transformers (ViTs) have achieved remarkable success across a variety of computer vision tasks. However, their massive parameter counts and heavy inference overheads often prevent them from running efficiently on memory-bounded edge devices like smartphones and smartwatches.

Knowledge Distillation (KD)—the process of training a tiny "student" network to mimic a large, pre-trained "teacher" network—is a standard solution for model compression. Yet, existing KD methods are mostly designed for Convolutional Neural Networks (CNNs) or treat images as a single holistic embedding. They fail to exploit the defining characteristic of ViTs: processing images as sequences of fine-grained patches.

The Challenge of Patch-Level Distillation

While some manifold learning-based KD methods exist, applying them directly to the patch level of ViTs causes a combinatorial explosion in computational complexity and memory usage. Calculating a full relation map across a batch of images and all their patches scales at $\mathcal{O}(B^2N^2D)$, making intermediate-layer distillation practically impossible.

Image-level vs. Patch-level manifold space

This paper asks a critical question: How can we efficiently distill the rich, fine-grained patch relationships from a teacher ViT to a student ViT without blowing up compute budgets?

Methodology: Fine-Grained Manifold Distillation

To address this, the authors propose Fine-Grained Manifold Distillation, which treats ViTs as feature projectors that map inputs into smooth manifold spaces layer by layer. Instead of just matching the final output predictions, the student is trained to match the patch-level relationship structures (the "manifold relation map") of the teacher at intermediate layers.

Overview of the Fine-Grained Manifold Distillation framework

To overcome the massive computational bottleneck, the authors introduce a novel decoupling scheme. They break the massive manifold relation map into three manageable, computationally light pieces:

  1. Intra-image relation map: Matches relationships between patches within the same image.
  2. Inter-image relation map: Matches relationships between patches at the exact same spatial position across different images in a batch.
  3. Randomly sampled relation map: Matches relationships across a random subset of patches to bridge any information gap left by the decoupling.

This orthogonal-like decomposition reduces computational complexity and memory requirements by roughly two orders of magnitude, making intermediate layer distillation feasible for ViTs without requiring supercomputers.

Additional Optimizations

  • Patch Merging: To further reduce compute in early layers where patch counts are high (such as in Swin Transformers), adjacent patches are merged before calculating the manifold loss.
  • Soft Distillation: Unlike DeiT, which uses a CNN teacher and hard labels via a distillation token, this method uses standard soft-label distillation. When both teacher and student are ViTs, they share the same "knowledge pattern," making soft labels superior.
  • Fixed Depth: The authors disable stochastic depth regularization for the student. Since the teacher's soft labels already encode this regularization, applying it again to the student leads to over-regularization and harms performance.

Key Results and Insights

The proposed method demonstrates significant improvements across multiple architectures and datasets:

  • ImageNet-1k: A DeiT-Tiny student (5M parameters) trained with a CaiT-S24 teacher achieves 76.5% top-1 accuracy. This is a massive +2.0% improvement over the original DeiT hard-label distillation baseline.
  • Swin Transformers: Distilling a Swin-Small teacher into a Swin-Tiny student yields 82.2% top-1 accuracy, outperforming the undistilled Swin-Tiny baseline by +1.0%.
  • Transfer Learning: The manifold-distilled DeiT-Tiny achieves 98.48% on CIFAR-10 and 88.05% on CIFAR-100, outperforming hard distillation baselines and proving the learned features generalize exceptionally well.
  • Downstream Tasks: The distilled Swin-Tiny backbone boosts object detection on COCO 2017 by +1.0% box AP (44.7%) and semantic segmentation on ADE20K by +1.15 mIoU (45.66) compared to standard training.

Ultimately, the paper proves that patch-level knowledge is the secret sauce for ViTs. Distilling the relationships between patches captures the self-attention mechanism's structural knowledge far better than just matching final classification logits.

Limitations and Future Work

The authors acknowledge a significant limitation: hyper-parameter sensitivity. The decoupled manifold loss introduces four new hyper-parameters (weights for the intra, inter, and random losses, plus the random sampling number). Tuning this large search space is tedious and computationally expensive.

For future work, the authors plan to simplify the proposed method to make it more parameter-insensitive, allowing it to be used more easily "out-of-the-box" without extensive grid searches.

Summary updated

BibTeX
@inproceedings{hao2022learning,
  author = {Zhiwei Hao and Jianyuan Guo and Ding Jia and Kai Han and Yehui Tang and Chao Zhang and Han Hu and Yunhe Wang},
  title = {{Learning Efficient Vision Transformers via Fine-Grained Manifold Distillation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=crFMP5irwzn},
}
Figure