# Kangaroo: Lossless Self-Speculative Decoding for Accelerating LLMs via Double Early Exiting

Kangaroo speeds up LLM decoding by drafting from the model's own shallow layers

Liu, Fangcheng, Tang, Yehui, Liu, Zhenhua, Ni, Yunsheng, Tang, Duyu, Han, Kai and 1 more · Advances in Neural Information Processing Systems · 2024-12-16

- **Problem** Speculative decoding needs a separate draft model, which is costly to train, and other self-drafting methods accept few tokens.
- **Method** Kangaroo reuses the target's first few layers as a draft model instead of training a new one, adds a small adapter, and stops drafting when confidence drops.
- **Results** Kangaroo averages 1.72× speedup on Vicuna-7B across Spec-Bench with tree decoding, compared to 1.63× for Medusa with tree.

## Why drafting with a second model is costly

Autoregressive decoding of an LLM is limited mainly by memory traffic rather than arithmetic, so the hardware is underused while one token is produced. Speculative decoding exploits that slack: a cheap draft model proposes several tokens, and the big model checks them in one forward pass. The catch is the draft model itself, which is usually a separate network trained from scratch on a large corpus.

Self-drafting methods drop the separate network but bring their own trade-offs. Medusa adds heads on the last decoder layer, and REST retrieves draft tokens from a database. Lookahead reaches a higher token acceptance rate than Medusa on math, yet its drafting is slower, so its end-to-end speedup is slightly lower. Draft & Verify gets high acceptance by skipping layers of the target, but its small model is slow enough to erode the gain.

The authors ask whether a draft can come from the target's own shallow layers without a separate training run. They also ask whether drafting can stop early on hard tokens, so that the cost of drafting stays small.

## Building the draft from shallow layers

Kangaroo takes the first l layers of the target LLM, written \\(M\_b\[:l\]\\), and uses their hidden states as draft features. For a prefix \\(x\_t\\), the shallow features are \\(f\_t = M\_b\[:l\](x\_t)\\), with l chosen from 1 to L. Those early features do not match the representation of the final layer, and the adapter is there to close that gap.

The adapter takes \\(f\_t\\), applies LayerNorm, runs multi-head attention, and adds the result back through a residual connection. The update is \\(f'\_t = f\_t + \\mathrm{MultiHead}(\\mathrm{LayerNorm}(f\_t))\\), and the feed-forward network of a standard block is left out. The target's LM Head \\(W\\) stays frozen and maps the normalized adapter output to the draft distribution \\(M\_s(x \\mid x\_t)=\\mathrm{Softmax}(W^\\top \\mathrm{LayerNorm}(f'\_t))\\).

With hidden size \\(N=4096\\), the adapter has \\(4N^2+2N\\) parameters, which the paper puts at 67.1M. That is about 11.3% of the parameters in Medusa's heads. Because the draft reuses the target's own layers and head, the design avoids training and deploying a separate draft model.

## Verifying drafts in one parallel pass

While drafting, each proposed token also yields an early-exited feature, and those features are kept. They are stacked into one matrix \\(f\_{t:t+\\gamma}\\) of size \\(N \\times (\\gamma+1)\\), and the remaining layers \\(M\_b\[l:\]\\) process that matrix together. So the verification cost is one pass over the upper part of the model, not one pass per drafted token.

The target's top-1 choices are compared with the drafted tokens, following the standard rule. The accepted length is the longest matching prefix plus one, so it ranges from 1 to \\(\\gamma+1\\). Standard speculative decoding keeps the target's sampling distribution, and Kangaroo keeps this acceptance rule.

If every drafted token is accepted, the next round can start one token further along. The unit holding the last two features then saves one drafting pass, because that feature was already computed.

## Training the adapter

Only the adapter's multi-head attention and two normalization layers are trained, while the target model and its LM Head stay fixed. The loss is cross-entropy in which the target's conditional distribution \\(M\_b(x \\mid x\_t)\\) acts as a soft label for \\(\\log M\_s(x \\mid x\_t)\\), averaged over positions \\(t\\). Minimizing this loss pushes the draft distribution toward the target's distribution.

The adapter is trained for 10 epochs with AdamW on the ShareGPT dataset, following Medusa. For Vicuna-7B, training took around 24 hours on 8 NVIDIA V100 GPUs.

## Stopping drafts on low confidence

Fixed-length drafting spends time on hard tokens and can miss easy ones, so Kangaroo stops once confidence drops. The stopping rule is \\(\\max\_{x} M\_s(x \\mid x\_t) \\le \\eta\\), where \\(\\eta\\) is a threshold, so drafting halts when the top-1 probability is at or below \\(\\eta\\). The authors observe that accepted tokens tend to have high top-1 probability, while rejected tokens cluster at lower values.

They treat the top-1 probability as a reliable indicator of acceptance, which is an assumption their own threshold rests on.

In tree decoding, the big model verifies several paths at once, and the same confidence test is applied to each node. A child's confidence is the product of its own conditional probability and its parent's, with the root set to 1. At the first level the top-K tokens are kept, and deeper levels select the top-K from the K times K child candidates.

Expansion stops when the tree reaches a maximum size or when the highest score at a level falls below \\(\\eta\\), and single-sequence decoding is the case K equals 1.

## Speedup on Spec-Bench

The authors test Vicuna-7B and Vicuna-13B on the six Spec-Bench subtasks. Baselines are Lookahead, Medusa, REST and SpS, and SpS uses Vicuna-68M as its draft model. Results are reported as walltime speedup ratio and as Compression Rate.

For Vicuna-7B, Kangaroo with tree decoding averages 1.72×, compared to 1.63× for Medusa with tree. Without the tree, Kangaroo averages 1.50×, compared to 1.41× for Medusa without the tree.

On Vicuna-13B, Kangaroo with tree averages 1.65×, compared to 1.24× for Medusa with tree. Without the tree, Kangaroo averages 1.44×, compared to 1.34× for Medusa without the tree. The authors report about a 12% gain from tree over single-sequence decoding at both model sizes.

Single-sequence Kangaroo with 67M additional parameters is described as comparable to SpS. With tree verification, Kangaroo outperforms SpS on most datasets. Medusa-1 has 591M additional parameters, while the Kangaroo adapter has 67M.

## Adapter design ablation

The authors vary the adapter architecture on Vicuna-7B and report average Spec-Bench speedup next to parameter counts. The feed-forward network makes up 67% of a transformer block's parameters, so it is the main part dropped in the Kangaroo design.

The authors read these rows as support for a lighter adapter at the tested sizes.

## Exit depth and stopping threshold

A deeper exit gives a stronger draft but raises drafting latency, so the exit layer sets a trade-off. The authors set l to 2 for Vicuna-7B and to 3 for Vicuna-13B. They recommend an exit layer between one-sixteenth and one-tenth of the target depth N.

With the threshold at zero, the fixed-step strategy reaches the highest compression rate but a suboptimal walltime speedup. For single-sequence decoding the authors use γ equal to 6 and η equal to 0.6. Across architectures and subtasks, the top-1 confidence distributions point to a stable threshold between 0.6 and 0.8.

## Sampling at non-zero temperature

Two confidence variants are compared: the original top-1 confidence and a top-1 computed from temperature-scaled logits.

At T equal to 0.2 with the original confidence, the average speedup is 1.48×, close to the 1.50× under greedy decoding. The adjusted confidence drops to 1.34× at the same temperature. The authors explain that the adjusted confidence tends to be overestimated when T is below 1, which makes early stopping harder to trigger. At T equal to 0.5 with the original confidence, the average is 1.43×.

## Limitations

The authors say the effect of Kangaroo depends on the target model and the task, and a representation gap may persist in complex tasks. The main evaluation covers Vicuna-7B and Vicuna-13B on Spec-Bench, and Llama2-13B-Chat appears only in an appendix table.

The reported results have no error bars or significance tests. Without them, small gaps between methods can't be read as settled differences. The adapter training cost is reported for Vicuna-7B only.

## Paper info

- **Authors**: Liu, Fangcheng, Tang, Yehui, Liu, Zhenhua, Ni, Yunsheng, Tang, Duyu, Han, Kai, Wang, Yunhe
- **Venue**: Advances in Neural Information Processing Systems · Published
- **First published**: 2024-12-16
- **Added**: 2026-11-25
- **DOI**: 10.52202/079017-0381
- **Original paper terms**: [Check in the original ↗](https://papers.nips.cc/paper_files/paper/2024/hash/16336d94a5ffca8de019087ab7fe403f-Abstract-Conference.html)
- **What we show**: Paper info and commentary

[Original paper ↗](https://papers.nips.cc/paper_files/paper/2024/hash/16336d94a5ffca8de019087ab7fe403f-Abstract-Conference.html)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Liu, Fangcheng, Tang, Yehui, Liu, Zhenhua, Ni, Yunsheng, Tang, Duyu, Han, Kai, Wang, Yunhe (2024). Kangaroo: Lossless Self-Speculative Decoding for Accelerating LLMs via Double Early Exiting. Advances in Neural Information Processing Systems. https://doi.org/10.52202/079017-0381

**BibTeX**

```
@article{fangcheng2024kangaroo,
  title = {{Kangaroo: Lossless Self-Speculative Decoding for Accelerating LLMs via Double Early Exiting}},
  author = {Liu, Fangcheng and Tang, Yehui and Liu, Zhenhua and Ni, Yunsheng and Tang, Duyu and Han, Kai and Wang, Yunhe},
  year = {2024},
  journal = {Advances in Neural Information Processing Systems},
  doi = {10.52202/079017-0381},
  url = {https://papers.nips.cc/paper_files/paper/2024/hash/16336d94a5ffca8de019087ab7fe403f-Abstract-Conference.html}
}
```

## Other paper commentary

- [KMed-31B Technical Report](https://refivu.com/en/papers/f1b37c66-9898-48db-825c-6abc8dde2417-kmed-31b-technical-report.md)
- [Mitigating Backdoors in Masked Diffusion Language Models](https://refivu.com/en/papers/150c4e6d-58c9-4496-8258-d064f65d4e29-mitigating-backdoors-in-masked-diffusion-language-models.md)
- [The Answer Is Not the State: Trajectory-Level Corrigibility in Diffusion Language Models](https://refivu.com/en/papers/69f37831-06db-4b91-8de5-af26e1d6db06-the-answer-is-not-the-state-trajectory-level.md)
- [Exact on Paper: Which LLM Serving Shortcuts Flip Graded Answers, Measured Against the Noise of Reordering the Same Requests](https://refivu.com/en/papers/a49cb446-e471-4aa0-a855-1f5269e00398-exact-on-paper-which-llm-serving-shortcuts-flip.md)
- [Optimal Labelling Designs for Sequential Decisions on Language Model Updates](https://refivu.com/en/papers/66a4f902-e289-4c64-80bb-f0d27a892648-optimal-labelling-designs-for-sequential-decisions-on.md)
- [SAE-Audit: Clinical-Trial Prediction via Inference-Time Optimization of Black-Box LLMs Audited by Sparse Autoencoder Evidence](https://refivu.com/en/papers/86fce25e-e423-4579-8a54-9d29731bae56-sae-audit-clinical-trial-prediction-via-inference-time.md)
- [VeriLadder: A Multi-Agent Specification Refinement System for Tool-Verified Verilog Datasets](https://refivu.com/en/papers/f3a3ce4f-fd41-462e-8bb7-f3e5263ba827-veriladder-a-multi-agent-specification-refinement-system-for.md)
- [From Pairwise to Collective: Encoder Collections Make Unpaired Vision-Language Alignment Reliable](https://refivu.com/en/papers/5dcdb240-b400-425a-832e-273e7da2f0a6-from-pairwise-to-collective-encoder-collections-make.md)
- [Beyond Single-Turn Privacy: Training-Data Leakage in Conversational RAG](https://refivu.com/en/papers/51c92831-e3a5-4575-943b-50961dd4fa10-beyond-single-turn-privacy-training-data-leakage-in.md)
- [What Must a Model Tell a Planner? Outcome Interfaces for Risk-Aware Planning After Robot Damage](https://refivu.com/en/papers/cf59043a-79f8-46e1-ae50-8eb9c875193e-what-must-a-model-tell-a-planner-outcome.md)
- [Open Vision Banana: An Open Framework for Unified Visual Perception through Generation in RGB Space](https://refivu.com/en/papers/576d924e-e958-4776-a33a-b4654b299686-open-vision-banana-an-open-framework-for-unified.md)
- [Make Position Uninformative: Exchangeable Self-Distillation Flattens the Lost-in-the-Middle Curve](https://refivu.com/en/papers/48d101ec-b6d5-4a6c-866d-ab3bd6458801-make-position-uninformative-exchangeable-self-distillation.md)

## Terms in this paper

- [cross-entropy loss](https://refivu.com/en/terms/14067bdf8b9f-cross-entropy-loss)
- [multi-head attention](https://refivu.com/en/terms/370ae5c971cd-multi-head-attention)
- [speculative decoding](https://refivu.com/en/terms/2496d9bbec40-speculative-decoding)
- [compression rate](https://refivu.com/en/terms/c6ce420315b1-compression-rate)
- [ShareGPT](https://refivu.com/en/terms/eec8a738c5eb-sharegpt)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/23eec56f-f281-4574-ac78-9af424b32f10-kangaroo-lossless-self-speculative-decoding-for-accelerating)
