Sequoia: Scalable and Robust Speculative Decoding

Authors: zhuoming  chen
avner  may
ruslan  svirschevski
yuhsun  huang
max  ryabinin
zhihao  jia
beidi  chen
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-07 18:04:01

Abstract: As the usage of large language models (LLMs) grows, it becomes increasingly important to serve them quickly and efficiently. While speculative decoding has recently emerged as a promising direction for accelerating LLM serving, existing methods are limited in their ability to scale to larger speculation budgets and adapt to different hyperparameters. This paper introduces Sequoia, a scalable and robust algorithm for speculative decoding. To improve scalability, Sequoia introduces a dynamic programming algorithm to find an optimal tree structure for the speculated tokens. To achieve robust speculative decoding, Sequoia uses a novel sampling and verification method that outperforms prior work across different decoding temperatures. Sequoia improves the decoding speed of Llama2-7B, Llama2-13B, and Vicuna-33B on an A100 GPU by up to $4.04\times$, $3.73\times$, and $2.27 \times$. To serve Llama3-70B-Instruct on a single L40 GPU through offloading, Sequoia reduces the per-token decoding latency to 0.60 s/token, $9.5\times$ faster than DeepSpeed-Zero-Inference.

Main paper: 
 introduction: 
 As large language models (LLMs) gain widespread adoption [3, 43, 7] , efficiently serving these LLMs becomes increasingly important. However, accelerating LLM inference is challenging since generating a single new token requires accessing all parameters of the LLM [34] . As a result of this I/O bottleneck, the hardware is poorly utilized during generation. This problem is exacerbated in both small-batch and offloading-based inference settings, where generating one token takes as much time as processing a prompt with hundreds or thousands of tokens on modern GPUs.To address this challenge, recent work has introduced speculative decoding to accelerate LLM inference while preserving the LLM's output distribution [24, 5, 28, 40] . These approaches leverage one or multiple draft models to predict the LLM's output; the predictions are organized in a token tree, whose nodes represent different sequences of speculated tokens. The correctness of these speculated tokens is then verified in parallel through a single forward pass of the LLM. Using a token tree-instead of a sequence-can increase the number of tokens accepted by the LLM by providing several options for each token position.While there are substantial studies on tree-based speculative decoding methods [28, 40] , we see in our experiments that they have a couple of limitations. First, we observe that existing token tree construction algorithms perform well for small token trees but are sub-optimal for large tree sizes. For example, SpecInfer constructs a token tree using k independent sequences, a topology that is bounded by the expected number of tokens it can accept, regardless of the tree size (Figure 1 ). Second, we observe that existing token tree sampling and verification algorithms are unable to perform well across inference hyperparam- Figure 1 : SEQUOIA is a scalable method for speculative decoding. Left: SEQUOIA tree construction algorithm is able to generate trees whose average number of generated tokens (after verification) continues to grow with the tree size while existing tree structures asymptote. This allows SEQUOIA to perform much better than existing methods in very memory-bound regimes like offloading. Right: A visualization to contrast SEQUOIA tree structure with other common handcrafted ones. eter configurations; for example, SpecInfer [28] and SpecTr [40] often perform poorly at low temperatures (Figure 3 ) since they can repeatedly sample an incorrect token with high draft model probability.In this paper, we aim to answer the following research question: how can we design an optimal tree-based speculative decoding method to maximize speedups on modern hardware? Realizing this goal requires addressing several technical challenges. First, for any tree size and depth, we must be able to efficiently search the exponentially large space of tree topologies to find the one that maximizes the expected number of generated tokens. Second, we must design a tree sampling and verification procedure that performs well across inference hyperparameters, avoids repeatedly sampling incorrect tokens, and maintains the correct output distribution. This paper introduces SEQUOIA, a scalable and robust speculative decoding algorithm. As shown in Figure 1 , SEQUOIA can attain up to 9.5× speedups over incremental decoding and introduces several key techniques to address the aforementioned challenges.• In Section 3.1, to solve the first challenge, we formulate tree construction as a constrained optimization problem and employ a dynamic programming algorithm to discover the optimal speculative token tree. Theoretically and empirically, we demonstrate that the number of tokens generated with this tree structure is unbounded, growing roughly logarithmically with the tree's size. • In Section 3.2, to address the second challenge, we build upon the SpecInfer [28] algorithm by performing sampling without replacement from the draft model-thereby preventing the draft model from making the same mistake twice, while maintaining the target model's output distribution. We prove that this new sampling and verification method can attain high acceptance rates at both high and low temperatures and validate this claim empirically.In Section 4, we perform extensive end-to-end experiments and ablation studies to demonstrate the effectiveness of SEQUOIA. We implement SEQUOIA on top of Hugging Face [45] with CUDA Graphs [31, 32] . We show that SEQUOIA achieves up to 4.04× speedup for Llama2-7B on a single A100 GPU and 9.5× for Llama3-70B-Instruct in the offloading setting on an L40 GPU. The latency of Llama3-70B-Instruct offloading on L40 can be reduced to 0.60 s/token with SEQUOIA while the inference speed of state-of-the-art offloading system (DeepSpeed-Zero-Inference [2] ) is 5.7 s/token. We also present ablation studies to show that: (1) the SEQUOIA tree structure can generate up to 33% more tokens per decoding step compared to k independent sequences (tree size ≤ 512), demonstrating better scalability; (2) the SEQUOIA sampling and verification algorithm is robust to the choice of hyperparameters (temperature, top-p), providing up to 65% and 27% speedup compared to SpecInfer and top-k sampling and verification algorithms, respectively. 
background: 
 Here, we review tree-based speculative decoding methods. In particular, we discuss the way existing methods choose the speculated tree structure (Section 2.1) and the algorithms they use to sample and verify the token trees (Section 2.2).The primary tree structure used by existing methods is one composed of k independent sequences of length L that branch from the tree root (which corresponds to the current prefix). The SpecTr paper additionally considers arbitrary branching patterns (k 1 ,k 2 ,...,k t ), but says that this did not perform better in their experiments than independent sequences. Medusa constructs a full k-ary tree, which increases the success rate at each layer but cannot form a deep tree under moderate token budgets [4] .We now review how SpecInfer [28] , SpecTr [40] , naive sampling [28] , and top-k sampling2 perform token tree sampling and verification. With regard to sampling, SpecInfer, SpecTr, and naive sampling all perform i.i.d. sampling with replacement from the draft model, while top-k sampling selects the top-k highest probability tokens from the draft model. In terms of verification, SpecInfer and SpecTr compare the draft and target model probabilities for the sampled tokens to decide which (if any) to accept; naive and top-k sampling, on the other hand, sample a token from the target model distribution and accept it if it corresponds to one of the tokens from the speculated tree. These methods all verify a speculated token tree in a recursive manner-starting at the root of the tree-differing only in the verification algorithm they apply at each node. SpecInfer: The SpecInfer method iteratively verifies tokens that were sampled from one or more draft models. Like the original speculative decoding method [24] , it compares the draft model probabilities to those from the target model to decide if to accept. Note that while the SpecInfer method allows sampling from k different draft models to generate k children for a node, in this work we consider the more common setting where only one draft model is available. Therefore, we compare with the version of SpecInfer which samples from a single draft model k times instead. To see pseudocode for SpecInfer, please see Algorithm 2 and ignore all blue lines (lines 10-16). SpecTr: The SpecTr algorithm is similar in spirit to the SpecInfer algorithm. It iterates through the children of a node, and uses a sampling procedure to decide if to accept a child, in such a way that the output distribution is unchanged. One important property of this algorithm is that it is within a factor of (1-1/e) of the best possible verification algorithm (i.e., the one with highest possible acceptance rate). For brevity, we refer readers to Algorithm 3 in the SpecTr paper for the exact pseudocode for this algorithm.Naive sampling and top-k sampling: Given a node in a token tree, the verification algorithm for naive sampling and top-k sampling first samples from the target model's distribution P(• | x <n ) at that node, and then accepts this sample if it is equal to one of the children of that node. This verification algorithm trivially maintains the target model output distribution-regardless of how the token tree was generated-given that one always samples from the target model in this algorithm (as opposed to from the draft model, like in SpecTr and SpecInfer). This observation motivates our choice-for the top-k sampling method-to populate the tree by taking the top-k children of each node, instead of the naive sampling approach of taking k i.i.d. samples (with replacement). We use the top-k sampling method in our experiments in Section 3.2, to better understand the limits of this verification algorithm. 
sequoia: 
 We now present SEQUOIA, a scalable and robust speculative decoding algorithm.• In Section 3.1, we present our scalable tree construction algorithm, which uses dynamic programming to solve for the optimal tree structure. We demonstrate both theoretically and empirically that the number of tokens generated by verifying SEQUOIA trees scales nearly logarithmically in the size of the tree, while existing tree structures asymptote in the number of tokens they can generate. • In Section 3.2, we present our robust tree verification algorithm, which modifies the SpecInfer algorithm by sampling without replacement from the draft model. We show both theoretically and empirically that SEQUOIA is robust, performing well across temperature values, while existing verification methods are not.We now present the SEQUOIA tree construction algorithm (Section 3.1.1), and prove that the expected number of tokens generated when verifying for these trees scales well with the tree size (Section 3.1.2).Tree #1 Tree #2 To derive the SEQUOIA tree construction algorithm, we first express the tree construction problem as a constrained optimization problem, and then use dynamic programming to solve this problem optimally and efficiently. In this optimization problem, we aim to maximize the expected number of tokens F (T ) generated by verifying a token tree T , under a constraint on the size of T . We begin by presenting a closed form expression for F (T ) (Proposition 3.4). We then present our tree construction algorithm, which uses dynamic programming to find the tree of size n which maximizes this expression (for any value of the speculation budget n).We first present a number of important definitions: Definition 3.1. Under the positional acceptance assumption, the probability of a verification algorithm accepting a token t which is the k th child of an already accepted token depends only on the value of k. Definition 3.2. The acceptance vector is the vector p = (p 1 , p 2 , ..., p k , ...) containing the probabilities p k that the verification algorithm accepts a token at child position k. Under the positional acceptance assumption, the acceptance dynamics of a verification algorithm can be completely described by the acceptance vector. Definition 3.3. Given an acceptance vector p and a tree T , we define the score functionf (v) for a node v ∈ T as f (v) = i∈Path(v) p i .where Path(v) is equal to the list of child indices along the path from the root to a node v ∈ T . For example, if v is the 3 rd child of the root's 2 nd child, then Path(v) = [2, 3] . We define f (root) = 1.We are now ready to present Proposition 3.4 (proof in Appendix F.1.2), which shows the closed form equation for the expected number of tokens generated by verifying a token tree T , under the positional acceptance assumption. This is the equation which our SEQUOIA dynamic program will optimize. Proposition 3.4. Let T be a token tree that is verified with the positional acceptance assumption, and let f (v) denote the score function for a node v ∈ T . Then the the expected number of tokens F (T ) generated by verifying T equalsF (T ) = v∈T f (v) .SEQUOIA Dynamic Programing Algorithm. The SEQUOIA tree construction algorithm finds the tree T of size N which maximizes F (T ), using dynamic programming. Our algorithm works by iteratively filling in the following 2-dimension tensor T :EQUATIONHere, FirstBranch(T ) denotes the number of direct children the root of T has, and B denotes an upper bound we impose on the number of direct children any node in the tree can have (we can let B = N -1 to make this constraint vacuous). Given the tensor T , the maximum expected number of generated tokens for any tree of size n ≤ N can be found by searching over all possible first-branch values b:max 0≤b≤B T [n, b].We now show how to iteratively fill in the tensor T (which we initialize to negative ∞). Pseudocode for the full dynamic programming method is shown in Algorithm 1).As the base case, we set T [1,0] = 1, representing the tree composed of just the root node, because 1 token is generated per iteration of speculative decoding when no tokens are speculated.For the recursive case, we can consider the tree composed of the root node and its first b-1 children and their descendants (tree #1), as well as the tree whose root is the last child of the root node and its descendants (tree #2). Letting m ≥ 1 denote the number of nodes in tree #2, we can see that the expected number of generated tokens for tree #1 is T [n-m, b-1]. Furthermore, the expected number of generated tokens for tree #2 is max 0≤j≤B T [m, j], but this sub-tree is only considered in the case where the b th child of the primary root node is accepted (which happens with probability P [b]). Therefore, we can compute T [n, b] by searching over all possible sizes m for tree #2 to find the one which maximizes the expected number of generated tokens for the full tree:T [n, b] = max 1≤m≤n-1 T [n-m, b-1]+P [b]• max 0≤j≤B T [m, j]) .We show in Appendix F.1.1 that by keeping track of the values of m and b that maximize the max expressions on lines 9 and 11, we can easily reconstruct the optimal tree T of size N (and FirstBranch(T ) ≤ B) that attains the maximum expected number of generated tokens. We additionally demonstrate in this appendix (with python implementation) that we can extend this algorithm in a couple important ways:• Bounded tree-depth: Because the amount of time it takes to speculate a token tree is proportional to the depth of the tree, it can be very beneficial to find the tree of depth ≤ D that maximizes the expected number of generated tokens. We demonstrate in Algorithm 4 that we can extend the SEQUOIA dynamic program to find the optimal tree of bounded depth. • Compatibility with self-speculation: For self-speculation methods like Medusa [4] , Eagle [25] ,and GLIDE [11] which leverage the target model's representations on the current prefix during decoding, the acceptance rates can meaningfully degrade as you get deeper into the speculation tree (i.e., further away from the current prefix). We demonstrate in Algorithm 4 that it is simple to extend our SEQUOIA dynamic program to take as input a 2-D acceptance rate matrix (instead of a 1-D vector) containing the average acceptance rate vectors at different tree depths. Thus, SEQUOIA is compatible with the latest advances in self-speculation methods, which can attain meaningfully higher acceptance rates than "standalone" draft models.This algorithm can be run offline, and thus does not slow down inference. T max [n] = max 0≤b≤B T [n, b] 12: end for 13: Return array Tfor b = 1 → B do 9: T [n, b] = max 1≤m≤n-1 T [n-m, b-1]+P [b] • T max [m]We now prove that the SEQUOIA tree construction algorithm scales well with the size of the speculated tree. In particular, we show that under certain assumptions on the acceptance rates of the verification algorithm, the number of generated tokens is lower-bounded by a function which is (roughly) logarithmic in the size of the tree. This is in contrast to existing tree construction algorithms, which are upper bounded in the expected number of tokens they generate, regardless of the size of the tree. For example, a single sequence of tokens has upper bound 1/(1-P 1 ) [24] ; k independent sequences can only increase this upper bound by 1, because they only increase the chance of acceptance of the first token. Even an infinitely deep binary tree is upper bounded by 1/(1-P 2 ).We first define what it means for a verification algorithm to have a b power-law acceptance rate, and then present our theorem on the scalability of SEQUOIA trees, under the assumption that the verification algorithm has a b power-law acceptance rate. Figure 3 : Rejection rate vs. number speculated tokens: We plot the average rejection rate (1 -acceptance_rate) for the different verification algorithms, as a function of the number of speculated tokens k. Across temperature settings ({0.2,0.6,1.0}, left to right), the SEQUOIA verification algorithm attains the lowest rejection rates, and consistently has a power-law acceptance rate (Definition 3.5). Definition 3.5. We say that a tree verification algorithm has a b power-law acceptance rate if the chance r k of the tree verification algorithm rejecting all k speculated children of a node in a tree is upper bounded by a power-law of k with exponent b-meaning,r k ≤ 1/k b ∀k ∈ N, for b > 0 ∈ R.The above definition is motivated by our observation (Figure 3 ) that the SEQUOIA sampling/verification algorithm attains power-law acceptance rates in practice. We now state the theorem (proof in App. F.3). Theorem 3.6. Using a tree verification algorithm with a b power-law acceptance rate, the expected number of tokens G(n) generated by verifying the SEQUOIA tree of size n is in Ω b•log(n)/log(log(n) .In Figure 1 , we plot the average number of tokens generated by SEQUOIA trees relative to various baseline tree structures, as a function of the number of tokens n in the tree, using Pythia-2.8B as a draft model for Pythia-12B, and WikiText-103. We see that the number of generated tokens for SEQUOIA trees is unbounded-scaling roughly logarithmically with the tree size-whereas the other tree structures asymptote. We show results for more draft/target model pairs in Figure 6 in Appendix G.3.We present our token tree sampling and verification algorithm, and prove it is the first such algorithm to satisfy two important robustness properties, while maintaining the target model's output distribution.We present the pseudocode for the SEQUOIA Tree sampling and verification algorithm in Algorithm 2. As discussed in Section 2, an important motivation for designing the SEQUOIA verification algorithm was the observation that SpecInfer and SpecTr both perform poorly at low temperatures, due to the fact that they can repeatedly sample (and then reject) a low-quality token that the draft model is confident in. Thus, we wanted to design an algorithm that would never make the same mistake twice-meaning, once a token was rejected, it would never propose that token again. Toward this end, SEQUOIA introduces two changes to the SpecInfer algorithm (shown in blue text in Algorithm 2): First, it performs sampling without replacement using the draft model distribution. Second, if all the tokens with non-zero draft model probability have already been sampled and rejected, it uses the uniform distribution over all tokens that have not yet been sampled as the new draft model distribution. These changes significantly improve the robustness of SEQUOIA relative to SpecInfer, while maintaining the guarantee that the output distribution is identical to that of the target model (proof in Appendix F.2.1).We now prove that the SEQUOIA verification algorithm is robust, in the sense that it satisfies both of the properties below, while existing verification algorithms do not.(The blue lines [10] [11] [12] [13] [14] [15] [16] distinguish SEQUOIA's sampling/verification from SpecInfer's [28] )1: Input: Prefix [x1,x2,...,xn-1], target model probabilities P(• | x<n), draft model probabilities Q(• | x<n),and number of branches k ≤ vocab_size. 2: Output: A token x sampled using SEQUOIA. 3: Initialize residual R with P, draft D with Q, and the set of rejected tokens S with ∅ 4:for i = 1 → k do 5: sample si ∼ D, ri ∼ Uniform(0,1) 6: if ri < R[s i ] D[s i ] then 7:Return si # Accept si 8: else 9:R ← norm(max(R-D,0)) 10:D[si] ← 0 11: S.add(si) 12:if sum(D) = 0 then 13:# Let D be uniform over non-rejected set 14: • The optimal transport property: When k = 1, the acceptance rate is equal to 1-∥P -Q∥1D[t] ← 0 if t ∈ S,. 3 • The cover property: If the support of the draft model probability distribution Q is of size k and is a superset of the support of the target model probability distribution P , at most k speculations will be needed to attain an acceptance rate of 1. Furthermore, if k is equal to the vocabulary size, the acceptance rate should always be 1 as well, regardless of the draft model used.Intuitively, satisfying the optimal transport property results in strong performance at high temperatures (because P and Q will approach uniform distributions), while satisfying the cover property results in strong performance at low temperatures (if top target model token is in the top-k draft model tokens).We now present our main robustness result (proof in Appendix F.3): Theorem 3.7. SEQUOIA verification satisfies both properties (optimal transport, cover); SpecInfer & SpecTr only satisfy the optimal transport property; top-k sampling only satisfies the cover property.In Figure 3 , we plot the average rejection rates (equal to 1acceptance rates) for the different verification algorithms, as a function of the number of speculated child tokens for a fixed token prefix, for various temperatures (0.2, 0.6, 1.0), measured on WikiText-103. We can see that across all temperature settings, the rejection rates for SEQUOIA decay faster than for the other algorithms.In general, we observe that the rejection rates r k for SEQUOIA follow a power-law, where r k ≈ 1/k b for some b > 0. We can also see that while SpecTr and SpecInfer perform relatively well at high temperatures, they struggle at lower temperatures, and that the opposite is true for top-k sampling. 
evaluation: 
 In this section, we aim to demonstrate that SEQUOIA can speed up LLM inference by a large margin in wall-clock time. We first present our end-to-end system results showing total speedup, followed by validating our claims that SEQUOIA is scalable and robust.• In Section 4.1, we demonstrate SEQUOIA's superior end-to-end performance. Specifically, SEQUOIA achieves up-to 4.04× speed-up for Llama2-7B on A100 and 9.5× for Llama3-70B on L40 offloading (achieving the latency as low as 0.60 s/token). • In Section 4.2.1, we show that the SEQUOIA tree can generate on average 33% more tokens than a tree of 16 independent sequences (tree size 512). 3 The SpecTr paper [40] showed that 1-∥P -Q∥ 1is the acceptance rate attained by the optimal verification algorithm for k = 1.Table 1 : On-device results (A100): The optimal tree configuration and speedup for different pairs of draft and target models, and different temperatures, for SEQUOIA vs. SpecInfer. We specify the average number of generated tokens per decoding step in parentheses, next to the speedup factor. SEQUOIA attains up to 4.04× speedup on an A100. The speed of incremental decoding is 24.2ms/token with Huggingface. The draft model speed is 0.5ms/token. TBT refers to time between tokens. • In Section 4.2.2, show SEQUOIA's sampling and verification algorithm is robust to temperature, consistently outperforming SpecInfer (by up to 1.65×) and top-k sampling (by up to 1.27×).We now demonstrate that SEQUOIA speeds up LLM decoding in the on-device setting by up 4.04× on an A100 GPU, and up to 9.5× with offloading on an L40 GPU. Setup. Our experiments are based on Llama and Vicuna models. For the on-device setting, we use JackFram/Llama-68m (JF68m) [28] and princeton-nlp/Sheared-Llama-1.3B (SL1.3B) [46] as the draft models, and Llama2-7B [43] , Llama2-13B, and Vicuna-33B [6] as the target models. For the offloading setting, we use Llama2-7B-chat/Llama3-8B-Instruct as the draft model and Llama2-70B-chat/Llama3-70B-Instruct as the target model. We evaluate our results on C4(en) [35] validation dataset, OpenWebText [14] , CNN DailyMail [36] and MT Bench [52] . In each experiment, we use 200 examples to measure the acceptance rate vector (mentioned in Section 3.1) and sample another 200 examples for evaluation (50 for offloading). The prompt length and generation length are both set to 128 tokens except MT Bench. We evaluate SEQUOIA on different hardware including on-device experiments on L40 and A100(-PCIE 80GB) GPUs, as well as offloading experiments on an L40 GPU (with PCIE4). We also compare SEQUOIA with SpecInfer [28] with 5×8 trees (5 independent sequences of length 8, the tree structure used in [28] for batch size 1) for the on-device setting, and 16×48 trees for the offloading setting.Implementation Details. We implement the draft and target models using Transformers [45] .Because we determine the optimal tree structure in advance, we are able to use PyTorch CUDA graphs [31, 32] to reduce the overhead of kernel launching during speculative decoding. To accelerate sampling without replacement-which is not efficient in PyTorch 2.1 [32] -we use the exponential-sort algorithm [44] , combined with PyTorch CUDA graphs [31, 32] . For offloading setting, we used an DeepSpeed-Zero-Inference [2] as baseline, which is 5.7 s/token. Hardware-Aware Optimization. For each hardware setting we consider in our experiments, we use the following method for selecting the size and depth of the Sequoia tree we should use to maximize speedups, while avoiding doing an exhaustive grid search. Letting G(n,d) denote the expected number of tokens generated by verifying the SEQUOIA tree of size n and depth d (computed via dynamic programming), t(n) denote the (hardware-dependent) amount of time it takes the target model to verify We observe that SEQUOIA consistently speeds up LLM decoding in a wide range of settings. SEQUOIA reaches up to 4.04× speedup for the on-device setting, and up to 9.5× speedup for the offloading setting, as a result of the huge gap between computation capacity and memory bandwidth. Notably, for the offloading setting on L40, SEQUOIA can achieve as low as 0.60 s/token latency. We present additional on-device results (A100 and L40) in Appendix G.Analysis. We made several interesting observations on the interplay between SEQUOIA tree construction, sampling and verification, and hardware-aware optimizer. (1) SEQUOIA selects much larger trees in the offloading setting (768 tokens) than in the on-device setting (64 to 128 tokens). (2) In general, the average number of generated tokens is close to the wall-clock time speedup (especially when JF68M is used as the draft) as a result of the hardware-aware tree optimizer. (3) The optimal trees found by SEQUOIA for slightly different configurations-e.g., different temperatures and model pairs-can be very different from one another. (4) SEQUOIA chooses deeper trees at low temperature than high temperature, due to the acceptance rates being higher for low temperature.We present our ablation experiments validating the scalability of the SEQUOIA tree construction algorithm (Section 4.2.1), and the robustness of SEQUOIA tree sampling and verification algorithm (Section 4.2.2). For each of these experiments, we only vary one element at a time (e.g., the tree structure for Section 4.2.1) to study the gains attained by each component of SEQUOIA.In Figure 4 (left) we compare the average number of generated tokens for the SEQUOIA tree construction method, relative to k independent sequences, at different budgets; we use SEQUOIA's sampling and verification algorithm for all trees. The SEQUOIA tree is able to generate up to 33% more tokens per decoding step, demonstrating the effectiveness of SEQUOIA's tree construction algorithm. Here, we use JackFram/Llama-68m as the draft model, Llama2-13B as the target model, 0.6 as the temperature, and CNN Daily Mail as the dataset.In Figure 4 (right) we compare the SEQUOIA sampling and verification algorithm to SpecInfer and top-k sampling across different temperature values, holding the tree structure fixed. We can see that SEQUOIA achieves the largest speedups across all temperatures, attaining up to 1.65× and 1.27× speedup relative to SpecInfer and top-k sampling, respectively. Here, we use JackFram/Llama-68m as the draft model, Llama2-7B as the target model, CNN Daily Mail as the dataset, and the corresponding SEQUOIA tree from Table 1 (temperature 0.6) as the tree structure. In Table 8 in Appendix G.4, we additionally show that the SEQUOIA sampling/verification algorithm is robust to the top-p parameter.Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?Answer: [Yes] Justification: In our supplementary zip file, we provide all code and evaluation datasets used, along with a README with instructions. We use public checkpoints for all draft and target models, public data for all evaluations, and report the hardware and hyperparameters used for each experiment. 
conclusion: 
 We presented SEQUOIA, a scalable and robust speculative decoding method. By improving the topology of the token tree and the sampling algorithms, SEQUOIA is able to speed up autoregressive LLM inference up to 4.04× on GPU and 9.5× with offloading. In addition to providing real speedups, we believe SEQUOIA also provides insight into both the large potential and fundamental limits of speculative decoding systems. We hope that this understanding inspires future work in this area, or even informs the design of custom chips for LLM inference. 
safeguards: 
 Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)? Answer: [NA] Justification: We do not release new data or models. Guidelines:• The answer NA means that the paper poses no such risks.• Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort. 12. Licenses for existing assets Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected? Answer: [Yes] Justification: We cite the papers that introduced the models and data used in our work. Guidelines:• The answer NA means that the paper does not use existing assets.• The authors should cite the original paper that produced the code package or dataset.• The authors should state which version of the asset is used and, if possible, include a URL. • The name of the license (e.g., CC-BY 4.0) should be included for each asset.• For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided. • If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. 
 
 Appendix: In this paper, we present a new algorithm for accelerating speculative decoding. While there are numerous application scenarios of large language models that warrant additional study regarding possible societal impact, we would like to highlight that our work does not advance the capabilities of these models. Our work is primarily an algorithmic study with no specific usage limitations, and while LLMs themselves can be used with malicious purpose, we believe that none of such use cases are specific to this paper.Theoretical limitations: On the theoretical front, there are two primary limitations to our results:1. The positional acceptance assumption (Definition 3.1: The optimality of our dynamic program depends on this assumption. In particular, this assumption states that the only factor influencing the acceptance rate for a token is what "number child" it is to it's "parent token" (e.g., if it is the first or fifth sampled token to follow the "parent" token). This allows us to model the acceptance dynamics using simple closed form equations, which ignore all contextual factors impacting acceptance rates (e.g., the current prefix, the confidence of the draft model, etc.).2. The b power law acceptance rate (Definition 3.5): While we observe in our experiments that SEQUOIA satisfies this assumption (see Figure 3 ), it's important to note that need this assumption for our theoretical results on the scalability of SEQUOIA trees to hold (Theorem F.2).In terms of the limitations of SEQUOIA in practice, the most important limitation/challenge is likely that the structure of the optimal SEQUOIA tree depends on the exact (average) acceptance rate vector, which depends on the draft/target model pair, temperature value, data domain, etc. The optimal tree also depends on the batch size, which can be considered by the hardware-aware optimizer. It is relatively work-intensive to have to measure the acceptance rate vector for each setting, and use this vector to compute the optimal tree. In practice, we believe computing a single tree for a typical use case can work well for other use cases (e.g., higher/lower temperatures, different data domains), but we leave a more thorough analysis of this issue for future work.This work introduces a new algorithm in the family of speculative decoding methods that aims to maintain the exact output distribution of the target model by improving the structure and sampling/verification algorithm for the speculated token tree. There exist many other directions within this line of work-for example, methods which introduce leniency into the speculative decoding algorithm to attain increased speed at the cost of accuracy [22, 38] , methods that reuse layers or representations from the target model as the draft model [50, 4] , etc. Alternatively, the draft model can be distilled to better approximate the target model; DistillSpec [53, 18, 41, 42] improves that process by using model-generated data and adjusting the objective depending on the task and the decoding strategy. Finally, LLMCad [47] proposes an advanced algorithm for token tree generation and verification in the context of on-device LLM inference.In addition to speculative decoding, there exist many other methods aimed at improving the speed of LLM inference. For example, model quantization is another very promising way of dealing with the I/O bottleneck during inference, by reducing the number of bits per parameter. However, unlike speculative decoding, these methods generally deteriorate the quality of the model to some degree, depending on the amount of quantization [17, 20, 30, 51, 26, 13, 10] or sparsity [29, 27, 19] .Meanwhile, various works [12, 39, 48, 1] have studied ways to improve LLM serving throughput. Pope et al. [33] investigated the batching effect in scaling up LLM. Orca [49] proposed a distributed LLM serving system that uses a finegrained scheduling policy to improve GPU utilization under various request lengths. vLLM [23] used page tables to manage GPU memory to increase memory utilization, which significantly boosts inference throughput. FlexGen [37] proposed an offloading mechanism to support larger batches to achieve high throughput.FlashAttention [9, 8] is another algorithm that aims to improve the speed of LLMs (at both training and inference time) by considering the I/O cost of different operations.Another promising approaching to speeding up inference is to change the fundamental building blocks of the model. Recently, numerous sub-quadratic architectures-including SSMs [16, 15] and linear attention models [21] -have been proposed. These models are particularly beneficial for long inputs.The original speculative decoding method [24, 5] proposes using a small "draft model" to speculate γ tokens into the future, and then using the "target model" to in parallel process these tokens and decide which of the tokens to "accept", in such a way that the output distribution of the target model is unchanged. This algorithm is presented in Algorithm 3.Leviathan et al. [24] analyze the performance of this algorithm, presenting equations for the expected number of accepted tokens from one run of the algorithm, and the expected wall-clock speed up from using speculative decoding (relative to standard autoregressive inference with the target model). In this analysis, they introduce the acceptance rate α ∈ [0,1], corresponding to the probability that a token x i is accepted by Algorithm 3, under the simplifying assumption that the acceptance decisions are i.i.d. 4 Under this assumption, they show that the expected number of generated tokens in each run of Algorithm 3 is 1-α γ+1 1-α . Additionally, letting c denote the ratio between the time to run the draft model and the time to run the target model, they show that the expected wall-clock speed-up from using this algorithm is 1-α γ+1(1-α)(γc+1) .Algorithm 3 Sequence-based Speculative Decoding q i (x) ← M q ([x 1 ,...,x i-1 ]) 5:x i ∼ q i (x) 6: end for 7: for i = n → n+γ do ▷ For loop below can be run in parallel with a single forward pass of M p 8:p i (x) ← M q ([x 1 ,...,x i-1 ]) p ′ (x) ← norm(max(0,p s+1 (x)-q s+1 (x))) 22: end if 23: t ∼ p ′ (x)▷ Sample a final token from p ′ (x) 24: Return x 1 ,...,x s ,tBelow we show more examples of SEQUOIA trees of various sizes. Note that for these plots we do not limit the depth of the tree. The acceptance rate vector we used for this (shown below) was computed with Llama3-70B-Instruct target model, Llama3-8B-Instruct draft model, on CNN daily news dataset: [0.7732, 0.1039, 0.0402, 0.0206, 0.0128, 0.0081, 0.0064, 0.0043, 0.0035, 0.0026, 0.0025, 0.0021, 0.0016, 0.0014, 0.0010, 0.0010, 0.0010, 0.0007, 0.0007, 0.0006, 0.0007, 0.0006, 0.0004, 0.0004, 0.0005, 0.0006, 0.0004, 0.0003, 0.0002, 0.0004, 0.0001]. We present additional details (as well as proofs for theorems) about the SEQUOIA tree construction (Section F.1) and tree sampling and verification (Section F.2) methods.We begin by presenting details about the SEQUOIA tree construction algorithm, and its corresponding theoretical properties.In this section, we present an extended version of the SEQUOIA tree construction dynamic programming (DP) algorithm (Algorithm 1), including a full python implementation of this extended algorithm (Algorithm 4). In Algorithm 1, we showed how to compute the expected number of generated tokens for the optimal tree of size N (and branching factor ≤ B). Here, we extend the algorithm to be able to handle:1. An upper bound D on the depth of the token tree, and 2. Self-speculation methods like Eagle [25] whose acceptance rates decay for tokens that are deeper in the speculated tree.We then show how to additionally generate the optimal tree structure using dynamic programming, for these more general settings.Extensions to bounded depth and self-speculation methods: To handle the above cases, we assume that we have a 2-D array p, where P [d, b] is the probability of acceptance for a node at depth d and branch number b. Here we assume p is zero-indexed, so depth 0 corresponds to the direct children of the root node. We also assume p has shape (D -1, B +1), where D is the limit on the depth of the speculated tree, and B is the limit on the branch factor of the tree (max number of children per node). This allows us to infer that when we are computing T [n, d, b] (during the internal running of the DP algorithm), in the case where the root node has a depth limit of D, the node being considered has depth limit d it must be at depth D-d; thus, D-d is the index of the P array (at dimension 0) that should be used at that time. Using this fact, we can show that the recursion equation for Eagle (with bounded depth) is quite similar the one from Equation 1 (and Algorithm 1) in Section 3.1.1:T [n, d, b] = max 1≤m≤n-1 T [n-m, d, b-1]+P [D-d, b]• max 0≤j≤B T [m, d-1, j]) ∀ 2 ≤ n ≤ N, 2 ≤ d ≤ D, 2 ≤ b ≤ B.Constructing the optimal tree structure: In the python implementation below of the extended SEQUOIA DP algorithm (Algorithm 4), we show how to recursively construct the optimal tree structure for each tree size n and depth limit d. Throughout the DP we maintain the following data structures:• This demonstrates how to build the optimal tree as part of the dynamic program. We now prove Proposition 3.4 by deriving the closed-form expression for F (T ) (the expected number of tokens generated by verifying tree T ), and show how to use dynamic programming to find the optimal tree T under a tree budget size.Proposition F.1. Let T be a token tree that is verified with the positional acceptance assumption, and let f (v) denote the score function for a node v ∈ T . Then the expected number of tokens F (T ) generated by verifying T is equal toF (T ) = v∈T f (v) .Proof. Let D(T ) denote the expected number of tokens generated by verifying tree T . We would like to prove that D(T ) = F (T ) ∀T . We will prove this by induction on the size of T .Base case (N = 1): A tree of size 1 is composed solely of the root node. By definition of the score function f (v) (Definition 3.3), we know that f (v) = 1 for the root node, so F (T ) = 1. D(T ) = 1 also, because verifying a tree composed of a root node with no children will simply sample from the target model, and generate 1 token.Inductive step (N > 1): For |T | = N > 1, let v be a leaf of T at child index i v of depth d with parent v p and sibling S v (set of sibling indices). We can then consider the tree T ′ = T -{v}. Based on the inductive assumption, we know that g(T ′ ) = D(T ′ ). Using this assumption, we can express D(T ) in terms of D(T ′ ):D(T ) = D(T ′ )-(d-1)•f (v p )• 1- i∈Sv p i +(d-1)•f (v p )• 1- i∈Sv∪{iv} p i +d•f (v) = D(T ′ )-(d-1)f (v p )p iv +d•f (v) = v ′ ∈T ′ f (v ′ )-(d-1)f (v)+d•f (v) = F (T ′ )+f (v) = F (T )Note that we use the inductive hypothesis, along with the fact the f(v p )•p iv = f (v) (by definition of f (v)).We now prove that, under certain assumptions on the acceptance rates of the tree verification algorithm, the expected number of tokens generated by verifying the SEQUOIA tree is lower bounded by a function which is roughly logarithmic in the size of the tree. We will do this by showing that a simpler tree-the k * (n) tree (defined below)-also has this lower bound, and using the fact that the SEQUOIA tree is by construction the tree with the largest expected number of generated tokens.We define the k * (n) tree to be the k-ary tree5 with ≤ n nodes that has the highest expected accepted sequence length. Letting G(n) denote the expected accepted sequence length for the k * (n) tree, we will now prove that G(n) ∈ Ω blog(n)/log(log(n) (meaning, it is lower-bounded by a scalar multiple of blog(n)/log(log(n))), under the assumption that the rejection rate r k is upper-bounded by a power-law of k. It then follows directly (as a corollary) that the growth rate of the tree generated by the SEQUOIA algorithm will also be in Ω blog(n)/log(log(n) .Theorem F.2. Assume the chance r k of a token tree verification algorithm rejecting all k speculated tokens (k child nodes of some node in the tree) is upper bounded by a power-law of k; sor k ≤ 1/k b for some b > 0 ∈ R. Then the growth rate G(n) for the k * (n) tree is in Ω blog(n)/log(log(n) .Proof. We will let k(n) = ⌊log(n) 1/b ⌋ denote the branch-width chosen for tree size n, and show that under this assumption, the growth rate G ′ (n) of the corresponding k(n)-tree is at least blog(n) 10log(log(n) , assuming that n is large enough. Given that G ′ (n) is a lower bound on G(n) (because the above choice of k(n) might not be fully optimal), and using the definition of Ω, this proves that G(n) ∈ Ω blog(n)/log(log(n) . Note that we will abbreviate k(n) as k in many places throughout the proof, for brevity.If we let d denote the depth of the tree, the number of nodes in the tree is1 + k + k 2 + ... + k d = k d+1 -1 k-1 ≤ n. This implies d ≤ log k (n), which we can prove as follows:k d+1 -1 ≤ n(k-1) ⇒k d+1 ≤ nk-n+1 ≤ nk ⇒d+1 ≤ log k (nk) = log k (n)+1 ⇒d ≤ log k (n)We can assume d is the largest integer such that d ≤ log k (n), so it also follows that d+1 ≥ log k (n).Letting α k := 1-r k , the expected length G ′ (n) of the accepted token sequence can be expressed as1•(1-α k )+2α k •(1-α k )+3α 2 k (1-α k )+...+(d+1)α d k = 1+α k +α 2 k +...+α d k = 1-α d+1 k1-α k (the first equality is a result of telescoping sums, the second is from the sum of a finite geometric series). We will now lower bound this expression, making use of Lemma F.4 (defined and proven below).EQUATIONapplying Lemma F.4, and assuming r k •(d+1) ≤ log(1.9)≥ log k (n) 10 = log(n) 10log(k) ≤ log(n) 10log(log(n) 1/b ) = blog(n) 10log(log(n))Now we simply need to understand when r k •(d+1) ≤ log(1.9):r k •(d+1) ≤ 1 k b log k (n)+1 ≤ 2log k (n) (log(n) 1/b -1) b using k(n) = ⌊log(n) 1/b ⌋ ≥ log(n) 1/b -1 ≤ 2log k (n) ( 1 2 log(n) 1/b ) b assuming log(n) 1/b ≥ 2 ⇔ n ≥ exp(2 b ) = 2 b+1 log(n) log(k)log(n) = 2 b+1 log(k)So if 2 b+1 log(k) ≤ log(1.9), then it follows that r k •(d+1) ≤ log(1.9).2 b+1 log(k) ≤ log(1.9) ⇔ 2 b+1 log(1.9) ≤ log(k) ⇔ exp 2 b+1 log(1.9) ≤ k Given that k(n) = ⌊log(n) 1/b ⌋ ≥ log(n) 1/b -1, we know that if log(n) 1/b -1 ≥ exp 2 b+1 log(1.9) , then it must hold that k(n) ≥ exp 2 b+1log(1.9)as well. We can see that this holds if:log(n) 1/b -1 ≥ exp 2 b+1 log(1.9)⇔ n ≥ exp 1+exp 2 b+1 log(1.9) b Thus, we have shown that as long as n is greater than the above expression, thenG ′ (n) ≥ blog(n) 10log(log(n) . Because we know that G(n) ≥ G ′ (n), this concludes the proof that G(n) is in Ω blog(n)/log(log(n) .We now prove, as a corollary of Theorem F.2, that the growth rate of the SEQUOIA tree is also in Ω blog(n)/log(log(n) .Corollary F.3. Under the same assumptions on the rejection rates as Theorem F.2, it holds that the growth rate for the SEQUOIA tree is in Ω blog(n)/log(log(n) .Proof. By construction, for every tree size n, the SEQUOIA tree is the tree that has the largest expected number of generated tokens. Thus, for every value of n the expected number of generated tokens for the SEQUOIA tree must be larger than that of the k * (n) tree, which was shown in Theorem F.2 to be in Ω blog(n)/log(log(n) . This concludes the proof.We now prove the lemma that we used to prove Theorem F.2: Lemma F.4. For any real number x ∈ (0,1], and integer m > 0 such that mx ≤ log(1.9), it holds that1-(1-x) m x ≥ m 10 .Proof.EQUATIONAssuming e mx ≤ 1.9, which is true by our initial assumption.We now move on to presenting proofs about the correctness and robustness of the SEQUOIA sampling and verification method.We prove now that the SEQUOIA verification algorithm maintains the output distribution of the target model. We assume we have a target model t, and a list of draft models (d 1 ,...d n ,d n+1 ,...), where d i in this case depends on the previously rejected samples x 1 ,...,x i-1 , and where d i (u) and t(u) denote the probabilities of sampling token u ∈ V from d i or t respectively (where V is the token vocabulary). We let t i denote the residual at iteration i of SEQUOIA loop, (after i-1 nodes have been rejected (so t 1 = t, as can be seen in Algorithm 2)We will prove by induction on the number of proposed tokens n that the SEQUOIA verification algorithm is correct.Base case (n = 0): SEQUOIA is trivially correct, as it will simply sample from the residual t 1 , which is equal to t.Recursive case: We assume SEQUOIA is correct for n-1 proposed samples and prove it is correct for n proposed samples.We first show that at stage i in the speculative decoding algorithm, the chance of SEQUOIA choosing to reject the proposed sample is equal to x max 0, t i (x)-d i (x) :Lemma F.5. P(No token accepted at iteration i) = x max 0, t i (x)-d i (x) .Proof.i) = x P (sample x)•P (reject x | x is sampled) = x d i (x)• 1-min t i (x) d i (x) ,1 = x d i (x)- x min t i (x), d i (x) = x t i (x)- x min t i (x), d i (x) = x t i (x)+max -t i (x),-d i (x) = x t i (x)-t i (x)+max 0, t i (x)-d i (x) = x max 0, t i (x)-d i (x)We are now ready to prove the recursive case of the SEQUOIA algorithm. By the inductive hypothesis, we know that for all u ∈ V , t(u) = P (u accepted in first n-1 iterations)+P (No token accepted in first n-1 iterations)•t n (u)What this means is that in the case where we run SEQUOIA for n -1 iterations (and if no token is accepted we sample from the residual t n ), this is equivalent to sampling from the target distribution t directly. We would like to show that this output distribution is equivalent to the one we would get if we run SEQUOIA for n iterations (and if no token is accepted we sample from the residual t n+1 ). The output distribution of this scenario can be written as follows:P (u accepted in first n-1 iterations)+P (No token accepted in first n-1 iterations)• d n (u)•P (u accepted at iteration n)+P (No token accepted in iteration n)•t n+1 (u)Thus, all we must show is thatt n (u) = d n (u)•P (u accepted at iteration n)+P (No token accepted in iteration n)•t n+1 (u)We now show this desired result. We will use Lemma F.5, and the fact that by definition of the SpecInfer algorithm (see Algorithm 2, ignoring blue lines), we know that t n+1 (u) = max 0, tn(u)-dn(u)x max 0, tn(x)-dn(x).d n (u)•P (u accepted at iteration n)+P (No token accepted in iteration n)•t n+1 (u) = d n (u)•min 1, t n (u) d n (u) + x max 0, t n (x)-d n (x) t n+1 (u) = min d n (u), t n (u) + x max 0, t n (x)-d n (x) • max 0,t n (u)-d n (u) x max 0,t n (x)-d n (x) = min d n (u), t n (u) +max 0, t n (u)-d n (u) = t n (u)To see that this last equality holds, we consider two cases:1. Case 1 t n (u) ≥ d n (u) : min(d n (u), t n (u)) + max(0, t n (u) -d n (u)) = d n (u) + t n (u) - d n (u) = t n (u). 2. Case 1 t n (u) < d n (u) : min(d n (u), t n (u))+max(0, t n (u)-d n (u)) = t n (u)+0 = t n (u).This completes the proof.We now prove the robustness results for the SEQUOIA verification algorithm.Theorem F.6. The SEQUOIA verification algorithm satisfies both the optimal transport and the cover properties, while SpecInfer and SpecTr only satisfy the optimal transport property, and (top-k) naive sampling only satisfies the cover property.Proof. This proof is quite straightforward:• SEQUOIA satisfies the optimal transport property: It is clear that SEQUOIA satisfies the optimal transport property, because at k = 1, it is identical to the original speculative decoding algorithm [24] .• SEQUOIA satisfies the cover property: To see why SEQUOIA satisfies the cover property, we will use the following two facts:-If the support of Q is of size k and k tokens are speculated by the draft model, the set of speculated tokens will always exactly equal the k tokens in the support of Q (because SEQUOIA does sampling without replacement from the draft model). -During the verification for-loop in Algorithm 2, the support of the residual will always be contained in the support of P intersected with the set of tokens that have not yet been rejected. This is because the support of the residual can never grow (because p i (x) = 0 ⇒ p i+1 (x) = norm(max(p i -q i ,0))(x) = 0, where p i and q i denote the residual and draft probabilities at iteration i, respectively), and because if a token x is rejected it will "exit" the residual (because x is rejected implies q i (x) > p i (x) which implies that p i+1 (x) = norm(max(p i -q i ,0))(x) = 0).Combining these two facts, we can see that if the first k -1 tokens were rejected, then the k th token must be accepted, because the residual must be a one-hot vector with probability 1 at the only remaining token, and the (updated) draft probabilities will also be this same one-hot vector (and thus, accepted with probability 1). Additionally, we can see that if V tokens are sampled (where V is the vocab size), these must exactly equal the V tokens in the vocabulary, and thus one of those tokens must be accepted. In the case where the support of Q is equal to the full vocabulary, this result follows directly from the discussion above. In the case where the support of Q does not equal the full vocabulary, this is a result of the fact that once all tokens in the support of Q have been sampled and rejected, we begin sampling (without replacement) from the uniform distribution over all non-rejected tokens.• SpecInfer satisfies the optimal transport property: For k = 1, SpecInfer is identical to the original speculative decoding algorithm [24] .• SpecInfer does not satisfy the cover property: It is easy to see that SpecInfer does not satisfy the cover property, with the following counter-example. Let Q = [0.5,0.5] and P = [1.0,0]. We can see that the support of Q is of size 2 and contains the support of P . But with probability 25%, SpecInfer will sample the second token twice in a row, and will reject both of them.• SpecTr satisfies the optimal transport property: For k = 1, SpecTr is identical to the original speculative decoding algorithm [24] , because γ = 1 by definition.• SpecTr does not satisfies the cover property: We can show that SpecTr (in particular, the 'k-sequential selection' algorithm from [40] ) does not satisfy the cover property, with the following counter-example. Let P = [1, 0] and Q = [0.5, 0.5]. Then β p,q (γ) = 1 x=0 min(Q(x), P (x)/γ) = min(0.5, 1/γ) + min(0.5, 0/γ) = 0.5 (because γ ∈ [1, 2] by assumption). We know the acceptance rate of SpecTr is 1 -(1 -β p,q (γ)) 2 = 1-(1-0.5) 2 = 0.75 ̸ = 1. Thus, SpecTr does not satisfy the cover property.• Top-k naive sampling does not satisfy the optimal transport property: Letting Q = [0.6,0.4] and P = [0.6,0.4], we can see that top-k naive sampling will accept with probability 0.6, whereas 1-∥P -Q∥/2 = 1.0.• Top-k naive sampling satisfies the cover property: It's easy to see that if the support of Q is of size k and contains the support of P , then top-k naive sampling will always accept (because it will sample from the target model and accept if the sampled token is among the top-k tokens according to the draft model). Similarly, if k = V , it must accept as well (because the top-V tokens must be the full vocabulary, and so any sample from the target model must accept).We provide additional end-to-end results comparing SEQUOIA to baselines, extending the results from Section 4.1. Here (Tables 3 and 4 ), we provide on-device results on A100 and L40 GPUs, for a more extended set of models, relative to the results in Table 1 , but on different hardware.To demonstrate the optimality of SEQUOIA's tree construction, we provide a sweep of tree configurations and corresponding speedups of SpecInfer in Tables 5 and 6 . SEQUOIA attains better speedups in both greedy decoding and stochastic decoding than all tree configurations of SpecInfer.Here we present additional results demonstrating the scalability of the SEQUOIA tree construction algorithm relative to baselines, for several Pythia draft and target model pairs on the WikiText-103 dataset:Table 3 : On-device results (A100): The optimal tree configuration and speedup for different pairs of draft and target models, and different temperatures, for SEQUOIA vs. SpecInfer. We specify the average number of generated tokens per decoding step in parentheses, next to the speedup factor. SEQUOIA attains up to 4.04× speedup on an A100. TBT refers to time between tokens. As mentioned in Section 4.1, one of the inputs to the hardware aware optimizer is t(n), which is the hardware-dependent amount of time it takes the target model to verify n tokens divided by the time to verify 1 token. In Figure 8 we show the forward pass times for different models on different hardware, for different number of tokens n. As you can see, the forward pass times are roughly constant for low values of n, but then eventually start growing roughly linearly in n-the value of n at which t(n) begins to grow is model and hardware dependent. In general, this value of n is lower for hardware that has Figure 7 : We compare the wall-clock time speedup of SEQUOIA trees of various sizes (orange lines)-chosen to maximize the # generated tokens-with the speedup of the trees selected by the hardware-aware tree optimizer (horizontal green lines)-chosen to maximize speedup-on A100 and L40 GPUs. The optimizer can select the optimal tree size and depth for each type of hardware; by limiting the depth of the tree it can make speculation faster and thus attain larger speedups than the trees with unconstrained depth (orange lines). We use these values to choose the optimal tree. a higher ratio of bandwidth (between GPU HBM and SRAM) to FLOPS, because it is less memory bound).Justification: All theoretical results are proven in Appendix F, and all assumptions are defined in Section 3.Guidelines:• The answer NA means that the paper does not include theoretical results.• All the theorems, formulas, and proofs in the paper should be numbered and crossreferenced. • All assumptions should be clearly stated or referenced in the statement of any theorems.• The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition. • Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material. • Theorems and Lemmas that the proof relies upon should be properly referenced.• The answer NA means that the paper does not include experiments.• If the paper includes experiments, a No answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not. • If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable. • Depending on the contribution, reproducibility can be accomplished in various ways.For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed. • While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. , with an open-source dataset or instructions for how to construct the dataset). (d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results.• The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.) • The assumptions made should be given (e.g., Normally distributed errors). • It should be clear whether the error bar is the standard deviation or the standard error of the mean. • It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified. • For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g. negative error rates). Guidelines:• The answer NA means that there is no societal impact of the work performed.• If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact.• Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations. • The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML).Top-k sampling is an improved version of naive sampling which we introduce as a baseline in this work.One can think of α as the average acceptance rate over many runs of this algorithm on a representative dataset.Recall that a k-ary tree is one where every non-leaf node has k children. 


Decision: The reviewers unanimously praise the paper's strong theoretical guarantees, novelty and extensive evaluation.
Furthermore, the reviewers either acknowledged the rebuttal addresses their concerns (uMCB) or that it is detailed and did not follow with more comments (yRtD). Given that and the initial support for the paper, there does not seem to be any outstanding issues regarding the paper. I have read it quickly and it appears to be of high quality and, importantly, the authors include discussion about limitations in the appendix. Considering all the things, and especially its theoretical grounding and resulting strong performance, it is a clear candidate for acceptance.

The only ask for the authors would be to incorporate as much as possible from the review process into a revision of their paper, since I expect a lot of those things would be interesting for potential readers as well.

Reviews: review: paper_summary: paper_summary: In this paper, the authors propose a novel speculative decoding algorithm to accelerate LLM generation. By leveraging the positional acceptance assumption and dynamic programming, they can determine an optimal tree topology with the tree size and depth. The experiments demonstrate that the proposed method outperforms previous works across various settings.
strength_weakness: strength_weakness: 1. The experimental setup for offloading is not clearly explained. It is unclear if the draft model is placed on a GPU while part of the target model is on the GPU and the other part on the CPU. If this is the case, the speedup is understandable since the throughput of the target model would be very low, and the draft model can run very fast.
2. The comparison with the SpecInfer algorithm may not be fair. In Table 1, the size of the SpecInfer tree is 5x8=40, which is much smaller than the Sequoria tree. On the other hand, in Table 2, the size of the SpecInfer tree is 16x48=768, the same as the Sequoria tree. However, the length of SpecInfer would be very long (48) in this case, which seems impractical.
questions: questions: 1. What is the standalone throughput of the draft and target models under different configurations? This information would help readers understand where the speedup comes from.
2. How do you determine the best configuration of SpecInfer for comparison?
3. How accurate is the acceptance rate vector measuring with 200 examples?
4. Should the dynamic programming algorithm also consider the standalone throughput of the target and draft models? For instance, if the draft model is exactly the same as the target model, each element in the acceptance rate vector would be close to one, as the draft model can generate the same output as the target model. In this case, the tree will keep growing, but the more tokens the draft model generates, the slower it will become.
limitations: limitations: Please refer to the previous sections.
paper_summary: paper_summary: This paper proposed an improvement on the tree-based speculative decoding methods to make the accepted tokens scale roughly in logarithm to the number of tokens generated by the draft model.

The author provided theoretical and empirical justifications for the tree construction and verification procedures.  The experiments shows this method has a good speedup over naive method, and it can generate more tokens each time.
strength_weakness: strength_weakness: 1. The differene with existing tree-based method in algorithm is marginal.
2. The speedups are compared against naive methods.  The speedup over SOTA is not provided.
questions: questions: 1. Could the author provide more reason why they don't compare with multiple draft model version of SpecInfer?
2. Could the author provide more justification for the validity of the positional acceptance assumption?  What's the impact of this assumption theoretically and empirically?  What is the distribution being used if the acceptance probability does not dependent on the token t?
limitations: limitations: The limitations are acknowledged but not fully addressed.
paper_summary: paper_summary: The paper proposes SEQUOIA, an algorithm designed to improve the efficiency of serving large language models (LLMs) through scalable and robust speculative decoding. The SEQUOIA algorithm introduces a dynamic programming method to construct optimal token trees for speculation, enhancing scalability. Additionally, a novel sampling and verification method ensures robustness across various decoding methods (top-k sampling, top-p sampling, temperature, ...). Empirical results demonstrate 4.04x speedup in a small model and 9.5x speedup in a large model with offloading inference.
strength_weakness: strength_weakness: - Building optimal tree is more time-consuming than previous approaches (k-ary tree or k-independent sequences)
- Due to this, the batch size that can benefit from speculation might be much smaller compared to other methods
questions: questions: - In Figure 4, why SpecInfer shows the opposite trend compared to Sequoia & Top-k sampling? In other words, Why it shows higher speedup when the temperature increases?
- It seems that SEQUOIA needs to conduct the dynamic programming algorithm every iteration. How long does that process take?
limitations: limitations: No additional limitations exist.
paper_summary: paper_summary: This paper introduces a speculative decoding method Sequoia, which uses a novel sampling and verification method that outperforms prior work across different decoding temperatures. The speedup of Sequoia is large.
strength_weakness: strength_weakness: 1.  Sequoia shows linear speedup with the tree size growing exponentially. However, it is less useful in batch serving (e.g., vllm). Do you think this problem can be solved by integrating a more efficient draft token proposing method (e.g., Medusa/Eagle) with the proposed Sequoia?
questions: questions: I notice that the speedup of speculative decoding decreases as the temperature grows (and in many previous works). Do you think this problem is solvable?
limitations: limitations: The authors have adequately addressed the limitations and potential negative societal impact.

Comments: comment: Thank you for your response and insightful question!

For long context serving, the memory bottleneck shifts from model parameters to KV cache. The increasing in context length is **orthogonal** to Sequoia since it almost does not increase the arithmetic intensity of decoding process, thus not reducing speculation budget. A recent work, Sun et al 2024 [1] discusses self-speculation for long contexts. We also conducted a simulation based on their methods, finding that Sequoia can help to accept about **30%** more tokens in their offloading setting for Llama-2-7B-128K (on PG19) than k-array trees with 256-512 speculation budget, demonstrating Sequoia's scalability in this scenario. It’s an interesting future work to evaluate Sequoia on a wide range of contexts with various draft models. 

**Simulation Results**
|Budget| 256 | 384| 512|
|----|----|----|----|
|Sequoia|15.2|16.1|16.6|
|16-array-tree|12.1|12.4|12.6|

The number stands for #accepted tokens. 

Thank you once again for your feedback. 

[1] Sun, Hanshi, Zhuoming Chen, Xinyu Yang, Yuandong Tian, and Beidi Chen. Triforce: Lossless acceleration of long sequence generation with hierarchical speculative decoding
Thank you for the responses. The authors have provided sufficient explanations and additional results, which have addressed most of my concerns.

One additional limitation that comes to my mind is the context length: in this work, the context length is relatively short (128). It is unclear how it would perform with a longer context length (up to 8k). This could be explored in future work.
I thank authors for their detailed response. I will maintain my score.