Efficient Inference With Model Cascades

Luzian Lebovitz, Lukas Cavigelli, Michele Magno, Lorenz K MullerTMLR 2023

Abstract

State-of-the-art deep learning models are becoming ever larger. However, many practical applications are constrained by the cost of inference. Cascades of pretrained models with conditional execution address these requirements based on the intuition that some inputs are easy enough that they can be processed correctly by a smaller model allowing for an early exit. If the smaller model is not sufficiently confident in its prediction, the input is passed on to a larger model. The selection of the confidence threshold allows to trade off computational cost against accuracy. In this work we explore the effective design of model cascades, thoroughly evaluate the impact on the accuracy-efficiency trade-off, and provide a reproducible state-of-the-art baseline that is currently missing for related research. We demonstrate that model cascades dominate the ImageNet Pareto front already with 2-model cascades, achieving an average reduction in compute effort at equal accuracy of almost 3.1x above 86% and more than 1.9x between 80% and 86% top-1 accuracy, while 3-model cascades achieve 4.4x above 87% accuracy. We confirm wider applicability and effectiveness of the method on the GLUE benchmark. We release the code to reproduce our experiments in the supplementary material and use only publicly available pretrained models and datasets.

Introduction

The rapid advancement of deep learning has led to state-of-the-art (SOTA) models of unprecedented size and complexity. While these models achieve remarkable accuracy, their computational demands make them expensive for data center deployment and often prohibitive for energy-constrained edge devices. Traditional approaches to efficiency, such as "dynamic" neural networks that skip layers, typically require complex, custom training procedures.

This work investigates a simpler, more modular alternative: model cascades. By chaining existing, off-the-shelf pretrained models, we can leverage the intuition that many inputs are "easy" and can be correctly classified by a small, fast model. Only "hard" inputs require the full power of a larger, more expensive model. We provide a rigorous evaluation of this approach, establishing a reproducible SOTA baseline for efficient deployment.

Methodology: The Cascading Framework

The proposed framework relies on a sequential execution strategy:

  1. Initial Inference: An input is first processed by a small, efficient model ($M_1$).
  2. Confidence Assessment: The system evaluates the confidence of $M_1$'s prediction using a metric such as Maximum Softmax (the highest class probability).
  3. Early Exit: If the confidence exceeds a predefined threshold $t$, the system returns $M_1$'s prediction and terminates.
  4. Escalation: If the confidence is below $t$, the input is passed to a larger, more accurate model ($M_2$).
  5. Final Prediction: The system can either use $M_2$'s prediction alone or ensemble the outputs of both models.

The study rigorously compared various confidence metrics—including Entropy and Logits Margin—and explored the impact of Temperature Scaling for calibration. The evaluation spanned a massive pool of 668 pretrained models on ImageNet and ImageNetV2, as well as four tasks from the GLUE benchmark for NLP.

Key Insights and Design Choices

A critical finding of this research is that the simplest confidence metric—Maximum Softmax—is often the most effective for determining early exits. While metrics like Entropy are popular, they often incorporate information about the distribution of incorrect classes that is irrelevant to the primary goal of identifying certain correct predictions.

Furthermore, the "sweet spot" for selecting model pairs involves choosing models with a small accuracy difference but a large computational (MAC) difference. This configuration allows the smaller model to handle the vast majority of inputs at a fraction of the cost, while the larger model provides a safety net for the most challenging cases.

The relationship between model differences and cascade improvement. Cascades perform best when the MAC difference is large but the accuracy gap is small.

Results and Pareto Dominance

The results demonstrate that model cascades significantly outperform individual models across the entire accuracy-efficiency spectrum. On ImageNet, 2-model cascades achieved a 3.1× reduction in compute (measured in MACs) at 86% accuracy compared to single-model baselines. For even higher accuracy requirements (above 87%), 3-model cascades pushed these savings to 4.4×.

ImageNet Pareto front comparison. The Softmax Cascade Pareto (orange) significantly dominates the baseline Pareto (green), with the right panel showing the improvement factor across different accuracy levels.

Importantly, these benefits are robust. The thresholds learned on validation data remained effective on ImageNetV2, suggesting that the cascading strategy generalizes well to real-world distribution shifts. While ensembling can marginally increase peak accuracy, it often reduces overall efficiency because it necessitates running the larger model more frequently.

Conclusion and Future Directions

Model cascades provide a powerful, "plug-and-play" method for improving inference efficiency without the need for specialized training. By systematically selecting thresholds and model pairs, practitioners can achieve dramatic speedups.

Future work will address the sensitivity of thresholds to data distribution changes and explore more intelligent heuristic searches for building deeper cascades. Additionally, while MACs serve as a useful hardware-agnostic proxy, future evaluations will incorporate "wall-clock" time on specific hardware architectures to further refine deployment strategies.

Summary updated

BibTeX
@article{lebovitz2023efficient,
  author = {Luzian Lebovitz and Lukas Cavigelli and Michele Magno and Lorenz K Muller},
  title = {{Efficient Inference With Model Cascades}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=obB415rg8q},
}
Figure