SNT: Sharpness-Minimizing Network Transformation for Fast Compression-friendly Pretraining

Jung Hwan Heo, Seyedarmin Azizi, Arash Fayyazi, Mahdi Nazemi, Massoud PedramarXiv 2023

Abstract

Transfer learning has become a popular task adaptation method in the era of foundation models. However, many foundation models require large storage and computing resources, which makes off-the-shelf deployment impractical. Post-training compression techniques such as pruning and quantization can help lower deployment costs. Unfortunately, the resulting performance degradation limits the usability and benefits of such techniques. To close this performance gap, we propose CrAFT, a simple fine-tuning framework that enables effective post-training network compression. In CrAFT, users simply employ the default fine-tuning schedule along with sharpness minimization objective, simultaneously facilitating task adaptation and compression-friendliness. Contrary to the conventional sharpness minimization techniques, which are applied during pretraining, the CrAFT approach adds negligible training overhead as fine-tuning is done in under a couple of minutes or hours with a single GPU. The effectiveness of CrAFT, which is a general-purpose tool that can significantly boost one-shot pruning and post-training quantization, is demonstrated on both convolution-based and attention-based vision foundation models on a variety of target tasks. The code will be made publicly available.

Introduction

Modern vision foundation models (VFMs), such as Vision Transformers (ViTs), achieve state-of-the-art performance but are often too large for edge deployment. Post-training compression (PTC) methods like quantization and one-shot pruning offer a fast path to deployment without expensive retraining. However, models fine-tuned with standard optimizers like Adam often exhibit "sharp" loss landscapes and erratic activation distributions, leading to significant accuracy drops when compressed.

Conceptual overview of CrAFT vs. standard fine-tuning showing the impact of loss landscape flatness on compression friendliness.

The CrAFT Framework

The core of CrAFT (Compression-Aware Fine-Tuning) is the integration of Sharpness-Aware Minimization (SAM) into the task adaptation phase. Instead of minimizing loss at a single point, SAM seeks a flat region in the loss landscape where the loss remains low even under weight perturbations. This flatness is directly linked to compressibility. By focusing on $\lambda_{max}$—the maximum eigenvalue of the Hessian matrix—CrAFT reduces the "worst-case" curvature of the loss surface.

CrAFT is designed to be a general-purpose, "orthogonal" tool. After fine-tuning with the CrAFT objective, any off-the-shelf compression tool can be applied, such as:

  • One-shot Pruning: Removing weights based on magnitude or activation importance (e.g., Wanda).
  • Post-Training Quantization (PTQ): Reducing precision to INT8 or lower.

Key Insights: Why Flatness Matters

The authors identify several reasons why sharpness minimization improves compression-friendliness:

  1. Lower Intrinsic Rank: SAM-trained models have weights with a lower intrinsic rank. Experiments show that 80% of information in a SAM-trained Feedforward Network can be explained by 200 principal components, compared to only 40% for standard models. This makes them much easier to prune without losing information.
  2. Activation Smoothing: A major hurdle in quantizing Transformers is the presence of high-magnitude activation outliers. CrAFT naturally smooths these activation ranges, making the model far more robust to the precision loss inherent in 8-bit or 4-bit quantization.
  3. Robustness to Perturbations: A flat landscape ensures that the weight changes introduced by pruning or quantization do not lead to catastrophic loss increases.

Experimental Results

CrAFT was evaluated across various architectures (ViT, ResNet, MobileNet) and tasks (CIFAR, fine-grained classification).

Accuracy vs. Sparsity and Pruning Ratio for ViT-B on CIFAR-100, comparing standard fine-tuning with CrAFT.

As shown in the figures above, CrAFT significantly improves the resilience of models to pruning. On CIFAR-100, CrAFT recovered up to 12% accuracy in high-sparsity scenarios. In quantization tasks, the gains were even more dramatic; for instance, a 4-bit quantized ViT-B model on Oxford Pets improved from 10.44% (baseline) to 74.27% with CrAFT. Furthermore, the benefits held true across different model families; for example, on MobileNet-V2, CrAFT improved INT8 quantization results by nearly 10% compared to the baseline.

Conclusion

CrAFT provides a simple yet powerful way to bridge the gap between high-performance foundation models and efficient edge deployment. By moving compression-awareness to the fine-tuning stage, it avoids the massive costs of pre-training while delivering substantial gains in post-training compressibility. Future work includes exploring the combination of CrAFT with parameter-efficient fine-tuning (PEFT) and extending the analysis to large language models.

Summary updated

BibTeX
@misc{heo2023snt,
  author = {Jung Hwan Heo and Seyedarmin Azizi and Arash Fayyazi and Mahdi Nazemi and Massoud Pedram},
  title = {{SNT: Sharpness-Minimizing Network Transformation for Fast Compression-friendly Pretraining}},
  year = {2023},
  eprint = {2305.04526},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.04526},
}
Figure