llama-server splits prompt processing into batches: –batch-size is the maximum number of tokens processed in one batch, and –ubatch-size is the micro-batch it splits that work into. Larger batches process long prompts faster but use more memory. This guide sets both and measures the difference on a long prompt.
Before you start
- llama.cpp installed, with llama-server on your PATH.
- A GGUF model file, for example a Qwen3 8B Q4_K_M file.
- A long prompt to test with, at least a few thousand tokens.
Check the current defaults
Run llama-server --help and look for –batch-size and –ubatch-size. The defaults are usually 2048 for the batch size and 512 for the micro-batch. Note them down so you can go back.
Start with larger sizes
Start the server with a bigger batch and micro-batch:
llama-server -m qwen3-8b-q4_k_m.gguf --batch-size 4096 --ubatch-size 1024 --port 8080
The micro-batch must not be larger than the batch size.
Compare prompt processing
Send the same long prompt to the completion endpoint with the new settings and with the defaults, and note the prompt-processing time each time. The larger batch should process the long prompt faster, as long as memory allows.
Worked example
Worked example: send a 4,000-word report with the request “List the three risks in this report.” With –batch-size 4096 and –ubatch-size 1024, the prompt-processing step should finish sooner than with the 2048 and 512 defaults; if the server runs out of memory, halve both values and try again.
Expected result
UNTESTED in this guide: no server was run while writing it. The expected result is that the server starts with the new sizes and a long prompt processes faster than with the defaults.
Limitations
Very large batches can exhaust VRAM and crash the server, and they do not help short prompts at all. Raise the sizes in steps and keep the defaults written down.
