Skip to content

Better & Faster Large Language Models via Multi-token Prediction

Skip →Modern serving: prefix cache, PD, KV
LLM stage 2 #8corefrontierpaperrubric 12/122024 · ~45 min

Fabian Gloeckle, Badr Youbi Idrissi, Baptiste Rozière, …, Gabriel Synnaeve

Status

TL;DR. Train the language model to predict the next nn tokens at every position, using a shared trunk and nn small independent heads. On code, this gives better models at 7B–13B scale, though it hurts small models. At inference you can drop the extra heads, or use them as a free draft model for self-speculative decoding, giving about 3× faster generation for a 4-token 7B code model.

Why it matters now. DeepSeek-V3 trains with a multi-token prediction objective (per its abstract), and newer reports reuse MTP modules for speculative decoding. For RL-trained search agents, rollout generation is often the main cost, so heads that speed up decoding for free are directly useful. The objective is also a clean case study in how changing the loss, not the architecture, shifts what a model learns.

Next-token training minimises −∑tlog⁡Pθ(xt+1∣xt:1)-\sum_t \log P_\theta(x_{t+1}\mid x_{t:1}). MTP instead minimises

Ln=−∑tlog⁡Pθ(xt+n:t+1∣xt:1)=−∑t∑i=1nlog⁡Pθ(xt+i∣zt:1).L_n = -\sum_t \log P_\theta(x_{t+n:t+1}\mid x_{t:1}) = -\sum_t \sum_{i=1}^{n} \log P_\theta(x_{t+i}\mid z_{t:1}).

The factorisation holds because a shared trunk fsf_s produces one latent zt:1z_{t:1}, and nn independent heads fhif_{h_i} (one transformer layer each) predict each future token through a shared unembedding fuf_u:

Pθ(xt+i∣xt:1)=softmax⁡(fu(fhi(fs(xt:1)))).P_\theta(x_{t+i}\mid x_{t:1}) = \operatorname{softmax}\big(f_u(f_{h_i}(f_s(x_{t:1})))\big).

Memory trick. Run forward and backward through one head at a time and accumulate the trunk gradient. Peak logit memory falls from O(nV+d)O(nV + d) to O(V+d)O(V + d) with no runtime cost.

Inference. Use head 1 alone (a normal LM), or draft nn tokens with all heads and verify them with head 1 in the next pass. This is blockwise parallel decoding, a self-speculative scheme that needs no separate draft model.

Multi-token prediction: shared trunk, n output heads, and self-speculative decoding Left: a shared transformer trunk reads tokens up to position t. Four independent one-layer heads sit on top of it and, through a shared unembedding, predict tokens t+1, t+2, t+3 and t+4. Each head adds a cross-entropy loss. Right: at inference the heads draft four tokens in one pass. The next pass checks the drafts with the next-token head and keeps the longest agreeing prefix plus one corrected token. Train with n heads; decode with one head, or use the others as drafters shared trunk reads x₁ … xₜ, outputs zₜ head 1 head 2 head 3 head 4 xₜ₊₁ xₜ₊₂ xₜ₊₃ xₜ₊₄ shared unembedding loss = Σᵢ₌₁..₄ −log P(xₜ₊ᵢ | zₜ), summed over t self-speculative decoding draft (pass k) a b c d verify (pass k+1) a b ✓ c ✓ d′ b and c agree with head 1, so they are kept. d disagrees, so head 1's token d′ replaces it. The same pass also drafts the next block. Paper: 4-token 7B code model ≈ 3.0× faster (≈2.5 of 3 drafts accepted on average)
Original sketch. Training uses n heads on a shared trunk. At inference the extra heads draft tokens, and the next-token head verifies them and keeps the agreeing prefix.
  • Scaling (§3.1, Figure 3). Across six sizes from 300M to 13B on at least 91B code tokens, MTP is worse at small sizes and better at large ones. At 13B it solves 12% more HumanEval and 17% more MBPP problems.
  • Choosing n (§3.4, Table 1). 7B on 200B code tokens: n = 4 is best on HumanEval and MBPP, for example MBPP@1 33.8 against 30.0 for n = 1.
  • Bytes (§3.3). With 8-byte prediction, a 7B byte-level model reaches MBPP@1 32.3 against 19.3 for next-byte training, a 67% relative gain.
  • Multiple epochs (§3.5). At 1T tokens (4 epochs), n = 4 still leads: MBPP@1 43.1 against 40.7, and HumanEval@100 86.2 against 83.0.
  • Speed (§3.2). 3.0× on code with an average of 2.5 of 3 drafts accepted, 2.7× on text, and 6.4× for the 8-byte model.
  • Natural language (§3.7). n = 2 roughly ties next-token training on multiple-choice benchmarks and n = 4 slightly regresses. Summarisation improves for n = 2 and n = 4 at both 200B and 500B tokens, but the gap shrinks at 500B.
  • The gains are concentrated in code and generative metrics. Multiple-choice language benchmarks do not improve.
  • MTP hurts small models, which matters for academic-scale pretraining.
  • The explanations in §5 are speculation, not controlled tests.
  • Heads are independent given ztz_t, so drafted tokens can be mutually inconsistent. This limits acceptance for long drafts.
  • On GSM8K, n = 2 beats the baseline at 200B tokens, but the pattern reverses at 500B tokens (§3.7). The benefit may not survive longer training.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    A 4-token MTP model uses vocabulary 32,000 and trains with 8,192 tokens per GPU micro-batch in bfloat16. (a) Compare peak memory for the logits plus their gradients when all heads are materialised at once and when heads run forward and backward one at a time. (b) With self-speculative decoding, the 7B model accepts on average 2.5 of 3 drafted tokens on code. How many tokens does one forward pass produce, and why is the measured speedup (3.0×) lower than that?

    What a strong answer covers
    • (a) One head's logits: 8192 × 32000 × 2 bytes ≈ 0.52 GB, and the same again for gradients, about 1.05 GB. All four heads at once: about 4.2 GB. One at a time: about 1.05 GB. This is the paper's move from O(nV + d) to O(V + d) per position, at no runtime cost.
    • Only the d-dimensional trunk gradient is kept across heads. The heads' gradients are accumulated into it one by one.
    • (b) Each verify pass yields 1 guaranteed token plus about 2.5 accepted drafts, about 3.5 tokens per pass.
    • The measured 3.0× is lower because each pass also runs the extra heads, verification attends over the drafted positions, and batches with different acceptance lengths waste some compute.
  2. Mechanism

    The paper offers two explanations for why predicting several tokens helps: lookahead weights choice points more heavily, and an information-theoretic argument. Explain both. For the second, use the identity H(X) + H(Y) = H(X | Y) + 2·I(X; Y) + H(Y | X) for consecutive tokens X and Y.

    What a strong answer covers
    • Choice points: a token that decides what follows also affects the loss for later tokens through the extra heads. Counting loss terms, the paper finds weight n(n+1)/2 on choice points against n on inconsequential tokens. Training effort shifts toward decisions that matter.
    • Next-token prediction on X given context, then Y given X, optimises H(X) + H(Y | X). Here H(X) = H(X | Y) + I(X; Y), so the mutual information term appears once.
    • Two-token prediction adds H(Y) given the same context. That equals H(Y | X) + I(X; Y), so the total has I(X; Y) with weight 2. The model is pushed to predict tokens that are informative about what comes next.
    • Both arguments say MTP shifts capacity from local, easy continuations to longer-range structure. This fits the gains on code and on induction and algorithmic tasks (§4).
  3. What if…

    Using the size sweep (300M to 13B parameters) and the n sweep (Table 1, 7B on 200B code tokens), describe when MTP helps and when it hurts, and propose the rule you would use to pick n for a new domain.

    What a strong answer covers
    • Size: MTP hurts small models and helps large ones. At 13B it solves 12% more HumanEval and 17% more MBPP problems than next-token training.
    • Token level: n = 4 is best on MBPP and HumanEval (MBPP@1: 30.0, 30.3, 33.8, 31.9, 30.7 for n = 1, 2, 4, 6, 8). n = 6 wins on APPS/Intro. Byte level: n = 8 is best (MBPP@1 32.3 against 19.3 for n = 1).
    • Natural language at 7B and 200B tokens: n = 2 roughly matches the baseline on choice tasks and n = 4 slightly regresses. Summarisation improves.
    • Rule: choose n to cover a meaningful unit in the domain (a few code tokens, about 8 bytes). Validate on generation tasks, not only on likelihood, and only at a model size large enough to benefit.
  4. Design

    You RL-train a search agent whose cost is dominated by generating long rollouts with a 7B policy. Compare three ways to speed up rollouts: (a) a separate small draft model, (b) MTP heads pretrained with the policy, and (c) heads added and trained only during RL. Address exactness of the sampled distribution, acceptance rates, and drift as the policy changes.

    What a strong answer covers
    • Exactness: greedy verification keeps the next-token head's greedy output unchanged. For sampled rollouts you need the speculative-sampling acceptance rule so that samples still follow the policy distribution and RL stays on-policy.
    • (a) A separate draft drifts away from the policy as RL updates it, so acceptance falls unless the draft is also distilled. It also costs extra memory and serving complexity.
    • (b) Heads share the trunk and update with it. The paper notes pretrained heads are much more accurate than heads added by finetuning a next-token model, so acceptance stays higher.
    • (c) Cheap to add, but heads lag the trunk. Train them with an auxiliary loss on the rollouts themselves, without letting it change the policy.
    • Measure tokens per second, the acceptance rate over RL steps, and the KL between rollouts with and without speculation as a correctness check.
  5. Critique

    The strongest results are on code at 7B–13B, while small models and natural-language choice tasks show no gain or a loss. Critique the claim that MTP is a generally better pretraining objective, and design an experiment that could falsify the choice-point explanation.

    What a strong answer covers
    • Evidence is skewed toward code generation with pass@k, where long-range structure matters a lot. Multiple-choice natural-language benchmarks show no clear gain, and summarisation gains shrink with more training (500B tokens).
    • Comparisons remove n − 1 trunk layers to add n − 1 heads. That keeps parameters fair but changes depth, which could matter separately.
    • The choice-point account is offered as speculation in §5, not tested directly.
    • Falsification: build synthetic data with labelled choice points and controlled amounts of inconsequential filler. If MTP's advantage does not grow with the share of choice-point loss, or if reweighting next-token loss by n(n+1)/2 on choice points recovers the gain, the explanation is wrong or incomplete.
  6. Research idea

    Generative retrieval decodes multi-token document identifiers, and deep-research agents emit long structured tool calls. Propose a research study on whether MTP pretraining or fine-tuning helps either setting, beyond decoding speed.

    What a strong answer covers
    • Hypothesis: docids and tool-call arguments are structured sequences with strong dependencies between tokens, close to the code setting where MTP helped most.
    • Setup: fine-tune the same backbone with n = 1, 2 and 4 heads on docid generation over a fixed corpus such as MS MARCO. Measure Recall@k and the rate of invalid docids, at matched compute.
    • Second axis: self-speculative decoding speed for docids and tool calls. Acceptance should be high when the suffix is nearly determined by the prefix.
    • Controls: next-token training with label smoothing over future tokens, to separate the effect of extra supervision from the effect of the architecture.

Done with this page?

Status