Why llama.cpp prompt lookup stops helping local coding agents
- Hardware
- Mac Studio M5 Ultra 512 GB
- Models & engines
- GLM 5.3 Flash (UD-Q6_K_XL) and GLM 5.3 (UD-Q2_K_XL) on llama.cpp
DeepSeek V4.1 Flash (oQ4e-mtp) on oMLX - Key gotcha
- ngram-mod acceptance fell from 79% to 10.9% once edits were JSON tool calls, so decode was no faster than with speculation off
What they built
l8w8 runs local coding agents against llama.cpp and oMLX on a Mac Studio M5 Ultra with 512 GB. In plain-text code-edit benchmarks, llama.cpp's prompt lookup speculative decoding (--spec-type ngram-mod) looked like a free lunch: when the model rewrote a Python file in plain Markdown, it hit 79% draft acceptance and +56% faster decode.
Then the author wrapped the same 8 automated-test Python bug-fix tasks inside real JSON tool-call payloads, the format terminal coding agents use to write files. Acceptance collapsed to 10.9% and the net speedup dropped to 0%. Models with native multi-token prediction (MTP) heads kept their speedup.
Setup
- Mac Studio M5 Ultra 512 GB
- GLM 5.3 Flash (UD-Q6_K_XL) and GLM 5.3 (UD-Q2_K_XL) on llama.cpp
- DeepSeek V4.1 Flash (oQ4e-mtp) on oMLX
- 8 automated-test Python file-edit tasks, seed 42, temperature 1.0
How it works
- Prompt lookup scans the prompt's token IDs for exact matching n-grams and proposes the following tokens as drafts
- Inside a JSON string, newlines become literal \n, quotes become \" and indentation merges with escaped newlines into different token IDs, so almost no spans match the source file in the prompt
- Native MTP uses a small learned draft head that predicts upcoming tokens from the model's hidden states, so it predicts escape sequences as well as raw code
Results & numbers
- GLM 5.3 Flash: 32.4 tok/s with speculation off and with ngram-mod on JSON, 52.9 tok/s (+63%) with native MTP
- GLM 5.3: 23.2 tok/s off and with ngram-mod, 37.2 tok/s (+61%) with MTP
- DeepSeek V4.1 Flash on oMLX: 49.8 tok/s off, 73.1 tok/s with MTP
- Late-November engine upgrades alone were flat (about 0%) with speculation off; MTP produced almost all of the real speedup
- With 64K warm prompt caching plus MTP, GLM 5.3 Flash went from 115.3 s cold to 0.58 s warm
Gotchas
- ngram-mod acceptance fell from 79% to 10.9% once edits were JSON tool calls, so decode was no faster than with speculation off
- DeepSeek with low effort plus MTP hit a 4,096-token whitespace loop on a strict nested-enum json_schema test
- DeepSeek MTP peaked at 2 simultaneous clients and saturated at 4, while GLM 5.3 Flash draft-mtp scaled smoothly to 4
- The first oMLX MTP call after boot compiles Metal shaders (about 62.5 s to first token); later calls drop to 0.3 s
Do it yourself
- Benchmark your coding agent with the payload format it really uses (JSON tool calls), not plain Markdown edits
- Compare speculation off against ngram-mod and, if your model has MTP heads, native MTP
- Warm up oMLX MTP once after boot before timing anything
- Check the author's raw per-task CSVs (github.com/l8w8/videos) to compare against your own runs
Similar setups
A small firm proofreads NDA-bound reports on its own 8-GPU llama.cpp rig with GLM 5.3
Jacques Mattheij's company can't send confidential due-diligence reports to a cloud AI without breaking its NDAs, so it built a ~$25K in-house GPU rig and proofreads them locally with open-weight models.
Running 80 GB MoE models on two 16 GB GPUs with llama.cpp 1.0
Gancho Stoychev measured five llama.cpp 1.0 settings one at a time on his homelab box with two RTX 5060 Ti 16 GB cards, running Qwen3.8-Flash-Next and DeepSeek V4 Flash, each about 80 GiB.
oMLX Prefill Accelerator: a second Mac speeds long-prompt prefill up to ~3×
oMLX 0.7.4.dev1 can run early layers of a long prompt on a faster Mac (for example M5 Max) while an M3 Ultra with enough unified memory keeps the KV cache and decode, with measured prefill gains on DeepSeek V4.1 Flash and Qwen3.8 Flash-Next.
Faster local Qwen on an AMD eGPU with the llama-cpp-rdna-boosts patches
A developer running a Qwen3.8-27B fine-tune on an AMD R9700 eGPU swapped vanilla llama.cpp for a small set of AMD-specific patches in a Podman image and roughly doubled prefill speed.