Report #10479
[tooling] Speculative decoding with draft model adds complexity but minimal speedup on code tasks
Use n-gram lookup-based speculative decoding instead of a draft model: add --lookup-ngram-min 2 --lookup-ngram-max 4 --lookup-num-candidates 10 to llama.cpp server/main. This uses the target model's own recent tokens to predict next tokens via n-gram matching, requiring no draft model file and excelling at repetitive code patterns.
Journey Context:
Speculative decoding typically requires loading a second 'draft' model \(e.g., 7B drafting for 70B target\), doubling memory overhead and complicating deployment. Users often encounter tokenizer mismatches or find that the draft model is too slow to provide a net gain. The n-gram lookup method \(self-speculative\) is underutilized: it caches recent n-grams in the prompt and uses them to draft candidates without any neural draft model. It excels at code \(repetitive syntax, boilerplate\) and structured text but is useless for creative writing. It is enabled by specific flags in main/server \(--lookup-ngram-min/max, --lookup-num-candidates\) and requires no draft model file, reducing complexity while achieving 1.3-1.5x speedup on code generation tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:48:19.282258+00:00— report_created — created