FlexDraft: Flexible Speculative Decoding via Attention Tuning and Bonus-Guided Calibration

Yaojie Zhang, Jianuo Huang, Junlong Ke, Yuhang Han, Yongji Long, Tianchen Zhao, Biqing Qi, Linfeng ZhangarXiv 2026

TL;DR

FlexDraft is a lossless speculative decoding framework that accelerates LLM inference by up to 4.59× while seamlessly adapting to varying batch sizes. It overcomes the core limitations of parallel speculative decoding—namely, bonus token and acceptance length uncertainties—through a novel combination of localized attention tuning, bonus-guided calibration, and dynamic execution mode switching.

What Problem Does This Paper Address?

Speculative decoding is a popular strategy to accelerate memory-bound Large Language Model (LLM) inference. It works by using a fast, lightweight "drafter" model to propose multiple candidate tokens, which a larger "target" model then verifies in parallel. Parallel speculative decoding takes this a step further by overlapping drafting and verification within a single target forward pass.

However, existing parallel speculative decoding methods suffer from two fundamental uncertainties that cause their efficiency to collapse, especially at larger batch sizes:

  1. Bonus Token Uncertainty: When the target model rejects a drafted token, it samples a corrected token (the "bonus token"). Because a parallel drafter works ahead without knowing this token, its subsequent drafts often diverge from the target model's actual trajectory, leading to low acceptance rates.
  2. Acceptance Length Uncertainty: The drafter cannot know in advance how many tokens the verifier will accept. To compensate, it must generate candidate branches for all possible accepted lengths. This causes the number of tokens in the target forward pass to grow quadratically ($O(N^2)$), introducing massive computational overhead that destroys throughput gains when serving large batches.
Figure 1: Limitations of the parallel speculative decoding paradigm. (a) Given the prefix, the target model predicts the next token and prefers “Er”, the first token of “Ernest Hemingway”, which constrains the subsequent generation toward Hemingway. Without access to the bonus token, the draft model tends to favor alternative continuations. (b) Accept length uncertainty forces parallel speculative decoding to consider all potentially accepted prefixes of the last draft, requiring mask embeddings to traverse all target layers and causing the target forward token count to grow as O(N 2). The right figure analyzes the resulting overhead for different numbers of target forward tokens, which is moderate at small batch sizes but grows rapidly at larger batch sizes.

Methods

To resolve these bottlenecks, FlexDraft introduces three interconnected designs:

  • Attention Tuning (Attn Tuning): Instead of costly full-model continual pretraining, FlexDraft freezes the target model's feed-forward network (FFN) layers and its standard autoregressive path. It only trains mask-specific attention projectors in the final few layers ($N$ layers). This adds a tiny parameter footprint (~6% of the target model) while perfectly preserving the original target distribution, making the acceleration entirely lossless.
  • Bonus-Guided Calibration: To fix the trajectory mismatch caused by bonus token uncertainty, FlexDraft introduces a lightweight, two-layer MLP. This module conditions on both the hidden states of the mask tokens and the embedding of the resolved bonus token to apply an additive calibration bias directly to the draft logits, steering them back into alignment with the target model.
  • Flex Decoding: FlexDraft dynamically adapts its execution based on the workload. At small batch sizes (where inference is memory-bound), it operates in parallel mode and uses Selective Verification to prune low-confidence draft branches based on cumulative probability. At large batch sizes (where inference becomes compute-bound), it automatically detaches the drafter and switches to a sequential Decoupled Execution mode, reusing the target's KV cache to eliminate redundant branch computation entirely.
Figure 2: Attention masks in FlexDraft. (a) Training. The target performs causal forward to build the clean prefix KV cache. Mask tokens attend bidirectionally within each block and to the prefix, isolated from other blocks. (b) Decoding. Our method supports both parallel and sequential speculative decoding. In parallel mode, the latest draft is verified while candidates for all possible accepted lengths are prepared in the same forward pass. In sequential mode, drafting and verification are executed sequentially by selecting the verification row and its corresponding draft row from the parallel attention mask.

Datasets

  • Training: All trainable baselines and FlexDraft variants were trained on a standardized dataset of 300K samples from mlabonne/open-perfectblend.
  • Evaluation: The authors evaluated FlexDraft across the Qwen3 model series (1.7B, 4B, and 8B parameters) using a diverse suite of standard benchmarks: GSM8K and MATH (mathematical reasoning), HumanEval and MBPP (code generation), and MT-Bench (multi-turn conversation).

Key Insights and Ideas

  • Attention is All You Need to Tune: Pretrained LLMs already encode deep structural knowledge about future tokens within their intermediate representations. You don't need to retrain the whole model to get a good parallel drafter; simply adapting the attention mechanism in the final layers is enough to unlock block-diffusion drafting capabilities.
  • The Detachable Drafter: By localizing the drafting mechanism to mask-specific attention projectors, the drafter becomes completely modular. This architectural choice is what enables Flex Decoding to seamlessly pivot between parallel and sequential execution modes depending on the batch size.
  • Confidence-Based Pruning: Rather than treating all hypothetical draft lengths equally, FlexDraft uses the cumulative product of token probabilities as a proxy for draft confidence. This allows the system to aggressively prune low-probability verification paths before they hit the target model.

Key Results

  • Substantial Speedups: On Qwen3-8B, FlexDraft achieved an average 4.59× speedup over standard autoregressive decoding under data-matched conditions, outperforming sequential methods like EAGLE-3 and dFlash, as well as parallel methods like BiTA and Apple MTP.
  • Robust Scaling: Under scaled training conditions, FlexDraft achieved up to a 5.88× speedup on the GSM8K benchmark.
  • Maintained Performance at Scale: Thanks to Flex Decoding, FlexDraft successfully prevented the speedup collapse typically seen in parallel speculative decoding at batch sizes of 2, 4, 8, and 16, maintaining superior latency reduction across the board.

Limitations and Future Work

  • Draft Depth Trade-offs: The authors noted that while increasing the number of trained draft layers (e.g., up to 13 layers) slightly improves acceptance lengths in parallel settings, it increases parameter overhead and draft computation costs, making it less efficient during large-batch decoupled execution. They settled on 10 layers as a balanced default.
  • Future Directions: While the paper thoroughly addresses batch size scaling, future work could explore how FlexDraft handles extremely long context windows or highly creative generation tasks where sampling temperatures are high and token predictability decreases.

Summary updated

BibTeX
@misc{zhang2026flexdraft,
  author = {Yaojie Zhang and Jianuo Huang and Junlong Ke and Yuhang Han and Yongji Long and Tianchen Zhao and Biqing Qi and Linfeng Zhang},
  title = {{FlexDraft: Flexible Speculative Decoding via Attention Tuning and Bonus-Guided Calibration}},
  year = {2026},
  eprint = {2605.20022},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.20022},
}
Figure