SmartFRZ: An Efficient Training Framework using Attention-Based Layer Freezing

Sheng Li, Geng Yuan, Yue Dai, Youtao Zhang, Yanzhi Wang, Xulong Tang

TL;DR

SmartFRZ is an innovative training framework that uses a lightweight attention-based predictor to automatically "freeze" neural network layers once they have converged. By analyzing weight history to make "in-situation" freezing decisions, it reduces training time by up to 24% and memory usage by up to 80% while maintaining or even slightly improving final model accuracy.

What Problem Does This Paper Address?

Training deep neural networks (DNNs) is notoriously resource-intensive, consuming massive amounts of time, energy, and memory. "Layer freezing"—the practice of stopping updates to certain layers during training—is a promising way to improve efficiency.

However, existing freezing methods have a major "generality" problem. Most rely on manual heuristics (e.g., "freeze the first three layers after 10 epochs") or simple metrics like gradient norms. These don't translate well across different architectures or datasets. If you freeze too early or pick the wrong layers, accuracy plummets. If you're too conservative, you save no resources. The field lacked a "smart," automated way to detect when a specific layer in a specific model has finished its job.

Overview of the SmartFRZ framework showing the training and freezing stages.

Methods

The authors introduce SmartFRZ, which centers on three novel components designed to make layer freezing both automated and universally applicable:

  1. Attention-Based Predictor: Instead of looking at a single snapshot, the framework uses an attention mechanism to analyze a sequence of weight histories. Because model convergence isn't always linear (weights can fluctuate or "noise" can enter the training process), the attention mechanism allows the predictor to focus on the most informative timestamps to decide if a layer is stable.
Architecture of the Attention-Based Predictor, highlighting how it filters noisy weight history to find optimal weights.
  1. Layer Tailoring: To make the predictor "one-size-fits-all," the authors use a subsampling technique. Regardless of whether a layer has 1,000 or 1,000,000 parameters, the predictor only looks at a randomly sampled subset (e.g., 1,024 weights). This keeps the predictor lightweight and applicable to any layer in any network.
  2. CKA-Guided Offline Training: To "teach" the predictor what convergence looks like, the authors use Centered Kernel Alignment (CKA). They train a model fully, then use CKA to measure how similar a layer's intermediate features are to the final "perfect" version. This similarity score serves as the ground-truth label for training the SmartFRZ predictor offline. Once trained, the predictor can be used on new models and datasets without further tuning.

Datasets

The framework was rigorously evaluated across both Computer Vision (CV) and Natural Language Processing (NLP) domains:

  • CV: ImageNet, CIFAR-10, and CIFAR-100.
  • NLP: MRPC and CoLA (from the GLUE benchmark).
  • Models: ResNet50, VGG11, MobileNetV2, DeiT-T (Vision Transformer), and BERT-base.

Key Insights and Ideas

  • Heuristics are often wrong: Common wisdom suggests freezing layers from front to back (early layers to late layers). SmartFRZ discovered that in architectures with residual connections (like ResNets), some later layers actually stabilize faster than earlier ones. An adaptive approach is necessary to capture this.
  • Attention filters the noise: Training is "noisy." A layer might look like it's converged for a few iterations only to jump again. By using an attention window (looking back at the last ~30 checkpoints), SmartFRZ can distinguish between temporary fluctuations and true convergence.
  • Subsampling is sufficient: You don't need to monitor every single weight to know if a layer is "done." A small random sample of weights provides a statistically significant proxy for the convergence of the entire layer, drastically reducing the overhead of the predictor itself.

Key Results

SmartFRZ consistently outperformed state-of-the-art baselines like AutoFreeze and Linear Freezing:

  • Accuracy: When training from scratch (ResNet50 on CIFAR-100), SmartFRZ achieved 0.16% higher accuracy than full training, likely due to a regularization effect from freezing stable layers. It outperformed AutoFreeze by 4.82% in accuracy.
  • Speedup: It reduced training time by 24% compared to full training and was significantly faster than other adaptive methods.
  • Memory Savings: For ResNet50, it reduced memory consumption by over 80% as training progressed. This is crucial for training large models on hardware with limited VRAM.
  • Versatility: The same predictor trained on ImageNet worked effectively for fine-tuning BERT on NLP tasks, proving its high generalizability.

Limitations and Future Work

  • Forward Pass Costs: While layer freezing eliminates the cost of calculating gradients (backpropagation), the frozen layers must still perform a forward pass to provide inputs for subsequent layers. Thus, the computational savings are primarily on the "backward" side.
  • Offline Dependency: The predictor requires an initial offline training phase using CKA labels from a pre-trained reference model. While this is a "one-time cost," it does require a high-quality reference dataset to start.
  • Future Directions: The authors suggest that SmartFRZ could be combined with other efficiency techniques like pruning or quantization to achieve even more dramatic resource reductions.

Summary updated

BibTeX
@inproceedings{li2023smartfrz,
  author = {Sheng Li and Geng Yuan and Yue Dai and Youtao Zhang and Yanzhi Wang and Xulong Tang},
  title = {{SmartFRZ: An Efficient Training Framework using Attention-Based Layer Freezing}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=i9UlAr1T_xl},
}
Figure