Batch-Aware Early Exiting as an Indexable POMDP

Early-exit neural networks put small classifiers partway through a deep model so that easy inputs can stop early. On paper this saves a lot of computation. On a GPU it often saves very little, and the reason is structural. Inputs are processed in batches, and running the next layer costs almost the same whether 32 samples continue or only 3. The cost changes in steps at the tile and warp sizes the hardware uses, and removing finished samples from the batch adds its own cost for gathering scattered memory. Current exit rules decide one sample at a time, as if each sample paid only for its own FLOPs. That accounting is wrong for batched serving.

We propose to make the exit decision jointly for the whole batch, against the measured latency curve of the hardware, while still respecting each sample's uncertainty. Each sample gets a small partially observable decision problem (a POMDP: the true state is hidden and only noisy signals are seen). The hidden state is the depth at which the network's best-so-far prediction becomes correct, and the observations are the intermediate classifier outputs. We solve this problem offline with point-based value iteration, which computes value functions only at a finite set of representative probability distributions ("beliefs") over the hidden state. From the solution we read off a per-sample priority score, a Whittle-style index. At run time, after each layer, the batch controller ranks the active samples by this score and picks how many to continue. It chooses that number only among hardware-friendly batch sizes, comparing the summed scores of the top samples against the measured latency of running a batch of that size.

Core Claim

The claim is that the right unit of exit decision on accelerators is the batch-layer step, not the sample. The coupling between samples, which comes entirely from the step-shaped hardware cost, can be removed with a Lagrangian price on compute. That leaves one small per-sample POMDP whose optimal stopping rule is a threshold in that price. This threshold property is called indexability: as compute becomes more expensive, the set of beliefs where continuing is worthwhile only shrinks.

Concretely, let $b_{i,l}$ be sample $i$'s belief after layer $l$. Let $c_l(k)$ be the measured wall-clock latency of running layer $l+1$ on $k$ samples, including compaction. Let $\lambda$ be a price per sample-layer. The per-sample problem replaces $c_l(k)$ with $\lambda$ per continued sample. Its index is

$$W_l(b) = \inf\{\lambda : \text{stopping is optimal at belief } b \text{ after layer } l \text{ under price } \lambda\},$$

where stopping returns the best prediction seen so far. At run time, with the scores sorted in decreasing order as $W_{(1)} \ge W_{(2)} \ge \dots$, the controller continues the top $k^*$ samples, where

$$k^* = \arg\max_{k \in \mathcal{K}} \Big( \sum_{j \le k} W_{(j)} \Big) - c_l(k),$$

and $\mathcal{K}$ is the set of batch sizes the kernel runs efficiently, plus zero. If the index is well defined, continuing exactly the samples whose index exceeds the price is optimal for the relaxed problem. The rounding to $\mathcal{K}$ is where the hardware enters.

Two prior results motivate this design. Hold That Exit proves that sequential no-recall threshold rules cannot reach a constant-factor approximation of the optimal accuracy-latency frontier, and it derives an adaptive threshold from a dynamic program with recall. However, its solver works on a discretized, fully observed loss state, costs that discretization roughly 8% accuracy, and prices each sample independently. BEEM and Fast yet Safe document "overthinking," where deeper layers overturn correct early predictions, and they handle it with a consensus counter or with marginal monotonicity over a calibration set. Our hidden state with recall treats overthinking as a belief question: is the best-so-far prediction already right?

The index construction itself comes from DeepTOP. DeepTOP shows that a Whittle index equals the optimal threshold of an auxiliary priced process, but it works only for fully observed scalar states and binary actions. We apply that equivalence to beliefs, where indexability is not guaranteed and must be checked.

Research Program

The work has four parts.

The first part is the per-sample model. The hidden state $z \in \{1,\dots,L,\infty\}$ is the earliest exit from which the recall prediction is correct, with $\infty$ meaning never. Observations are discretized intermediate signals: top-1 confidence, whether this exit agrees with the running best, and the margin. Their distributions are estimated per layer from a held-out split. The planning horizon is the number of exits, and there is no discounting. This makes the setting the finite-horizon, undiscounted one targeted by FiVI, Point-Based Value Iteration for Finite-Horizon POMDPs. We reuse its time-indexed value functions, its gap-guided belief expansion, and its Perseus-style backup selection (Perseus). The belief set comes from beliefs actually reached on training data, following the reachable-belief idea of Pineau et al..

The second part is structure. The hidden state is ordered, so beliefs can be partially ordered by first-order stochastic dominance, meaning one belief puts more probability on later correctness depths than another. This ordering is not automatically monotone with the value of continuing. Mass on $z=\infty$ makes continuing pointless, so the continue region may be an interval rather than a half-space. This is exactly the non-monotone case that the structural literature flags as breaking threshold methods.

We will not assume a threshold. Instead, we will check numerically whether $W_l$ is well defined, that is, whether the continue set shrinks monotonically as $\lambda$ rises. If it is, the index for each belief can be found by bisection over $\lambda$, instead of solving the POMDP on a dense grid of prices. We will also test a pruning rule in the spirit of the structure-aware dynamic programming of To Skip or to Switch?. If the action is fixed at two beliefs ordered by dominance and the two beliefs agree on the $z=\infty$ mass, the backups between them are skipped. We will measure how many backups this saves and whether it ever changes the policy.

The third part is the hardware cost. For each backbone and accelerator we measure $c_l(k)$ for every layer and every active batch size, with and without compaction. This yields the step-shaped curve that FLOP counts hide. Mind the Budget had to rewrite its runtime in Rust because Python dispatch overhead erased its FLOP savings. We take that lesson as a constraint and implement the controller inside a compiled serving loop, so that the controller does not itself become the overhead.

The fourth part is the run-time controller. It needs one table lookup per active sample, using the belief update from discretized observations and the precomputed index, then a sort and a scan over $\mathcal{K}$.

Baselines

The naive reference point is the full backbone with no exits, run at the same batch size. Every speedup is reported against it.

The strongest per-sample method is risk-controlled thresholding from Fast yet Safe, run from its released code metodj/RC-EENN. On ImageNet it reports about a 61% reduction in the average number of layers evaluated while staying within 5% of the full model. It is the strongest competitor because it gives statistical error guarantees and is the most widely reproducible. However, it reports layer counts rather than batched wall-clock time; we found no reported batched GPU wall-clock result for it on Lacuna. We will run it on the same backbones, the same calibration split our observation model uses, and the same serving loop, executed two ways: once with naive masking, where the batch runs until every sample exits, and once with per-layer compaction. Beating it means a higher accuracy at equal measured p50 and p99 latency per batch, or lower latency at equal accuracy, across the frontier.

The second strongest is the recall dynamic program of Hold That Exit. It reports up to a 2x speedup over the backbone with about 8% accuracy loss on ImageNet VGG models. We will reimplement it per sample, plugged into the same compacting loop, at the same discretization budget as our belief set.

We also include latency-constrained threshold optimization from Empowering Adaptive Early-Exit Inference, which reports a 0.79% accuracy gain over heuristics on CIFAR-100. On GLUE we include BEEM, which reports 1.9x to 2.1x speedups at matched accuracy.

Two ablations isolate the key ingredients. The first keeps our point-based value iteration index but chooses $k$ per sample: everyone with $W_l(b) > \lambda$ continues, with no rounding to $\mathcal{K}$. This isolates the batch-aware cost. The second keeps the batch-aware controller but replaces the index with a small regressor trained to predict the gain from continuing. This isolates the POMDP. All methods get the same calibration data and an equal hyperparameter search budget, measured in grid points over their single price or threshold knob.

Why not just…?

Why not just compact the batch with a per-sample calibrated threshold? This is the most serious threat, and it may capture much of the gain. Compaction removes wasted rows, but it does not decide how many rows to keep. Below a tile boundary, dropping a sample saves nothing, and gathering costs real time. A per-sample rule cannot know that the fourth-weakest remaining sample is effectively free to continue. The comparison against compacted RC-EENN tests this directly. If our method only matches it, the batch-aware claim fails, and we will report that.

Why not just learn a stopping head that predicts the gain from continuing? This could plausibly match the POMDP index, and Mind the Budget shows that amortized gating heads work well. The regressor ablation settles the question. If the regressor matches, the contribution narrows to batch-aware indexing plus a solver that supplies training targets, and we will say so. We expect the POMDP to help most on overthinking-heavy tasks and under the large-$\lambda$ end of the frontier, where samples are rare and a regressor has little data. That expectation is untested.

Why not just pre-assign each input one exit layer? Scheduling Inputs in Early Exit Neural Networks removes intermediate overhead entirely by assigning an exit before execution. On the CICIDS2017 WebAttacks trace, its model-based policy cut the job loss ratio from 0.0636 for exit-last to 0.0000. Its decision ignores the input's content, though. We include it on that trace as the content-blind reference. Our controller has to beat it on accuracy at equal loss ratio.

Proposed Experiments

The main testbeds are ImageNet with MSDNet and ResNet multi-exit backbones from the RC-EENN pipelines, CIFAR-100 with S-ResNet-18, and GLUE (SST-2, MNLI, QNLI) with multi-exit BERT. All run at batch sizes from 8 to 256 on one GPU type, with latency curves re-measured on a second accelerator to test portability. The CICIDS2017 traces serve as a streaming check. Metrics are accuracy, measured per-batch p50 and p99 wall-clock time, FLOPs (reported only to expose the gap between FLOPs and time), solver time, and backups saved by pruning.

Four checks decide whether the claim holds. The first asks whether the index is actually well defined on real observation models. We report the fraction of beliefs whose continue set is not nested in $\lambda$; if it is large, the index method is invalid as stated. The second measures whether the batch-aware controller's advantage over per-sample compaction grows with batch size and with the sharpness of the latency steps, as the mechanism predicts, and vanishes for single-sample serving. The third compares the POMDP index against the regressor on the overthinking subset, defined as samples where an early exit was correct and the final layer was not. The fourth checks whether dominance pruning reduces backups without changing any action on the evaluated belief set.