# SparklingTree: 30-40% faster speculative decoding over DSpark TLDR: By combining first-order markov correction (DSpark), DDTree (tree based block diffusion draft speculative decoding), and a best-first search approximation, we create a speculator called SparklingTree. SparklingTree has a +32.7% increase in acceptance at budget 64 (+31.2% wall clock speedup), and +47.4% acceptance at budget 256 (+43.9% wall clock) over DSpark. ![SparklingTree (right) races against DSpark and other speculators, decoding faster.](/content/sparklingtree/race_4way.gif) GitHub: [jwlaboratory/sparkling-tree](https://github.com/jwlaboratory/sparkling-tree) # Understanding DFlash Speculative decoding is a method in which a draft (tiny) language model drafts multiple tokens at once, so that a target (large) model can verify multiple tokens at once (parallel) instead of one at a time. For more information, you should read this article: [Speculative decoding from first principles](https://jwlabs.vercel.app/post/speculative-decoding-first-principles). Traditionally, speculative decoding has been done using autoregressive language models (step by step generation, like ChatGPT or Claude). Over time, advancements from MTP to Medusa to Eagle led to higher and higher acceptance lengths. To increase the max amount of drafted tokens, we would increase the amount of work by a linear factor, since the model is autoregressive. *Actually, it'd be even more than linear, since attention is an $O(n^2)$ operation that grows as the number of tokens increases.* ![As sequence length increases, the wall clock time increases (super) linearly.](/content/sparklingtree/fig-ar-latency.png) Suddenly, the "free drafter" does not look like a free drafter, even though acceptance lengths are high. This motivates DFlash. DFlash uses a block level diffusion draft model, instead of an autoregressive language model. This means that instead of creating one token at a time, DFlash "denoises" an entire block in parallel. (For diffusion models, increasing the number of tokens generated does not increase the latency, while it may reduce quality of the drafter.) ![Diffusion models denoise in parallel, so increasing sequence length does not increase diffusion decoding time.](/content/sparklingtree/fig-diffusion-latency.png) While the quality of the entire DFlash is lower (lower acceptance rate), it can draft 15 tokens instead of traditional drafters, i.e. Eagle3 (drafting just 3 at a time). ![Even though DFlash has a lower per-token acceptance rate, it has more net accepted tokens because of the increased drafting depth.](/content/sparklingtree/fig-eagle-vs-dflash.png) DFlash creates a matrix of marginal probabilities that is sampled from and used as the drafted token for the target. We'll see how this is important in the next section. You can visualize this as a table with `Vocab` columns and `draft block size` rows. $$ \begin{aligned} p_{\mathrm{AR}}(u_{1:k} \mid c) &= \prod_{i=1}^{k} p(u_i \mid c, u_{