alphaFeedback

WorksComputer Science

Towards an Optimal Control Foundation of Early Exits - Turnpikes and ResNets

AI contributions
Not recorded for this paper
View details
Ancillary data
1 code link
View

Abstract

The feed-forward propagation through neural networks is crucial for training and inference. To trade off efficiency and accuracy, it has been proposed to consider intermediate outputs of hidden states as data-dependent regularization during training and, ultimately, as early-exits during inference. In this work, we analyze the joint optimization of loss functions computed for the output layer and intermediate layers using optimal control theory. We prove that ResNets trained in this joint fashion exhibit the so-called turnpike phenomenon, this implies that the number of layers required to reach a prescribed loss level is bounded from above independently of the overall network depth. This induces a similarity property across the internal representations of early-exiting networks of varying depths. We connect the turnpike to the overthinking phenomenon, and provide theoretical insights into the success of early-exit criteria derived from softmax probabilities, specifically entropy and max-probability. In a range of experiments, we demonstrate the existence and effect of turnpikes and the resulting similarity in the early-exit performance for ResNets of varying depths.

Introduction

Training deep neural networks is arguably the tipping point of today’s success of deep learning models. Key techniques are residual connections and intermediate output heads informing the network’s hidden layers about their current performance [47] (He et al. 2016b). What was initially used only as training scheme [26], quickly evolved as inference method to save computation on instances handled equally well by shallower parts of the network [48] and has since been applied to early-exiting language models and vision transformers [44, 51, 45, 6]. Without early-exiting, a key failure mode of deep neural networks is overthinking [21]: samples correctly classified by earlier layers are propagated further, incurring unnecessary computation and potentially degrading predictions at later stages. At the core of training these early-exit networks lies an optimization problem considering a combined loss of all auxiliary and final output heads, as illustrated in Figure 1a. As we show in this work, it is precisely this joint training formulation that gives rise to the turnpike phenomenon from optimal control, offering a principled explanation for why early-exit classifiers perform well and why overthinking can be avoided. With the turnpike phenomenon at hand, we are able to show that the early-exit depth required to reach a prescribed loss level is independent of the overall backbone depth. Consequently, the early-exit losses of networks of different depths are similar, as illustrated in Figure 1b.

ResNet with early-exits and joint training, and loss trajectories

Figure 1. Illustration of a ResNet with early-exits (EE), the joint training formulation induces the turnpike phenomenon from optimal control, which implies that early-exiting ResNets of different depths have similar trajectories of the early-exit losses along the network depth.

Prior theoretical work has analyzed early-exit training either under restrictive assumptions such as strong convexity [26] or focused on layer-wise supervision regimes that lack the upstream gradient signal of joint optimization [43]. Consequently, a fundamental understanding of how joint early-exit training behaves and why one can expect intermediate classifiers to perform well has remained elusive; a gap this work addresses through the lens of optimal control theory.

Motivated by residual connection-based neural networks (ResNets) and their connection to neural ODEs [He et al., 2016b,a, Chen et al., 2018], research started using tools from optimal control to investigate these deep learning models, where trainable parameters act as control inputs that steer hidden states towards a target representation determined by the loss function [11, 12, 42]. A central technique is to use a stage cost over the full forward trajectory accumulating (loss-) penalties along the trajectory the data takes through the network. This can be understood as shaping the transient loss behavior, which enables stronger convergence guarantees and explicit depth bounds [11, 14]. A commonality of these works is the turnpike phenomenon: hidden representations tend to cluster around the loss minimizer for the majority of layers, independent of network depth. However, while existing analyses focus on continuous space-time networks [11], the application of this framework to standard ResNets architectures remains an open problem. In addition, our novel optimal control perspective on early-exiting enables new avenues towards formal analysis of training formulations.

In this work, we exploit the close relation between stage cost terms in discrete-time optimal control problems and the joint optimization formulation of early-exit neural networks. This allows us to show under which conditions this approach leads to the turnpike phenomenon. In turn this helps to uncover the fundamental mechanisms of joint training of early-exit neural networks. In short, our paper makes the following contributions:

  • A turnpike-based foundation of early-exit-based ResNet training and inference.

  • Novel asymptotic upper bounds on the cross-entropy loss during forward propagation revealing the loss turnpike phenomenon.

  • Theoretical bounds on guaranteeing correct classification and bounded early-exiting depths, derived for entropy and maximum softmax probability criteria.

  • Empirical support of the turnpike analysis and a principled approach to obtain the intermediate outputs in standard ResNets.

Preliminaries

We begin with a review of the concepts of early-exiting neural networks and optimal control theory.

Early-Exiting ResNets

Early-exiting, as proposed by Teerapittayanon et al. [ [48], augments a neural network with intermediate classifiers that provide predictions before the final layer. The inference process is interrupted as soon as an intermediate prediction is deemed sufficiently confident, thereby reducing computational cost and preventing the model from overthinking [21].

In this work, we consider standard ResNets [10] (He et al. 2016a) with NN residual blocks (RBs) which for a given input sample x(i)x^{(i)} produce the output y^(i)\hat{y}^{(i)} by

x(i)=V(x(i),wV),xk+1(i)=Sk(xk(i),wS,k)+Fk(xk(i),wF,k),y^(i)=O(xN(i),wO).(1)x^{(i)} = \mathcal{V}\left(x^{(i)},\mathbf{w}_{\mathcal{V}}\right), \quad x_{k+1}^{(i)} = S_k\left(x_k^{(i)},\mathbf{w}_{S,k}\right) + F_k\left(x_k^{(i)},\mathbf{w}_{F,k}\right), \quad\hat{y}^{(i)} = \mathcal{O}\left(x_N^{(i)},\mathbf{w}_{\mathcal{O}}\right). \tag*{(1)}

This architecture includes the input block V\mathcal{V} with parameters wV\mathbf{w}_{\mathcal{V}}, NN residual blocks with skip connection SkS_k and residual term FkF_k with parameters wS,k\mathbf{w}_{S,k} and wF,k\mathbf{w}_{F,k} (summarized as wk=[wS,k,wF,k]\mathbf{w}_k = [\mathbf{w}_{S,k},\mathbf{w}_{F,k}]), as well as the output head O\mathcal{O} with parameters wO\mathbf{w}_{\mathcal{O}}. We collect all parameters of the ResNet into w=[wV,w0,…,wN−1,wO]\mathbf{w} = [\mathbf{w}_{\mathcal{V}},\mathbf{w}_0,\ldots,\mathbf{w}_{N-1},\mathbf{w}_{\mathcal{O}}]. Our subsequent analysis applies to both networks with varying state dimensions, such as convolutional ResNets [He et al., 2016a], or ResNets with a constant state dimension. For details on the ResNet implementation and our control-inspired notation, we defer to Appendix § 9.

In the classical case, the output head produces the final prediction y^(i)\hat{y}^{(i)}, while early-exit neural networks additionally have intermediate output heads Ok\mathcal{O}_k with parameters wO,k\mathbf{w}_{\mathcal{O},k} attached to the kk-th hidden layer (where k∈KO⊆N[0,N−1]k \in\mathcal{K}_{\mathcal{O}} \subseteq\mathbb{N}_{[0,N-1]}) to obtain intermediate predictions: y^k(i)=Ok(xk(i),wO,k)\hat{y}^{(i)}_k = \mathcal{O}_k\left(x^{(i)}_k,\mathbf{w}_{\mathcal{O},k}\right). During inference, common decision rules are based on the indication of high confidence such as by low entropy H(y^k(i))\mathcal{H}(\hat{y}^{(i)}_k) or high maximum softmax probability p^max⁡(y^k(i))\hat{p}_{\max}(\hat{y}^{(i)}_k) [20, 36, 29].

To train the backbone network and the early-exits, different strategies have been proposed [25, 41] (Rahmath P et al. 2024). In this work, we set out to study the joint training formulation through its intrinsic connection to optimal control theory, considering a supervised classification problem with labeled training data D={(x(1),y(1)),…,(x(D),y(D))}\mathbb{D} = \{(x^{(1)},y^{(1)}),\ldots,(x^{(D)},y^{(D)})\}, where x=[x(1),x(2),…,x(D)]\mathbf{x} = [x^{(1)},x^{(2)},\ldots,x^{(D)}] denotes the stacked features (boldface symbols used for their propagation through the network), y^\hat{\mathbf{y}} the network output over the entire dataset, and L(y^)\mathcal{L}(\hat{\mathbf{y}}) the corresponding average cross-entropy loss.2 The main training approaches are either sequential—first optimizing the backbone and then keeping it frozen while training the early-exits—or joint, where backbone and early-exits are trained simultaneously. This is achieved by minimizing the joint training objective, a weighted sum of intermediate and final losses,

∑k∈KOγL(y^k)+L(y^),\sum_{k\in\mathcal{K}_{\mathcal{O}}} \gamma\mathcal{L}(\hat{\mathbf{y}}_k) + \mathcal{L}(\hat{\mathbf{y}}),

where the scalar hyperparameter γ∈(0,1]\gamma\in(0,1] controls the trade-off between the intermediate and final losses. Larger values of γ\gamma emphasize the intermediate losses, while smaller values prioritize the final loss.

The Turnpike Phenomenon in Optimal Control

Control theory aims to determine input signals or feedback policies for dynamic systems to induce a desired trajectory behavior. Optimal control, in particular, determines these control inputs by solving an optimization problem.

Consider the dynamic system xk+1=f(xk,wk)x_{k+1} = f(x_k,w_k), with the initial condition x0=x0x_0 = x^0. The evolution of the state xk∈Rnx_k \in\mathbb{R}^n over the discrete time index kk is steered by the control inputs wk∈Rmw_k \in\mathbb{R}^m. The goal of control is to determine the inputs wkw_k as to achieve a desired behavior of the state trajectories xkx_k. This is achieved by optimizing over the possible trajectories of this dynamic system. A simple optimal control problem (OCP) with finite horizon N∈NN \in\mathbb{N} reads

min⁡w0,…,wN−1∑k=0N−1ℓ(xk,wk)+Jf(xN)s.t. xk+1=f(xk,wk),x0=x0,∀k=0,…,N−1.(2)\min_{w_0,\ldots,w_{N-1}} \sum_{k=0}^{N-1} \ell(x_k,w_k) + J_f(x_N) \quad\text{s.t. } x_{k+1}=f(x_k,w_k),\quad x_0=x^0,\quad\forall k=0,\ldots,N-1. \tag*{(2)}

The objective entails the stage cost ℓ:Rn×Rm→R\ell:\mathbb{R}^n \times\mathbb{R}^m \to\mathbb{R}, which penalizes the states and control inputs along the trajectory and the terminal cost Jf:Rn→RJ_f:\mathbb{R}^n \to\mathbb{R} which considers the terminal state xNx_N. The structure of the OCP depends on the system dynamics ff and the choice of the objective. It can range from linear systems with quadratic costs to nonlinear systems with non-convex costs (or it may include inequality constraints which we neglect here). Such problems can be solved using various methods, ranging from direct solution using numerical optimization to applying dynamic programming/reinforcement learning to compute/approximate optimal value function [4]. Figure 2 shows solutions of the simple OCP (2) with xk+1=2xk+wkx_{k+1}=2x_k+w_k, x0=0x^0=0, ℓ(xk,wk)=(xk−2)2+wk2\ell(x_k,w_k)=(x_k-2)^2+w_k^2, and Jf(xN)=0J_f(x_N)=0 for varying horizons N=5,10,…,40N=5,10,\ldots,40. In the middle of the horizon, all trajectories cluster around xs⋆=1x_s^\star=1 and ws⋆=−1w_s^\star=-1, while they depart towards the end of the horizon. One may observe that xs⋆=1x_s^\star=1 and ws⋆=−1w_s^\star=-1 is the optimal steady state pair of the OCP (2), i.e., the steady state pair that minimizes the stage cost (xs⋆,ws⋆)=argmin⁡(xs,ws)ℓ(xs,ws)(x_s^\star,w_s^\star)=\operatorname*{argmin}_{(x_s,w_s)}\ell(x_s,w_s), s.t. xs=f(xs,ws)x_s=f(x_s,w_s). However, near the end of the finite horizon, the objective is minimized by departing from the optimal equilibrium, a phenomenon known as a leaving arc.

Example of optimal trajectories of the OCP

Figure 2. Example of optimal trajectories of the OCP (2) for varying horizons N=5,10,…,40N=5,10,\ldots,40. The red dashed lines indicate the turnpike (xs⋆,ws⋆)=(1,−1)(x_s^\star,w_s^\star)=(1,-1).

This characteristic clustering of optimal trajectories close to the optimal steady state is known as the turnpike property, early observations of which can be traced back to von Neumann [ [50], predating the fundamental works of Bellman [ [2] and Boltyanskii et al. [ [5]. The term turnpike has been coined in the book by Dorfman et al. [ [9] and it has received widespread attention in control, cf. McKenzie [ [32], Trélat and Zuazua [ [49]. Indeed, the turnpike property is a similarity property of the OCP solutions, i.e., the input and state trajectories remain close to the optimal steady state for most of the time independent of the initial conditions x0x_0 and horizon lengths NN. A formal definition of the phenomenon is as follows.

Definition 2.1 (Turnpike phenomenon). The OCP (2) is said to exhibit the turnpike phenomenon with respect to (xs⋆,ws⋆)=const(x_s^\star,w_s^\star)=const if for every threshold ε>0\varepsilon>0, there exists a constant κ<∞\kappa<\infty such that the number of time steps for which the optimal state and input lie outside of an ε\varepsilon-neighborhood of (xs⋆,ws⋆)(x_s^\star,w_s^\star) satisfies the uniform bound #{k=0,…,N∣∥(xk,wk)−(xs⋆,ws⋆)∥>ε}≤κ\#\{k=0,\ldots,N\mid\|(x_k,w_k)-(x_s^\star,w_s^\star)\|>\varepsilon\}\leq\kappa independent of the horizon NN and the initial condition x0x^0.

Indeed, there exist different approaches on how turnpikes can be analyzed, we refer to Trélat and Zuazua [ [49] and Faulwasser and Grüne [ [13] for recent overviews.

Optimal Control Theory for Early-Exiting

We now formalize the joint training formulations for early-exiting ResNets from an optimal control perspective. We begin by considering ResNets as dynamic systems and view early exit training as optimal control problem in § 3.1. Our main contributions are twofold: in § 3.2, we introduce a novel turnpike notion, and in § 3.3, we extend this analysis to early-exit criteria.

Training Early-Exit ResNets as Optimal Control

References

  1. [1]D. J. Bajpai and M. K. Hanawal. Beyond greedy exits: Improved early exit decisions for risk control and reliability. In Advances in Neural Information Processing Systems, volume 38, pages 170634–170659, 2025.
  2. [2]R. Bellman. The theory of dynamic programming. Bulletin of the American Mathematical Society, 60(6):503–515, 1954.DOI
  3. [3]M. Benning, E. Celledoni, M. J. Ehrhardt, B. Owren, and C.-B. Schönlieb. Deep learning as optimal control problems: Models and numerical methods. Journal of Computational Dynamics, 6(2): 171–198, 2019.arxiv.org/abs/1904.05657
  4. [4]D. P. Bertsekas. Dynamic Programming and Optimal Control. Athena Scientific, 2005. ISBN 978-1-886529-26-7.
  5. [5]V. Boltyanskii, R. Gamkrelidze, and L. Pontryagin. On the theory of optimal processes. Doklady Akademii Nauk SSSR, 110:7–10, 1956.
  6. [6]M. Chen, M. Lin, K. Li, Y. Shen, Y. Wu, F. Chao, and R. Ji. CF-ViT: A general coarse-to-fine method for vision transformer. In AAAI Conference on Artificial Intelligence, 2023.
  7. [8]J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009.
  8. [9]R. Dorfman, P. Samuelson, and R. Solow. Linear Programming and Economic Analysis. McGraw-Hill, New York, 1958.
  9. [10]A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
  10. [11]C. Esteve, B. Geshkovski, D. Pighin, and E. Zuazua. Large-time asymptotics in deep learning. arXiv preprint arXiv:2008.02491, 2020.arxiv.org/abs/2008.02491
  11. [12]C. Esteve-Yagüe and B. Geshkovski. Sparsity in long-time control of neural ODEs. Systems & Control Letters, 172:105452, 2023.
  12. [13]T. Faulwasser and L. Grüne. Turnpike properties in optimal control: An overview of discrete-time and continuous-time results. In Handbook of Numerical Analysis, volume 23, pages 367–400. 2022.
  13. [14]T. Faulwasser, A.-J. Hempel, and S. Streif. On the turnpike to design of deep neural networks: Explicit depth bounds. IFAC Journal of Systems and Control, 30:100290, 2024.DOI
  14. [15]B. Geshkovski. Control in moving interfaces and deep learning. PhD thesis, Universidad Autónoma de Madrid, 2021.
  15. [16]Y. Han, D. Han, Z. Liu, Y. Wang, X. Pan, Y. Pu, C. Deng, J. Feng, S. Song, and G. Huang. Dynamic perceiver for efficient visual recognition. In IEEE/CVF International Conference on Computer Vision, pages 5992–6002, 2023.arxiv.org/abs/2306.11248
  16. [17]M. Hardt and T. Ma. Identity matters in deep learning. In International Conference on Learning Representations, 2017.arxiv.org/abs/1611.04231
  17. [20]G. Huang, D. Chen, T. Li, F. Wu, L. van der Maaten, and K. Q. Weinberger. Multi-scale dense networks for resource efficient image classification. In International Conference on Learning Representations, 2017.arxiv.org/abs/1703.09844
  18. [21]Y. Kaya, S. Hong, and T. Dumitras. Shallow-deep networks: Understanding and mitigating network overthinking. In International Conference on Machine Learning, 2019.
  19. [22]J. Kim, M. Kim, and B. Mozaffari. Provable memorization capacity of transformers. In International Conference on Learning Representations, 2023.
  20. [23]A. Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
  21. [24]P. Kubaty, F. Szatkowski, M. Jazbec, and B. Wójcik. Failure prediction is a better performance proxy for early-exit networks than calibration. In NeurIPS 2025 Workshop on Structured Probabilistic Inference & Generative Modeling, 2025a.
  22. [25]P. Kubaty, B. Wójcik, B. T. Krzepkowski, M. Michaluk, T. Trzcinski, J. Pomponi, and K. Adamczewski. How to train your multi-exit model? analyzing the impact of training strategies. In International Conference on Machine Learning, 2025b.
  23. [26]C.-Y. Lee, S. Xie, P. Gallagher, Z. Zhang, and Z. Tu. Deeply-supervised nets. In International Conference on Artificial Intelligence and Statistics, 2015.arxiv.org/abs/1409.5185
  24. [28]M. Liu, T. Xie, X. Cheng, J. Deng, M. Yang, X. Wang, and M. Liu. FocusedDropout for convolutional neural network. Applied Sciences, 12(15), 2022a.arxiv.org/abs/2103.15425
  25. [29]Z. Liu, Z. Xu, H.-J. Wang, T. Darrell, and E. Shelhamer. Anytime dense prediction with confidence adaptivity. In International Conference on Learning Representations, 2022b.arxiv.org/abs/2104.00749
  26. [30]A. W. Marshall, I. Olkin, and B. C. Arnold. Inequalities: Theory of Majorization and Its Applications. Springer, New York, 2 edition, 2011.
  27. [31]Y. Matsubara, M. Levorato, and F. Restuccia. Split computing and early exiting for deep learning applications: Survey and research challenges. ACM Computing Surveys, 55(5), 2022.DOI
  28. [32]L. W. McKenzie. Turnpike theory. Econometrica, 44(5):841–865, 1976.
  29. [33]I. Meza De la Jara, C. Rodriguez-Opazo, D. Teney, D. Ranasinghe, and E. Abbasnejad. Mysteries of the deep: Role of intermediate representations in out of distribution detection. In Advances in Neural Information Processing Systems, volume 38, pages 110728–110762, 2025.arxiv.org/abs/2510.05782
  30. [34]K. Miao and K. Gatsis. How deep do we need: Accelerating training and inference of neural ODEs via control perspective. In International Conference on Machine Learning, 2024.
  31. [35]Q. Nguyen and M. Hein. Optimization landscape and expressivity of deep CNNs. In International Conference on Machine Learning, 2018.arxiv.org/abs/1710.10928
  32. [36]N. Passalis, J. Raitoharju, A. Tefas, and M. Gabbouj. Efficient adaptive inference for deep convolutional neural networks using hierarchical early exits. Pattern Recognition, 105:107346, 2020.DOI
  33. [37]J. Püttschneider, S. Heilig, A. Fischer, and T. Faulwasser. Towards an optimal control perspective of resnet training. In ICML 2025 Workshop on High-dimensional Learning Dynamics, 2025.arxiv.org/abs/2506.21453
  34. [39]J. Püttschneider, S. Heilig, L. Adilova, A. Fischer, and T. Faulwasser. Turnpikes in deep learning: Beyond resnets and neural odes? In 2026 European Control Conference (ECC), pages 1910–1916, 2026.
  35. [41]F. Regol, J. Chataoui, and M. Coates. Jointly-learned exit and inference for a dynamic neural network. In International Conference on Learning Representations, 2024.arxiv.org/abs/2310.09163
  36. [42]D. Ruiz-Balet and E. Zuazua. Neural ODE control for classification, approximation, and transport. SIAM Review, 65(3):735–773, 2023.
  37. [43]K. Sakamoto and I. Sato. End-to-end training induces information bottleneck through layer-role differentiation: A comparative analysis with layer-wise training. Transactions on Machine Learning Research, 2024.arxiv.org/abs/2402.09050
  38. [44]S. Scardapane, M. Scarpiniti, E. Baccarelli, and A. Uncini. Why should we add early exits to neural networks? Cognitive Computation, 12(5):954–966, 2020.DOI
  39. [45]T. Schuster, A. Fisch, J. Gupta, M. Dehghani, D. Bahri, V. Tran, Y. Tay, and D. Metzler. Confident adaptive language modeling. In Advances in Neural Information Processing Systems, volume 35, pages 17456–17472, 2022.arxiv.org/abs/2207.07061
  40. [46]Y. Sui, Y.-N. Chuang, G. Wang, J. Zhang, T. Zhang, J. Yuan, H. Liu, A. Wen, S. Zhong, N. Zou, H. Chen, and X. Hu. Stop overthinking: A survey of efficient reasoning for large language models. Transactions on Machine Learning Research, 2025.arxiv.org/abs/2503.16419
  41. [47]C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich. Going deeper with convolutions. In IEEE Conference on Computer Vision and Pattern Recognition, pages 1–9, 2015.
  42. [48]S. Teerapittayanon, B. McDanel, and H. Kung. BranchyNet: Fast inference via early exiting from deep neural networks. In International Conference on Pattern Recognition, pages 2464–2469, 2016.
  43. [49]E. Trélat and E. Zuazua. The turnpike property in finite-dimensional nonlinear optimal control. Journal of Differential Equations, 258(1):81–114, 2015.arxiv.org/abs/1402.3263
  44. [50]J. von Neumann. Über ein ökonomisches Gleichungssystem und eine Verallgemeinerung des Brouwerschen Fixpunktsatzes. In Ergebnisse eines Mathematischen Seminars. 1938.
  45. [51]W. Zhou, C. Xu, T. Ge, J. McAuley, K. Xu, and F. Wei. BERT loses patience: Fast and robust inference with early exit. In Advances in Neural Information Processing Systems, volume 33, pages 18330–18341, 2020.arxiv.org/abs/2006.04152

Paper details

vlnc:W_p8k44pvk
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents