Ollama 0.6 parallel inference deep dive
Ollama 0.6 finally made parallel requests a first-class thing instead of a queue, and I have spent the week prodding it. Short version: it works, but the memory math surprises people.
The two variables that matter:
OLLAMA_NUM_PARALLEL— how many requests are processed simultaneously. Each parallel slot gets its own KV cache allocation.OLLAMA_MAX_LOADED_MODELS— how many distinct models stay resident. On a single GPU this is almost always 1.
The surprise: context is divided per slot. With num_ctx 8192 and OLLAMA_NUM_PARALLEL=4, each request effectively sees a 2048-token context unless you raise the global setting to compensate. I measured KV allocation on an 8B Q4 model: going from 1 to 4 parallel slots took VRAM from 6.1GB to 11.8GB at the same per-request context.
Throughput at concurrency 4 on my 3090, 8B Q4_K_M: 41 tok/s aggregate versus 34 tok/s single-stream. So parallelism buys you latency fairness, not much raw throughput — the GPU was already saturated by one stream's compute phases.
The VRAM multiplication is the thing that fills up the "CUDA out of memory" tag on the Ollama tracker. Rule of thumb I now give people: KV memory scales linearly with parallel slots at fixed per-request context, so budget (slots × per-slot KV) plus the weights, not just the weights.
Concrete example from my box: 8B Q4, 4k context per request, 4 slots = 5.2GB weights + 4.4GB KV + overhead, which is why it OOMs on an 8GB card that runs the same model happily at one slot. Dropping to 2 slots and 2k context fits with room to spare.
For comparison, the same knobs in raw llama-server are --parallel N plus an explicit -c that is the total context across slots — which I prefer, because the division is visible in one place instead of implied. Ollama's per-slot semantics are friendlier until the moment you wonder why your 32k context became 8k.
One more data point for the thread: with MoE models the parallel-scaling story is better than dense, because the expert weights are read once per token regardless of slots. My Scout setup went from 28 tok/s single-stream to 74 tok/s aggregate at 4 slots. If you are sizing a home server for a household, MoE plus parallel slots is currently the best tokens-per-watt deal around.