TL;DR
Existing speculative decoding methods force a tough choice: flexible external Transformer drafters that suffer from slow generation and ballooning KV caches, or fast self-speculation heads that must be painfully retrained for each target model. This paper shows that Mamba (a selective state-space model) delivers the best of both worlds—functioning as an ultra-fast, plug-and-play external drafter with constant memory usage and latency, boosted further by an adaptive bandit-based tree search algorithm.
What Problem Does This Paper Address?
Speculative decoding (SD) speeds up large language model (LLM) inference by pairing a heavy target model with a lightweight "drafter" that speculates candidate tokens in advance, which the target then verifies in parallel.
However, existing approaches face a fundamental dilemma:
- External Transformer drafters (e.g., smaller Pythia or Mistral models) can be deployed across different target LLMs, but their attention mechanism suffers from quadratic prefill complexity and linear KV-cache growth, making them slow and memory-hungry on long sequences.
- Self-speculation drafters (e.g., EAGLE, Medusa) leverage the target model's internal representations for speed, but they require costly, bespoke training runs for every individual target architecture and checkpoint.
The authors ask: Can we build a fast, memory-efficient external drafter that retains cross-model flexibility without the Transformer's quadratic baggage?
Methods
The authors replace Transformer-based drafters with Mamba, a linear-time selective State Space Model (SSM):
- Constant Memory & Latency Drafting: Unlike Transformers, Mamba maintains a fixed-size recurrent hidden state. Per-token generation time and decoding memory remain flat regardless of prompt context length.
- Batch-wise Tree-Structured Drafting: To draft multiple branching candidate tokens concurrently, Transformers rely on complex tree attention to avoid duplicating KV caches. For Mamba, branching is trivial: the drafter simply copies the fixed-size recurrent state and runs batched forward steps. The authors optimize this using pre-allocated batch-wise state caches and CUDA computation graphs.
- Dynamic Tree Search via Multi-Armed Bandit (MAB): Optimal tree shapes (depth vs. width) vary across tasks and prompt types. The authors formulate candidate tree selection as an MAB problem, employing Upper Confidence Bound (UCB) at inference time with a reward function derived directly from the theoretical SD speedup objective.
[Prompt Prefix]
│
┌──────┴──────┐
(Mamba State S_t copied across branches)
├── Token A ── Token A1
└── Token B ── Token B1
│
[Target Model parallel verification]
Datasets
- Pre-training & Fine-tuning: Drafters are pre-trained from scratch on FineWeb-Edu (5,000 steps, context 2k) and instruction fine-tuned on ShareGPT. Validation uses HellaSwag, ARC-Easy, and PIQA.
- Pre-trained Evaluation: XSum and CNN-DailyMail (summarization), and GSM-8K (math reasoning).
- Instruction Evaluation: MT-Bench (multi-turn chat), Alpaca (general instruction), and HumanEval (code generation).
- Long-Context Evaluation: Six tasks from LongBench (1k to 8k context lengths): NarrativeQA, Qasper, and MultifieldQA-en (Single-Document QA); HotpotQA, 2WikiMultihopQA, and MuSiQue (Multi-Document QA).
Key Insights and Ideas
- Smaller Mamba models beat larger Transformers: On GSM-8K, a 130M Mamba drafter outperforms a 410M Transformer drafter by nearly 2× throughput (119.67 vs. 63.64 tokens/s in sampling). Because drafting is blazing fast, Mamba can propose more candidates per second even if individual token acceptance rates are slightly lower.
- Better statistical alignment: Reliability diagrams show a 130M Mamba aligns better with a 6.9B target distribution (lower Expected Calibration Error) than a comparable 160M Transformer drafter.
- Robust long-context extrapolation: As input lengths grow from 1k to 8k tokens on LongBench Single-Doc QA, Mistral-160M's acceptance length drops sharply (2.43 → 2.21), while Mamba remains remarkably stable (2.83 → 2.73).
Key Results
- Vs. External Transformer Drafters: On HumanEval with Pythia-6.9B, Mamba-130M boosts generation to 186.45 tokens/s (greedy), compared to 109.51 tokens/s using Pythia-160M drafter and 54.76 tokens/s for vanilla autoregression.
- Vs. State-of-the-Art Self-Speculation (EAGLE): On MT-Bench with Pythia-6.9B, Mamba achieves 133.17 tokens/s, surpassing EAGLE’s 125.61 tokens/s.
- Substantial Memory Savings in Long Contexts: At 8k context on LongBench Single-Doc QA, Mamba consumes 52 GB peak memory compared to EAGLE’s 72 GB (a 20 GB savings) while maintaining higher throughput (26.06 vs. 26.12 tokens/s; and 18.20 vs. 17.36 tokens/s on Multi-Doc QA).
- Cross-Model Portability: A Mamba drafter trained with a Mistral tokenizer applied out-of-the-box to an instruction-tuned Pythia-6.9B target delivers 93.20 tokens/s, approaching the target-specific EAGLE baseline (94.75 tokens/s) without any model-specific retraining.
- Outperforming Sparse KV Baselines: On MuSiQue 8k context, Mamba drafts ~3× faster than TriForce (11.20 ms vs. 36.78 ms), yielding 17.91 vs. 10.81 tokens/s overall throughput.
Limitations and Future Work
- State Maintenance Overhead: While Mamba avoids an expanding KV cache, maintaining recurrent states across large batch sizes during tree branching still incurs memory overhead that could benefit from lower-level systems tuning.
- Bandit Hyperparameters: MAB tree selection depends on preset hyperparameters ($\lambda_{UCB}$, $\lambda_{\gamma}$) and a predefined candidate pool. Fully parameter-free or continuous tree adaptation remains an open problem.
- Self-Drafting with Mamba: The paper evaluates Mamba as an external drafter for Transformer target LLMs. Exploring pure-Mamba architectures where a single model handles both drafting (early layers/heads) and verification remains promising future work.
Summary updated