betaFeedback

WorksComputer Science

APEX: Speculate smarter, not deeper

Abstract

Speculative decoding reduces large language model inference latency by drafting multiple tokens before target-model verification, but its effectiveness depends on both the proposal mechanism and draft depth. Fixed configurations cannot respond to changes in predictability, repetition, and acceptance during generation, so deeper drafting can increase wasted computation without proportional speedup. We introduce APEX, a learned controller that balances decoding speed and draft-token waste through request-level expert selection and block-level depth adaptation. APEX-Router selects among EAGLE-3, n-gram, and draft-model speculation for each request, while APEX-Depth adjusts draft length at each verification block using causal decoding signals and recent verifier feedback. APEX models accepted draft length as censored survival feedback, learning position-wise rejection hazards, block execution costs, and an action utility that balances throughput, accepted progress, and wasted tokens. This allows the controller to adapt speculation while retaining the target model's verification procedure. We integrate APEX into vLLM and evaluate it with Qwen3-8B across six workloads, achieving up to 5.24X speedup over autoregressive decoding. Across the aggregate evaluation, APEX-S achieves 4.27X speedup, while APEX-B achieves 3.27X speedup with a 41.0% relative reduction in wasted-token percentage compared with fixed n-gram speculation at k=16, providing distinct operating points for balancing acceleration and draft-token utilization.

Introduction

Large language models (LLMs) increasingly serve interactive and long-form workloads such as code generation, mathematical reasoning, and conversational assistance. In these settings, inference latency is not merely a backend cost, it directly affects user-perceived responsiveness and the feasibility of deploying capable models at scale Kwon et al. [15]; Agrawal et al. [1]. Yet acceleration must preserve the behavior of the target model. The systems challenge is therefore not simply to generate more tokens per second, but to convert additional computation into verified output progress without changing the target model’s generation semantics.

Autoregressive decoding Schuurmans et al. [23] produces each token conditioned on the preceding prefix. Speculative decoding (SD) Xia et al. [24] reduces the number of sequential target-model invocations by using a cheaper mechanism to propose multiple tokens, which the target model then verifies. Accepting a long draft prefix allows generation to advance several positions in one verification step. However, an early rejection leaves much of the proposed draft unused. Increasing draft depth consequently offers more potential progress while also increasing the amount of speculative work exposed to rejection. High speedup can coexist with substantial draft-token waste, and low waste can coexist with slow execution. Both wall-clock latency and draft-token utilization are therefore needed to assess the resulting trade-off. The proposal mechanism also shapes this trade-off. Learned speculators such as EAGLE-3 Li et al. [17] can provide useful drafts when upcoming tokens are predictable. Retrieval-based approaches like n-gram reuse available text He et al. [9], making inexpensive matching methods attractive when repeated structure is present. A separate draft model can produce plausible continuations across varied inputs, but its execution cost may offset the benefit of accepting additional tokens. These mechanisms therefore differ in both the drafts they produce and the cost of producing them. The same acceptance rate or wasted-token percentage can have different latency consequences across mechanisms.

The value of speculation depends jointly on the proposal mechanism, draft depth, and decoding state. A mechanism that proposes tokens cheaply may still discard a large fraction of its drafts, while a more accurate mechanism may incur enough proposal latency to offset its acceptance gains. Selecting an appropriate mechanism and depth requires accounting for the progress and cost of verification. This motivates our central research question:

Can speculative decoding adapt its proposal mechanism and depth to maximize verified progress per unit cost as decoding evolves?

We address this question with APEX, a learned controller that combines request-level expert selection with block-level depth adaptation. At the beginning of a request, APEX-Router selects a proposal mechanism and an initial draft depth using the available request information. The selected mechanism remains fixed for that request, while APEX-Depth adjusts its draft length at each subsequent verification block. The depth controller uses causal features describing the current prefix, generation progress, and recent verifier outcomes. This separation accommodates the different timescales of the two decisions: routing determines the speculative execution path, while depth control responds to changes in acceptance and runtime within that path.

The central modeling idea is to treat accepted draft length as censored survival feedback. When a draft is rejected at a particular position, the observation identifies how far it survived verification. When every proposed token is accepted, the observation establishes survival only through the chosen depth; it does not reveal where a longer draft would first be rejected. APEX captures this structure through position-wise rejection hazards, from which it derives survival probabilities and expected accepted length. Runtime prediction complements this model because accepting more tokens does not necessarily produce greater speedup when drafting or verification costs also increase.

Contributions

Our work makes the following contributions:

  1. Empirical characterization of speculative speed and waste. We examine how proposal mechanisms and draft depths behave across workloads, entropy, repetition, and execution costs. The analysis identifies conditions in which deeper speculation increases waste without proportional acceleration and motivates control using decoding-state information.

  1. Hierarchical control of heterogeneous speculators. We introduce APEX, which coordinates request-level selection among EAGLE-3, n-gram, and draft-model speculation with block-level depth adaptation. This structure combines mechanism selection with finer-grained responses to changing verifier feedback.

  1. A survival-based model of draft acceptance. We formulate accepted draft length using position-wise rejection hazards and a likelihood that handles both early rejection and fully accepted, right-censored blocks. Joint prediction of acceptance behavior and runtime provides supervision for learning the value of different depths.

  1. Trace-supervised learning of action utility. We construct utility targets from observed throughput, accepted progress, draft-token waste, and regret relative to observed alternatives. Multi-task prediction and candidate-ranking losses train the controller to select depths using features available at inference time.

  1. System integration and detailed evaluation. We integrate APEX into vLLM and evaluate it with Qwen3-8B across six workloads, including component ablations and candidate-depth sensitivity analysis. APEX achieves up to 5.24×\times wall-clock speedup over autoregressive decoding and an aggregate speedup of 4.27×\times. APEX-B achieves an aggre-

gate speedup of 3.27× while reducing the mean wasted-token percentage from 79.90% to 47.17% relative to fixed n-gram speculation at k=16k = 16, a relative reduction of 41.0%.

Background and Related Work

Autoregressive Decoding

Let pθp_\theta denote the target language model. Given a prompt or prefix x≤t=(x1,…,xt)x_{\leq t} = (x_1, \ldots, x_t), autoregressive decoding Schuurmans et al. [23] generates one token at a time according to xt+1∼pθ(⋅∣x≤t)x_{t+1} \sim p_\theta(\cdot\mid x_{\leq t}). The newly generated token is appended to the prefix and the process repeats until a stopping condition is reached. This decoding procedure preserves the target model’s generation semantics, but it introduces a strict sequential dependency: producing TT output tokens requires TT target-model decoding steps. For large models, each step requires loading and applying the target network to the current prefix, making decoding latency scale directly with output length.

This sequential structure is especially costly for long-form generation settings such as code synthesis, multi-step reasoning, long-context completion, and software engineering tasks. The goal of inference acceleration is therefore not merely to reduce computation, but to reduce the number or cost of sequential target-model invocations while preserving the output distribution or verification semantics of the target model.

SD accelerates autoregressive generation by separating token proposal from target-model verification [24, 16, 5]. A cheaper proposal mechanism qq first drafts a block of kk candidate tokens, x^t+1:t+k∼q(⋅∣x≤t)\hat{x}_{t+1:t+k} \sim q(\cdot\mid x_{\leq t}), and the target model verifies the proposed block in parallel. If multiple draft tokens are accepted, generation advances by more than one token using a single target-model verification step.

The efficiency of this procedure depends on how many proposed tokens survive verification. Let Lt∈{0,…,k}L_t \in\{0, \ldots, k\} denote the accepted draft length at block tt, and let rtr_t denote the first rejection position, with the event rt>kr_t > k corresponding to full acceptance of the draft block. If rejection occurs early, all remaining draft tokens after the first rejected token are discarded. Thus, the useful progress of a speculative block is not the proposed depth kk, but the accepted length LtL_t.

This observation makes SD a cost-sensitive procedure. A larger kk increases the maximum possible progress per verifier call, but it also increases the amount of draft work that can be wasted after early rejection. The relevant quantity for efficient serving is therefore accepted progress per unit cost:

At(m,k)=LtCt,(1)\mathcal{A}_t(m,k) = \frac{L_t}{C_t}, \tag*{(1)}

where mm denotes the speculative mechanism and CtC_t denotes the block-level proposal and verification cost. A speculative configuration is profitable only when the accepted progress outweighs the extra drafting and verification overhead.

Speculative Mechanisms

Early SD methods use an auxiliary draft model to propose tokens for target-model verification [24, 16]. Followup works improve drafting through knowledge distillation, specialized architectures, or objectives aligned with target-model acceptance [3, 27]. Improving an individual proposal mechanism does not by itself determine when that mechanism is preferable to alternatives with different proposal costs and acceptance behavior. A fixed choice can therefore retain a costly or poorly matched speculative path even when another mechanism offers a more favorable speed–waste trade-off.

A second line of work reduces reliance on separate draft models. Medusa adds decoding heads to the target model for parallel verification of tree-structured continuations [4], while SpecInfer constructs token trees for parallel candidate verification [21]. EAGLE-style methods instead use target-model hidden states to build lightweight neural speculators [18 a]. Their gains, however, still depend on proposal survival and cost.

A third class uses retrieval or surface repetition instead of neural drafting. N-gram and suffix-based methods copy continuations from the prompt, generated prefix, or external text, making them cheap and effective in repetitive regimes but brittle on novel continuations [11]. This creates a complementary tradeoff: neural speculators can better model semantic continuation, while retrieval-based speculators can be faster when repeated structure is available.

APEX is orthogonal to these mechanisms; it treats mechanisms like EAGLE-3, n-gram, and draft-model speculation as candidate experts and learns which of them to use and how deeply to speculate in each decoding state. APEX can thus choose among mechanisms with different proposal costs and acceptance behavior while retaining their existing proposal and verification algorithms.

Adaptive Speculative Decoding

Dynamic Speculation Lookahead shows that using the same speculation lookahead for all decoding iterations is suboptimal and proposes dynamically selecting the number of draft tokens during generation Mamou et al. [19]. AdaEAGLE Zhang et al., [26] explicitly models adaptive draft structures and uses a lightweight draft length predictor to choose the number of draft tokens for EAGLE-style speculation. BanditSpec Hou et al., [10] formulates speculative hyperparameter selection as a multi-armed bandit problem and adapts the configuration online without training a controller. DSDE Yang et al., [25] studies dynamic speculation length in serving settings using KLD-based stability signals and adaptive caps. Production systems such as vLLM also support dynamic SD through manually specified schedules that map concurrency or batch-size ranges to a chosen number of speculative tokens Kwon et al., [14].

These studies show that a single fixed depth (kk) can limit inference acceleration as acceptance behavior and serving conditions change. They motivate a broader control problem: selecting a proposal mechanism together with depths that balance verified progress, runtime, and draft-token waste. APEX addresses this problem through request-level expert selection and block-level depth adaptation, using learned rejection hazards and runtime signals to score candidate depths.

Speculative Decoding

Empirical Motivation: Fixed Speculation Is Not Enough

We examine how the proposal mechanism and draft depth affect acceleration and draft-token waste. Using Qwen3-8B in vLLM, we compare autoregressive decoding with EAGLE-3, n-gram, and draft-model speculation across code generation, mathematical reasoning, long-context completion, long-chain reasoning, conversational generation, and SWE-style tasks. Workload details and full evaluation results appear in § 5.

Speculative performance depends on the workload and mechanism. Figure 1 summarizes the highest observed speedups in the characterization set, illustrating workload-dependent differences between mechanisms. These peak results are distinct from the aggregate averages reported on a separate evaluation set in Table 1. Figure 2a further shows that acceptance alone does not determine acceleration: draft-model speculation remains near or below autoregressive performance in the plotted median results, even at relatively high acceptance rates, while the other mechanisms achieve substantial speedup. This motivates considering execution cost alongside acceptance when selecting a speculative mechanism.

Speedup over autoregressive decoding across six workloads and three speculative mechanisms

Figure 1. Speedup over autoregressive decoding across six workloads and three speculative mechanisms. Each cell reports highest speedup and its depth kk; boxes mark the best method per workload.

Acceptance rate and speedup; entropy–repetition and speedup

Figure 2. Online signals associated with SD performance (a) Median speedup over autoregressive decoding versus acceptance rate, with shaded variability. (b) Median speedup versus token entropy and repetition density; the gray plane marks autoregressive performance.

MethodDepthSpeedup vs. AR ↑Wasted Token % ↓WAS ↑
EAGLE-3k=2k = 21.71×1.71 \times64.71%2.64
EAGLE-3k=4k = 42.35×2.35 \times66.25%3.55
EAGLE-3k=8k = 81.94×1.94 \times87.11%2.23
EAGLE-3k=16k = 161.37×1.37 \times97.67%1.41
n-gram SDk=2k = 21.76×1.76 \times54.56%3.23
n-gram SDk=4k = 42.79×2.79 \times54.14%5.16
n-gram SDk=8k = 83.59×3.59 \times63.56%5.64
n-gram SDk=16k = 164.22×4.22 \times79.90%5.28
Draft-SDk=2k = 20.96×0.96 \times27.82%3.44
Draft-SDk=4k = 40.87×0.87 \times38.39%2.26
Draft-SDk=8k = 80.73×0.73 \times52.46%1.39
Draft-SDk=16k = 160.50×0.50 \times68.98%0.72
APEX-Sadaptive4.27×4.27 \times55.30%7.73
APEX-Badaptive3.27×3.27 \times47.17%6.93
APEX-Eadaptive1.83×1.83 \times63.69%2.87

Table 1. Overall decoding performance. APEX is compared against autoregressive decoding and fixed speculative baselines. Higher speedup is better; lower wasted-token percentage is better.

Greater depth does not guarantee a better speed–waste trade-off. The aggregate sweep in Table 1 shows contrasting responses to deeper speculation. Increasing n-gram depth from k=8k = 8 to k=16k = 16 raises mean speedup from 3.59× to 4.22×, while mean waste increases from 63.56% to 79.90%. For EAGLE-3, increasing depth from k=4k = 4 to k=16k = 16 reduces mean speedup from 2.35× to 1.37× and raises mean waste from 66.25% to 97.67%. Deeper drafting therefore offers a modest speed gain at substantially higher waste in one case and worsens both metrics in the other. These responses motivate depth selection that accounts for the active mechanism and expected verification outcome.

Observable decoding signals can inform control. Figure 2b relates median speedup to token entropy and repetition density. Performance varies across these conditions, and the patterns differ between mechanisms. These associations motivate using entropy and repetition as controller inputs alongside recent verifier feedback. Prefix statistics describe the context in which a draft is proposed, while verifier history records how well recent drafts have performed. Both can be obtained from information available during decoding, allowing adaptation without requiring workload labels at inference time.

Verifier feedback reveals where drafts fail. For a draft of length kk, first rejection at position rr leaves r−1r - 1 accepted draft tokens and k−r+1k - r + 1 discarded draft tokens. Full acceptance provides a different observation: the draft survives through depth kk, but the outcome of extending it further remains unknown. Verifier feedback thus contains both observed rejection events and right-censored full-acceptance events. This structure motivates modeling position-wise rejection hazards, which describe how acceptance can change with depth and provide supervision for adaptive speculative control.

APEX: Breathing Adaptivity into Static Speculation

We propose APEX, a learned online controller that selects a proposal mechanism and initial depth at request granularity and adjusts speculation depth at block granularity. Its learned utility balances throughput and accepted progress against discarded draft tokens. APEX operates at two coupled timescales. APEX-Router selects a speculative expert (EAGLE-3, n-gram, or draft-model speculation) and its initial depth for each request, while APEX-Depth adapts depth kk at the block level. This separation reflects systems constraints: expert selection affects model placement, batching, and worker routing, whereas depth can change more frequently within the selected path.

Figure 3 summarizes the framework. We first define the decoding state and request-level routing decision, then formulate accepted draft length as censored survival feedback. This formulation provides the acceptance model used by APEX-Depth, which learns acceptance, runtime, and utility predictions from a shared representation.

APEX overview

Figure 3. APEX overview. The router selects a speculative expert and initial depth from prompt features. After each verifier block, the depth controller uses the updated decoding state and prior verifier feedback to select the next depth. Observed acceptance and runtime update the controller state; network parameters remain fixed during inference.

Problem Formulation and State Representation

Let pθp_\theta denote the target language model and let m∈Mm \in\mathcal{M} denote a proposal mechanism, where

M={EAGLE-3, n-gram SD, Draft-SD}.(2)\mathcal{M} = \{\mathrm{EAGLE\text{-}3},\ \text{n-gram SD},\ \text{Draft-SD}\}. \tag*{(2)}

We index verifier blocks by tt and denote the prefix available before block tt by ctc_t. Given this prefix, mechanism mm proposes a draft block dtd_t of length ktk_t according to qm(⋅∣ct;kt)q_m(\cdot\mid c_t; k_t), its induced proposal distribution. The target model then verifies the draft block. Let Lt∈{0,…,kt}L_t \in\{0,\ldots,k_t\} be the number of accepted draft tokens. If Lt=ktL_t = k_t, the full block is accepted; if Lt<ktL_t < k_t, the verifier rejects at position Lt+1L_t + 1. We define the discarded draft-token count and waste fraction as

Rt=kt−Lt,Wt=Rtkt.(3)R_t = k_t - L_t,\qquad W_t = \frac{R_t}{k_t}. \tag*{(3)}

Here, RtR_t includes the first rejected token and the discarded suffix, and WtW_t is the fraction of drafted tokens that are not accepted. Since WtW_t measures token utilization rather than wasted computation, we measure latency separately to assess the speed–waste trade-off.

Let CtC_t denote block-tt wall-clock latency, including drafting and verification, and TPSt\mathrm{TPS}_t the executed action’s throughput. APEX uses these observations to learn a block-level utility balancing accepted progress, runtime, and speculative waste. In our experiments, Kmax⁡=16K_{\max} = 16, and candidate depths form a finite set K⊆{1,…,Kmax⁡}\mathcal{K} \subseteq\{1,\ldots,K_{\max}\}.

Request-level state The request-level state s0s_0 contains the information available before generation begins:

s0=[eprompt,ℓprompt,ρprompt,ηprompt,cdecode].(4)s_0 = [e_{\mathrm{prompt}}, \ell_{\mathrm{prompt}}, \rho_{\mathrm{prompt}}, \eta_{\mathrm{prompt}}, c_{\mathrm{decode}}]. \tag*{(4)}

Here, eprompte_{\mathrm{prompt}} is a fixed-dimensional prompt embedding, ℓprompt\ell_{\mathrm{prompt}} is the prompt length, ρprompt\rho_{\mathrm{prompt}} contains repetition and lexical-structure features, ηprompt\eta_{\mathrm{prompt}} contains entropy or token-distribution features, and cdecodec_{\mathrm{decode}} contains decoding configuration variables such as temperature and maximum generation length.

Block-level state The block-level state sts_t contains information available before verifier block tt:

st=[eprompt,ℓprompt,cdecode,πt,ht−1,gt].(5)s_t = [e_{\mathrm{prompt}}, \ell_{\mathrm{prompt}}, c_{\mathrm{decode}}, \pi_t, \mathbf{h}_{t-1}, \mathbf{g}_t]. \tag*{(5)}

Here, πt\pi_t denotes generation progress, ht−1\mathbf{h}_{t-1} summarizes verifier feedback from blocks 1,…,t−11,\ldots,t-1, and gt\mathbf{g}_t contains statistics computed from the current prefix ctc_t. We supply the active mechanism mm and candidate depth kk separately when constructing state-action features.

The history vector ht−1\mathbf{h}_{t-1} includes the number of observed verifier blocks, rolling mean and variance of accepted length, first-rejection position statistics, full-acceptance rate, rejection rate, mean rejected-token count, and short-window summaries over the most recent verifier blocks. The prefix vector gt\mathbf{g}_t includes entropy and repetition features. These features are causal: the current block outcome is never used to predict the current block.

APEX-Router

APEX-Router jointly selects the speculative expert and initial depth expected to provide the best speed–cost trade-off for each request before generation. It scores initial actions a=(m,k0)a=(m,k_0), where m∈Mm\in\mathcal{M} is the speculative mechanism and k0k_0 is the initial depth. Let AR⊆M×KA_R\subseteq\mathcal{M}\times\mathcal{K} denote the admissible initial actions. Using the pre-generation state s0s_0, it predicts

U^R(s0,m,k0)=fθR(ϕR(s0,m,k0)),(6)\widehat{U}_R(s_0,m,k_0)=f_{\theta_R}\left(\phi_R(s_0,m,k_0)\right), \tag*{(6)}

where ϕR\phi_R combines the request features with the candidate method and initial depth, and fθRf_{\theta_R} is a neural scoring function. The selected action is

(m⋆,k0⋆)=arg⁡max⁡(m,k0)∈AR U^R(s0,m,k0).(7)(m^\star,k_0^\star)=\underset{(m,k_0)\in A_R}{\arg\max}\ \widehat{U}_R(s_0,m,k_0). \tag*{(7)}

The router is trained from completed request-level traces rather than workload labels. Each observed request–method–initial-depth combination supplies a training example:

(s0(r),m,k0)⟶uR(r,m,k0),\left(s_0^{(r)},m,k_0\right)\longrightarrow u_R(r,m,k_0),

where s0(r)s_0^{(r)} is the initial state of request rr and uR(r,m,k0)u_R(r,m,k_0) is its empirical request-level utility label. The observed label uRu_R provides offline supervision for the predicted score U^R\widehat{U}_R. The resulting acceptance, latency, and waste are execution outcomes; they are not inputs available when routing a new request.

At inference, the router scores each admissible method–initial-depth pair using only s0s_0 and the candidate action. The selected action determines the speculative decoding path and initializes its depth. The mechanism m⋆m^\star remains fixed for the request, the first block uses k1=k0⋆k_1=k_0^\star, and APEX-Depth controls subsequent depths.

Once the expert is selected, the depth decision depends on how its drafts survive verification as generation evolves. We next formulate this acceptance feedback before describing the depth controller.

Acceptance as Censored Survival Feedback

The accepted length of a speculative block contains more information than an aggregate acceptance rate. A partially accepted block identifies the first rejected position, while a fully accepted block establishes only that rejection did not occur within the executed depth. APEX models these two outcomes using a discrete survival formulation.

For a candidate depth kk, define JtJ_t as the first rejected draft position using one-indexed positions. Thus, Jt=jJ_t=j means the first j−1j-1 draft tokens were accepted and the jj-th draft token was rejected. If the entire block is accepted, then Jt>kJ_t>k. The accepted length is

Lt={Jt−1,Jt≤k,k,Jt>k.(8)L_t = \begin{cases} J_t-1, & J_t\leq k,\\ k, & J_t>k. \end{cases} \tag*{(8)}

Position-wise rejection hazards. For each position j∈{1,…,Kmax⁡}j \in\{1,\ldots,K_{\max}\}, the model predicts a discrete hazard:

q^t,j(k)=PθD(Jt=j∣Jt≥j,st,m,k),(9)\hat{q}_{t,j}(k) = P_{\theta_D}(J_t = j \mid J_t \ge j, s_t, m, k), \tag*{(9)}

where θD\theta_D denotes the parameters of the depth controller. This is the conditional probability of rejection at position jj, given that all preceding draft tokens have been accepted.

The probability that the first jj draft tokens survive is

S^t,j(k)=PθD(Jt>j∣st,m,k)=∏i=1j(1−q^t,i(k)).(10)\hat{S}_{t,j}(k) = P_{\theta_D}(J_t > j \mid s_t, m, k) = \prod_{i=1}^{j}(1-\hat{q}_{t,i}(k)). \tag*{(10)}

The expected accepted length follows as

E^[Lt∣st,m,k]=∑j=1kS^t,j(k),(11)\widehat{\mathbb{E}}[L_t \mid s_t,m,k] = \sum_{j=1}^{k}\hat{S}_{t,j}(k), \tag*{(11)}

using the identity E[L]=∑j=1kP(L≥j)\mathbb{E}[L] = \sum_{j=1}^{k} P(L \ge j).

Accepted-length likelihood. If the observed accepted length is Lt=ℓ<kL_t = \ell< k, the first rejected position is Jt=ℓ+1J_t = \ell+ 1. The likelihood is therefore

PθD(Lt=ℓ∣st,m,k)=[∏j=1ℓ(1−q^t,j(k))]q^t,ℓ+1(k).(12)P_{\theta_D}(L_t = \ell\mid s_t,m,k) = \left[\prod_{j=1}^{\ell}(1-\hat{q}_{t,j}(k))\right]\hat{q}_{t,\ell+1}(k). \tag*{(12)}

The empty product equals one when ℓ=0\ell= 0. If Lt=kL_t = k, the entire block is accepted and the rejection position is right-censored beyond kk:

PθD(Lt=k∣st,m,k)=∏j=1k(1−q^t,j(k)).(13)P_{\theta_D}(L_t = k \mid s_t,m,k) = \prod_{j=1}^{k}(1-\hat{q}_{t,j}(k)). \tag*{(13)}

This observation contributes evidence of survival through position kk without imposing a rejection at position k+1k+1.

The survival loss over NN training blocks is

Lsurv=−1N∑t=1Nlog⁡PθD(Lt∣st,mt,kt).(14)\mathcal{L}_{\mathrm{surv}} = -\frac{1}{N}\sum_{t=1}^{N}\log P_{\theta_D}(L_t \mid s_t,m_t,k_t). \tag*{(14)}

This objective trains the controller to capture the first-rejection structure of SD. Acceptance prediction is then combined with runtime and utility supervision, since accepted length alone does not determine the efficiency of a candidate depth.

APEX-Depth

APEX-Depth adapts speculation depth to balance accepted progress, latency, and draft-token waste. Its operation begins with the speculative method and initial depth selected by APEX-Router. Before each subsequent block, it observes the causal state sts_t, evaluates the candidate depths, and selects the depth with the highest predicted utility.

Shared representation For each candidate depth k∈Kk \in\mathcal{K}, the controller constructs

zt(k)=ϕD(st,m⋆,k),vt(k)=gθD(zt(k)).(15)z_t(k) = \phi_D(s_t,m^\star,k), \qquad v_t(k) = g_{\theta_D}(z_t(k)). \tag*{(15)}

Here, ϕD\phi_D standardizes numerical features, embeds categorical variables, and appends the prompt representation. The shared encoder therefore evaluates each depth in the context of the current generation state.

Four prediction heads receive vt(k)v_t(k). Each head is a task-specific output branch of the same network: the survival, cost, and throughput heads predict execution outcomes, while the utility head predicts the action score used for depth selection.

Survival head The survival head outputs a vector of Kmax⁡K_{\max} conditional rejection probabilities:

q^t(k)=fsurv(vt(k)).(16)\widehat{q}_t(k)=f_{\mathrm{surv}}(v_t(k)). \tag*{(16)}

Its jj-th entry is the hazard q^t,j(k)\widehat{q}_{t,j}(k) defined in Equation equation 9. The first kk entries determine the survival curve and expected accepted length through Equations equation 10–equation 11. This head is trained with the censored likelihood in Section 4.3, allowing fully accepted and partially rejected blocks to provide appropriate supervision.

Cost head The cost head predicts the wall-clock cost of executing the candidate block, including drafting and verification. Its scalar output is the predicted log latency:

c^t(k)=fcost(vt(k))=log⁡C^t(k).(17)\widehat{c}_t(k)=f_{\mathrm{cost}}(v_t(k))=\log\widehat{C}_t(k). \tag*{(17)}

This head provides runtime supervision because a candidate depth can accept many tokens but still be slow when proposal or verification overhead is high.

Throughput head The throughput head predicts the rate of output progress achieved by the candidate action. Its scalar output is

τ^t(k)=ftps(vt(k))=log⁡(1+TPS^t(k)).(18)\widehat{\tau}_t(k)=f_{\mathrm{tps}}(v_t(k))=\log\left(1+\widehat{\mathrm{TPS}}_t(k)\right). \tag*{(18)}

Where the cost head models elapsed time, the throughput head models the observed progress rate. Their targets are obtained from measured execution traces, and their regression losses are defined in Section 4.6.

Utility head The utility head predicts the final learned action value:

U^D(st,m⋆,k)=futil(vt(k)).(19)\widehat{U}_D(s_t,m^\star,k)=f_{\mathrm{util}}(v_t(k)). \tag*{(19)}

The hatted quantity U^D\widehat{U}_D is a network prediction made before the candidate block executes. During training, it is fitted to an observed scalar label uD,tu_{D,t} computed from execution outcomes, as defined in Equation equation 25. The utility-regression loss in Equation equation 28 directly connects this prediction to its label, while the ranking loss supervises candidate ordering. The other three heads ground the shared representation in measurable outcomes.

Select, execute, and update The controller chooses the highest-scoring candidate:

kt⋆=arg⁡max⁡k∈K U^D(st,m⋆,k),t≥2.(20)k_t^\star=\underset{k\in\mathcal{K}}{\arg\max}\ \widehat{U}_D(s_t,m^\star,k),\qquad t\ge2. \tag*{(20)}

The utility head supplies the deployed selection score; the other heads support it through shared training. The chosen speculative block is then executed, and its observed outcomes update the state for the next decision. This allows depth to respond to changes in acceptance behavior and execution cost throughout generation.

Trace-Derived Training Targets

We train APEX from offline collected speculative decoding traces. Each depth-controller training example corresponds to an observed verifier block under a particular state-action pair:

(st,mt,kt)⟶(Lt,Rt,Wt,Ct,TPSt).(s_t,m_t,k_t)\longrightarrow(L_t,R_t,W_t,C_t,\mathrm{TPS}_t).

The input contains only information available before executing the block, while the targets contain the outcomes observed after verification. Accepted length supervises the survival head, latency and throughput supervise the runtime heads, and the following utility target supervises the utility head. We use lowercase uu for observed utility labels and hatted U^\widehat{U} for their learned predictions.

Dataset-derived regret targets The trace dataset provides offline comparisons among speculative configurations. For a request rr, let D(r)\mathcal{D}(r) denote the set of method-depth actions observed in the dataset, and let TPSr,m,k\mathrm{TPS}_{r,m,k} denote the recorded request-level throughput under action (m,k)(m,k). We define the best observed global throughput as

Bglobal(r)=max⁡(m,k)∈D(r)TPSr,m,k,(21)B_{\mathrm{global}}(r)=\max_{(m,k)\in\mathcal{D}(r)}\mathrm{TPS}_{r,m,k}, \tag*{(21)}

and the best observed throughput within a fixed mechanism as

Bmethod(r,m)=max⁡k:(m,k)∈D(r)TPSr,m,k.(22)B_{\mathrm{method}}(r,m)=\max_{k:(m,k)\in D(r)}\mathrm{TPS}_{r,m,k}. \tag*{(22)}

For a training block tt belonging to request rtr_t, the global and same-method regret terms are

Gt=[Bglobal(rt)−TPSt]+Bglobal(rt),(23)G_t=\frac{\left[B_{\mathrm{global}}(r_t)-\mathrm{TPS}_t\right]_+}{B_{\mathrm{global}}(r_t)}, \tag*{(23)}
Mt=[Bmethod(rt,mt)−TPSt]+Bmethod(rt,mt),(24)M_t=\frac{\left[B_{\mathrm{method}}(r_t,m_t)-\mathrm{TPS}_t\right]_+}{B_{\mathrm{method}}(r_t,m_t)}, \tag*{(24)}

where [x]+=max⁡(x,0)[x]_+=\max(x,0). These normalized penalties compare block throughput with the best observed request-level reference throughputs. The global term accounts for alternatives across mechanisms and depths, while the same-method term accounts for depth choices within the active mechanism. Both terms are used only to construct training targets and are not required during inference.

Block-level utility For each observed training block, the depth-utility label is

uD,t=log⁡(TPSt)+αAlog⁡(Lt+ϵ)−αWWt−αGGt−αMMt,(25)u_{D,t}=\log(\mathrm{TPS}_t)+\alpha_A\log(L_t+\epsilon)-\alpha_W W_t-\alpha_G G_t-\alpha_M M_t, \tag*{(25)}

where ϵ=0.1\epsilon=0.1 keeps the accepted-length term finite when Lt=0L_t=0. This is the trace-derived label for the executed action (st,mt,kt)(s_t,m_t,k_t); U^D(st,mt,kt)\hat{U}_D(s_t,m_t,k_t) is the network’s prediction of that label.

The utility combines speed, accepted progress, waste, and offline regret. High accepted length is useful only if the resulting progress justifies its runtime, while low waste is useful only if the system still makes enough progress per verifier call. The coefficients allow different training preferences for this speed–waste trade-off.

Training Objective for APEX-Depth

The APEX-Depth network is multi-task by design. The survival loss in Equation equation 14 supervises the rejection hazards. The cost and throughput losses supervise runtime predictions, while utility regression and candidate ranking train the score used for depth selection.

Cost and throughput losses Using the observed action (st,mt,kt)(s_t,m_t,k_t) for each training block, we train the cost head with

Lcost=1N∑t=1Nρ(c^t(kt)−log⁡Ct),(26)\mathcal{L}_{\mathrm{cost}}=\frac{1}{N}\sum_{t=1}^{N}\rho\left(\hat{c}_t(k_t)-\log C_t\right), \tag*{(26)}

where ρ(⋅)\rho(\cdot) is the SmoothL1 loss. The throughput head is trained with

Ltps=1N∑t=1Nρ(τ^t(kt)−log⁡(1+TPSt)).(27)\mathcal{L}_{\mathrm{tps}}=\frac{1}{N}\sum_{t=1}^{N}\rho\left(\hat{\tau}_t(k_t)-\log(1+\mathrm{TPS}_t)\right). \tag*{(27)}

Utility regression The utility head is trained by comparing its prediction for each observed state-action pair with the corresponding trace-derived label:

Lutil=1N∑t=1Nρ(U^D(st,mt,kt)−uD,t).(28)\mathcal{L}_{\mathrm{util}}=\frac{1}{N}\sum_{t=1}^{N}\rho\left(\hat{U}_D(s_t,m_t,k_t)-u_{D,t}\right). \tag*{(28)}

Thus, the same predicted score used to select depths at inference is directly supervised during training.

Candidate ranking Deployment depends on the ordering of candidate depths, as well as the accuracy of their predicted utilities. We therefore group observed candidate rows by prompt, speculative method, and block index. For a group gg, let KgK_g denote the depths present, and let uD,g(k)u_{D,g}(k) denote the observed utility label at depth kk. Writing sg,ks_{g,k} for that row’s pre-block state and mgm_g for the group’s method, its predicted score is

U^D,g(k)=U^D(sg,k,mg,k).(29)\hat{U}_{D,g}(k)=\hat{U}_D(s_{g,k},m_g,k). \tag*{(29)}

The preferred depth is

kg+=arg⁡max⁡k∈KguD,g(k).(30)k_g^{+} = \arg\max_{k \in K_g} u_{D,g}(k). \tag*{(30)}

The ranking loss is

Lrank=−1∣G∣∑g∈Glog⁡exp⁡(U^D,g(kg+))∑k∈Kgexp⁡(U^D,g(k)).(31)\mathcal{L}_{\mathrm{rank}} = -\frac{1}{|\mathcal{G}|} \sum_{g \in\mathcal{G}} \log\frac{\exp(\hat{U}_{D,g}(k_g^{+}))}{\sum_{k \in K_g} \exp(\hat{U}_{D,g}(k))}. \tag*{(31)}

where G\mathcal{G} is the set of rank groups. This term encourages the depth with the highest observed training utility in each group to receive the highest predicted score.

Combined objective The depth controller is trained with

LD=λsLsurv+λcLcost+λvLtps+λuLutil+λrLrank.(32)\mathcal{L}_{D} = \lambda_s \mathcal{L}_{\mathrm{surv}} + \lambda_c \mathcal{L}_{\mathrm{cost}} + \lambda_v \mathcal{L}_{\mathrm{tps}} + \lambda_u \mathcal{L}_{\mathrm{util}} + \lambda_r \mathcal{L}_{\mathrm{rank}}. \tag*{(32)}

In our implementation, the default loss weights are

(λs,λc,λv,λu,λr)=(1.00,0.20,0.30,1.00,1.00).(33)(\lambda_s,\lambda_c,\lambda_v,\lambda_u,\lambda_r) = (1.00, 0.20, 0.30, 1.00, 1.00). \tag*{(33)}

APEX Variants

We train three APEX variants with identical architectures, features, candidate-depth interfaces, data, and deployment procedures; only the utility weights in Equation equation 25 differ, producing distinct speed–waste operating points.

APEX-S (Speed) uses (αA,αW,αG,αM)=(0.20,0.20,0.20,0.15)(\alpha_A,\alpha_W,\alpha_G,\alpha_M) = (0.20, 0.20, 0.20, 0.15) and places greater relative emphasis on throughput competitiveness. The default APEX-B (Balanced) uses (0.30,0.35,0.15,0.20)(0.30, 0.35, 0.15, 0.20) to balance throughput, accepted progress, and waste. APEX-E (Efficient) uses (0.40,0.50,0.10,0.25)(0.40, 0.50, 0.10, 0.25) and assigns a larger penalty to waste. These weights specify training preferences; they do not guarantee that every profile is Pareto-efficient or that APEX-E always has the lowest waste. Additional ablations are reported in § 5.3.

Online Deployment

At inference, the router selects the speculative expert m⋆m^\star and initial depth k0⋆k_0^\star. After each verifier block, APEX updates its causal state with observed outcomes, scores every candidate depth in KK, and selects the next block’s depth. The controller adapts its actions using the evolving state; its network parameters remain fixed during generation.

Algorithm 1 summarizes this procedure. Here, SpeculateAndVerify drafts a block using the selected mechanism, applies target-model verification, and records the execution outcomes. It returns the emitted output Δyt\Delta y_t and observations ot=(Lt,Rt,Wt,Ct,TPSt)o_t = (L_t, R_t, W_t, C_t, \mathrm{TPS}_t). The output extends the prefix, while the observations update the history used for the next decision.

Results and Discussion

We evaluate whether APEX can maintain substantial inference acceleration while reducing discarded draft tokens relative to fixed speculative configurations. We first examine aggregate performance and workload-specific trade-offs, then study the contributions of individual controller components and the sensitivity to the candidate-depth set.

Experimental Setup

Target model and serving system We implement APEX in vLLM with Qwen3-8B as the target verifier. All evaluated methods use the same target model, allowing us to compare the acceleration and draft-token utilization achieved by different proposal mechanisms, fixed depths, and adaptive controller profiles.

Algorithm 1 APEX Online Speculative Decoding
Require: Prompt $x$, decoding configuration $c_{\mathrm{decode}}$, target model $p_{\theta}$, initial actions $A_R$, depths $\mathcal{K}$
1: $s_0 \leftarrow \operatorname{RequestState}(x, c_{\mathrm{decode}})$
2: $(m^\star, k_0^\star) \leftarrow \underset{(m,k_0)\in A_R}{\arg\max}\ \widehat{U}_R(s_0,m,k_0)$
3: $h_0 \leftarrow \varnothing$, $y \leftarrow \varnothing$
4: for $t = 1, 2, \ldots$ until generation completes do
5: $c_t \leftarrow x \mathbin\Vert y$
6: $s_t \leftarrow \operatorname{State}(s_0,c_t,h_{t-1})$
7: if $t = 1$ then
8: $k_t \leftarrow k_0^\star$
9: else
10: $k_t \leftarrow \underset{k\in\mathcal{K}}{\arg\max}\ \widehat{U}_D(s_t,m^\star,k)$
11: end if
12: $(\Delta y_t,o_t) \leftarrow \operatorname{SpeculateAndVerify}(p_\theta,m^\star,k_t,c_t)$
13: $y \leftarrow y \mathbin\Vert \Delta y_t$
14: $h_t \leftarrow \operatorname{Update}(h_{t-1},o_t)$
15: end for
16: return $y$

Workloads and datasets We evaluate six workloads: code generation using MBPP [2] and HumanEval [6]; conversational generation using UltraChat-200k [8]; long-chain reasoning using GPQA [22]; long-context completion using The Stack Smol [13]; software engineering using SWE-bench Lite [12]; and mathematical reasoning using GSM8K [7] and AIME-style data [20]. We follow the dataset-provided splits for training and evaluation.

Baselines and operating profiles We compare APEX with autoregressive decoding and fixed-depth EAGLE-3, n-gram, and draft-model speculation (Draft-SD). The fixed-depth sweep considers k∈{1,2,4,8,16}k \in\{1, 2, 4, 8, 16\}. We evaluate all three APEX operating profiles: APEX-S, APEX-B, and APEX-E.

Metrics We measure wall-clock latency speedup relative to autoregressive decoding as

Speedup=LatencyARLatencymethod(34)\mathrm{Speedup} = \frac{\mathrm{Latency}_{\mathrm{AR}}}{\mathrm{Latency}_{\mathrm{method}}} \tag*{(34)}

Values above one indicate lower end-to-end latency. We also report wasted draft-token percentage,

Waste%=100×Rejected Draft TokensTotal Draft Tokens(35)\mathrm{Waste}\% = 100 \times\frac{\mathrm{Rejected\ Draft\ Tokens}}{\mathrm{Total\ Draft\ Tokens}} \tag*{(35)}

which measures the fraction of proposed tokens discarded during speculation.

To summarize the speed–waste trade-off, we report Waste-Amortized Speedup (WAS):

WAS=SpeedupWaste%/100.(36)\mathrm{WAS} = \frac{\mathrm{Speedup}}{\mathrm{Waste}\%/100}. \tag*{(36)}

Speedup and waste are averaged over the evaluated requests, and WAS is computed from the corresponding unrounded averages. Higher WAS is better, but we interpret it alongside latency speedup and waste to retain the distinction between these outcomes. A configuration is Pareto-efficient if no alternative is at least as fast and no more wasteful, with a strict improvement in at least one metric.

Overall Results

Table 1 reports aggregate performance, and Figure 4 visualizes the same measurements as speedup versus the percentage of non-wasted draft tokens. APEX-S achieves the highest reported aggregate speedup of 4.27×4.27\times with 55.30% waste. The fastest fixed baseline, n-gram speculation at k=16k = 16, reaches 4.22×4.22\times speedup with 79.90% waste. Thus, APEX-S slightly improves the reported speedup while reducing the wasted-token percentage by 30.8% relative to this baseline.

Figure 4. Speedup vs Token Wastage. The plot shows the trend of Speedup (vs AR) vs Token Wastage across different depths and mechanisms. The horizontal axis reports non-wasted draft tokens (100 − Waste%), and the vertical axis reports speedup over autoregressive decoding.

APEX-B provides a different operating point, achieving 3.27×3.27\times speedup with 47.17% waste. Relative to n-gram speculation at k=16k = 16, this corresponds to a 41.0% reduction in the wasted-token percentage, at the cost of lower acceleration. APEX-S and APEX-B obtain the highest aggregate WAS values of 7.73 and 6.93, respectively, compared with the best fixed-baseline WAS of 5.64 from n-gram speculation at k=8k = 8.

The fixed baselines illustrate why speed and waste must be considered jointly. Increasing n-gram depth from k=8k = 8 to k=16k = 16 raises speedup from 3.59×3.59\times to 4.22×4.22\times, but increases waste from 63.56% to 79.90%, reducing WAS from 5.64 to 5.28. EAGLE-3 reaches its highest aggregate speedup at k=4k = 4; increasing its depth to k=16k = 16 reduces speedup from 2.35×2.35\times to 1.37×1.37\times while raising from 66.25% to 97.67%. Conversely, Draft-SD at k=2k = 2 has only 27.82% waste but achieves 0.96× speedup. Efficient draft-token utilization alone therefore does not ensure lower end-to-end latency.

The three learned profiles also require separate evaluation. APEX-E achieves 1.83× speedup with 63.69% waste and is outperformed by both APEX-S and APEX-B on both metrics. Its efficiency-oriented objective does not produce the lowest aggregate waste, highlighting the importance of evaluating the realized behavior of each profile across workloads.

Performance Across Workloads

The workload-level results reveal where adaptive control improves both speed and utilization, where it offers a trade-off, and where a fixed configuration remains preferable.

Mathematical reasoning. Table 3 shows the strongest acceleration achieved by APEX. APEX-S reaches 5.24× speedup with 47.00% waste, while APEX-B achieves 5.16× speedup with 44.00% waste. Both improve speed and reduce waste relative to the fastest fixed baseline, n-gram speculation at k=8k = 8, which achieves 4.15×4.15\times speedup with 60.62%60.62\% waste. APEX-B obtains the highest WAS of 11.72, retaining nearly the acceleration of APEX-S while discarding fewer draft tokens.

MethodDepthSpeedup vs. AR ↑Wasted Token % ↓WAS ↑
EAGLE-3k=2k = 21.55×72.50%2.14
k=4k = 42.50×62.50%4.00
k=8k = 83.22×72.25%4.46
k=16k = 162.05×93.44%2.19
n-gram SDk=2k = 21.89×55.50%3.41
k=4k = 42.85×53.75%5.30
k=8k = 84.15×60.62%6.84
k=16k = 163.74×82.88%4.51
Draft-SDk=2k = 20.99×28.22%3.51
k=4k = 40.86×41.46%2.07
k=8k = 80.66×59.84%1.10
k=16k = 160.43×75.66%0.57
APEX-Sadaptive5.24×47.00%11.15
APEX-Badaptive5.16×44.00%11.72
APEX-Eadaptive2.43×72.90%3.33

Table 3. Workload-level speed–waste comparison for mathematical reasoning.

Conversational generation. A similar improvement appears in Table 6. APEX-S achieves 4.88×4.88\times speedup with 51.50%51.50\% waste, compared with 4.63×4.63\times and 54.63%54.63\% for n-gram speculation at k=8k = 8. APEX-B reduces waste further to 46.56%46.56\% while achieving 4.15×4.15\times speedup. Increasing the fixed n-gram depth to k=16k = 16 worsens both speed and waste, showing that deeper speculation is not uniformly beneficial even within a workload where n-gram proposals are effective.

MethodDepthSpeedup vs. AR ↑\uparrowWasted Token % ↓\downarrowWAS ↑\uparrow
EAGLE-3k=2k = 21.78×1.78\times61.00%2.92
EAGLE-3k=4k = 42.35×2.35\times66.25%3.55
EAGLE-3k=8k = 82.61×2.61\times79.88%3.27
EAGLE-3k=16k = 161.21×1.21\times98.69%1.23
n-gram SDk=2k = 21.84×1.84\times58.00%3.17
n-gram SDk=4k = 43.05×3.05\times48.75%6.26
n-gram SDk=8k = 84.63×4.63\times54.63%8.48
n-gram SDk=16k = 163.20×3.20\times86.25%3.71
Draft-SDk=2k = 20.91×0.91\times29.03%3.13
Draft-SDk=4k = 40.75×0.75\times43.01%1.74
Draft-SDk=8k = 80.58×0.58\times61.95%0.94
Draft-SDk=16k = 160.36×0.36\times77.78%0.46
APEX-Sadaptive4.88×4.88\times51.50%9.48
APEX-Badaptive4.15×4.15\times46.56%8.91
APEX-Eadaptive1.29×1.29\times74.03%1.74

Table 6. Workload-level speed–waste comparison for conversational generation.

Long-context completion. Table 4 presents a different trade-off. N-gram speculation at k=16k = 16 remains the fastest configuration at 6.40×6.40\times speedup with 66.25%66.25\% waste. APEX-S achieves 5.04×5.04\times speedup while reducing waste to 49.50%49.50\%, yielding a higher WAS of 10.18 versus 9.66. This benefit does not extend to every learned profile: n-gram speculation at k=4k = 4 is both faster and less wasteful than APEX-B and APEX-E.

MethodDepthSpeedup vs. AR ↑\uparrowWasted Token % ↓\downarrowWAS ↑\uparrow
EAGLE-3k=2k = 21.59×1.59\times70.50%70.50\%2.262.26
EAGLE-3k=4k = 41.89×1.89\times77.75%77.75\%2.432.43
EAGLE-3k=8k = 80.51×0.51\times99.02%99.02\%0.520.52
EAGLE-3k=16k = 161.26×1.26\times98.38%98.38\%1.281.28
n-gram SDk=2k = 21.22×1.22\times37.41%37.41\%3.263.26
n-gram SDk=4k = 43.32×3.32\times34.50%34.50\%9.629.62
n-gram SDk=8k = 82.03×2.03\times61.53%61.53\%3.303.30
n-gram SDk=16k = 166.40×6.40\times66.25%66.25\%9.669.66
Draft-SDk=2k = 20.89×0.89\times38.16%38.16\%2.342.34
Draft-SDk=4k = 41.08×1.08\times33.24%33.24\%3.243.24
Draft-SDk=8k = 81.07×1.07\times25.68%25.68\%4.174.17
Draft-SDk=16k = 160.87×0.87\times41.10%41.10\%2.122.12
APEX-Sadaptive5.04×5.04\times49.50%49.50\%10.1810.18
APEX-Badaptive1.83×1.83\times44.42%44.42\%4.124.12
APEX-Eadaptive2.72×2.72\times41.05%41.05\%6.636.63

Table 4. Workload-level speed–waste comparison for long-context completion.

Long-chain reasoning. In Table 5, n-gram speculation at k=16k = 16 achieves the highest speedup of 4.57×4.57\times but wastes 77.69% of drafted tokens. APEX-B achieves 3.07×3.07\times speedup with 40.59% waste, obtaining the highest WAS of 7.56. Here, adaptive control offers substantially better draft-token utilization while retaining acceleration over autoregressive decoding.

MethodDepthSpeedup vs. AR ↑\uparrowWasted Token % ↓\downarrowWAS ↑\uparrow
EAGLE-3k=2k = 21.46×1.46\times77.00%77.00\%1.901.90
EAGLE-3k=4k = 42.13×2.13\times71.75%71.75\%2.972.97
EAGLE-3k=8k = 81.64×1.64\times92.00%92.00\%1.781.78
EAGLE-3k=16k = 161.37×1.37\times97.69%97.69\%1.401.40
n-gram SDk=2k = 21.70×1.70\times65.00%65.00\%2.622.62
n-gram SDk=4k = 42.46×2.46\times63.50%63.50\%3.873.87
n-gram SDk=8k = 83.57×3.57\times67.88%67.88\%5.265.26
n-gram SDk=16k = 164.57×4.57\times77.69%77.69\%5.885.88
Draft-SDk=2k = 20.98×0.98\times27.79%27.79\%3.533.53
Draft-SDk=4k = 40.84×0.84\times41.58%41.58\%2.022.02
Draft-SDk=8k = 80.68×0.68\times59.04%59.04\%1.151.15
Draft-SDk=16k = 160.42×0.42\times75.18%75.18\%0.560.56
APEX-Sadaptive3.92×3.92\times63.50%63.50\%6.176.17
APEX-Badaptive3.07×3.07\times40.59%40.59\%7.567.56
APEX-Eadaptive1.89×1.89\times58.12%58.12\%3.253.25

Table 5. Workload-level speed–waste comparison for long-chain reasoning.

Software-engineering tasks. Table 7 shows that APEX-S achieves 3.15×3.15\times speedup with 48.12% waste. N-gram speculation at k=16k = 16 is faster at 4.15×4.15\times, but its waste rises to 80.31%. APEX-S consequently achieves the highest WAS of 6.55, compared with 5.17 for that baseline. It also achieves both higher speedup and lower waste than APEX-B and APEX-E on this workload.

MethodDepthSpeedup vs. AR ↑\uparrowWasted Token % ↓\downarrowWAS ↑\uparrow
EAGLE-3k=2k = 21.67×1.67\times66.50%2.51
EAGLE-3k=4k = 42.45×2.45\times63.75%3.84
EAGLE-3k=8k = 80.98×0.98\times99.39%0.99
EAGLE-3k=16k = 161.24×1.24\times98.50%1.26
n-gram SDk=2k = 21.76×1.76\times62.00%2.84
n-gram SDk=4k = 42.50×2.50\times62.50%4.00
n-gram SDk=8k = 82.62×2.62\times76.53%3.42
n-gram SDk=16k = 164.15×4.15\times80.31%5.17
Draft-SDk=2k = 21.02×1.02\times20.47%4.98
Draft-SDk=4k = 40.90×0.90\times32.70%2.75
Draft-SDk=8k = 80.81×0.81\times46.89%1.73
Draft-SDk=16k = 160.54×0.54\times66.06%0.82
APEX-Sadaptive3.15×3.15\times48.12%6.55
APEX-Badaptive2.54×2.54\times51.21%4.96
APEX-Eadaptive2.17×2.17\times50.23%4.32

Table 7. Workload-level speed–waste comparison for swe-style tasks.

Code generation. Code generation exposes a limitation of the learned controller (Table 2). N-gram speculation at k=16k = 16 achieves 4.25×4.25\times speedup and a WAS of 5.33, exceeding all three APEX profiles on these metrics. The limitation also appears in direct speed–waste comparisons: n-gram speculation at k=8k = 8 is both faster and less wasteful than APEX-S, while EAGLE-3 at k=4k = 4 is both faster and less wasteful than APEX-B. These results identify code generation as a setting where improved routing and utility calibration are needed.

MethodDepthSpeedup vs. AR ↑Wasted Token % ↓WAS ↑
EAGLE-3k=2k = 22.11×44.50%4.74
k=4k = 42.78×55.50%5.01
k=8k = 82.01×87.38%2.30
k=16k = 161.27×98.31%1.29
n-gram SDk=2k = 22.08×46.00%4.52
k=4k = 42.31×67.25%3.43
k=8k = 83.47×69.13%5.02
k=16k = 164.25×79.69%5.33
Draft-SDk=2k = 21.00×22.06%4.53
k=4k = 40.90×33.74%2.67
k=8k = 80.71×51.88%1.37
k=16k = 160.49×69.30%0.71
APEX-Sadaptive2.80×76.00%3.68
APEX-Badaptive1.99×56.83%3.50
APEX-Eadaptive0.99×75.50%1.31

Table 2. Workload-level speed–waste comparison for code generation.

Ablation Study

We examine the contributions of survival supervision, cost and throughput supervision, and decoding-state features in Table 8. This study uses a smaller diagnostic subset containing twenty requests from each of the six workloads, for a total of 120 requests. All variants are evaluated on the same requests under the same serving configuration. Ablation effects are measured relative to the corresponding full controller on this subset; the absolute values therefore differ from the main evaluation.

Table 8: Ablation study across operating profiles. Each variant removes one component from the corresponding full APEX controller. Speedup is measured relative to autoregressive decoding AR=1.00×

ProfileVariantSpeedupWaste %WAS
APEX-SFull APEX-S2.44×2.44\times59.22 %4.12
APEX-Sw/o survival loss1.62×1.62\times68.16 %2.37
APEX-Sw/o cost/TPS objective2.41×2.41\times62.69%3.85
APEX-Sw/o entropy features2.49×2.49\times62.41 %3.99
APEX-Sw/o repetition features2.42×2.42\times62.22 %3.89
APEX-Sw/o verifier-history features1.14×1.14\times54.74 %2.09
APEX-EFull APEX-E2.34×2.34\times52.85 %4.43
APEX-Ew/o survival loss1.56×1.56\times67.62 %2.31
APEX-Ew/o cost/TPS objective2.26×2.26\times57.83 %3.91
APEX-Ew/o entropy features2.31×2.31\times58.06 %3.98
APEX-Ew/o repetition features2.29×2.29\times58.12 %3.94
APEX-Ew/o verifier-history features1.31×1.31\times56.48 %2.32
APEX-BFull APEX-B2.40×2.40\times54.62 %4.39
APEX-Bw/o survival loss1.53×1.53\times69.38 %2.21
APEX-Bw/o cost/TPS objective2.33×2.33\times57.83 %4.03
APEX-Bw/o entropy features2.35×2.35\times58.34 %4.03
APEX-Bw/o repetition features2.30×2.30\times58.45 %3.94
APEX-Bw/o verifier-history features1.14×1.14\times56.22 %2.03

Table 8.

Full-controller profiles. Among the full controllers, APEX-S achieves the highest speedup of 2.44×2.44\times with 59.22% waste. APEX-B achieves 2.40×2.40\times speedup with 54.62% waste, while APEX-E achieves 2.34×2.34\times speedup with 52.85% waste and the highest WAS of 4.43. The profile ordering differs from the aggregate evaluation, further illustrating its dependence on the evaluated requests.

Survival supervision. Removing the survival loss produces the largest increase in waste among the examined ablations for all three profiles. Waste rises to 67.62%–69.38%, speedup falls to 1.53×1.53 \times–1.62×1.62 \times, and WAS decreases to 2.21–2.37. These results support the role of first-rejection survival supervision in selecting depths that convert drafted tokens into accepted progress.

Cost and throughput supervision. Removing the cost/TPS objective causes smaller speed reductions but consistently increases waste and lowers WAS. For APEX-B, waste increases from 54.62% to 57.83%, while WAS decreases from 4.39 to 4.03. The results support accounting for runtime cost alongside acceptance behavior when comparing candidate actions.

Entropy and repetition features. Removing either feature group increases waste and reduces WAS across all three profiles. The effect on raw speedup is smaller and is not uniformly negative. For example, removing entropy features from APEX-S increases speedup from 2.44×2.44 \times to 2.49×2.49 \times, but also increases waste from 59.22% to 62.41%, lowering WAS from 4.12 to 3.99. These features therefore contribute primarily to the observed speed–waste balance.

Verifier-history features. Removing recent verifier feedback produces the largest speed reductions, with speedup falling to 1.14×1.14 \times–1.31×1.31 \times and WAS to 2.03–2.32. For APEX-S, waste actually decreases from 59.22% to 54.74%, but speedup falls from 2.44×2.44 \times to 1.14×1.14 \times. This illustrates why lower waste alone is insufficient and supports using recent acceptance and rejection outcomes to guide block-level decisions.

Sensitivity to Candidate Depths

Table 9 reports a separate comparison of three candidate-depth sets across all APEX profiles: Kdense={1,…,16}\mathcal{K}_{\mathrm{dense}} = \{1,\ldots,16\}, Kdeep={3,…,16}\mathcal{K}_{\mathrm{deep}} = \{3,\ldots,16\}, and Ksparse={2,4,8,12,16}\mathcal{K}_{\mathrm{sparse}} = \{2,4,8,12,16\}. The dense set permits fine-grained choices, the deep set removes the two shallowest actions, and the sparse set reduces the number of available depths.

Table 9: APEX candidate-kk sweep under the quality-balanced operating profile. Higher speedup and WAS are better; lower wasted-token percentage is better.

MethodCandidate kk setMean kkSpeedup vs. ARWasted Token %WAS
APEX-Sk=1k = 1–163.613.34×3.34\times47.18%7.07
APEX-Sk=3k = 3–164.543.43×3.43\times50.57%6.79
APEX-Sk∈{2,4,8,12,16}k \in\{2, 4, 8, 12, 16\}3.923.39×3.39\times47.95%7.06
APEX-Bk=1k = 1–163.093.25×3.25\times42.76%7.60
APEX-Bk=3k = 3–164.283.34×3.34\times48.55%6.89
APEX-Bk∈{2,4,8,12,16}k \in\{2, 4, 8, 12, 16\}3.573.31×3.31\times45.10%7.33
APEX-Ek=1k = 1–162.961.56×1.56\times59.88%2.61
APEX-Ek=3k = 3–164.131.60×1.60\times67.83%2.35
APEX-Ek∈{2,4,8,12,16}k \in\{2, 4, 8, 12, 16\}3.401.58×1.58\times62.85%2.52

Table 9.

Removing shallow actions increases the mean selected depth and slightly improves speedup across all three profiles, but also increases waste and reduces WAS. For APEX-B, moving from the dense to the deep set raises speedup from 3.25×3.25 \times to 3.34×3.34 \times, while waste increases from 42.76% to 48.55% and WAS decreases from 7.60 to 6.89. Shallow actions therefore contribute to controlling waste even when excluding them produces a modest speed gain.

The sparse set provides an intermediate operating point. For APEX-S, it achieves 3.39×3.39 \times speedup with 47.95% waste, compared with 3.34×3.34 \times and 47.18% for the dense set. Their WAS values are nearly identical at 7.06 and 7.07. APEX-B and APEX-E also retain acceleration under the sparse set, although their WAS values remain below those obtained with the dense set. These results show that fine-grained depth choices are not equally important for every profile, while access to shallow actions consistently improves the measured speed–waste balance in this study.

Discussion

The results support adaptive speculative control while establishing its workload-dependent limits. APEX-S provides the highest aggregate speedup, and APEX-B offers lower aggregate waste at reduced acceleration. Mathematical reasoning and conversational generation show simultaneous improvements over the fastest fixed baselines, while other workloads expose trade-offs or favor fixed configurations. The ablations support combining survival supervision, runtime-cost supervision, and recent verifier feedback. Together, these findings motivate evaluating speculative controllers through both latency and draft-token utilization, with profile selection guided by the workload and the desired operating point.

Conclusion and Future Work

APEX combines request-level speculator selection with block-level depth adaptation to balance decoding speed and draft-token waste. Its learned controller provides a modular way to coordinate heterogeneous proposal mechanisms while preserving target-model verification. The results demonstrate strate substantial acceleration with lower waste than aggressive fixed-depth configurations, with trade-offs that vary across workloads.

Future work will use traces collected during decoding to update the controller online as workloads and execution conditions change. We also plan to evaluate APEX beyond single-turn prompts, including multi-turn conversations, reinforcement-learning rollouts, and tool-augmented generation. These settings would test how well the controller responds to changes in context and generation patterns over successive steps. To expand beyond the current three speculative methods, we plan to add a common interface for new speculators and their execution traces. The router and depth controller could then be retrained on these traces to incorporate the additional methods.

References

  1. [1]Amey Agrawal et al. Taming throughput-latency tradeoff in llm inference with sarathi-serve. In 18th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2024.arxiv.org/abs/2403.02310
  2. [2]Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Jiang Ellen, Carrie J Cai, Michael Terry, Quoc V Le, and Charles Sutton. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.arxiv.org/abs/2108.07732
  3. [3]Shrenik Bhansali and Larry Heck. Draft, verify, and improve: Toward training-aware speculative decoding, 2025. URL https://arxiv.org/abs/2510.05421.
  4. [4]Tianle Cai, Yuhong Li, Zhengyang Geng, Hongwu Peng, Jason D. Lee, Deming Chen, and Tri Dao. Medusa: Simple llm inference acceleration framework with multiple decoding heads, 2024. URL https://arxiv.org/abs/2401.10774.
  5. [5]Charlie Chen, Sebastian Borgeaud, Geoffrey Irving, Jean-Baptiste Lespiau, Laurent Sifre, and John Jumper. Accelerating large language model decoding with speculative sampling, 2023. URL https://arxiv.org/abs/2302.01318.
  6. [6]Mark Chen et al. Evaluating large language models trained on code, 2021.arxiv.org/abs/2107.03374
  7. [7]Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Rejchiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems, 2021.arxiv.org/abs/2110.14168
  8. [8]Ning Ding, Yulin Chen, Bokai Xu, Yujia Qin, Zhi Zheng, Shengding Hu, Zhiyuan Liu, Maosong Sun, and Bowen Zhou. Enhancing chat language models by scaling high-quality instructional conversations, 2023. URL https://arxiv.org/abs/2305.14233.
  9. [9]Zhenyu He, Zexuan Zhong, Tianle Cai, Jason D. Lee, and Di He. Rest: Retrieval-based speculative decoding, 2024. URL https://arxiv.org/abs/2311.08252.
  10. [10]Yunlong Hou, Fengzhuo Zhang, Cunxiao Du, Xuan Zhang, Jiachun Pan, Tianyu Pang, Chao Du, Vincent Y. F. Tan, and Zhuoran Yang. Banditspec: Adaptive speculative decoding via bandit algorithms, 2025. URL https://arxiv.org/abs/2505.15141.
  11. [11]Yuxuan Hu, Ke Wang, Xiaokang Zhang, Fanjin Zhang, Cuiping Li, Hong Chen, and Jing Zhang. Sam decoding: Speculative decoding via suffix automaton, 2024. URL https://arxiv.org/abs/2411.10666.
  12. [12]Carlos E Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik R Narasimhan. SWE-bench: Can language models resolve real-world github issues? In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=VTF8yNQM66.arxiv.org/abs/2310.06770
  13. [13]Denis Kocetkov, Raymond Li, Loubna Ben Allal, Jia Li, Chenghao Mou, Carlos Muñoz Ferrandis, Yacine Jernite, Margaret Mitchell, Sean Hughes, Thomas Wolf, Dzmitry Bahdanau, Leandro von Werra, and Harm de Vries. The stack: 3 tb of permissively licensed source code. ArXiv, abs/2211.15533, 2022. URL https://api.semanticscholar.org/CorpusID:254044610.arxiv.org/abs/2211.15533
  14. [14]Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention, 2023a. URL https://arxiv.org/abs/2309.06180.
  15. [15]Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th Symposium on Operating Systems Principles (SOSP), pp. 611–626. ACM, 2023b.arxiv.org/abs/2309.06180
  16. [16]Yaniv Leviathan, Matan Kalman, and Yossi Matias. Fast inference from transformers via speculative decoding, 2023. URL https://arxiv.org/abs/2211.17192.
  17. [17]Yuhui Li, Fangyun Wei, Chao Zhang, and Hongyang Zhang. Eagle-3: Scaling up inference acceleration of large language models via training-time test, 2025a. URL https://arxiv.org/abs/2503.01840.
  18. [18]Yuhui Li, Fangyun Wei, Chao Zhang, and Hongyang Zhang. Eagle: Speculative sampling requires rethinking feature uncertainty, 2025b. URL https://arxiv.org/abs/2401.15077.
  19. [19]Jonathan Mamou, Oren Pereg, Daniel Korat, Moshe Berchansky, Nadav Timor, Moshe Wasserblat, and Roy Schwartz. Dynamic speculation lookahead accelerates speculative decoding of large language models, 2024. URL https://arxiv.org/abs/2405.04304.
  20. [20]Mathematical Association of America. American invitational mathematics examination (aime), 1983. URL https://maa.org.
  21. [21]Xupeng Miao, Gabriele Oliaro, Zhihao Zhang, Xinhao Cheng, Zeyu Wang, Zhengxin Zhang, Rae Ying Yee Wong, Alan Zhu, Lijie Yang, Xiaoxiang Shi, Chunan Shi, Zhuoming Chen, Daiyaan Arfeen, Reyna Abhyankar, and Zhihao Jia. Specinfer: Accelerating large language model serving with tree-based speculative inference and verification. In Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 3, ASPLOS ’24, pp. 932–949. ACM, April 2024. doi: 10.1145/3620666.3651335. URL http://dx.doi.org/10.1145/3620666.3651335.
  22. [22]David Rein, Betty Li Hou, Asa Cooper Stickland, Jackson Petty, Richard Yuanzhe Pang, Julien Dirani, Julian Michael, and Samuel R. Bowman. Gpqa: A graduate-level google-proof q&a benchmark, 2023. URL https://arxiv.org/abs/2311.12022.
  23. [23]Dale Schuurmans, Hanjun Dai, and Francesco Zanini. Autoregressive large language models are computationally universal, 2024. URL https://arxiv.org/abs/2410.03170.
  24. [24]Heming Xia, Tao Ge, Peiyi Wang, Si-Qing Chen, Furu Wei, and Zhifang Sui. Speculative decoding: Exploiting speculative execution for accelerating seq2seq generation. In Houda Bouamor, Juan Pino, and Kalika Bali (eds.), Findings of the Association for Computational Linguistics: EMNLP 2023, pp. 3909–3925, Singapore, December 2023. Association for Computational Linguistics. doi: 10.18653/v1/2023.findings-emnlp.257. URL https://aclanthology.org/2023.findings-emnlp.257/.DOI
  25. [25]Mingyu Yang, Jae-Young Choi, Kihyo Moon, Minsung Jang, and EunJoo Jeon. Dsde: Dynamic speculative decoding with kld stability for real-world serving, 2025. URL https://arxiv.org/abs/2509.01083.
  26. [26]Situo Zhang, Hankun Wang, Da Ma, Zichen Zhu, Lu Chen, Kunyao Lan, and Kai Yu. Adaeagle: Optimizing speculative decoding via explicit modeling of adaptive draft structures, 2024. URL https://arxiv.org/abs/2412.18910.
  27. [27]Xiandong Zou, Jianshu Li, Jing Huang, and Pan Zhou. Variational speculative decoding: Rethinking draft training from token likelihood to sequence acceptance, 2026. URL https://arxiv.org/abs/2602.05774.

Paper details

vlnc:W_gscdmny9
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

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

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents