Faster Assisted Generation with Dynamic Speculation
Dynamic speculative decoding stops the draft model's token generation as soon as its softmax confidence falls below a threshold (assistant_confidence_threshold), rather than always drafting a fixed or heuristically adjusted number of tokens before verification by the target model. An oracle analysis shows optimal speculation lookahead varies widely across iterations, so static values waste forward passes. On an RTX 4090 the dynamic schedule beat the heuristic in every tested model pair, reaching 2.71x on OPT-6.7B summarization and 1.52x for Llama-3.1-8B with Llama-3.2-1B where the heuristic gave no speedup. It is the default for assisted generation in Transformers 4.45.0 and can be tuned or reverted through generation_config parameters.
Related posts
- Assisted Generation: a new direction toward low-latency text generation
Hugging Face mediumAdeptAssisted generation cuts autoregressive LLM latency by letting a much smaller assistant model with the same tokenizer greedily draft candidate tokens, then verifying them all in a single forward pass of the large model. The large model keeps matching tokens plus the first divergent one. The draft length adapts: it grows by 2 when every candidate matches and shrinks by 1 otherwise. The approach exploits the fact that forward passes are memory-bandwidth bound. In 🤗 Transformers it is exposed through an `assistant_model` argument to `generate` (batch size 1 only) and yields up to 2x speedups, 3x with INT8, and up to 10x when the model relies on memory offloading. It works best on input-grounded tasks like ASR and summarization, and with sampling only at low temperatures.
- Speculation Is All You Need
Modal hardMaster
Speculative decoding delivers integral-factor (2-3x+) LLM decode speedups, far beyond the few-percent gains from kernel or host-side optimization, and its benefit scales roughly linearly with acceptance length. Modal and Z Lab release DFlash speculators for several Qwen 3.5/3.6 models that add 5-20% over existing DFlash baselines, reaching over 1000 tok/s for Qwen 3.5 122B-A10B at concurrency 1 on a B200 node. Mocking acceptance in SGLang via SGLANG_SIMULATE_ACC_LEN shows Qwen 3.5 27B speeding up 5.62x at acceptance length 8, and a toy model plus a roofline model explain why speedup tracks acceptance length and where drafting overhead erodes it. Training custom speculators on application data is framed as easy-mode ML: fine-tuning has lifted acceptance length from 3 to over 9.
- Achieve state-of-the-art inference latencies with speculative decoding
Modal hardMaster
Speculative decoding is the dominant lever for low-latency LLM serving because decode steps dominate latency and speculation yields multiplicative speedups roughly linear in acceptance length. Working with Decagon's voice agents, Modal combined regional serving, SGLang host-overhead fixes, and open-source kernels with DFlash draft models that reuse target-model KV projections and draft tokens in parallel. Fine-tuning ("mid-training") the speculator on synthetic data generated by the target model from public prompts in the task's output grammar avoids exposing user data. The custom speculator cut about 100ms from a ~290ms p50 baseline, roughly 40% of server-side decode latency, and beat proprietary providers by over 60ms. Out-of-distribution evaluation was used to guard against overfitting.
- Universal Assisted Generation: Faster Decoding with Any Assistant Model
Hugging Face hardMasterUniversal Assisted Generation (UAG) extends speculative decoding so the assistant model no longer needs the target's tokenizer. Draft tokens are translated in both directions through text, re-encoded with a window of preceding tokens, and aligned to the target sequence, and mismatched tokens are evicted from the assistant's KV cache. Benchmarks pair models such as gemma-2-9b, Mixtral-8x22B and Llama-3.1-70B with tiny cross-family assistants like vicuna-68m and Qwen2-0.5B and report 1.5x–1.9x speedups. UAG ships in Transformers 4.46 via the tokenizer/assistant_tokenizer arguments to generate(), and with sampling it currently supports only multinomial sampling, not speculative sampling.
- Accelerate RL rollouts by up to 50% with distribution-aware speculative decoding
Together AI hardMasterDistribution-aware speculative decoding (DAS) speeds up the rollout phase of LLM RL post-training, which can consume ~70% of training time due to long-tail straggler generations, while keeping outputs identical to standard decoding. It combines a training-free suffix tree drafter built from a sliding window of recent rollouts with length-aware scheduling. The drafter adapts to the evolving policy by inserting newly verified tokens back into the tree. The scheduler interleaves long requests across GPUs and gives long requests aggressive speculation budgets from the start, medium requests moderate budgets, and short ones none. Reported results are over 50% rollout time reduction on math RL with DeepSeek-R1-Distill-Qwen-7B and ~25% on code RL with Qwen3-8B, with matching reward curves across 8k–16k sequence lengths and batch sizes of 16–32.