Faster Cascades via Speculative Decoding

## Abstract

Abstract Cascades and speculative decoding are two common approaches to improving language models’ inference efficiency.
Both approaches
involve
interleaving models of different sizes,
but via fundamentally distinct mechanisms:
cascades employ a deferral rule that invokes the larger model only for “hard” inputs,
while speculative decoding uses speculative execution to primarily invoke the larger model in parallel verification mode.
These mechanisms offer different benefits: empirically, cascades offer better cost-quality trade-offs, often even outperforming the large model, while theoretically, speculative decoding offers a guarantee of quality-neutrality.
In this paper, we leverage the best of both these approaches by designing new speculative cascading techniques that implement their deferral rule through speculative execution. We characterize the optimal deferral rule for our speculative cascades, and employ a plug-in approximation to the optimal rule.
Experiments with Gemma and T5 models on a range of language benchmarks show that our approach yields better cost-quality trade-offs than cascading and speculative decoding baselines.

## 1 Introduction

Large language models (LLMs) have yielded significant advances in quality on a range of natural language processing tasks (Radford et al., ; Raffel et al., ; Brown et al., ; Black et al., ; Chowdhery et al., ; Wei et al., ; Chung et al., ; Tay et al., ; Anil & et al., ; Touvron et al., ; Team et al., ), at the cost of an
increase in inference latency.
This has sparked a growing body of literature on reducing LMs’ inference costs without (overly) compromising
on quality (Elbayad et al., ; Pope et al., ; Schuster et al., ; Leviathan et al., ; Chen et al., ; Sheng et al., ; Sun et al., ).
One such line of work involves constructing a family of models of various sizes (e.g., a small and large model), and suitably orchestrating amongst them to make a prediction.
Two canonical instantiations of this strategy are *model cascading* (Wang et al., ; Mamou et al., ; Varshney & Baral, ; Khalili et al., ; Dohan et al., ; Chen et al., ; Gupta et al., ; Ding et al., ) and *speculative decoding* (Stern et al., ; Chen et al., ; Leviathan et al., ; Sun et al., ; Li et al., ; Xia et al., ).

While similar in spirit,
cascades and speculative decoding are fundamentally different in details.
Cascades
employ a *deferral rule* to identify “hard” inputs,
and only invoke larger models on such inputs.
For example,
in a two-model cascade, one first invokes the smaller model, and uses its associated probability of the generated output to decide whether to defer to the larger model.
By contrast,
speculative decoding
uses a small model to *draft* a block of tokens via standard auto-regressive decoding, which are then *verified* in parallel by a large model.
One
then accepts all drafted tokens until the first “implausible” one,
which is rolled back
based on
the larger LM’s prediction.

Owing to their different mechanisms, both methods have complementary strengths.
Cascades seek to output distributions that have the best quality for a given cost budget,
and potentially provide better cost-quality trade-offs, sometimes even
yielding better accuracies than the individual models they are constructed with (Jitkrittum et al., ; Kim et al., ) (§3).
By contrast,
speculative decoding is theoretically guaranteed to match the output distribution (or a close approximation thereof (Tran-Thien, )), and are practically observed to provide impressive speed-ups (Stern et al., ; Chen et al., ; Leviathan et al., ; Sun et al., ).
Given the complementary nature of these two approaches, a natural question arises: *can we leverage the best of both techniques?*

In this paper, we do so by designing new
techniques for two-model cascades
that implement their deferral rule in a speculative manner:
we have the smaller model generate drafts auto-regressively, and the larger model execute in parallel on the drafts to decide *whether or not to defer on them*. We show that this *speculative cascading* approach yields better
cost-quality trade-offs than both standard cascades and speculative decoding. In detail, we make the following contributions:

- (i)
We introduce a general recipe for speculative execution, where we seek to mimic a general *target* distribution that interleaves the drafter’s and verifier’s distributions.
Lossy speculative sampling (Tran-Thien, ) is a special case of
this recipe
for a particular target distribution (§4.1).
- (ii)
We show how common cascading rules,
such as Chow’s rule (Chow, ) and confidence-difference thresholding (Jitkrittum et al., ),
can be implemented speculatively by plugging in their target distribution into our framework. We refer to these as *speculative cascades* (§4.2).
- (iii)
We characterize the *theoretically optimal* deferral rule for a speculative cascade, and design a speculative cascading technique that implements a plug-in estimate to the optimal rule (§4.3, Lemma 4, Table 1). We also present token-specific variants of our deferral rules (§4.4).
- (iv)
Through experiments with
Gemma (Team et al., ) and T5 models (Raffel et al., ) on a range of benchmark language tasks including summarization, translation, reasoning, coding and QA, we show that speculative cascades are able to provide better cost-quality trade-offs than their sequential cascade and speculative decoding counterparts (§6).

## 2 A Tale of Two Efficient LM Inference Strategies

Let $\mathscr{V}$ denote a finite vocabulary of *tokens*,
with $\mathscr{V}^{*}$ denoting the set of all *sequences* generated by this vocabulary.
Let $\Delta_{\mathscr{V}}$ denote the set of all probability distributions over tokens in $\mathscr{V}$.
Given an arbitrary length sequence $x=x_{1}x_{2}\ldots x_{L}\in\mathscr{V}^{*}$ and index $i\leq L$, denote by $x_{<i}=x_{1}x_{2}\ldots x_{i-1}$.
A *language model* (LM)
is a
probability distribution over $\mathscr{V}^{*}$.
Let $\mathbb{P}$ denote the ground-truth probability distribution over $\mathscr{V}^{*}$. This could be, for example, a distribution over prompt-response pairs
that the LM may encounter during deployment, or a distribution of sequences used to pre-train the LM.
We will measure the quality of an LM based on how closely it mimics $\mathbb{P}$.

Suppose we are provided two LMs $q$ and $p$,
where $p$ is the larger (more expensive)
model. Our goal is to design an inference strategy that selectively invokes $q$ and $p$ to trade-off between quality and latency (which may be approximated by the fraction of times that $p$ is invoked).
We will denote by $q(x_{t}|x_{<t})$ the probability $q$ associates to token $x_{t}\in\mathscr{V}$ given prefix
$x_{<t}\in\mathscr{V}^{t-1}$, and by $p(x_{t}|x_{<t})$
the same distribution from model $p$. Whenever it is clear from context, we will hide the conditioning on prefix $x_{<t}$, and use the shorthand $p_{t}(\cdot)$ for $p(\cdot|x_{<t})$ and $q_{t}(\cdot)$ for $q(\cdot|x_{<t})$.

Cascades
are an effective strategy to trade-off cost and quality by having the smaller model $q$ handle the “easy” samples,
and the larger model $p$ handle the “hard” ones (Gupta et al., ; Yue et al., ). A common cascading approach is confidence thresholding or Chow’s rule (Chow, ; Jitkrittum et al., ),
where we first run $q$ on the input, and defer to $p$ when $q$’s confidence for its generated response is sufficiently low. This strategy is typically
implemented at the *sequence-level*, where for a given prefix $x_{<m}$ we invoke $q$ to generate a complete response $x_{m}\ldots x_{m+n}$. We evaluate $q$’s predicted probability for the response, and check whether it falls below a threshold $\alpha\in[0,1]$:

$$ $\displaystyle\textstyle q(x_{m}\ldots x_{m+n}\,|\,x_{<m})<1-\alpha.$ (1) $$

If the above holds,
we defer to $p$ to generate a new response;
otherwise,
we retain $q$’s response. One may tune the threshold to achieve a desired cost-quality trade-off. The literature also offers variants of Chow’s rule that use a more nuanced aggregation of *per-token* uncertainties (Gupta et al., ).

Speculative decoding
is an alternate strategy that applies *token-level* interleaving between $q$ and $p$,
resulting in *provably* matching the larger model quality at a reduced inference cost (Stern et al., ; Leviathan et al., ).
Given a prefix $x_{<t}$, we
*draft* $\gamma$ draft tokens $x_{t},\ldots,x_{t+\gamma-1}$ via auto-regressive sampling from $q$,
and *verify* if these tokens can be accepted
by
running $p$ in parallel on the $\gamma$ prefixes $x_{<t},\ldots,x_{<t+\gamma-1}$.
We then rollback to the first rejected token $t+j^{*}$ (where $j^{*}\in\{0,1,\ldots,\gamma-1\}$), replace $x_{t+j^{*}}$
with a new token, and repeat the process with prefix $x_{<t+j^{*}+1}$.

During the verification stage, a draft token $x_{t+j}$ generated by $q$ is accepted
with probability
$\min\left(1,\frac{p_{t+j}(x_{t+j})}{q_{t+j}(x_{t+j})}\right)$
and rejected otherwise,
recalling the shorthand
$q_{t+j}(\cdot)=q(\cdot|x_{<t+j})$ and $p_{t+j}(\cdot)=p(\cdot|x_{<t+j})$.
A rejected token is then replaced by a new token sampled from a modified distribution
$\operatorname{norm}\left(\max\left\{0,\,p_{t+j}(\cdot)-q_{t+j}(\cdot)\right\}
\right),$
where $\text{norm}(\cdot)$
denotes normalization to sum to 1.
This sampling process is
provably
equivalent to sampling $\gamma$ tokens auto-regressively from $p$ for prefix $x_{<t}$ (Leviathan et al., ).
We summarize this speculative sampling procedure in Algorithm 1.
Each invocation of this algorithm generates
at most $\gamma+1$ next tokens (and at least one)
color=RoyalBlue!35!white]and at least $1$? Hari: done!
for a given prefix $x_{<t}$. One may run this algorithm multiple times to generate a complete output sequence.

In practice, one may employ a lossy variant (Tran-Thien, ) of the above sampling that allows some *deviation* from verifier’s distribution $p$. In this case, a draft token $x_{t+j}$ is accepted
with probability
$\min\left(1,\frac{p_{t+j}(x_{t+j})}{(1-\alpha)\cdot q_{t+j}(x_{t+j})}\right)$,
where $\alpha\in[0,1)$ is a strictness parameter, with higher values indicating greater deviation from $p$.
A rejected token may then be replaced by a token sampled from the residual distribution
$\operatorname{norm}\left(\max\left\{0,\,\frac{1}{\beta}\cdot p_{t+j}(\cdot)-q_
{t+j}(\cdot)\right\}\right),$
where $\beta\geq 1-\alpha$ is a parameter that depends on $\alpha$, $q$ and $p$.
A common heuristic is to simply set $\beta=1$ (Zhou et al., ).

**Table 1: Target distributions associated with different inference algorithms, where $\alpha$ is a free parameter and $\beta\geq 1-\alpha$ depends on $\alpha$, $q$ and $p$. The last column indicates whether the execution is sequential (Algorithm 2), via an oracle (Algorithm 3), or speculative (Algorithm 5) (Leviathan et al., ). See (6) for details on $\delta$. The third row presents a variant of the BiLD algorithm of Kim et al. (), where $D(q,p)$ is a measure of discrepancy between $q$ and $p$; the original algorithm differs in the use of a deterministic speculative decoding procedure with a dynamic draft window (see §5).**
| Inference strategy | Deferral decision $\delta(q,p)$ | Target distribution $\pi(x)$ | Execution |
| --- | --- | --- | --- |
| SpecDecoding (Leviathan et al., ) | - | $p(x)$ | Speculative |
| Lossy SpecDecoding (Tran-Thien, ) | - | $\max\{\min\{q(x),\frac{p(x)}{1-\alpha}\},\frac{p(x)}{\beta}\}$ | Speculative |
| BiLD* (Kim et al., ) | $\bm{1}\big{(}\,D(q,p)>\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| TokenCascade [Chow] (Chow, ) | $\bm{1}\big{(}\max_{v}q(v)<1-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Sequential |
| Oracle [Diff] (Jitkrittum et al., ) | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Oracle |
| SpecCascade [Chow] | $\bm{1}\big{(}\max_{v}q(v)<1-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [Diff] | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [OPT] | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\cdot D_{\textrm{TV}}(p,q)\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |

## 3 Cascades Meet Speculative Decoding

Both cascades and speculative decoding interleave models of different sizes to reduce inference cost, but fundamentally differ in the mechanisms they use.
As a step towards comparing the strengths and weaknesses of these approaches, we first
describe how one may design a *token-level cascade*.

### 3.1 Warm-up: Token-level cascades

It is straightforward to extend
the sequence-level
Chow’s rule from §2 to form a *token-level cascade* between $q$ and $p$. For a prefix $x_{<t}$, we first compute the smaller model’s distribution $q(\cdot|x_{<t})$, and check whether $\max_{v\in\mathscr{V}}\,q(v|x_{<t})$ is below a pre-chosen threshold.
if so,
we evaluate $p(\cdot|x_{<t})$, and sample $x_{t}\sim p(\cdot|x_{<t})$;
otherwise,
we sample
$x_{t}\sim q(\cdot|x_{<t})$.

More generally, we may design a token-level *deferral rule* ${r}:\mathscr{V}^{t-1}\rightarrow\{0,1\}$ that takes the prefix $x_{<t}$ as input and outputs a binary decision, with ${r}(x_{<t})=1$ indicating that we
defer to $p$ (i.e., draw a sample from $p$ rather than $q$).
For example, token-level Chow’s rule can be written as:

$$ $\displaystyle\textstyle{r}_{\rm\tt Chow}(x_{<t})=1\leavevmode\nobreak\ \iff \leavevmode\nobreak\ \max_{v\in\mathscr{V}}\,q(v|x_{<t})<1-\alpha,$ (2) $$

where $\alpha$ is a threshold parameter;
the higher the value, the lower is the frequency of deferral to $p$.
One may also use other confidence measures than the maximum probability, such as the entropy of the small model’s probability distribution.
We elaborate in §B
that the choice of confidence measure would depend on the evaluation metric of interest; Equation 2
is typically prescribed when the cascade’s quality
is evaluated in terms of its accuracy against the ground-truth distribution on individual tokens, whereas entropy is prescribed when the metric of interest is the cross-entropy loss.

### 3.2 Optimal token-level cascade deferral

While Chow’s rule equation 2 is easy to implement,
it can be sub-optimal if the smaller model’s max-token probability is not reflective of which of the two models are better equipped to predict the next token for a given prefix (Jitkrittum et al., ).
Given this, it is natural to ask what the *optimal* deferral rule $r$ for a token-cascade looks like,
and whether we can reasonably approximate this rule.

For this, we must first specify an objective to minimize at each step $t$.
Following the prior cascade literature (Jitkrittum et al., ; Gupta et al., ), a reasonable objective to minimize is the expected loss from the deferral rule against the ground-truth distribution
$\mathbb{P}$,
with an added cost for deferring to the larger model. We state this below for a fixed prefix $x_{<t}$,
using as before
color=RoyalBlue!35!white]“using once more”? Hari: done!
the short-hand $q_{t}(\cdot)$ for $q(\cdot|x_{<t})$ and $p_{t}(\cdot)$ for $p(\cdot|x_{<t})$:

$$ $\displaystyle L_{\rm def}(r;x_{<t})$ $\displaystyle=\mathbb{E}_{v\sim\mathbb{P}(\cdot|x_{<t})}\Big{[}\big{(}1-r(x_{< t})\big{)}\cdot\ell(v,q_{t})+r(x_{<t})\cdot\big{(}\ell(v,p_{t})+\alpha\big{)} \Big{]},$ (3) $$

for a cost penalty $\alpha\geq 0$
and loss function $\ell:\mathscr{V}\times\Delta_{\mathscr{V}}\rightarrow\mathbb{R}_{+}$.
Common choices for $\ell$ include the 0-1 loss $\ell_{\text{0-1}}(v,q_{t})=\bm{1}\left(v\neq\operatorname*{arg\,max}_{v^{
\prime}}q_{t}(v^{\prime})\right)$ and the log loss $\ell_{\log}(v,q_{t})=-\log\left(q_{t}(v)\right).$

###### Lemma 1 (Optimal deferral for token-level cascades (Jitkrittum et al., 2023 ) ) .

The minimizer of equation 3 is of the form:

$$ $\displaystyle r^{*}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{v\sim\mathbb{P}(\cdot|x_ {<t})}\left[\ell(v,q_{t})\right]\,>\,\mathbb{E}_{v\sim\mathbb{P}(\cdot|x_{<t}) }\left[\ell(v,p_{t})\right]+\alpha.$ (4) $$

Intuitively, we compare the expected loss from $q$ with the expected cost of invoking $p$, and decide to defer when the latter is smaller.
We note here that this optimization problem is set up for a *fixed* prefix $x_{<t}$. One may also consider the coupled optimization problem across all positions.

*Plug-in estimator for equation 4.* The optimal rule in equation 4 requires computing expectations over the ground-truth distribution $\mathbb{P}(\cdot|x_{>t})$, which is not available during inference time.
A common approach in the cascades literature is to replace the expected losses with the models’ confidence estimates (Jitkrittum et al., ). For example, when $\ell=\ell_{\text{0-1}}$, it may be reasonable to use $1-\max_{v}q_{t}(v)$ as an estimate of the expected 0-1 loss $\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell_{\text{0-1}}(x_{t},q_
{t})\right]$ and $1-\max_{v}p_{t}(v)$ as an estimate of $\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell_{\text{0-1}}(x_{t},q_
{t})\right]$. The extent to which these estimates are accurate depend on how well $q$ and $p$ are calibrated (Guo et al., ). The resulting plug-in estimator
for (4) thresholds the difference of confidence estimates from both distributions:

$$ $\displaystyle\textstyle{\hat{r}_{\rm\tt Diff}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak\ \leavevmode\nobreak\ \max_{v}q_{ t}(v)\,<\,\max_{v}p_{t}(v)-\alpha.}$ (5) $$

Similarly, when $\ell=\ell_{\log}$, we may use the entropy $-\sum_{v}q_{t}(v)\cdot\log(q_{t}(v))$ from $q_{t}$ as an estimate of its expected log-loss, and similarly for $p_{t}$ (see Appendix C).

###### Remark 1 ( Oracle deferral rules ) .

For efficiency reasons,
$\hat{r}_{\rm\tt Diff}$ cannot be directly used in a *token-level* cascade,color=green!30!white]“to improve efficiency”? We can if we want quality, right? Hari: yep, added a clarification
as it needs the large model to be invoked at every step $t$.
However, it serves as an *oracle* that allows to analyze the head-room available to improve upon Chow’s rule.
See also Remark 2.

###### Lemma 1 (Optimal deferral for token-level cascades (Jitkrittum et al., 2023 ) ) .

###### Remark 1 ( Oracle deferral rules ) .

### 3.3 Contrasting token-level cascade and speculative decoding trade-offs

Token-level cascades and
speculative decoding differ in the distribution over tokens they seek to mimic. Speculative decoding seeks to mimic the large model’s output distribution, and is usually used when one wants to match the quality of the large model.
On the other hand, token-level cascades seek to output distributions that closely approximate the ground-truth label distribution and potentially offer good cost-quality trade-offs, sometimes yielding better quality than even the large model.

Cascades are useful when the draft model fares better than the verifier on some inputs, and one may want to retain the drafter’s predictions even when it disagrees with the verifier. Even in cases where both the drafter and verifier fare poorly on some inputs (e.g., due to label noise), one may want to ignore the disagreement between the drafter and verifier to avoid triggering unnecessary roll-backs.

As a concrete example, we consider token-level cascades of T5 models (Raffel et al., ) of two different sizes finetuned on a WMT EN $\rightarrow$ DE translation Bojar et al. () and an extreme summarization (XSum) task (Narayan et al., ). We construct these cascades using both
(token-level)
Chow’s rule in equation 2 and the oracle Diff rule in equation 5, and also apply speculative decoding with the smaller (larger) model as the drafter (verifier). In Figure 1, we plot quality as a function of fraction of samples deferred to the large model (number of deferrals divided by number of generated tokens), as we vary the cost parameter $\alpha$.
Note that with speculative decoding, each verification stepcolor=green!30!white]Minor: worth explicitly mentioning $\gamma$ tokens are verified in parallel.
verifies $\gamma$ tokens in parallel, but
is counted as a single deferral to the large model.
While speculative decoding matches the quality of the large model (right-most point), the oracle yields significantly better
cost-qualty trade-offs.
Even Chow’s rule, which is sub-optimal for cascading (Jitkrittum et al., ), offers better trade-offs, and
outperforms speculative decoding in a small region.color=cyan]But does this small improvement comes at some added cost? E.g., higher latency? – Okay, we seem to be discussing this in the following program. But should we breifly allude to this in the caption of Figure 1 as well? Hari: done! As noted by Kim et al. (), this may be attributed to the ensembling effect in a cascade.
color=RoyalBlue!35!white]the caption refers to “deferral rate”, but the x-axis says “Fraction of calls”. Hari: changed this as per next comment!
color=RoyalBlue!35!white]maybe the x-axis could be more explicit, like “# large-model calls / # generated tokens”. Hari: done!

However, as also evident from the plots, token-level cascades require a significantly larger number of deferrals to the large model to achieve the same quality.
This is because token-level cascades are executed *sequentially*: whenever $q$ defers, we execute $p$ once to generate one next token for the prefix accumulated so far, and the control transfers back to $q$. In contrast, speculative decoding runs $p$ in *scoring* mode to verify $\gamma$ draft tokens from $q$ in parallel. Moreover, the stochastic verification algorithm in speculative decoding often results in fewer tokens from $q$ getting rejected compared to the deterministic deferral rules used in a cascade. These observations motivate a natural question: *given their complementary strengths, how can we leverage the best of both these techniques?*

Figure: Figure 1: Plots of quality as a function of the number of deferrals to the larger model divided by the total number of generated tokens for cascades constructed from T5 models (under temperature sampling with $T=1$). The left-most point represents the small model and the right-most represents the large model. We compare token-level cascades constructed with Chow’s rule (Chow) and an oracle deferral rule (Diff), and speculative decoding with block size $\gamma=5$. With a cascade, each call to the large model yields exactly one token, whereas with speculative decoding, a single call scores $\gamma$ draft tokens in parallel. While speculative decoding matches the quality of the large model (see dashed horizontal line), the oracle deferral rule yields significantly better quality on a range of deferral rates; this however comes at the cost of higher number of deferrals to the large model.
Refer to caption: x1.png

## 4 Speculative Cascades: Leveraging the Best of Both Worlds

In addressing the above question, we present our main contribution: a principled approach to combining the better trade-offs cascades offer with the faster execution of speculative decoding.

### 4.1 Speculative decoding with general target distributions

We begin by considering a generic version of speculative sampling that seeks to mimic a *general* target distribution derived from the drafter’s and verifier’s distributions.
In the proposed sampling procedure outlined in Algorithm 4, we sample tokens auto-regressively as before from the drafter’s distribution. During the verification step, however, we do not compare the drafter’s token probabilities against the verifier’s distribution. Instead, we use a user-specified target distribution $\pi=\mathbb{T}(q,p)\in\Delta_{\mathscr{V}}$ derived from the drafter’s and verifier’s distributions at position $t$, for some function $\mathbb{T}(\cdot,\cdot)$ that is inexpensive to compute.
We accept a draft token $x_{t}$ when $q(x_{t})\leq\pi(x_{t})$ and reject it otherwise with probability $1-\frac{\pi(x_{t})}{q(x_{t})}$. Upon rejection, we re-sample from the residual distribution $\operatorname{norm}\left(\max\{0,\pi(\cdot)-q(\cdot)\}\right)$.

This general procedure not only encompasses standard speculative decoding (Leviathan et al., ) for $\mathbb{T}(q,p)=p$, but also includes lossy speculative decoding (Tran-Thien, ) as a special case:

###### Lemma 2 .

Algorithm 4 reduces to the lossy speculative sampling procedure in (Tran-Thien, ) with parameters $\alpha$ and $\beta$ when $\mathbb{T}(q,p)(v)=\max\{\min\{q(v),\frac{p(v)}{1-\alpha}\},\frac{p(v)}{\beta}\}$.

###### Lemma 2 .

### 4.2 From sequential to speculative cascades

Equipped with Algorithm 4, we now propose new cascading techniques that implement their deferral rule in a speculative manner. Recall
from §3.1
that a
token-level
cascade of two models $q$ and $p$ is defined by a deferral rule $r:\mathscr{V}^{t-1}\rightarrow\{0,1\}$.
For a prefix $x_{<t}$, the next-token distribution at position $t$ modeled by this cascade can be written as:

$$ $\pi(v)=(1-r(x_{<t}))\cdot q_{t}(v)+r(x_{<t})\cdot p_{t}(v).$ $$

In fact, for all the deferral rules described in §2, the resulting distribution can be described by a target distribution function $\mathbb{T}_{\delta}$ of the form:

$$ $\mathbb{T}_{\delta}(q,p)(v)=(1-\delta(q,p))\cdot q(v)+\delta(q,p)\cdot p(v),$ (6) $$

for some function $\delta:\Delta_{\mathscr{V}}\times\Delta_{\mathscr{V}}\rightarrow\{0,1\}$ that maps distributions $(q,p)$ to a binary decision. For example, for Chow, $\delta(q,p)=\bm{1}\big{(}\max_{v}q(v)<1-\alpha\big{)}$, and for Diff, $\delta(q,p)=\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\big{)}.$ See Table 1 for a summary of target distributions for different deferral rules. color=green!30!white]Table 1 is referred to for the first time here. But it is placed a few pages back. Hari: added a ref in the contributions list

Our proposal is to then invoke the speculative sampling procedure in Algorithm 4 with $\mathbb{T}_{\delta}$ as the target distribution function.
We outline this generic *speculative cascading* approach in Algorithm 5, and contrast it with the sequential execution of a deferral rule in Algorithm 2.

###### Remark 2 ( Exact implementation of oracle deferral rule Diff ) .

In a sequential cascade, the large model’s distribution $p$ cannot be used color=green!30!white]Saying that $p$ is not available may confuse some readers. “using $p$ defeats the purpose of a cascade”? Hari: done! at the time the deferral decision is made (see Remark 1), as this would defeat the purpose of the cascade. With a speculative cascade, however, we can employ rules like Diff that depend on both $q$ and $p$. This is because we run the large model $p$ in parallel on drafts generated by the small model $q$, allowing us to compute both $p(\cdot)$ and $q(\cdot)$ on every prefix.

So far we have considered deferral rules designed for sequential cascades. In what follows, we derive the optimal deferral rule $r$ for a speculative cascade, where we sample speculatively from a target distribution $\pi=(1-r(x_{<t}))\cdot q_{t}+r(x_{<t})\cdot p_{t}$ using $q_{t}$ as the drafter.

Figure: Algorithm 1 SpecDecode

###### Remark 2 ( Exact implementation of oracle deferral rule Diff ) .

### 4.3 Optimal speculative cascade deferral

As with sequential cascades (§2), we begin by defining an objective to minimize. We seek a deferral rule $r:\mathscr{V}^{t-1}\rightarrow\{0,1\}$ that minimizes a loss against the ground-truth distribution, while limiting the inference cost to be within a budget.
(Per above, this deferral rule implicitly defines a target distribution $\pi$.)
The inference cost crucially depends on how frequently a draft token is rejected in the verification phase, triggering a rollback.
To this end, we derive the probability that a token sampled from $q$ is rejected during verification, for a target distribution resulting from a deferral rule $r$.color=RoyalBlue!35!white]nit, in Section 3 we did not keep a separate section on “deferral risk for token-level cascades”. Hari: combined with next section!

###### Lemma 3 .

For a given prefix $x_{<t}$, and target distribution $\pi=(1-r(x_{<t}))\cdot q_{t}+r(x_{<t})\cdot p_{t}$,color=green!30!white]$\pi_{t}$? the probability of a token drawn from draft distribution $q_{t}$ being rejected is equal to:
$r(x_{<t})\cdot D_{\textup{{TV}}}(p_{t},q_{t}),$
where $D_{\textup{{TV}}}(p,q)=\sum_{v\in\mathscr{V}}\max\{0,p(v)-q(v)\}$ is the *TV* distance between $p$ and $q$.

Intuitively, whenever $r(x_{<t})=0$, $\pi(v)=q_{t}(v)$, and therefore there is no rejection or roll-back; when $r(x_{<t})=1$, the rejection rate equals $D_{\textup{{TV}}}(p_{t},q_{t})$.

For a fixed prefix $x_{<t}$, we formulate the goal of finding a solution to:

$$ $\displaystyle\min_{r}$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{v\sim \mathbb{P}(\cdot|x_{<t})}\Big{[}\big{(}1-r(x_{<t})\big{)}\cdot\ell(v,q_{t})+r( x_{<t})\cdot\ell(v,p_{t})\big{)}\Big{]}\hskip 2.84544pt\text{s.t.}\leavevmode \nobreak\ \leavevmode\nobreak\ r(x_{<t})\cdot D_{\textrm{TV}}(p_{t},q_{t})\, \leq\,B,$ (7) $$

for some budget $B>0$. Equivalently, one may minimize an unconstrained objective similar to equation 3,
for suitable cost parameter $\alpha>0$ (see §C.4):

$$ $\displaystyle L_{\rm spec}(r;x_{<t})$ $\displaystyle=\mathbb{E}_{v\sim\mathbb{P}(\cdot|x_{<t})}\big{[}\big{(}1-r(x_{< t})\big{)}\cdot\ell(v,q_{t})+r(x_{<t})\cdot\big{(}\ell(v,p_{t})+\alpha\cdot D_ {\textrm{TV}}(p_{t},q_{t})\big{)}\big{]},$ (8) $$

Contrasting equation 8color=green!30!white]nit: sometimes we use "equation 3". Sometimes we use (3). with the deferral risk in equation 3 for a sequential cascade, a key difference is that the cost of deferring to the larger model is *no longer a constant*, but depends on the similarity between $q_{t}$ and $p_{t}$, as measured by the TV distance between them.

color=RoyalBlue!35!white]nit, have we used the phrase “speculative deferral” in the text? what about “optimal speculative cascade deferral”?. Hari: done!
We next derive the optimal deferral rule for equation 8, and construct a feasible estimator for it.

###### Lemma 4 (Optimal deferral for speculative cascades) .

The minimizer of equation 8 is of the form:

$$ $\displaystyle r^{*}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{v\sim\mathbb{P}(\cdot|x_ {<t})}\left[\ell(v,q_{t})\right]\,>\,\mathbb{E}_{v\sim\mathbb{P}(\cdot|x_{<t}) }\left[\ell(v,p_{t})\right]+\alpha\cdot D_{\textup{{TV}}}(p_{t},q_{t}).$ (9) $$

When $p_{t}$ and $q_{t}$ are similar, the rejection rate for $q_{t}$ is low, and hence the deferral decision will depend largely on which of the two models yields a lower expected loss. When $p_{t}$ and $q_{t}$ are very different, the optimal decision is to defer to $p_{t}$ only when it yields a substantially lower loss than $q_{t}$.

*Plug-in estimator for equation 9.*
The optimal rule requires estimating expectations with respect the ground-truth distribution $\mathbb{P}(\cdot|x_{<t}).$ We employ similar plug-in estimators as the ones used with sequential cascades (§3). When $\ell=\ell_{\text{0-1}}$, we replace the expected 0-1 loss with (one minus) the maximum probability from the model, giving us:

$$ $\displaystyle\textstyle{\hat{r}_{\rm\tt OPT}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak\ \leavevmode\nobreak\ \max_{v}q_{ t}(v)\,<\,\max_{v}p_{t}(v)-\alpha\cdot D_{\textup{{TV}}}(p_{t},q_{t}).}$ (10) $$

The efficacy of the plug-in estimator depends on how closely the individual models approximate the ground-truth distribution $\mathbb{P}(\cdot|x_{<t})$; this is formalized by the following regret bound:

###### Lemma 5 (Regret bound for $\hat{r}_{\rm\tt OPT}$ ) .

Suppose $\ell=\ell_{\emph{\text{0-1}}}$. Then for a fixed prefix $x_{<t}$:

$$ $\displaystyle L_{\rm spec}(\hat{r}_{\rm\tt OPT};x_{<t})-\min_{r}\,L_{\rm spec} (r;x_{<t})\leavevmode\nobreak\ \leq\leavevmode\nobreak\ \max_{v\in\mathscr{V}} \big{|}\mathbb{P}(v|x_{<t})-q_{t}(v)\big{|}\,+\,\max_{v\in\mathscr{V}}\big{|} \mathbb{P}(v|x_{<t})-p_{t}(v)\big{|}.$ $$

One can now run the speculative cascading procedure in Algorithm 5 using equation 10 as the deferral rule; the corresponding $\delta(\cdot)$ is listed in Table 1. See §C.2 for a similar derivation for $\ell=\ell_{\log}$.

###### Lemma 3 .

###### Lemma 4 (Optimal deferral for speculative cascades) .

###### Lemma 5 (Regret bound for r ^ 𝙾𝙿𝚃 subscript ^ 𝑟 𝙾𝙿𝚃 \hat{r}_{\rm\tt OPT} over^ start_ARG italic_r end_ARG start_POSTSUBSCRIPT typewriter_OPT end_POSTSUBSCRIPT ) .

### 4.4 Token-specific speculative cascades

The plug-in deferral rules
in (5) and (10)
decide between the drafter’s distribution $q_{t}(\cdot)$ and the verifier’s distribution $p_{t}(\cdot)$ by comparing their maximum token probabilities. A downside to this approach is that the draft token $x_{t}\sim q_{t}(\cdot)$ may not
maximize
$q_{t}(\cdot)$.
Thus, even when $x_{t}$ is of poor quality, we may end up accepting it because $q_{t}$ happens to be *more peaked* than $p_{t}$.

To alleviate this problem, we propose the use of *token-specific deferral rules* $r:\mathscr{V}^{t-1}\times\mathscr{V}\rightarrow\{0,1\}$
that use both the prefix $x_{<t}$ and a candidate token $v$ to provide a binary decision $r(x_{<t},v)\in\{0,1\}$, with 0 indicating that the token is of acceptable quality. We may then construct a target distribution of the following form:

$$ $\displaystyle\pi_{\rm\tt Token}(v)=q_{t}(v)\cdot(1-r(x_{<t},v))+p_{t}(v)\cdot\eta,$ (11) $$

where $\eta=\sum_{v^{\prime}\in\mathscr{V}}r(x_{<t},v^{\prime})\cdot q_{t}(v^{\prime})$ is a normalizing term chosen to ensure that $\sum_{v}\pi_{\tt Token}(v)=1$. This target distribution closely mimics $q_{t}(\cdot)$ on tokens that the deferral rule $r$ deems to be of acceptable quality, and defers to $p_{t}(\cdot)$ otherwise.
One can modify the generic speculative sampling algorithm in Algorithm 4 to use $\pi_{\tt Token}$ as the target distribution, as shown in Algorithm 6 in §D.

To design $r$, we propose a heuristic variant of the Diff rule in equation 4 that compares the expected 0-1 loss from the candidate token $v$ with the expected 0-1 loss from distribution $p_{t}$ (in §D, we discuss deriving a similar variant of the OPT rule in equation 9):
color=RoyalBlue!35!white]the reviewer may wonder how these relate to Equations 4 and 9. Hari: added refs to eq 4 and 9.

$$ $\displaystyle r(x_{<t},v)=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ 1-\mathbb{P}(v|x_{<t})\,>\,\mathbb{E }_{v\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell_{\text{0-1}}(v,p_{t})\right]+\alpha,$ (12) $$

for a cost parameter $\alpha$.
The following are some simple plug-in approximations to equation 12:

$$ $\displaystyle\hat{r}_{\rm\tt TokenV1}(x_{<t},v)=1$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak \ \leavevmode\nobreak\ \textstyle q_{t}(v)\,<\,\max_{v^{\prime}}p_{t}(v^{ \prime})-\alpha$ (13) $\displaystyle\hat{r}_{\rm\tt TokenV2}(x_{<t},v)=1$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak \ \leavevmode\nobreak\ \textstyle p_{t}(v)\,<\,\max_{v^{\prime}}p_{t}(v^{ \prime})-\alpha$ (14) $\displaystyle\hat{r}_{\rm\tt TokenV3}(x_{<t},v)=1$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak \ \leavevmode\nobreak\ \textstyle p_{t}(v)\,<\,\max_{v^{\prime}}p_{t}(v^{ \prime})\cdot(1-\alpha),$ (15) $$

where we approximate $\mathbb{P}(v|x_{<t})$ with either $q_{t}(v)$ or $p_{t}(v)$. Equation 15 is a multiplicative plug-in approximation that has similarities to the rejection criterion used by Leviathan et al. () for lossy speculative greedy decoding, and results in an intuitive target distribution:

$$ $\displaystyle\textstyle\pi_{\tt TokenV3}(v)=q_{t}(v)\cdot\bm{1}\big{(}v\in \textup{Top}_{\alpha}\big{)}\,+\,p_{t}(v)\cdot\sum_{v^{\prime}\notin\textup{ Top}_{\alpha}}q_{t}(v^{\prime}),$ $$

where $\textup{Top}_{\alpha}=\{v\in\mathscr{V}:\,p_{t}(v)\,\geq\,\max_{v^{\prime}}p_{
t}(v^{\prime})\cdot(1-\alpha)\}$ is the set of top ranked tokens by $p_{t}(\cdot)$. For these top-ranked tokens, $\pi_{\tt TokenV3}$ approximates $q_{t}(\cdot)$; for the rest, it is a re-scaled version of $p_{t}(\cdot)$.

## 5 Further related work and conclusions

There has been a stream of work on improving
the draft generation process in speculative decoding; these include having the drafter and verifier share the same backbone (Stern et al., ; Kim et al., ; Cai et al., ; Monea et al., ; Hooper et al., ; Zhang et al., ; Elhoushi et al., ; Liu et al., ), using multiple small draft models Chen et al. (); Wang et al. (), using tree-structured draft batches (Spector & Re, ; Miao et al., ), distilling the drafter with the verifier (Zhou et al., ), and leveraging multiple sampled draft candidates Sun et al. ().color=RoyalBlue!35!white]maybe this can come after Experiments? Hari: the problem with doing this is that we reference this section in the expts when pointing to the target distribution for BiLD!

The work that is most closely related to our specific proposal is the Big Little Decoder (BiLD) (Kim et al., ), which can be seen as another lossy variant of speculative decoding (Leviathan et al., ; Tran-Thien, ; Zhou et al., ). BiLD has two phases: a *fallback* phase, during which the drafter $q$ is run auto-regressively until its maximum predicted probability is sufficiently low; and a *rollback* phase, during which the verifier $p$ is run in parallel on the prefixes generated by $q$ and rolls back to the point where $D(q,p)>\alpha$, for a metric $D$ that measures discrepancy
and threshold $\alpha$. The fallback phase implements Chow’s deferral rule in (2), and allows for the draft window size to vary dynamically based on an estimate of how likely the draft tokens will be accepted; the rollback phase can be seen as a deterministic variant of the rejection sampling algorithm of Leviathan et al. ().

An advantage of BiLD over the rejection sampling algorithm in (Leviathan et al., ) is the use of Chow’s rule to vary the draft window size. However, the final target distribution it seeks to mimic, $\mathbb{T}_{\textup{BiLD}}(q,p)(v)=\bm{1}(D(q,p)\leq\alpha)\cdot q(v)+\bm{1}(D
(q,p)>\alpha)\cdot p(v)$, is an approximation to $p$; specifically, the target distribution $\pi=\mathbb{T}_{\textup{BiLD}}(q,p)$ is chosen to satisfy $D(\pi,p)\leq\alpha$. Hence, in cases where $q$ deviates substantially from $p$, BiLD would choose $p$ as the target distribution, even when $q$ offers better quality on a prefix (where quality can be measured using a suitable loss function). In contrast, our proposed approach in §4 uses speculative decoding to approximate target distributions that seek to *optimally* cascade between $q$ and $p$.
In our experiments, we compare the efficacy of using $\mathbb{T}_{\textup{BiLD}}$ as the target distribution with the target distributions we propose in this paper (see Table 1).

Figure: Table 2: Reduction in latency from different methods ($T=1,\gamma=5$) when matching the quality of the large model (cols 2–7), and the best quality metric when matching each method yields without exceeding the latency of the large model (cols 8–13). Quality is measured in terms of the BLEU for WMT and ROUGE-2 for XSum and CNNDM. See Figure 2 for $T=0.5$ and §E.2 for $T=0$.
Refer to caption: x3.png

## 6 Experimental results

We compare our speculative cascading techniques with both sequential cascades and standard speculative decoding on a range of language benchmarks, including translation, reasoning, coding, QA, etc.
We evaluate speculative cascades constructed from both the T5 v1.1 family of encoder-decoder models (Raffel et al., ), and Gemma v2 decoder-only models (Team et al., ).
We construct the cascades with four deferral rules: (i) Chow in (2), (ii) Diff in (5), (iii) OPT in (10), and (iv)
the Token-specific rule in (15) (we present results for the V1 and V2 variants in §E.7).

Cascades versus SpecDecode evaluation. Our evaluation protocol is markedly different from the standard evaluation of speculative decoding algorithms, where the goal is to speed up inference with a large model while preserving its output distribution.
In contrast, our focus is on trading-off quality for lower inference costs by cascading two models of different sizes. color=RoyalBlue!35!white]the “and” seems like it could be a new sentence. it is not related to the point about deviating from the standard SPEED evaluation protocol? Hari: done!
We also
do not claim to develop a new state-of-the-art method for fast LM inference. Furthermore, the speculative cascades we design build on the original speculative decoding algorithm Leviathan et al. (). While one could potentially also adapt our proposal to other recent variants of speculative decoding (Cai et al., ; Li et al., ), these involve a wholly orthogonal suite of techniques to what we propose (such as architectural changes, allowing for multiple drafts, distillation, and so on; see §5).

Baselines. The cascading and speculative decoding methods we compare to include:

- (i)
*Sequence-level cascade* (Jitkrittum et al., ; Gupta et al., ) based on sequence-level Chow’s rule in equation 1 (SeqCascade [Chow]).
- (ii)
*Token-level cascade*
outlined in Algorithm 2, with token-level Chow’s rule in equation 2 used for deferral (Chow, ; Gupta et al., ) (TokenCascade [Chow]).
- (iii)
*Lossy speculative decoding* described in §2, with both $\beta=1$ (Leviathan et al., ; Zhou et al., ) (SpecDecode [Lossy]) and $\beta$ tuned using the procedure in Tran-Thien () (Lossy^⋆).
- (iv)
*Big-Little Decoder approach* (Kim et al., ), with both the original deterministic version (BiLD), and the variant where we apply Algorithm 4 to the target distribution $\mathbb{T}_{\textup{BiLD}}$ in §5 (BiLD^∗).

Fine-tuned T5 cascades.
color=RoyalBlue!35!white]maybe the para heading can explicate fine-tuning here, vs few-shot for Gemma. Hari: done!
Our experiments on T5 models are based on the setup in Zhou et al. (); see §E.1 for details. We use T5-small (77M) as the small model, and either T5-large (800M) or T5-XL (3B) as the large model. In each case, we supervised
fine-tune these models on three tasks: WMT EN$\rightarrow$DE translation (Bojar et al., ), CNN/DM summarization (Hermann et al., ), and XSum abstractive summarization (Narayan et al., ). color=RoyalBlue!35!white]do the latency numbers match what is reported in DistillSpec? Hari: our quality metrics match what they report; I’ll be able to compare with their speed ups once I better understand how they compute relative latency
We use temperatures $T=0,0.1,0.5,1.0$, and block sizes $\gamma=3,5,7$ (full results in §E). Following the protocol in Leviathan et al. (); Zhou et al. (), to measure latency, we evaluate the wall-clock decoding time with batch size 1.

Figure: Figure 3: Plots of quality vs. rejection rate for methods that interleave Gemma 2B with Gemma 27B ($\gamma=1$). We use instruction-tuned models; for MBPP we report additional results with pre-trained models. See §E.7 for remaining plots, comparison to (13–14) and results on 2B $\rightarrow$ 9B cascades.
Refer to caption: x5.png

In Figure 2, we present plots of quality vs. latency for the different methods. In each case, we vary the lenience parameter $\alpha$, and plot either the BLEU or ROUGE-2 metric as a function of the relative latency to the larger model. For brevity, we include the three main baselines; in §E.5–E.6,
we compare to SpecDecode [Lossy^⋆] (Tran-Thien, ) and the original BiLD algorithm Kim et al. ().
Methods that use speculative execution are considerably faster than sequential token-level cascades (TokenCascade [Chow]), although sequential cascades do have an advantage in the low-latency regimes. This is because unlike speculative approaches, which always call the large model after every $\gamma$ steps, a sequential cascade only invokes the large model when the small model defers. color=RoyalBlue!35!white]the legend is a bit hard to make out. we may consider only including two plots per row. Hari: Did this for Fig 2. For Fig 3, I’ve made the font size bigger. Would you like two figures per row for Fig 3 too?
color=RoyalBlue!35!white]further to the above, we may consider the value of including full deferral curves for both T5 and Gemma, versus having a summary like Table 2. Hari: hmm, I think reviewers usually like to see numbers in a tabulated form, especially when it comes to speed-ups

In Table 2,
color=RoyalBlue!35!white]caption should clarify this is for T5. Hari: done!
we report (i) the reduction in latency from T5 cascades when matching the quality of the large model, and (ii) the best quality that each method can deliver without exceeding the latency of the large model. SpecCascade [Token] often yields the highest speed-up and the best quality metrics, with OPT coming in second. The cascading approaches are often seen to fare poorly on both quality and latency metrics, with the exception of WMT, where SeqCascade yields non-trivial speed-ups.color=cyan]Do we need to briefly remind the reader that BiLD* is different from BiLD implementation?
The reason the Token-specific rule fares better than OPT and Diff is because the latter compute their deferral decisions based on which of $q_{t}(\cdot)$ and $p_{t}(\cdot)$ is more peaked; this can be a disadvantage when the sampled token is not close to the distribution mode, which is likely to happen with higher temperatures. As shown in §E.3, with lower temperatures, the gap between these rules diminishes.color=RoyalBlue!35!white]should we also call out the WMT results being sensitive to temperature? Hari: I think this is true of all methods. I’ll be including plots with varying temperatures in the appendix. After I include that, I’ll add a note in the main text.

Few-shot Gemma cascades.
color=RoyalBlue!35!white]what about the MBPP results? Hari: TBD
To evaluate the Gemma model cascades, we use few-shot prompting with 8 language benchmarks: WMT, CNN/DM, GSM8K, MBPP, SQuAD 2.0, WebQuestions, NaturalQA and TriviaQA; many of these feature in the SpecBench suite (Xia et al., ). Figure 3 presents plots of quality vs. rejection rate with a 2B drafter and 27B verifier for $\gamma=1$. For brevity, we only compare the methods that fare the best in the previous experiments. With the exception of TriviaQA, SpecCascade [Token] is able to both match the 27B’s quality at a lower rejection rate and yield the best overall quality, often better than 27B.
Since all three methods use the exact same implementation for speculative execution, a lower rejection rate directly translates to a lower latency.

Interestingly, OPT is not as effective as with T5. We attribute this to the differences in distributions between the two setups: with T5, the maximum token probability served as a good indicator of token accuracy for both $q$ and $p$; with Gemma, we expect the large model to have a closer alignment with the ground-truth distribution (due to it being several billion parameters apart from the smaller model), and hence using the large model probabilities to measure confidence for both the small and large model (15) yields better trade-offs than comparing the modes from the two model distributions.

## 7 Conclusions

We have proposed new speculative cascading techniques that use a combination of auto-regressive drafting and parallel verification to implement their deferral rule, and shown that they yield better cost-quality trade-offs than standard cascades and speculative decoding. A limitation of our approach is that while it offers a higher throughput, it also incurs a higher total compute cost compared to sequential cascades.
In the future, we wish to replace our plug-in estimators
with a router model (Gupta et al., ) trained on ground-truth samples, to improve the local deferral objective at each position $t$ (8) with a global
objective, and to extend our proposal to more than two models.

## Appendix A Proofs

### A.1 Proof of Lemma 1

###### Proof.

Expanding the loss in equation 3, we have:

$$ $\displaystyle L_{\rm def}(r;x_{<t})$ $\displaystyle=\big{(}1-r(x_{<t})\big{)}\cdot\mathbb{E}_{x_{t}\sim\mathbb{P}( \cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]+r(x_{<t})\cdot\big{(}\mathbb{E}_{ x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]+\alpha\big{)}$ $\displaystyle=r(x_{<t})\cdot\left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t} )}\left[\ell(x_{t},p_{t})\right]+\alpha-\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot| x_{<t})}\left[\ell(x_{t},q_{t})\right]\right)\,+\,\mathbb{E}_{x_{t}\sim\mathbb {P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]$ $$

This objective is minimized by a deferral rule $r:\mathscr{V}^{t-1}\rightarrow\{0,1\}$ that minimizes, for each prefix $x_{<t}$, the term within the parenthesis. Therefore the minimizer $r^{*}(x_{<t})=1$ whenever the term within the parenthesis is negative:

$$ $\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]+ \alpha-\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t}) \right]<0,$ $$

and $r^{*}(x_{<t})=0$ otherwise. Re-arranging the terms completes the proof.
∎

###### Proof.

### A.2 Proof of Lemma 2

###### Proof.

The proof follows straight-forwardly from the results in (Tran-Thien, ). Recall from §2 that the lossy speculative decoding procedure of (Tran-Thien, ) accepts a draft token $x$ with probability:

$$ $\kappa(x)=\min\left\{1,\frac{p(x)}{(1-\alpha)\cdot q(x)}\right\},$ (16) $$

and replaces a rejected draft token with a token sampled from the residual distribution:

$$ $p_{\rm res}(x)=\operatorname{norm}\left(\max\left\{0,\,\frac{1}{\beta}\cdot p( x)-q(x)\right\}\right),$ (17) $$

for parameters $\alpha\in[0,1)$ and $\beta\geq 1-\alpha$.

We need to show that running Algorithm 4 with the target distribution:

$$ $\pi(x)=\max\left\{\min\left\{q(x),\frac{p(x)}{1-\alpha}\right\},\frac{p(x)}{ \beta}\right\}$ $$

results in the same acceptance probability equation 16 and residual distribution equation 17.

The acceptance probability for a draft token $x$ when running Algorithm 4 on $\pi$ is given by:

$$ $\kappa^{\pi}(x)=\min\left\{1,\frac{\pi(x)}{q(x)}\right\}.$ $$

The corresponding residual distribution is given by:

$$ $p^{\pi}_{\rm res}(x)=\operatorname{norm}\left(\max\left\{0,\,\pi(x)-q(x)\right \}\right).$ $$

We consider three possible cases:

Case (i): $q(x)>\frac{1}{1-\alpha}\cdot p(x)\geq\frac{1}{\beta}\cdot p(x)$. In this case, $\pi(x)=\frac{1}{1-\alpha}\cdot p(x)$. As a result:

$$ $\kappa^{\pi}(x)=\min\left\{1,\frac{p(x)}{(1-\alpha)\cdot q(x)}\right\}=\kappa( x);$ $$

$$ $\displaystyle p^{\pi}_{\rm res}(x)$ $\displaystyle=\operatorname{norm}\left(\max\left\{0,\,\frac{1}{1-\alpha}\cdot p (x)-q(x)\right\}\right)$ $\displaystyle=0=\operatorname{norm}\left(\max\left\{0,\,\frac{1}{\beta}\cdot p (x)-q(x)\right\}\right)=p_{\rm res}(x).$ $$

Case (ii): $\frac{1}{1-\alpha}\cdot p(x)\geq\frac{1}{\beta}\cdot p(x)>q(x)$. In this case, $\pi(x)=\frac{1}{\beta}\cdot p(x)$. As a result:

$$ $\kappa^{\pi}(x)=\min\left\{1,\frac{p(x)}{\beta\cdot q(x)}\right\}=1=\min\left \{1,\frac{p(x)}{(1-\alpha)\cdot q(x)}\right\}=\kappa(x);$ $$

$$ $\displaystyle p^{\pi}_{\rm res}(x)$ $\displaystyle=\operatorname{norm}\left(\max\left\{0,\,\frac{1}{\beta}\cdot p(x )-q(x)\right\}\right)=p_{\rm res}(x).$ $$

Case (iii): $\frac{1}{1-\alpha}\cdot p(x)\geq q(x)\geq\frac{1}{\beta}\cdot p(x)$. In this case, $\pi(x)=q(x)$. As a result:

$$ $\kappa^{\pi}(x)=1=\min\left\{1,\frac{p(x)}{(1-\alpha)\cdot q(x)}\right\}= \kappa(x);$ $$

$$ $p^{\pi}_{\rm res}(x)=0=\operatorname{norm}\left(\max\left\{0,\,\frac{1}{\beta} \cdot p(x)-q(x)\right\}\right)=p_{\rm res}(x).$ $$

In all three cases, the acceptance probabilities and residual distributions are identical.
∎

###### Proof.

### A.3 Proof of Lemma 3

###### Proof.

Under a target distribution $\pi_{t}$, the probability of a draft token drawn from $q_{t}$ being is rejected is given by (Leviathan et al., ):

$$ rejection probability $\displaystyle=\sum_{v\in\mathscr{V}}q_{t}(v)\cdot\left(1-\min\left\{1,\frac{ \pi_{t}(v)}{q_{t}(v)}\right\}\right)$ $\displaystyle=1-\sum_{v\in\mathscr{V}}\min\left\{q_{t}(v),\pi_{t}(v)\right\}$ $\displaystyle=\sum_{v\in\mathscr{V}}\pi_{t}(v)-\sum_{v\in\mathscr{V}}\min\left \{q_{t}(v),\pi_{t}(v)\right\}$ $\displaystyle=\sum_{v\in\mathscr{V}}\max\left\{0,\pi_{t}(v)-q_{t}(v)\right\}.$ $$

Expanding $\pi$, the rejection probability becomes:

$$ $\text{rejection probability}=\sum_{v\in\mathscr{V}}\max\left\{0,\,(1-r(x_{<t}) )\cdot q_{t}(v)+r(x_{<t})\cdot p_{t}(v)-q_{t}(v)\right\}$ $$

When $r(x_{<t})=1$, we have:

$$ rejection probability $\displaystyle=\sum_{v\in\mathscr{V}}\min\left\{0,\,p_{t}(v)-q_{t}(v)\right\}=D _{\textrm{TV}}(p_{t},q_{t})=r(x_{<t})\cdot D_{\textrm{TV}}(p_{t},q_{t}).$ $$

When $r(x_{<t})=0$, we have:

$$ rejection probability $\displaystyle=0=r(x_{<t})\cdot D_{\textrm{TV}}(p_{t},q_{t}),$ $$

as desired.
∎

###### Proof.

### A.4 Proof of Lemma 4

###### Proof.

Expanding the deferral risk in equation 8, we have:

$$ $\displaystyle L_{\rm spec}(r;x_{<t})$ $\displaystyle=r(x_{<t})\cdot\left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t} )}\left[\ell(x_{t},p_{t})\right]+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})- \mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\right)$ $\displaystyle\hskip 199.16928pt+\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})} \left[\ell(x_{t},q_{t})\right].$ $$

This objective is minimized by a deferral rule $r:\mathscr{V}^{t-1}\rightarrow\{0,1\}$ that minimizes, for each prefix $x_{<t}$, the term within the parenthesis. Therefore the minimizer $r^{*}(x_{<t})=1$ whenever the term within the parenthesis is negative:

$$ $\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]+ \alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot |x_{<t})}\left[\ell(x_{t},q_{t})\right]<0,$ $$

and $r^{*}(x_{<t})=0$ otherwise. Re-arranging the terms completes the proof.
∎

###### Proof.

### A.5 Proof of Lemma 5

For a fixed prefix $x_{<t}$, we can write the deferral risk in equation 8 as:

$$ $\displaystyle L_{\rm spec}(r;x_{<t})$ $\displaystyle=r(x_{<t})\cdot\left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t} )}\left[\ell(x_{t},p_{t})\right]+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})- \mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right] \right)+C,$ $$

where $C$ is a term independent of the deferral rule $r$. Let $r^{*}:\mathscr{V}^{t-1}\rightarrow\{0,1\}$ denote the optimal deferral rule that minimizes $L_{\rm spec}$ for any prefix $x_{<t}$. We then have:

$$ $\displaystyle L_{\rm spec}\left(\hat{r}_{\rm\tt OPT};x_{<t}\right)-L_{\rm spec }\left(r^{*};x_{<t}\right)$ $\displaystyle=\left(\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t})\right)\cdot \left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t}) \right]+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\mathbb{E}_{x_{t}\sim\mathbb{ P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\right).$ $$

Adding and subtracting $\max_{v}q_{t}(v)-\max_{v}p_{t}(v)$ to the term within the second parenthesis, we get:

$$ $\displaystyle L_{\rm spec}\left(\hat{r}_{\rm\tt OPT};x_{<t}\right)-L_{\rm spec }\left(r^{*};x_{<t}\right)$ $\displaystyle=\left(\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t})\right)\cdot \left(\max_{v}q_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\max_{v}p_{t}( v)\right)$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\left(\hat{r}_{\rm\tt OPT}(x_{<t})- r^{*}(x_{<t})\right)\cdot\left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})} \left[\ell(x_{t},p_{t})\right]-\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})} \left[\ell(x_{t},q_{t})\right]-\max_{v}q_{t}(v)+\max_{v}p_{t}(v)\right)$ $\displaystyle=\left(\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t})\right)\cdot \left(\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\max_{v}q_{t}( v)\right)$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\left(\hat{r}_{\rm\tt OPT}(x_{<t})- r^{*}(x_{<t})\right)\cdot\left(\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})} \left[\ell(x_{t},p_{t})\right]-1+\max_{v}p_{t}(v)\right)$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\left(\hat{r}_{\rm\tt OPT}(x_{<t})- r^{*}(x_{<t})\right)\cdot\left(1-\max_{v}q_{t}(v)-\mathbb{E}_{x_{t}\sim\mathbb {P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\right)$ $\displaystyle=\left(\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t})\right)\cdot \left(\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\max_{v}q_{t}( v)\right)$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\left|\hat{r}_{\rm\tt OPT}(x_{<t})- r^{*}(x_{<t})\right|\cdot\left|\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})} \left[\ell(x_{t},p_{t})\right]-1+\max_{v}p_{t}(v)\right|$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\left|\hat{r}_{\rm\tt OPT}(x_{<t})- r^{*}(x_{<t})\right|\cdot\left|1-\max_{v}q_{t}(v)-\mathbb{E}_{x_{t}\sim\mathbb {P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\right|$ $\displaystyle=\underbrace{\left(\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t}) \right)\cdot\left(\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})- \max_{v}q_{t}(v)\right)}_{\text{term}_{1}}$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ +\underbrace{\left|\mathbb{E}_{x_{t} \sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]-1+\max_{v}p_{t}(v) \right|}_{\text{term}_{2}}+\underbrace{\left|1-\max_{v}q_{t}(v)-\mathbb{E}_{x_ {t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\right|}_{\text{ term}_{3}}$ (18) $$

where we have used the fact that
$\left|\hat{r}_{\rm\tt OPT}(x_{<t})-r^{*}(x_{<t})\right|\leq 1.$

We bound each term separately. For the first term, consider two cases: (i) $\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\max_{v}q_{t}(v)\leq
0$ and (ii) $\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})-\max_{v}q_{t}(v)>0$. When (i) holds, $\hat{r}_{\rm\tt OPT}(x_{<t})=1$; so irrespective of whether $r^{*}(x_{<t})$ is 0 or 1,

$$ $\displaystyle\text{term}_{1}$ $\displaystyle\leq\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{t})- \max_{v}q_{t}(v)\leq 0$ $$

When (ii) holds, $\hat{r}_{\rm\tt OPT}(x_{<t})=0$; so irrespective of whether $r^{*}(x_{<t})$ is 0 or 1,

$$ $\displaystyle\text{term}_{1}$ $\displaystyle\leq-\left(\max_{v}p_{t}(v)+\alpha\cdot D_{\textrm{TV}}(p_{t},q_{ t})-\max_{v}q_{t}(v)\right)<0.$ $$

Thus we have:

$$ $\displaystyle\text{term}_{1}\leq 0.$ (19) $$

We next move to the second term. Since $\ell=\ell_{\text{0-1}}$, we have:

$$ $\displaystyle\text{term}_{2}$ $\displaystyle=\left|\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\ell(x _{t},p_{t})\right]-1+\max_{v}p_{t}(v)\right|$ $\displaystyle=\left|\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[1\left (x_{t}\neq\operatorname*{arg\,max}_{v}p_{t}(v)\right)\right]-1+\max_{v}p_{t}(v )\right|$ $\displaystyle=\left|\max_{v}p_{t}(v)-\sum_{x_{t}}\mathbb{P}(x_{t}|x_{<t})\cdot 1 \left(x_{t}=\operatorname*{arg\,max}_{v}p_{t}(v)\right)\right|$ $$

Suppose $v^{*}\in\operatorname*{arg\,max}_{v}p_{t}(v)$, then:

$$ $\displaystyle\text{term}_{2}$ $\displaystyle=\left|p_{t}(v^{*})-\mathbb{P}(v^{*}|x_{<t})\right|\leq\max_{v} \left|p_{t}(v)-\mathbb{P}(v|x_{<t})\right|.$ (20) $$

Similarly, we can show that:

$$ $\displaystyle\text{term}_{3}$ $\displaystyle\leq\max_{v}\left|q_{t}(v)-\mathbb{P}(v|x_{<t})\right|.$ (21) $$

Substituting equation 19–equation 21 in equation 18 completes the proof.

**Table 3: Target distributions associated with different inference algorithms, where $\alpha$ is a free parameter and $\beta\geq 1-\alpha$ is a parameter dependent on $q,p$ and $\alpha$. The last column indicates whether the execution is sequential (Algorithm 2), via an oracle (Algorithm 3), or speculative (Algorithm 5) (Leviathan et al., ). The third row presents a variant of the BiLD algorithm of Kim et al. (), where $D(q,p)$ is a measure of discrepancy between $q$ and $p$; the original algorithm differs from (Leviathan et al., ) in the use of a deterministic speculative decoding procedure with a dynamic draft window (see §5).**
| Inference strategy | Deferral decision $\delta(q,p)$ | Target distribution $\pi(x)$ | Execution |
| --- | --- | --- | --- |
| SpecDecoding Leviathan et al. () | - | $p(x)$ | Speculative |
| Lossy SpecDecoding (Tran-Thien, ) | - | $\max\{\min\{p(x),\frac{q(x)}{1-\alpha}\},\frac{q(x)}{\beta}\}$ | Speculative |
| BiLD* (Kim et al., ) | $\bm{1}\big{(}\,D(q,p)>\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| Cascade [Chow] (Chow, ) | $\bm{1}\big{(}\max_{v}q(v)<1-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Sequential |
| Cascade [ChowLog] | $\bm{1}\big{(}\,\textrm{entropy}(q)>\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Sequential |
| Oracle [Diff] (Jitkrittum et al., ) | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Oracle |
| Oracle [DiffLog] | $\bm{1}\big{(}\,\textrm{entropy}(p)<\textrm{entropy}(q)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Oracle |
| SpecCascade [Chow] | $\bm{1}\big{(}\max_{v}q(v)<1-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [ChowLog] | $\bm{1}\big{(}\,\textrm{entropy}(q)>\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [Diff01] | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [DiffLog] | $\bm{1}\big{(}\,\textrm{entropy}(p)<\textrm{entropy}(q)-\alpha\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [OPT01] | $\bm{1}\big{(}\max_{v}q(v)<\max_{v}p(v)-\alpha\cdot D_{\textrm{TV}}(p,q)\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |
| SpecCascade [OPTLog] | $\bm{1}\big{(}\,\textrm{entropy}(p)<\textrm{entropy}(q)-\alpha\cdot D_{\textrm{<br>TV}}(p,q)\big{)}$ | $(1-\delta)\cdot q(x)+\delta\cdot p(x)$ | Speculative |

## Appendix B Derivation of Chow’s rule

We show below that Chow’s rule is a plug-in estimator to the optimal solution to the following objective

$$ $\displaystyle L_{\rm rej}(r;x_{<t})$ $\displaystyle=\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\Big{[}\big{(}1-r( x_{<t})\big{)}\cdot\ell(x_{t},q_{t})+r(x_{<t})\cdot\alpha\Big{]},$ (22) $$

where the deferral rule is penalized with a constant penalty $\alpha\in[0,1]$ for choosing to defer to the large model.

Following the same steps as Lemma 1, it is easy to show:

###### Lemma 6 .

The minimizer of equation 22 is of the form:

$$ $\displaystyle r^{*}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{x_{t}\sim\mathbb{P}( \cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\,>\,\alpha.$ (23) $$

If $\ell=\ell_{\text{0-1}}$, one may employ a plug-in estimator to equation 23 by replacing the expected 0-1 loss over $q_{t}$ with $1-\max_{v}q_{t}(v)$, giving us $\hat{r}_{\rm\tt Chow}(x_{<t})$ in equation 2. If $\ell=\ell_{\log}$, one may replace the expected log loss over $q_{t}$ with the entropy of $q_{t}$, giving us:

$$ $\displaystyle\hat{r}_{\rm\tt ChowLog}(x_{<t})=1\leavevmode\nobreak\ \iff \leavevmode\nobreak\ \textrm{entropy}\big{(}q(\cdot|x_{<t})\big{)}>\alpha,$ (24) $$

where $\textrm{entropy}(q)=-\sum_{v\in\mathscr{V}}q(v)\cdot\log(q(v)).$

###### Lemma 6 .

## Appendix C Optimal Deferral: Additional Discussion

We provide additional discussion for the optimal deferral rules derived in §3 and §4.

### C.1 Optimal sequential deferral when ℓ = ℓ log ℓ subscript ℓ \ell=\ell_{\log} roman_ℓ = roman_ℓ start_POSTSUBSCRIPT roman_log end_POSTSUBSCRIPT

Recall that the optimal deferral rule for a sequential cascade in Lemma 1 takes the form:

$$ $\displaystyle r^{*}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{x_{t}\sim\mathbb{P}( \cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\,>\,\mathbb{E}_{x_{t}\sim\mathbb{ P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]+\alpha\cdot D_{\textup{{TV}}}( p_{t},q_{t}).$ $$

When $\ell=\ell_{\log}$, we may use the entropy $-\sum_{v}q_{t}(v)\cdot\log(q_{t}(v))$ from $q_{t}$ as an estimate of its expected log-loss, and similarly for $p_{t}$, giving us the plug-in estimator:

$$ $\displaystyle\textstyle\hat{r}_{\rm\tt DiffLog}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff\leavevmode\nobreak\ \leavevmode\nobreak\ \sum_{v}q_{ t}(v)\cdot\log(q_{t}(v))\,<\,\sum_{v}p_{t}(v)\cdot\log(p_{t}(v))-\alpha.$ (25) $$

### C.2 Optimal speculative deferral when ℓ = ℓ log ℓ subscript ℓ \ell=\ell_{\log} roman_ℓ = roman_ℓ start_POSTSUBSCRIPT roman_log end_POSTSUBSCRIPT

Recall that the optimal deferral rule for a speculative cascade in Lemma 4 takes the form:

$$ $\displaystyle r^{*}(x_{<t})=1\leavevmode\nobreak\ \leavevmode\nobreak\ \iff \leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{x_{t}\sim\mathbb{P}( \cdot|x_{<t})}\left[\ell(x_{t},q_{t})\right]\,>\,\mathbb{E}_{x_{t}\sim\mathbb{ P}(\cdot|x_{<t})}\left[\ell(x_{t},p_{t})\right]+\alpha\cdot D_{\textup{{TV}}}( p_{t},q_{t}).$ $$

When $\ell=\ell_{\log}$, one may construct a plug-in estimator for the above rule by replacing the expected log loss with the entropy from the distribution:

$$ $\displaystyle\textstyle\hat{r}_{\rm\tt OPTLog}(x_{<t})=1\leavevmode\nobreak\ \iff\leavevmode\nobreak\ \sum_{v}q_{t}(v)\cdot\log(q_{t}(v))\,<\,\sum_{v}p_{t} (v)\cdot\log(p_{t}(v))-\alpha\cdot D_{\textup{{TV}}}(p_{t},q_{t}).$ (26) $$

###### Lemma 7 (Regret bound for $\hat{r}_{\rm\tt OPTLog}$ ) .

Suppose $\ell=\ell_{\log}$. Suppose for a fixed $x_{<t}$, $|\log(q(v))|\leq B_{q}$ and $|\log(p(v))|\leq B_{p},\,\forall v\in\mathscr{V}$, for some $B_{q},B_{p}>0$. Then:

$$ $L_{\rm spec}(r_{\rm\tt OPT};x_{<t})-\min_{r}L_{\rm spec}(r;x_{<t})\leavevmode \nobreak\ \leq\leavevmode\nobreak\ \textstyle B_{q}\cdot\sum_{v\in\mathscr{V}} \big{|}\mathbb{P}(v|x_{<t})-q_{t}(v)\big{|}\,+\,B_{p}\cdot\sum_{v\in\mathscr{V }}\big{|}\mathbb{P}(v|x_{<t})-p_{t}(v)\big{|}.$ $$

###### Proof.

The proof follows similar steps to that for Lemma 5, except in bounding the resulting $\text{term}_{2}$ and $\text{term}_{3}$ for the log loss. In this case,

$$ $\displaystyle\text{term}_{2}$ $\displaystyle=\left|\mathbb{E}_{x_{t}\sim\mathbb{P}(\cdot|x_{<t})}\left[\log(p _{t}(x_{t}))\right]-\sum_{v}p_{t}(v)\cdot\log(p_{t}(v))\right|$ $\displaystyle=\left|\sum_{v}\mathbb{P}(v|x_{<t})\cdot\log(p_{t}(v))-\sum_{v}p_ {t}(v)\cdot\log(p_{t}(v))\right|$ $\displaystyle\leq\sum_{v}\left|\mathbb{P}(v|x_{<t})-\sum_{v}p_{t}(v)\right| \cdot\log(p_{t}(v))$ $\displaystyle\leq B_{p}\cdot\sum_{v}\left|\mathbb{P}(v|x_{<t})-\sum_{v}p_{t}(v )\right|.$ $$

Similarly,

$$ $\displaystyle\text{term}_{3}$ $\displaystyle\leq\sum_{v}\left|\mathbb{P}(v|x_{<t})-\sum_{v}p_{t}(v)\right| \cdot\log(p_{t}(v))$ $\displaystyle\leq B_{q}\cdot\sum_{v}\left|\mathbb{P}(v|x_{<t})-\sum_{v}q_{t}(v )\right|.$ $$

Plugging these bounds into the equivalent of equation 18 in Lemma 5 for the log-loss completes the proof.
∎

###### Lemma 7 (Regret bound for r ^ 𝙾𝙿𝚃𝙻𝚘𝚐 subscript ^ 𝑟 𝙾𝙿𝚃𝙻𝚘𝚐 \hat{r}_{\rm\tt OPTLog} over^ start_ARG italic_r end_ARG start_POSTSUBSCRIPT typewriter_OPTLog end_POSTSUBSCRIPT ) .

###### Proof.

### C.3 Optimal speculative deferral for greedy decoding

###### Lemma 8 .

When $T\rightarrow 0$, running Algorithm 5 with $\tilde{r}_{\rm\tt OPT}$ as the deferral rule and $\tilde{q}_{t}$ as the drafter is equivalent to running it with $\hat{r}_{\rm\tt Diff}$ in equation 5 as the deferral rule and $\tilde{q}_{t}$ as the drafter.

###### Proof.

Note that under greedy inference, $\tilde{q}_{t}$ $\tilde{p}_{t}$ are one-hot encodings of $\operatorname*{arg\,max}_{v}q_{t}(v)$ and $\operatorname*{arg\,max}_{v}p_{t}(v)$ respectively. As a result,

$$ $D_{\textrm{TV}}(\tilde{q}_{t},\tilde{p}_{t})=\bm{1}\left(\operatorname*{arg\, max}_{v}q_{t}(v)\neq\operatorname*{arg\,max}_{v}p_{t}(v)\right).$ $$

When running Algorithm 5 with $\tilde{r}_{\rm\tt OPT}$ as the deferral rule, we will accept a draft token $v$ with probability:

$$ $\kappa(v)=\min\left\{1,\frac{(1-\delta_{\rm OPT}(q,p))\cdot\tilde{q}(v)+\delta _{\rm OPT}(q,p)\cdot\tilde{p}(v)}{\tilde{q}(v)}\right\}$ $$

where $\delta_{\rm OPT}(q,p)\leavevmode\nobreak\ =\leavevmode\nobreak\ \bm{1}\left(
\max_{v}q(v)\,<\,\max_{v}p(v)-\alpha\cdot\bm{1}\left(\operatorname*{arg\,max}_
{v}q(v)\neq\operatorname*{arg\,max}_{v}p(v)\right)\right)$.
When $\operatorname*{arg\,max}_{v}q(v)=\operatorname*{arg\,max}_{v}p(v)$, then $\tilde{q}=\tilde{p}$, and irrespective of the outcome of $\delta(q,p),$ we have that $\pi(v)=1$. When $\operatorname*{arg\,max}_{v}q(v)\neq\operatorname*{arg\,max}_{v}p(v)$, then

$$ $\pi(v)=1-\delta_{\rm OPT}(q,p)=\bm{1}\left(\max_{v}q(v)\,\geq\,\max_{v}p(v)- \alpha\right)=1-\delta_{\rm\tt Diff}(q,p).$ $$

When a token gets rejected, we sample a new token from the residual distribution:

$$ $p_{\rm res}(v)\propto\min\{0,(1-\delta_{\rm OPT}(q,p))\cdot\tilde{q}(v)+\delta _{\rm OPT}(q,p)\cdot\tilde{p}(v)-\tilde{q}(v)\}=\delta_{\rm OPT}(q,p)\cdot\min \{0,\tilde{p}(v)-\tilde{q}(v)\}$ $$

When $\operatorname*{arg\,max}_{v}q(v)=\operatorname*{arg\,max}_{v}p(v)$, $p_{\rm res}(v)=0$. When $\operatorname*{arg\,max}_{v}q(v)\neq\operatorname*{arg\,max}_{v}p(v)$,

$$ $p_{\rm res}(v)\propto\delta_{\rm OPT}(q,p)\cdot\min\{0,\tilde{p}(v)-\tilde{q}( v)\}=\delta_{\rm Diff}(q,p)\cdot\min\{0,\tilde{p}(v)-\tilde{q}(v)\}.$ $$

Thus both the acceptance probability and the residual distribution are the same as the one we would have used had we run Algorithm 5 with $\hat{r}_{\rm\tt Diff}$ as the deferral rule.
∎

###### Lemma 8 .

###### Proof.

### C.4 Equivalence between equation 7 and equation 8

Since the prefix $x_{<t}$ is fixed in equation 7, the constrained optimization we seek to solve is of essentially of the following form:

$$ $\min_{r\in\{0,1\}}(1-r)\cdot c_{0}+r\cdot c_{1}\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ \text{s.t.}\leavevmode\nobreak\ \leavevmode\nobreak\ \leavevmode\nobreak\ r\cdot c_{2}\leq B,$ $$

for some coefficients $c_{0},c_{1},c_{2}>0$. Since $r$ is a binary variable, we may formulate an equivalent unconstrained problem with the same minimizer:

$$ $\min_{r\in\{0,1\}}(1-r)\cdot c_{0}+r\cdot c_{1}+\alpha\cdot r\cdot c_{2},$ $$

where we choose $\alpha=0$ when $c_{2}\leq B$ and choose an $\alpha>\frac{1}{c_{2}}\cdot(c_{0}-c_{1})$ otherwise. This unconstrained optimization problem is of the form in equation 8.

## Appendix D Token-specific Speculative Cascade

We provide a modification of Algorithm 5 to accommodate the token-specific deferral rules in §4.4.

Figure: Algorithm 6 TokenSpecCascade

Optimal token-specific deferral. Similar to §4.3, we may consider deriving the optimal token-specific deferral rule. We start by formulating a similar optimization objective. For a fixed prefix $x_{<t}$, this would look like:

$$ $\displaystyle\min_{r}$ $\displaystyle\leavevmode\nobreak\ \leavevmode\nobreak\ \mathbb{E}_{v\sim \mathbb{P}(\cdot|x_{<t})}\Big{[}\ell(v,\pi_{\tt Token})\big{)}\Big{]}$ (27) $\displaystyle\text{s.t.}\leavevmode\nobreak\ \leavevmode\nobreak\ D_{\textrm{ TV}}(\pi_{\tt Token},q_{t})\,\leq\,B,$ $$

where
$\pi_{\tt Token}(v)\stackrel{{\scriptstyle.}}{{=}}(1-r(x_{<t},v))\cdot q_{t}(v)
+\eta\cdot p_{t}(v)$ is the target distribution resulting from the choice of $r$, $\eta=\sum_{v^{\prime}\in\mathscr{V}}r(x_{<t},v^{\prime})\cdot q_{t}(v^{\prime})$ is a normalization term, and $B>0$ is a budget parameter.

However, unlike §4.3, the above constrained optimization problem does not lend itself to a simple closed-form solution. In some highly simplistic special cases, we may be able to derive a solution. For example, suppose $\ell=\ell_{\text{0-1}}$, and the mode of $q_{t}$ coincides with that of $\mathbb{P}(\cdot|x_{<t})$, i.e., $\operatorname*{arg\,max}_{v}q_{t}(v)=\operatorname*{arg\,max}_{v}\mathbb{P}(v|
x_{<t})$; then the optimal token-specific rule is given by $r(x_{<t},v)=0,$ for all $v\in\mathscr{V}$.

Under more realistic cases, we may not be able to derive a solution as simple as the OPT rule in equation 10.
Therefore, in our experiments, we employ the three heuristic rules in equations 13–15, which are motivated by the form of the simpler Diff rule in equation 5.

## Appendix E Additional Experimental Details

We provide additional details about our experimental setup and additional experimental results. We will release code and an illustrative tutorial notebook along with the final manuscript.

Figure: Figure 4: Plots of quality vs. latency for T5 models with temperature $T=1$ and block size $\gamma=5$. We include T5 plots not included in Figure 2 in the main text. Each method interleaves T5-small with T-large (or T5-XL). The $x$-axis tracks the latency *relative* to that of calling the large model on all inputs. The horizontal dotted line denotes the quality of the large model.
Refer to caption: x11.png

Figure: Figure 5: Plots of quality vs. latency for T5 models with greedy decoding with temperature $T=0$ and block size $\gamma=5$. Each method interleaves T5-small with T-large (or T5-XL). The $x$-axis tracks the latency *relative* to that of calling the large model on all inputs. The horizontal dotted line denotes the quality of the large model.
Refer to caption: x15.png

### E.1 Experimental setup and hyper-parameters

We elaborate on our experimental setup and the hyper-parameters used.

T5 datasets. For the WMT English to German translation task (Bojar et al., ), we use a validation sample of size 3000 provided with the dataset. We set the maximum input length to 80 and the maximum output length to 80. For the Extreme Summarization (XSum) task (Narayan et al., ), we use a validation sample of size 11305, and set the maximum input length to 1024 and the maximum output length to 64. For the CNN/Daily Mail summarization task (Hermann et al., ), we use a validation sample of size 13368, and set the maximum input length to 2048 and the maximum output length to 128. Following (Zhou et al., ), we use ROUGE-2 as the evaluation metric for the summarization tasks.

We note that Kim et al. () report ROUGE-L metrics for CNN/DM, which generally tend to evaluate to higher values than ROUGE-2. Furthermore, most of their experimental results are with greedy decoding ($T=0$), and hence, the ROUGE-L evaluation metrics they report in their paper tend to be higher for the same T5 models when compared to our numbers for ROUGE-2 with temperature sampling.

Gemma datasets. In addition to the WMT EN$\rightarrow$DE translation and the CNN/DM summarization datasets, we use the GSM8K (Cobbe et al., ) math reasoning dataset, the MBPP (Austin et al., ) Python programming dataset, and four question-answering datasets: Natural Questions (Kwiatkowski et al., ), TriviaQA (Joshi et al., ), WebQuestions (Berant et al., ) and the Stanford Question-Answering Dataset (SQuAD) 2.0 (Rajpurkar et al., ).
In each case, we sample 1000 prompts for evaluation. We employ few-shot inference, and set the maximum output length to 80 for WMT, to 128 for CNN/DM, to 320 for GSM8K and MBPP, and to 5 for all the question-answering datasets.

Models. We construct cascades from T5 v1.1 family of encoder-decoder models (Raffel et al., ), of different sizes T5-small (77M), T5-base (250M), T5-large (800M) and T5-XL (3B).(^1^11The pre-trained checkpoints we use are available [here](https://console.cloud.google.com/%0Astorage/browser/t5-data/pretrained_models).) We follow the protocol in (Zhou et al., ): we initialize with the public checkpoints, pre-train them further for 100K steps, and supervise finetune pre-trained models on the three respective tasks. We finetune them for a maximum of 250K steps on WMT, a maximum of 100K steps on XSum and a maximum of 200K steps on CNNDM.

We construct the Gemma cascades from instruction-tuned decoder-only v2 models. For MBPP alone we additionally experiment with pre-trained models. We use a 2B drafter, and either a 9B verifier or a 27B verifier (Team et al., ).

Evaluation. For each dataset, we evaluate the quality metrics on the entire validation set. For the run-time analysis, we adopt the protocol followed in Leviathan et al. (); Zhou et al. (). We randomly sample 500 examples from the validation set, and calculate the wall-clock time taken for decoding with a batch size of 1. We repeat this for three trials and report the average running time. All methods are run on the same TPUv4 device. The drafter and verifier models are run without model parallelism.

Hyper-parameters. We set the block-size $\gamma$ to 5 for all methods that use speculative execution. For the token-level cascades, we allow the small model to predict for a maximum of 10 tokens (similar to (Kim et al., )), before invoking the large model. This was needed, as otherwise, the small model would predict a long sequence, and when it eventually defers to the large model, the large model is bottle-necked by the pre-filling of the long prefix accumulated by the small model. We vary the lenience parameter $\alpha$ to vary the latency and plot quality as a function of latency. We vary this parameter in the range 0 to 1 for all methods where the thresholding is on a probability metric; the exceptions to this are the BiLD variants, for which, we use a longer range, as detailed below.

BiLD baseline. For the BiLD method, we adopt the same discrepancy metric $D$ as (Kim et al., ) for greedy decoding:

$$ $D(q,p)=-\log\left(p\left(\operatorname*{arg\,max}_{v}q(v)\right)\right),$ $$

and pick the value of the threshold $\alpha$ on this metric from the range $[0,10]$.
For temperature sampling with a non-zero temperature, we use the following natural analogue to the above $D$:

$$ $D(q,p)=-\mathbb{E}_{v\sim q}\left[\log(p(v))\right]=-\sum_{v\in\mathscr{V}}q(v )\cdot\log(p(v)).$ $$

In §E.5, we present comparisons between different implementations of this method.

Lossy speculative decoding. See §E.6 for details.

### E.2 Additional experimental plots

In Figures 4 and 5, we provide additional plots of quality vs. latency for different inference strategies under temperature sampling ($T=1$) and greedy decoding respectively.

As noted in §C.3, with greedy decoding, the OPT deferral rule coincides with the Diff deferral rule. When temperature $T\rightarrow 0$, $D_{\textup{{TV}}}(\tilde{p}_{t},\tilde{q}_{t})=1$ whenever $\operatorname*{arg\,max}_{v}p_{t}(v)\neq\operatorname*{arg\,max}_{v}q_{t}(v)$, and is zero otherwise. In this case, running Algorithm 5 with $\tilde{r}_{\rm\tt OPT}$ as the deferral rule (and $\tilde{q}_{t}$ as the drafter) is equivalent to running it with $\hat{r}_{\rm\tt Diff}$ in equation 5 as the deferral rule. In other words, for greedy decoding, the optimal deferral rules for a speculative cascade coincides with that for a sequential cascade.

Note that under greedy decoding, all methods yield better quality metrics compared to their performance under temperature sampling.

### E.3 Comparing speculative deferral rules under different temperatures

In Figure 6, we present latency-quality trade-off plots for T5 cascades under temperature sampling with different temperatures. We compare lossy speculative decoding with two speculative cascade deferral rules: OPT rule in equation 5 and the Token-specific rule in equation 15. We find that the gap between OPT and the Token-specific rule diminishes as the temperature decreases.

The reason the Token-specific rule fares better than OPT is because the latter compute their deferral decisions based on which of $q_{t}(\cdot)$ and $p_{t}(\cdot)$ is more peaked; this can be a disadvantage when the sampled token is not be close the distribution mode, which is likely to happen with higher temperatures. With lower temperatures, however, the sampled token is likely to be close the distribution mode, and as a result, the advantage that the Token-specific rule has over OPT diminishes.

Figure: Figure 6: Plots of quality vs. latency for T5 models with varying temperatures. Each method interleaves T5-small with T-large. The $x$-axis tracks the latency *relative* to that of calling the large model on all inputs. The horizontal dotted line denotes the quality of the large model.
Refer to caption: x20.png

color=RoyalBlue!35!white]add plots. Hari: done!

### E.4 Comparing speculative deferral rules under different block sizes γ 𝛾 \gamma italic_γ

In Figure 7, we present latency-quality trade-off plots for T5 cascades under different block sizes $\gamma$. In each case, we find that the proposed speculative cascading techniques outperform lossy speculative decoding across different latency values. Furthermore, higher values of $\gamma$ are seen to yield a wider range of trade-offs, with lower quality operating points shifting to the left, and better quality operating points shifting to the right. For example, with XSum, SpecDecode [Lossy] with $\gamma=3$ matches the small model’s quality at  0.64 relative latency, and matches the large model’s quality at  0.85 relative latency; with $\gamma=7$, it matches the small model’s quality at an even lower latency, but practically provides no speed-up when matching the larger model’s quality. The reason a larger block size can hurt speed-up at the higher quality regime is because it can result in frequent rollbacks, thus defeating the purpose of using speculative execution.

Figure: Figure 7: Plots of quality vs. latency for T5 models with with varying block sizes $\gamma$. Each method interleaves T5-small with T-large. The $x$-axis tracks the latency *relative* to that of calling the large model on all inputs. The horizontal dotted line denotes the quality of the large model.
Refer to caption: x29.png

Figure: Figure 8: Top: Plots of quality vs. latency comparing BiLD^∗ with the original BiLD algorithm in Kim et al. () with varying maximum draft window size $\gamma$ and fallback confidence threshold $\alpha_{f}$. Bottom: Comparison of lossy speculative decoding with $\beta=1$ [Lossy] and $\beta$ tuned using the procedure in (Tran-Thien, ) [Lossy^⋆].
Refer to caption: x38.png

### E.5 Big Little Decoder (BiLD) variants

In §6, we compared against a version of the Big Little Decoder method (Kim et al., ) that applied Algorithm 4 to the target distribution $\mathbb{T}_{\textup{BiLD}}$ the authors seek to mimic (§5). We now show that this version performs similarly to the original BiLD algorithm in (Kim et al., ).

A key difference to the original algorithm in (Kim et al., ) is the use of the fallback phase, where the drafter is run until its maximum predicted probability $\max_{v}q(v)<1-\alpha_{f}$, for a threshold $\alpha_{f}\in[0,1]$ (or until a maximum block size of 10 is reached), and the use of a deterministic rollback policy where the verifier rejects a draft token whenever $D(q,p)>\alpha$.
In our implementation, we adopt the speculative sampling algorithm from (Leviathan et al., ): we do not have the fallback policy and replace the determinisic rollback policy with the rejection sampling in Algorithm 4.

Figure 8 (top) compares the original version of BiLD with the version we use in §6. We interleave between a T5-small and T5-large model on WMT, using greedy decoding ($T=0$) for inference. As prescribed by the authors (Kim et al., ), we use the following discrepancy metric for greedy decoding:

$$ $D(q,p)=\log p\left(\operatorname*{arg\,max}_{v}q(v)\right).$ $$

We compare our implementation (BiLD^∗), where we set the block size 5 (same as our proposed speculative cascading approaches) with the original BiLD for different choices of maximum block size $\gamma$ and different fallback thresholds $\alpha_{f}$. For both methods, we vary the threshold $\alpha$ on $D(q,p)$ to vary the latency and plot the resulting BLEU score.

A higher fallback threshold $\alpha_{f}$ results in larger draft generation windows; this gives an advantage in the low latency regime, where most of the draft tokens are accepted. As a result, BiLD [$\gamma=10,\alpha=0.9$] yields the lowest latencies, but also yields lower quality. A low fallback threshold results in very small draft generation windows, and consequently, in higher latencies. This is why BiLD [$\gamma=5,\alpha=0.1$] is the slowest but yields high quality metrics.

Our implementation BiLD^∗ is seen to perform comparable to the best parameter choices for the original BiLD algorithm in Figure 8.

Note: It is worth noting that while we view $\mathbb{T}_{\rm BiLD}$ as the target distribution that algorithm in (Kim et al., ) seeks to mimic, the presence of the fallback phase could mean that on some inputs a output response is generated without the verification (or rollback) phase being invoked. In such cases, the output will be a sample from the drafter even if it turns out that it contains tokens for which $D(q_{t},p_{t})>\alpha$.

### E.6 Lossy speculative decoding variants

In §6, we compared against the lossy speculative decoding Tran-Thien (); Zhou et al. () described in §2, with the parameter $\beta$ set to 1. We now present results for this method with $\beta$ tuned according to the procedure in Tran-Thien (), and show that choosing $\beta=1$ fares at least as well as tuning $\beta$.

The goal in Tran-Thien () is to choose $\alpha$ and $\beta$ so as to maximize the acceptance rate for the draft token, while ensuring that the KL divergence between the resulting target distribution and $p$ is within an allowable limit $R$. The authors prescribe specifying $R$, and for each prefix, tuning $\alpha$ and $\beta$ to solve the resulting constrained optimization problem. To be consistent with the rest of our experimental setup, we vary $\alpha$ to vary the draft acceptance rate (note that each choice of $\alpha$ corresponds to a particular KL divergence to $p$), and tune $\beta\geq 1-\alpha$ to satisfy the following condition outlined in Tran-Thien ():

$$ $\sum_{v}\max\left\{0,q(v)-\frac{p(v)}{1-\alpha}\right\}=\sum_{v}\max\left\{0, \frac{p(v)}{\beta}-q(v)\right\}$ $$

We pick $\beta$ using a grid-search over 1000 values between $\alpha$ and 10. Since this tuning procedure, in turn, can add to the method’s latency,
for a fair comparison, we analyze quality as a function of the fraction of calls to the large model. In Figure 8 (bottom), we plot these trade-off curves for loss speculative decoding with $\beta=1$ (Lossy) and for speculative decoding with $\beta$ tuned using the above procedure (Lossy^⋆). We compare performances on WMT and XSum, and in each case, interleave a T5-small model with a T5-large model.

In both cases, setting $\beta=1$ provides trade-offs comparable to or better than using a tuned value of $\beta$. The reason using a tuned value of $\beta$ fares worse than setting $\beta=1$ might be because we are measuring quality in terms of BLEU or ROUGE-2, which is different from the KL divergence to $p$ objective that the tuning procedure in Tran-Thien () seeks to optimize.

### E.7 Token-specific speculative cascades

In Figure 9, we present latency-quality trade-off plots for cascades constructed from a T5 small and a T5 large model. We include in these comparisons, all three token-specific deferral rules in equations 13–15.
In Figure 10, we present trade-off plots for cascades constructed from Gemma 2B and Gemma 27B models with all three token-specific rules, and
in Figure 11, we include similar plots for cascades constructed from Gemma 2B and Gemma 9B models.
We note that the trends with the 2B $\rightarrow$ 9B are similar to those seen with the 2B $\rightarrow$ 27B cascades.

With the T5 models, the results are mixed, with the V1 and V2 variants sometime surpassing the V3 variant (which is the variant we included in the main experiments results in §6) Interestingly, with the Gemma models, the V3 variant is seen to outperform the others for most rejection rates, with the exception of the 2B$\rightarrow$27B cascade on SQuAD 2.0, where the V2 variant is better.

The reason the V3 variant outperforms V1 and V2 on the Gemma models could be due to the fact that it uses the larger model’s distribution $p_{t}(\cdot)$ to measure confidence for both the drafter and verifier (see LHS and RHS in equation 13). We expect this to be particularly helpful when there is a larger gap in sizes between $q$ and $p$, and the larger model’s distribution is better aligned with the ground-truth distribution compared to the smaller model. Furthermore, as noted in §4.4, the multiplicative form of the rule results in a target distribution that has an intuitive form: it seeks to mimic $q_{t}(\cdot)$ on the top-$\alpha$ ranked tokens by $p_{t}(\cdot)$ and uses a re-scaled version of $p_{t}(\cdot)$ for the other tokens.

Figure: Figure 9: Plots of quality vs. latency for T5 models with all three token-specific speculative cascade deferral rules in equations 13–15. Each method interleaves a T5 small and a T5 large model. The $x$-axis tracks the latency *relative* to that of calling the large model on all inputs. The horizontal dotted line denotes the quality of the large model.
Refer to caption: x41.png

Figure: Figure 10: Plots of quality vs. rejection rate for Gemma models with all three token-specific speculative cascade deferral rules in equations 13–15. Each method interleaves a Gemma 2B drafter with a Gemma 27B verifier. The horizontal dotted line denotes the quality of the large model. We include all three token-specific speculative cascade deferral rules in equations 13–15.
Refer to caption: x44.png

color=RoyalBlue!35!white]add plots. Hari:done!

Figure: Figure 11: Plots of quality vs. rejection rate with Gemma 2B $\rightarrow$ 9B speculative cascades. Each method interleaves a Gemma 2B drafter with a Gemma 9B verifier. The horizontal dotted line denotes the quality of the large model. We include all three token-specific speculative cascade deferral rules in equations 13–15.
Refer to caption: x52.png

color=RoyalBlue!35!white]add plots. Hari:done!

## Appendix F Limitations

One of the limitations of our proposal is the use of plug-in estimators to approximate the optimal rule equation 9. While these approximations are effective in practice, they rely on the individual models being calibrated. An alternative to the use of plug-in estimators is to use a router model explicitly trained to mimic the optimal rule using a validation sample drawn from $\mathbb{P}$ (Gupta et al., ). Another limitation is that the optimization objectives we seek to minimize are local objectives that seek to make the best deferral decision at the current position $t$. In doing so, they ignore the downstream effects of choosing a particular model in the current step. Devising a global deferral objective that takes downstream errors into account would be an interesting direction for future work.
More broadly, our paper seeks to improve cost-quality trade-offs in LM inference. It is important that such improvements do not unfairly advantage one slice of the data or a subset of the population, at the cost of others. Ensuring that the trade-off gains that our approach offers is equitable across different slices of the data is another important direction for the future.

## Peer Reviews

confidence: 4
contribution: 1
initial_rating: 3
presentation: 3
questions: 1. What is the ground truth (mentioned in lines 76, 156, 166, etc) in this paper? Why would you optimize toward the ground truth probabilities?
2. Line 353, what is OPT?
3. What hardware is used for the experiment? How are the models implemented? 
4. What is SpecDecode [Token] in Figure 3?
soundness: 1
strengths: - The proposed method is lightweight and does not require supervised fine-tuning. 
- The paper flows naturally and is easy to read and understand overall.
summary: The paper introduced new speculative decoding variations by combining two techniques: speculative decoding and cascade language models. This is achieved by applying cascade rules on the token level. Experiments showed that the proposed method achieves faster decoding and performs better when the temperature is high.
weaknesses: - The reasoning behind the designs of the loss functions in Equations (3) and (8) is unclear. 
- The experimental design seems unfair and the improvements are limited. SpecCascade [Token] uses top tokens, while the other methods are evaluated with vanilla sampling at a temperature of 1. Sampling methods like Top-K and Top-P can lead to better performance by avoiding out-of-distribution tokens. To ensure a fair comparison, baseline methods should also use Top-K or Top-P sampling. Given the experiment in Figure 5, which shows that SpecCascade does not improve over lossy SD when T=0, I doubt whether the proposed method offers meaningful enhancements other than inserting a logic removing out-of-distribution tokens. 
- The evaluations in Table 2 and Figure 2 use gamma=5, which is not optimal; speculative decoding typically requires hyperparameter tuning for the best results. 
- The sub-figures in Figure 3 (and other figures with sub-figures) are not properly aligned.

---

confidence: 2
contribution: 3
initial_rating: 6
presentation: 4
questions: Most of my primary concerns are outlined in the weaknesses section above. Here is an additional minor concern:

- In line 527, the authors state, “a lower rejection rate directly translates to a lower latency.” It would be helpful to provide a direct demonstration of this relationship, showing the correlation between latency and rejection rate for clarity.
- As I am not a specialist in the theoretical domain, I cannot fully assess the accuracy of the theoretical analysis presented in this manuscript. My opinion on this aspect may change after reading insights from other reviewers or engaging in further discussions.
soundness: 3
strengths: 1. The paper addresses a promising and challenging research direction by combining model cascades with speculative decoding.  Recent studies have shown interest in integrating speculative decoding with advanced techniques, such as contrastive decoding [1], to accelerate inference while enhancing the generation quality of LLMs. Speculative cascading complements these efforts by exploring model cascades in speculative decoding. Through both empirical and theoretical analyses, this work innovatively integrates various deferral rules within a speculative execution framework, which is non-trivial and could provide valuable insights for the the academic community.
2. The design of speculative cascading is thorough and well-motivated. The authors provide a clear exposition of the theoretical foundations for both model cascades and speculative decoding, which they summarize effectively in Table 1. Speculative cascading is systematically crafted to leverage the strengths of each of these techniques.
3. The authors conduct extensive experiments with the Gemma and T5 models, carefully detailing experimental settings and effectively validating the efficacy of speculative cascading. The results demonstrate that speculative cascading achieves better cost-quality trade-offs compared to conventional cascades and speculative decoding methods.
4. The manuscript is clearly written, with a well-structured narrative, compelling motivation, detailed analyses, and transparent demonstrations that enhance its readability and impact.
summary: This work investigates the integration of two front-ended inference strategies: model cascades and speculative decoding. It introduces a novel decoding strategy called speculative cascading. This method combines the strengths of both strategies to achieve a more favorable cost-quality trade-off during inference. Experiments with Gemma and T5 models across  various benchmarks (e.g., summarization, translation, coding, and reasoning) demonstrate the effectiveness of this method, which yields better cost-quality trade-offs than cascading and speculative decoding baselines.
weaknesses: 1. **Fairness of Comparison**: In Table 2, the authors report minimal latency when matching the quality of a large model, as well as the best quality metric achievable without exceeding the latency of LLMs for each method. However, it is unclear if these comparisons are entirely fair. For instance, it would be helpful to know if the results for BiLD were reported under similar configurations, ensuring a consistent basis for comparison.
2. **Applicability of Speculative Cascading**: Figures 2 and 3 suggest that the quality of speculative cascading can be significantly affected by relative latency. The manuscript would benefit from a more detailed discussion on optimizing the cost-quality trade-off during inference. Specifically, guidance on configurations for maximizing speed-ups while maintaining quality or improving quality without exceeding the latency of the original LLMs, would enhance understanding and practical applicability.
3. **Quality Improvement of Speculative Cascading**: As shown in Figures 2 and 3, the quality improvements of speculative cascading are relatively modest across several tasks, including WMT 5-shot, GSM8K 8-shot, WebQ 1-shot, and NaturalQA 1-shot with Gemma models. This limited improvement in quality may constrain the broader applicability of speculative cascading. Additional discussion on scenarios where speculative cascading performs optimally would provide valuable context for readers.

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 3
questions: - The intuition behind 4.4 (the first paragraph in that section) is not entirely clear to me. Can you please explain in more detail the problem you are trying to address here?
soundness: 4
strengths: - An interesting and intuitive approach: in cascading, the small model can sometimes outperform the larger one. In contrast, in speculative decoding, the model is guaranteed to match the large model quality, but is typically faster. By combining them, the authors allow for fast decoding, with potential improvement, which leads to overall higher speedup.
- Some of the claims are clever. I particularly like the intuition that only considering the confidence of the small model is sub-optimal, and we should also take the large model's confidence into account, and how this could be implemented in speculative decoding (Remark 2).
- The best proposed method (SpecCascade [Token]) seems to outperform all baselines quite consistently.
summary: This paper studies way to interleave two adaptive computation methods: cascading and speculative decoding. The authors present a framework that combines both methods, and aims to enjoy the benefits of both approaches. They also derive theoretical guarantees as to the optimal deferral rule for their method. The key idea is replacing the target distribution in speculative decoding with a different distribution, which takes both the small and large distributions into account. Experimental results on various benchmarks show that the best two variants lead better speed-accuracy tradeoffs compared to either approaches.
weaknesses: * I had some trouble following section 4.3. A roadmap/intuition would have been helpful. In particular, I did not fully understand the role of Lemma 3, and the overall takeaway from this section.

- The experiments section was also a bit hard to follow. It starts with outlying the different deferral rules, and then presents the baselines. It seems both parts are somewhat overlapping. It would be helpful to merge them and discuss the link between the two, and particularly not have a paragraph separating the two.

- It is not entirely clear from table 2 which lines are the current work and which are previous work. I think only the last two lines are new, but the line separating the different groups appears before the last four lines. Also, the name SpecDecode (which hints of the current work) also appears earlier (SpecDecode [Lossy]). I think this name stems from the new perspective presented in this work, but it is still quite confusing and makes evaluating the results challenging. I would suggest clearly separating existing and new methods both visually (within the table) and by name to avoid confusion.

Meta-review: This paper proposes speculative cascading, a novel integration of cascading and speculative decoding methods to improve language model inference. The approach intelligently balances speed and quality trade-offs, showing consistent improvements over existing methods under various conditions. While minor revisions are suggested for clarity and comprehensibility, the paper is sound in its contributions and warrants acceptance.

Decision: Accept (Oral)