Skip to main content
QUICK REVIEW

[Paper Review] The Role of Masking for Efficient Supervised Knowledge Distillation of Vision Transformers

Seung‐Woo Son, Ryu, Jegwang|arXiv (Cornell University)|Feb 21, 2023
Advanced Neural Network ApplicationsComputer Science5 citations
TL;DR

MaskedKD is a method that reduces the computational cost of knowledge distillation for Vision Transformers by masking 25–50% of input image patches during teacher inference, using saliency scores derived from the student model's attention mechanisms. This approach cuts distillation FLOPs by up to 50% without sacrificing student accuracy, achieving up to 28% reduction in total training FLOPs and 2.0×–3.7× throughput improvement.

ABSTRACT

Knowledge distillation is an effective method for training lightweight vision models. However, acquiring teacher supervision for training samples is often costly, especially from large-scale models like vision transformers (ViTs). In this paper, we develop a simple framework to reduce the supervision cost of ViT distillation: masking out a fraction of input tokens given to the teacher. By masking input tokens, one can skip the computations associated with the masked tokens without requiring any change to teacher parameters or architecture. We find that masking patches with the lowest student attention scores is highly effective, saving up to 50% of teacher FLOPs without any drop in student accuracy, while other masking criterion leads to suboptimal efficiency gains. Through in-depth analyses, we reveal that the student-guided masking provides a good curriculum to the student, making teacher supervision easier to follow during the early stage and challenging in the later stage.

Motivation & Objective

  • To address the high computational cost of distilling large Vision Transformer (ViT) teachers during knowledge distillation.
  • To reduce the distillation cost—defined as the FLOPs required to run the teacher model—without degrading student model performance.
  • To develop a method that avoids pre-computing and storing teacher predictions, which are memory-intensive and degrade accuracy under data augmentation.
  • To enable efficient distillation in self-supervised and audio-based transformer settings, extending beyond supervised ViT training.

Proposed method

  • MaskedKD selects patches to mask based on a patch saliency metric computed from the student model’s last multi-head attention layer, reusing existing attention scores with negligible overhead.
  • The saliency metric averages inter-patch attention scores (excluding the class token) to identify and preserve the most relevant image features for student prediction.
  • Patches with the lowest saliency scores are masked, ensuring core features are retained while reducing the number of tokens fed to the teacher model.
  • The method operates during the distillation forward pass, requiring no architectural changes or retraining of the teacher model.
  • Masking is applied only to the teacher’s forward pass, while the student processes the full image, preserving feature learning integrity.
  • The approach is compatible with various ViT distillation methods, including vanilla KD, DINO, and patch-level distillation.

Experimental results

Research questions

  • RQ1Can we reduce the computational cost of ViT distillation without degrading student accuracy?
  • RQ2Can we achieve significant FLOP reduction by masking input patches to the teacher model, using only information from the student’s attention mechanism?
  • RQ3How does attention-based patch saliency compare to other masking strategies like random or DINO-based saliency in preserving distillation performance?
  • RQ4Can MaskedKD be extended to self-supervised learning and non-vision transformer tasks, such as audio processing?
  • RQ5What is the optimal fraction of patches to mask for maximum efficiency while maintaining performance?

Key findings

  • MaskedKD reduces the number of input patches to the teacher model by 25–50% without any drop in student top-1 accuracy across diverse ViT architectures and distillation methods.
  • The method achieves a 50% reduction in distillation FLOPs (i.e., teacher inference cost), leading to a 28% reduction in total training FLOPs when distilling DeiT-S to DeiT-Ti.
  • Throughput increases by 2.0× to 3.7× depending on the setting, due to reduced teacher computation.
  • Using inter-patch attention scores for masking degrades performance, confirming that the proposed saliency metric is more effective.
  • Masking based on DINO attention scores fails to outperform MaskedKD despite higher computational cost, indicating the superiority of student-attention-based masking.
  • Keeping the top-k saliency patches (i.e., most important) outperforms random or bottom-k masking, validating the correlation between saliency and performance.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.