Suffix decode - #26283
Conversation
|
The concept is very elegant! It treats the context and previous outputs as a memory of sequences, proposes the continuation of a previously seen pattern in one block, and then has the LLM verify it, so it mimics the effect of MTP without requiring MTP heads. It becomes extremely effective whenever patterns repeat, especially in code, structured documents, JSON, and agentic loops. |
|
Can you add some unit-tests to showcase the functionality? |
|
without looking too deep, sounds just like ngram with tree, like #8648 (tho that pr is probably dead) |
|
Launching CI :p |
|
Tested on my prod (Qwen 3.6 dense 27B Q8, single slot): default config drops decode from 42 to 31 t/s on normal prompts. The per-request tree has count=1 almost everywhere so min_prob filters nothing, and short junk drafts eat the perf in verification. Attached commit adds a n_min gate (default 3) like the other draftless impls -> back to 41 t/s worst case, long matches untouched. On a MoE the gap is even bigger: 110 t/s without the gate vs 185 t/s with it. Default can go back down once a global cross-request cache gives real frequency stats. I'd suggest adding this patch and default values until the global cross-request cache from the paper is implemented: |
|
Quick demo on a dense model: chat baseline runs at 41 t/s, then repetitive XML generation ramps up to 122 t/s as the suffix tree warms up : suffix-decode.mp4 |
|
@ServeurpersoCom opening a minimal pr in a sec that can improve perf further for all non draft-model speculators for models with recurrent state. edit: here #26499 |
|
thanks! cherry picking the commit thanks @ServeurpersoCom |
Short drafts from low-support matches rarely pay for their verification batch and degrade decode speed on non-repetitive prompts. Discard drafts shorter than n_min, configurable with --spec-ngram-suffix-n-min (default: 3), consistent with the other draftless implementations.
Overview
Initial implementation of https://suffix-decoding.github.io/, which is a model-free spec. decoding method. We build the tree online over the current request and tokens generated so far, and it's best when the matched suffix is longer.
Additional information
Currently, we build only the online tree only and no global corpus tree. vLLM optionally keeps the global cross-request cache (up to 10k past requests). We implement the per-request/prompt tree only.
Requirements