Measuring and tuning local inference speed
For engineers
Measuring prompt processing and generation speed, tuning GPU offload, context and KV cache settings, speculative decoding and diagnosing slow runs
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
A benchmark prints rows named pp512 and tg128. What does tg128 measure?
Check yourself · 2 of 5
What does the -ngl flag in llama.cpp set?
Check yourself · 3 of 5
In speculative decoding, what does the large target model do with the draft model's tokens?
Check yourself · 4 of 5
A local model suddenly runs at a fraction of its usual speed, with no error. The log says 0 layers were offloaded. What is the most likely cause?
Check yourself · 5 of 5
You want to compare two local runners on speed. Which model setup is fair?
Topics
- Measuring tokens per second and time to first token4 min read · Prompt processing versus generation speed, warm-up runs and llama-bench for repeatable numbers
- Tuning GPU offload and context length4 min read · How many layers go on the GPU, the speed cliff of partial offload, and how context length and KV cache quantization use memory
- Speeding generation with speculative decoding4 min read · A small draft model or extra prediction heads propose tokens the large model verifies, and when the speed-up appears
- Diagnosing slow local inference4 min read · Silent CPU fallback, memory swapping, thermal throttling, a wrong backend build and an oversized context
- Benchmarking runtimes on the same hardware fairly4 min read · Same model file, quant, prompt length and output length, warm caches and several runs before comparing runners or settings
Start here
- llama-bench (llama.cpp) (opens in a new tab)DocsFree
The standard tool for repeatable prompt and generation speed numbers, with options for offload, flash attention and repetitions.
- llama.cpp server README (opens in a new tab)DocsFree
Lists the flags for context size, GPU layers, KV cache types, flash attention and draft models.
- llama.cpp (opens in a new tab)ToolFree
The runtime behind many local tools; build instructions show which backends (CUDA, Metal, Vulkan) a binary includes.
Helps to know first
110 questions · last verified 2026-12