↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Decoding ahead without a draft model

Medusa and EAGLE speed up decoding with extra trained weights that guess the next tokens. Lookahead decoding needs none. In every forward pass it spends spare parallel capacity on two jobs at once: a lookahead branch that runs Jacobi iterations to produce guesses of future n-grams, and a verification branch that checks n-grams collected earlier against the model's own greedy choice. The output is exactly the greedy answer; the question is only how many tokens each forward yields.

The page decodes Vicuna-7B v1.3 greedily with lookahead decoding on the Medusa and EAGLE tabs' prompt, in float16 on the Mac's GPU, with a window of columns, (so n-grams of five tokens and four levels of guesses) and at most n-grams kept per first token.

Jacobi decoding

Greedy decoding of tokens solves equations, for , one after another. Jacobi iteration solves them all at once: start from any guess and update every position in parallel from the previous guess,

Each iteration is one forward over positions, and it fixes at least the first wrong position, so it reaches greedy's answer in at most iterations. In practice it rarely gains more than one token per iteration: a later token is usually guessed in the wrong context and changes again as soon as an earlier one does. The intermediate guesses still contain useful pieces, short runs of tokens that the model will in fact produce, and lookahead decoding harvests them.

The lookahead branch

The lookahead branch keeps a two-dimensional window of guesses: columns of future positions and levels, each level one earlier Jacobi iteration. The Lookahead branch panel draws it. The token at level , column sits at position after the newest accepted token and attends to the cache, to , to level 0 up to its column and to its own column above it, so each column is a short causal sequence. The model's outputs at the last level form the next level; the oldest level drops out, and every level moves up one.

At the start, level 0 is filled with tokens copied at random from the prompt, and the window needs a few steps to fill, during which each forward yields only one token. Once it is full, every column read downwards together with its new output is tokens at consecutive positions. The N-grams collected panel adds them to a pool keyed by their first token, keeping at most per key and dropping the least recently seen.

The verification branch and the mask

In the same forward, the verification branch takes the pool's n-grams that start with and appends them as candidates. A candidate attends only to the cache, to and to itself, so the model's argmax at each of its tokens is exactly what greedy decoding would compute there; its longest prefix that agrees with those argmaxes is accepted, and the model's own next token after it comes free. The One forward, one mask panel shows the attention mask for , the window and the candidates together (up to 56 tokens per forward here), shaded by the attention weights recorded in block 1. The Verification branch panel lists the candidates and how many tokens of each were kept.

What it gains on this page

The 75-token answer takes 58 Vicuna forwards including the prompt's, 1.29 tokens per forward, against 75 for plain greedy decoding; every token equals greedy's, and the same as the Medusa and EAGLE tabs'. Most forwards (48 of 58) still yield a single token, six keep one n-gram token, one keeps three and three keep four. By the end the pool holds 269 n-grams. The Whole answer table counts forwards the same way for all three methods: Medusa 32, EAGLE 19, lookahead 58, greedy 75.

Each lookahead forward processes dozens of tokens instead of one, and on this Mac that is not free: a step took 250 ms on average against 175 ms for a greedy token, so lookahead decoding measured 5.20 tokens per second against greedy's 5.71. A short answer also spends a larger share of its steps filling the window. The paper's trade is explicit: more FLOPs per step for fewer steps, with the number of steps falling roughly linearly in the logarithm of the per-step FLOPs. On GPUs with spare compute it reports up to 1.8× on MT-Bench and up to 4× with strong scaling over several GPUs on code completion.

Where it came from

Song et al. (2021) sped up feedforward computations such as autoregressive sampling by solving them as nonlinear equations with Jacobi and Gauss–Seidel iterations, and Santilli et al. (2023) applied Jacobi decoding to machine translation. Fu, Bailis, Stoica and Zhang (2024; first described on the LMSYS blog in 2023) added the n-gram pool and the verification branch, which turned Jacobi's discarded guesses into accepted tokens. CLLMs (Kou et al., 2024) went the other way and fine-tuned the model itself so that Jacobi decoding converges in fewer iterations. Drafting by copying, from the prompt or a reference text as LLMA did, needs no extra weights either. The Medusa and EAGLE tabs show what trained draft weights buy on the same answer.

Papers

  1. Break the Sequential Dependency of LLM Inference Using Lookahead Decoding Yichao Fu, Peter Bailis, Ion Stoica, Hao Zhang · ICML 2024 The method on this page: a 2-D window of Jacobi guesses, an n-gram pool and a verification branch in one forward, with its scaling law in FLOPs per step.
  2. Accelerating Transformer Inference for Translation via Parallel Decoding Andrea Santilli et al. · ACL 2023 Greedy decoding reframed as Jacobi and Gauss–Seidel fixed-point iterations, without retraining the model.
  3. Accelerating Feedforward Computation via Parallel Nonlinear Equation Solving Yang Song, Chenlin Meng, Renjie Liao, Stefano Ermon · ICML 2021 Sequential feedforward computations, autoregressive sampling among them, solved as a system of equations by parallel Jacobi iterations.
  4. CLLMs: Consistency Large Language Models Siqi Kou, Lanxiang Hu, Zhezhi He, Zhijie Deng, Hao Zhang · ICML 2024 Fine-tunes a model to jump to the Jacobi fixed point in fewer iterations, the training-side follow-up to Jacobi and lookahead decoding.
  5. Inference with Reference: Lossless Acceleration of Large Language Models Nan Yang et al. · arXiv 2023 Drafts by copying spans from a reference text and verifies them in one forward: another way to speculate without draft weights.
  6. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena Lianmin Zheng et al. · NeurIPS Datasets and Benchmarks 2023 The paper Vicuna's model card cites for Vicuna, the model decoded on this page, and the source of the MT-Bench the lookahead paper measures on.

See also