Efficient Vision Transformers via Fine-Grained Manifold Distillation

Ding Jia, Kai Han, Yunhe Wang, Yehui Tang, Jianyuan Guo, Chao Zhang, Dacheng Tao

TL;DR

This paper introduces a novel knowledge distillation technique called "fine-grained manifold distillation" to make powerful Vision Transformers (ViTs) more efficient for deployment on edge devices. By focusing on the relationships between image patches within intermediate layers, their method significantly improves the accuracy of smaller student ViTs compared to existing distillation approaches.

What Problem Does This Paper Address?

Vision Transformers (ViTs) have shown remarkable success in computer vision tasks, often outperforming traditional Convolutional Neural Networks (CNNs). However, their computational demands, particularly their large number of parameters and high inference overhead, make them unsuitable for resource-constrained edge devices like smartphones and smartwatches. Knowledge distillation (KD) is a common technique to compress large models into smaller ones, but existing KD methods for ViTs often overlook the unique patch-based nature of these models and are primarily designed for CNNs. This paper aims to bridge this gap by developing a KD method that specifically leverages the patch-level information inherent in ViTs to achieve efficient compression without sacrificing significant performance.

Methods

The core innovation is fine-grained manifold distillation. Instead of just distilling the final output (logits) of a teacher ViT, this method distills knowledge from intermediate layers. The key idea is to treat each layer of a ViT as a projector that maps input patches into a manifold space. The authors propose to match the "manifold structure" or "manifold relation map" of patches between corresponding layers of a teacher and a student ViT.

To make this computationally feasible, they decouple the complex manifold relation map into three components:

  1. Intra-image relation map: Captures relationships within patches of a single image.
  2. Inter-image relation map: Captures relationships across different images in a batch.
  3. Randomly sampled relation map: Captures relationships from randomly selected patches to mitigate information loss from decoupling.

This decoupled loss is then combined with the standard KD loss. Additionally, the authors suggest using soft labels from the teacher (instead of hard labels) and training a fixed-depth student (without stochastic depth regularization) for better performance. They also introduce a patch merging technique to further reduce computational complexity when dealing with very small initial patches.

Datasets

The primary dataset used for evaluation is ImageNet-1k for image classification. The authors also evaluate their method on:

  • CIFAR-10/100 for transfer learning tasks.
  • COCO 2017 for the downstream task of object detection.

Key Insights and Ideas

  • Patch-level manifold is crucial: The paper argues that the patch-level manifold space in ViTs contains fine-grained information that is vital for effective knowledge transfer, a detail often missed by previous KD methods.
  • Decoupling for efficiency: The proposed decoupling of the manifold relation map is a critical step that drastically reduces computational complexity, making fine-grained manifold distillation practical for multiple layers.
  • Soft labels and fixed depth matter: For ViT-to-ViT distillation, using soft labels from the teacher and training the student without stochastic depth regularization leads to better performance than their counterparts.
  • Layer selection is important: The paper highlights that distilling from both the early ("shallow") and late ("deep") layers of the ViT architecture is beneficial for optimal knowledge transfer.

Key Results

  • On ImageNet-1k, a DeiT-Tiny student (5M parameters) trained with the proposed method achieved 76.5% top-1 accuracy, which is +2.0% higher than previous distillation approaches using a CaiT-S24 teacher.
  • Similar improvements were observed with a weaker teacher (CaiT-XXS24), showing the robustness of the method.
  • For SwinTransformer models, the proposed method achieved a +0.5% improvement over standard KD.
  • On CIFAR-10/100, students trained with fine-grained manifold distillation showed better generalization, with improvements of +0.25% on CIFAR-10 and +0.71% on CIFAR-100.
  • In object detection on COCO 2017, the manifold-distilled student backbone (Swin-Tiny) outperformed the non-distilled student by +1.0% box AP.

Limitations and Future Work

  • Hyperparameter sensitivity: The authors acknowledge that the large search space for hyperparameters (α, β, γ, K) is a drawback, and their current settings might not be fully optimal. They suggest that future work could focus on simplifying the method to be more parameter-insensitive.
  • Computational cost: While significantly reduced, the method still incurs computational overhead, especially with very small initial patches. The patch merging technique helps, but further simplification is desired.
  • Future work: The authors aim to further simplify the proposed method and make it more parameter insensitive.

Summary updated

BibTeX
@inproceedings{jia2022efficient,
  author = {Ding Jia and Kai Han and Yunhe Wang and Yehui Tang and Jianyuan Guo and Chao Zhang and Dacheng Tao},
  title = {{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