On the CPU, llama.cpp splits generation across threads, and the right thread count is usually close to the number of physical cores — too few leaves cores idle, too many adds overhead and can slow things down. The server README documents -t, --threads N as the number of CPU threads to use during generation, and -tb, --threads-batch N as the number of threads for batch and prompt processing, defaulting to the same value as --threads.
Related guide: How to Run a llama.cpp Model with GPU Offload
Set the threads on the command line
llama-cli -m model.gguf -t 8 -tb 8 -p "Explain what a lighthouse keeper does in two sentences."
Replace 8 with your own count: start with the number of physical cores on your machine. The man page for llama-cli says the default for -t is the number of CPUs, so you only need the flag when the default is wrong for your machine — for example when you want to leave cores free for other work, or when hyper-threading makes the CPU count misleading. The same flags work for llama-server, where they apply to the CPU layers during generation.
How to tell if the setting helped
Run the same prompt twice — once with the default and once with your chosen count — and compare how long the reply takes to appear. The server README notes that -t has no effect on model layers offloaded to the GPU, so if your model is fully on the GPU, changing threads will change nothing; this guide is for CPU runs. If generation gets slower as you add threads past your physical core count, you have oversubscribed: step back down.
Expected result. We checked the llama.cpp server README and the llama-cli man page for the -t and -tb flags and their defaults. We did not run this software ourselves for this guide, so no output here is a recorded result; steps marked UNTESTED were checked against the sources below, not run.
Limits
Thread count is a tuning knob, not a fix for a model that does not fit in memory, and the best value depends on the machine — there is no universal number. The server README says -t has no effect when the maximum number of GPU layers is used. We did not run llama.cpp, so no speed here is a measured result.
Sources
- llama.cpp server README — -t/–threads: number of CPU threads to use during generation; -tb/–threads-batch: threads for batch and prompt processing, default same as –threads
- llama-cli man page — -t/–threads N, number of CPU threads during generation, default the number of CPUs; -tb/–threads-batch, default same as –threads
Checked 2026-11-28.
