Knowledge Distillation for Efficient Sequences of Training Runs

Xingyu Liu, Alexander Leonardi, Lu Yu, Christopher Gilmer-Hill, Matthew L Leavitt, Jonathan FranklePre-Training @ ICML 2022 · DOI

TL;DR

Training machine learning models often involves many sequential, related runs (e.g., hyperparameter tuning). This paper proposes using knowledge distillation (KD) from previous runs to significantly speed up future training, even when previous runs were suboptimal. They demonstrate that KD can reduce training time by up to 70% with minimal accuracy loss and introduce strategies to further reduce KD's overhead, making it a cost-effective approach for iterative model development.

What Problem Does This Paper Address?

Developing and deploying machine learning models frequently involves iterative processes like hyperparameter search, model tweaking, or retraining on new data. Each of these steps typically requires training a model from scratch, discarding any computational investment made in previous, related training runs. This "start from scratch" approach is computationally expensive, especially as model training costs skyrocket. The paper addresses the challenge of efficiently leveraging the knowledge gained from these prior training runs to accelerate future runs, without simply reusing the previous models themselves, which can sometimes hinder adaptation to new conditions.

Methods

The core technique employed is Knowledge Distillation (KD). In KD, a "student" model is trained to mimic the outputs of one or more "teacher" models, rather than solely relying on ground truth labels. This paper adapts KD for sequential training runs:

  • Teacher Models: These are models trained in previous runs. Crucially, these teachers might be suboptimal due to hyperparameter search or being intermediate results.
  • Student Model: This is the model being trained in the current run.
  • Distillation Loss: The student's loss function is a combination of the standard cross-entropy loss (with ground truth labels) and a mean squared error (MSE) loss between the student's output logits and the averaged output logits of the teacher models.
  • Efficiency Strategies: To mitigate the overhead of KD (which involves extra forward passes through teachers), the authors explore two key strategies:
  • Sampling: Instead of using all available teachers on every training step, only a randomly sampled subset of teachers is used.
  • Scheduling: KD is applied only during specific portions of the training process, rather than continuously.

Datasets

The experiments are conducted using the CIFAR-100 dataset and the ResNet-56 model architecture. This combination is chosen as a challenging benchmark that captures properties of larger-scale settings while allowing for exploration of the experimental design space within limited computational resources.

Key Insights and Ideas

  • KD as a "Middle Ground": KD offers a way to benefit from prior computation without the potential constraints of directly fine-tuning from a previous model's weights. This allows for adaptation to new conditions while still inheriting learned features.
  • Suboptimal Teachers Can Still Help: Surprisingly, KD from teachers that are suboptimal (e.g., due to hyperparameter search) still provides significant speedups and can even lead to better student performance than training from scratch.
  • KD is Pareto-Optimal: Even when accounting for the overhead of KD, the proposed approach offers a Pareto improvement over training from scratch, meaning it achieves better accuracy for the same cost, or lower cost for the same accuracy.
  • Efficiency is Key: The overhead of KD can be substantial. The paper highlights that strategies like sampling teachers and scheduling KD application are crucial for making KD practically beneficial in terms of overall cost reduction.
  • Incorrect Teacher Signals Can Be Useful: Discarding distillation when teacher outputs disagree with ground truth labels actually hurts performance, suggesting that even "incorrect" signals contribute to the student's learning process.

Key Results

  • Significant Speedups: Distilling from five identically trained teachers allowed the student to reach teacher-level accuracy in 70% fewer steps. When trained to completion, the student achieved 3.9 percentage points higher accuracy.
  • Suboptimal Teachers Still Effective: Even when teachers resulted from hyperparameter search (with varying learning rates), distilling from all five teachers led to a student model that performed as well or better than identically trained teachers, achieving 69% accuracy in 33% of the training time of the best teacher.
  • Efficiency Gains:
    • Sampling just one teacher per step reduced training cost overhead by 5x compared to using all teachers, with only a small drop in accuracy.
  • Scheduling KD to specific parts of training (e.g., 20 epochs total) increased training cost by only 17% (compared to 167% for continuous KD), while still yielding significant benefits.
  • Comparison to Baselines: KD outperformed fine-tuning from the best teacher's weights and training a larger ResNet-110 model in terms of both speed and accuracy.

Limitations and Future Work

  • Larger-Scale Settings: The current study focuses on CIFAR-100 and ResNet-56. The authors plan to investigate how these strategies perform in larger-scale settings and for different domains like Natural Language Processing (NLP).
  • Impact on Workloads: The paper primarily focuses on individual training runs. Future work will evaluate how this KD strategy affects the overall trajectory and outcome of multi-run workloads like hyperparameter search.
  • Optimal Sampling/Scheduling: While sampling and scheduling show promise, further research is needed to determine the optimal strategies for selecting which teachers to use and when to apply distillation for maximum efficiency and effectiveness.

Summary updated

BibTeX
@misc{liu2022knowledge,
  author = {Xingyu Liu and Alexander Leonardi and Lu Yu and Christopher Gilmer-Hill and Matthew L Leavitt and Jonathan Frankle},
  title = {{Knowledge Distillation for Efficient Sequences of Training Runs}},
  year = {2022},
  eprint = {2303.06480},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.06480},
}
Figure