New optimization makes the guessing step in llama.cpp significantly faster
A developer has trimmed a shortcut in the open AI tool llama.cpp and measures draft steps up to 42 times faster and up to 2.6 times less memory use. The figures are his own, and they apply only to the draft step itself.

A developer has improved a technique in llama.cpp, a popular open program for running language models on your own computer. According to his own blog post from September 26, 2026, four changes make one specific sub-step up to 42 times faster and cut memory use by up to 2.6 times.
What got faster?
The technique is called prompt lookup decoding, also known as n-gram speculation. It is a form of speculative decoding: A simple model guesses the next word fragments (tokens), and the large model checks the guesses. The simple model looks back through earlier text to find what usually comes next. The technique is found in llama.cpp, vllm and Hugging Face's transformers library, among others.
llama.cpp uses three lookup stores (caches): one for the current text, a dynamic one from earlier runs and a static one built from a fixed text collection.
The four changes
The biggest single gain came from stopping unnecessary copying of inner data structures (maps). That made drafting 4.5-25.6 times faster, depending on the size of the text collection.
The developer then switched the outer map to a flat hash table, replaced the inner hashmaps with sorted lists and used Daniel Lemire's constmap for the static cache. Each of these typically gave a 1-2x speedup, and loading the static cache became 6.32-16.12 times faster. For a 541 MB collection, it dropped from 3.76 to 0.23 seconds.
Daniel Lemire has also submitted a proposal (pull request) that checks thresholds before scores are calculated for all candidates. According to the developer, this makes drafting up to 140 times faster overall. The sources do not say whether this proposal or the other changes have been merged into llama.cpp.
The share of guesses that the large model accepts is unchanged, according to the developer. The quality of the guesses is therefore the same.
Caveats
The figures are the developer's own measurements on one machine, an Apple M4 Pro with 48 GB of memory, and one dataset, WikiText-103. No independent replication has been found. The 42x figure is also an upper bound.
Most important for ordinary users: The figures apply to the time per guessed token in the draft step itself, not to how quickly you get your answer. The sources contain no figures for overall speed in tokens per second.
kenashe.ai points this out as well in an independent assessment. According to it, the 42x figure is not a general improvement of all text generation. The technique is expected to help when text is repeated, for example in code editing, rewriting and extracting from documents, and in search with cited passages. On novel reasoning, free-form language and open-ended chat, it is expected to help only a little. According to the commentary, what matters is the actual time on your own task, machine and context length.
Updated 14 October 2026: The article has been rewritten from additional sources.
Read also



