Progressively Knowledge Distillation via Re-parameterizing Diffusion Reverse Process

Xufeng Yao, Fanbin Lu, Yuechen Zhang, Xinyun Zhang, Wenqian Zhao, Bei YuAAAI 2024

Abstract

Knowledge distillation aims at transferring knowledge from the teacher model to the student one by aligning their distributions. Feature-level distillation often uses L2 distance or its variants as the loss function, based on the assumption that outputs follow normal distributions. This poses a significant challenge when distribution gaps are substantial since this loss function ignores the variance term. To address the problem, we propose to decompose the transfer objective into small parts and optimize it progressively. This process is inspired by diffusion models from which the noise distribution is mapped to the target distribution step by step. However, directly employing diffusion models is impractical in the distillation scenario due to its heavy reverse process. To overcome this challenge, we adopt the structural re-parameterization technique to generate multiple student features to approximate the teacher features sequentially. The multiple student features are combined linearly in inference time without extra cost. We present extensive experiments performed on various transfer scenarios, such as CNN-to-CNN and Transformer-to-CNN, that validate the effectiveness of our approach.

Introduction

Knowledge Distillation (KD) is a cornerstone of model compression, where a compact "student" model is trained to replicate the behavior of a larger, high-performance "teacher" model. Traditional feature-level distillation typically employs an $L_2$ loss function to minimize the distance between the student's and teacher's internal representations.

However, this approach relies on the simplifying assumption that feature distributions follow a normal distribution, often neglecting the variance term. This assumption fails when the architectural gap between models is large—for instance, when distilling a Swin Transformer into a MobileNet. In such "cross-architecture" scenarios, the distribution gap can lead to unstable training, marginal performance gains, or even "negative transfer," where the student performs worse than if trained from scratch.

Methodology: Kdiffusion

To address these challenges, we introduce Kdiffusion, a framework that treats feature transfer as a progressive, multi-step process.

Diffusion-Inspired Decomposition

Instead of attempting to map the student feature ($x_n$) directly to the teacher feature ($x_0$) in a single jump, Kdiffusion decomposes the objective into a sequence of intermediate steps ($x_{n-1}, ..., x_1$). This is modeled after the reverse process in diffusion models, where a target distribution is recovered from noise through a series of small, manageable transitions. By breaking down a high-variance optimization problem into a Markov chain of low-variance steps, the training process becomes significantly more stable.

Comparison between classical KD, which uses a direct transfer path, and the proposed Diffusion KD, which utilizes a progressive multi-step transfer path.

Structural Re-parameterization and Efficiency

Standard diffusion models are computationally expensive due to their iterative nature. Kdiffusion avoids this overhead through structural re-parameterization. During training, multiple linear branches generate a sequence of student features. At inference time, these linear branches are mathematically collapsed into a single set of weights. This ensures that the final student model maintains its original architecture and speed, achieving zero-cost inference.

Additional training strategies include Target-Guided Training, which aligns distilled features with the teacher's final-layer weights to preserve task relevance, and Shuffle Sampling, which prevents over-reliance on specific steps in the sequence.

Experimental Results

We evaluated Kdiffusion across several benchmarks, including CIFAR-100, ImageNet-100, and ImageNet-1k, focusing on challenging transfer scenarios.

Performance in Cross-Architecture Transfer

Kdiffusion excels in the difficult Transformer-to-CNN scenario. On ImageNet-100, while state-of-the-art methods like CRD resulted in a performance drop (-0.32%) for a MobileNetV2 student, Kdiffusion achieved a +1.84% improvement. Similarly, for a ResNet18 student, Kdiffusion provided a +1.88% gain over the baseline. On the large-scale ImageNet-1k dataset, distilling a ResNet50 into a MobileNetV2 yielded a Top-1 accuracy of 73.62%, outperforming ReviewKD (72.56%) and DKD (72.05%).

Efficiency and Parameter Trade-offs

A key advantage of Kdiffusion is its efficiency. Unlike "bridge-module" methods that require significant extra parameters during training, Kdiffusion achieves superior accuracy with a much smaller footprint.

Accuracy vs. extra training parameters. Kdiffusion (Ours) achieves higher accuracy with significantly fewer extra training parameters compared to methods like ReviewKD.

Conclusion

Kdiffusion demonstrates that accounting for variance through progressive decomposition is vital for effective knowledge distillation, especially when bridging large architectural gaps. While the current implementation is limited by the linearity required for re-parameterization and increased GPU memory during training, it provides a robust foundation for future research in distilling large-scale foundation models into efficient edge-ready architectures.

Summary updated

BibTeX
@inproceedings{yao2024progressively,
  author = {Xufeng Yao and Fanbin Lu and Yuechen Zhang and Xinyun Zhang and Wenqian Zhao and Bei Yu},
  title = {{Progressively Knowledge Distillation via Re-parameterizing Diffusion Reverse Process}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=XdUYYNRRdN},
}
Figure