How many concurrent requests fit in vLLM? A KV cache planner that follows vLLM's own startup math
vLLM answers this at startup, and you can compute the same number before you launch. It takes total GPU memory × gpu_memory_utilization, keeps what the weights, the activations and the CUDA graphs need, cuts what is left into blocks of 64 tokens (16 up to v0.33.0), and logs GPU KV cache size: N tokens, Maximum concurrency for L tokens per request: X.XXx. X is the number of blocks divided by the blocks one request of max_model_len tokens needs. Lowering --max-model-len does not free memory; it only raises X. How many requests really run together is capped separately by --max-num-seqs (256 or 1,024 by default).
The planner below runs that calculation in your browser, from a config.json before launch or from a startup log afterwards. It follows vLLM v0.34.0 and, with the version switch, v0.33.0 and earlier. It uses vLLM's layer grouping, so it also gets models with sliding-window layers right (Gemma 2 and 3, gpt-oss), where "bytes per token × context" overshoots by a factor of two or more.
What v0.34.0 changed. A block is 64 tokens instead of 16 (PR #63231). On CUDA and ROCm the "extensible KV cache" is on by default: the cache is sized from the memory that is actually free after CUDA graph capture and warmup, not from an estimate, and gpu_memory_utilization, when not given, is 1.0 instead of 0.92. --no-enable-extensible-kv-cache, --kv-cache-memory-bytes, --num-gpu-blocks-override, other platforms and some KV connectors keep the estimate and 0.92. The grouping of layers and the blocks one request needs are the same code as in v0.33.0.
Planner
Examples:
Nothing you paste leaves the page. The same logic as a script: kvplan.py (one file, standard library only, MIT), python kvplan.py plan --config config.json --gpu-gib 24 --weights-gib 14.96 --max-model-len 32768 (add --vllm-version 0.33 for v0.33.0 and earlier) or python kvplan.py log --file vllm.log.
Which tab? The config tab is exact about the KV side (blocks, groups, what one request reserves) and only as good as your guess for the non-KV memory, which vLLM measures with a profiling pass. Once the server has started, the log tab is exact for both, and it works for every model, including the ones the config tab refuses (Qwen3.5 and other hybrids with linear-attention or Mamba layers, DeepSeek-V4, packed KV formats).
What does vLLM compute at startup?
Seven steps, all visible in the v0.34.0 source. The example is the planner's default: Llama-3.1-8B in bf16 on a 24 GiB GPU with nothing else on it, 14.96 GiB of weights, and an assumed 1.5 GiB for activations and CUDA graphs, 1.0 GiB of it a transient peak.
- Budget = ceil(total memory ×
gpu_memory_utilization). It is a share of the total, not of what is free. With the extensible KV cache the default is 1.0 and the budget is only a cap; with estimate-based sizing (and in every release up to v0.33.0) the default is 0.92, and if less than the budget is free, startup stops withFree memory on device ... is less than desired GPU memory utilization(worker/utils.py, config/cache.py). Example: 24 × 1.0 = 24 GiB; up to v0.33.0, 24 × 0.92 = 22.08 GiB. - KV memory. With the extensible KV cache, vLLM measures after CUDA graph capture and warmup: min(budget − resident, free at startup − resident − margin) − transient peak, where resident is what stays allocated (weights, CUDA graphs, workspaces), the margin is max(1 GiB, 0.75 × transient peak) (3 GiB floor on ROCm), and the transient peak is the larger of the measured activation peak and the growth of PyTorch's reservation. It logs
Memory after warmup: ... N KV cache blocks (X GiB) fit within the requested ...; the earlierAvailable KV cache memoryline is only the address range reserved before warmup (extensible_kv_cache.py). Example: min(24 − 15.46, 24 − 15.46 − 1) − 1 = 6.54 GiB. With estimate-based sizing: budget − weights − activation peak of a profiling pass − estimated CUDA graph memory, which is theAvailable KV cache memoryline (gpu_worker.py); up to v0.33.0, 22.08 − 14.96 − 1.5 = 5.62 GiB.--kv-cache-memory-bytessets it directly. - One page is one block of one layer: KV heads × (key dims + value dims) × bytes per element × block size (64 tokens; 16 up to v0.33.0). With tensor parallel, each GPU holds max(1, KV heads ÷ TP) heads (kv_cache_interface.py, config/model.py). Example: 8 × 256 × 2 × 64 = 262,144 bytes.
- Layers are put into groups that share a block table, and one block holds the pages of the widest group. A model whose layers are all alike is one group (kv_cache_planning.py). Example: 32 layers × 262,144 = 8,388,608 bytes per block, which is 128 KiB per token.
- Blocks = KV memory // bytes per block. Example: 837 blocks (2,877 blocks of 16 tokens from 5.62 GiB up to v0.33.0).
- Blocks one full-length request needs: ceil(L ÷ block size) for a full-attention group; for a sliding-window group, ceil(min(window − 1 + tokens in flight, L) ÷ block size) + 1, where tokens in flight = concurrent batches (2 with async scheduling, the default) ×
max_num_batched_tokens. Example at L = 32,768: 512 blocks. - Maximum concurrency = blocks ÷ blocks per request, and
GPU KV cache size= int(concurrency × L) tokens. One block is the permanently reserved null block: if a single request does not fit in the rest, startup stops and prints an estimated maximum model length. Example: 53,568 tokens, 1.63x at 32,768; 6.54x at 8,192; at 131,072 it refuses to start and estimates 53,504. Up to v0.33.0 the same GPU gives 46,032 tokens and 1.40x at 32,768.
How much KV cache does one token take?
It depends on the attention type of each layer, not only on the model size. b is the size of one element: 2 bytes for bf16 or fp16, 1 for fp8.
| Layer type | Bytes per token, per layer | What one request holds | Example |
|---|---|---|---|
| Full attention (MHA, GQA, MQA) | 2 × KV heads × head dim × b | every token up to its length | Llama-3.1-8B: 32 layers × 8 × 128 → 128 KiB per token; 64 KiB with fp8 |
| MLA (DeepSeek-V2/V3, Kimi K2 and others) | (kv_lora_rank + qk_rope_head_dim) × b; one latent vector, no separate V, not divided by tensor parallel | every token | DeepSeek-V3: 61 layers × 576 → 68.6 KiB per token |
| Sliding-window layer | same as full attention | only window − 1 + tokens in flight, plus one block | Gemma 3 (five of six layers; window 1,024 in the 27B config), gpt-oss (every other layer, window 128) |
| Linear attention, Mamba (Qwen3.5, Jamba, ...) | a fixed-size state per request, independent of length | use the log tab | |
| Sparse MLA (DeepSeek-V4), HiSparse, packed formats (int4, NVFP4, TurboQuant ...) | page layouts chosen by the attention backend | use the log tab | |
--kv-cache-dtype auto means "the model's dtype", so a 4-bit AWQ or AutoRound model still gets a 16-bit KV cache. fp8 is opt-in, except for llm-compressor checkpoints that declare a KV cache scheme (attention.py).
Why is "bytes per token × context" wrong for Gemma 3 and gpt-oss?
Because their sliding-window layers do not keep the whole context, and vLLM sizes them by the window. Gemma 3 27B has 62 layers; 52 of them attend to the last 1,024 tokens only. The flat formula gives 496 KiB per token and 62.0 GiB for one 131,072-token request. vLLM instead builds 7 groups (one with the 10 full-attention layers, six with the sliding layers) and reserves:
| Gemma 3 27B, bf16 KV, 40 GiB of KV memory, max_model_len 131,072 | One request reserves | Maximum concurrency |
|---|---|---|
| Flat formula (every layer keeps every token) | 62.0 GiB | 0.65x, "does not fit" |
vLLM, max_num_batched_tokens 8,192 (default on GPUs of 70 GiB and more) | 18.0 GiB | 2.23x |
vLLM, max_num_batched_tokens 2,048 (default below 70 GiB) | 12.4 GiB | 3.24x |
vLLM with --disable-hybrid-kv-cache-manager (also what a KV connector without hybrid support forces) | 62.0 GiB | refuses; estimated maximum model length 84,544 |
Three details move the number. The sliding layers hold window − 1 tokens plus everything the scheduler may have in flight, so a larger --max-num-batched-tokens lowers the concurrency of these models. The 52 sliding layers are split into six groups of at most 10, so vLLM reserves for 60: 8 padding layers, which it also reports in a warning. And every sliding group costs one extra block per request, because a window rarely starts on a block boundary. For gpt-oss-20b the same effect turns 6.0 GiB per 131,072-token request into 3.1 GiB.
A config that sets sliding_window without layer_types makes every layer a sliding-window layer in vLLM. Qwen2 and Qwen3 configs carry a sliding_window value but ignore it unless use_sliding_window is true, so they are plain full attention.
Readings of these numbers that go wrong
Six expectations the startup numbers seem to support, and what vLLM does instead.
| Expectation | What vLLM does |
|---|---|
A smaller --max-model-len uses less GPU memory | The pool keeps its size; only the concurrency figure changes. A T4 with Llama-3.2-3B logged 5.83, 5.85 and 5.78 GiB of KV cache at 8,192, 4,096 and 16,384 tokens, and 6.66x, 13.37x and 3.30x (forum thread). To use less memory, lower --gpu-memory-utilization or set --kv-cache-memory-bytes. |
gpu_memory_utilization is a share of the free memory | It is a share of the total, for this instance. Two servers on one GPU need shares that add up to less than 1, and each needs its whole share to be free when it starts. |
| "Maximum concurrency 3.81x" means three requests at most | It is the count for requests that all reach max_model_len. Blocks are handed out as tokens are processed, so shorter requests share the pool; the cap on running requests is --max-num-seqs. When the pool runs out the scheduler preempts a running request, frees its blocks and recomputes it later (scheduler.py). Watch vllm:kv_cache_usage_perc, vllm:num_preemptions and vllm:num_requests_waiting. |
| A 4-bit model leaves the saved memory free | vLLM still takes its whole budget; what the smaller weights save becomes KV cache. That is why nvidia-smi shows the GPU nearly full for any model. |
A larger --max-num-batched-tokens only speeds up prefill | It raises the activation peak, which comes out of the KV memory (an A30 went from 6.24 to 4.53 GiB between 64K and 80K, forum thread), and for sliding-window models it raises what each request reserves. |
| Everything needed is in config.json | Hub configs leave out keys that equal the class default. Gemma 3 4B's text_config has no head counts (discussion); 8 heads, 4 KV heads and head_dim 256 come from the transformers config class. The planner fills such keys from transformers 5.22.2 and says so under the result. |
What are the defaults for max_num_seqs and max_num_batched_tokens?
They depend on the GPU's memory, and on whether you use vllm serve or the LLM class (get_batch_defaults in arg_utils.py; the function is the same code in v0.33.0 and v0.34.0):
| GPU memory | max_num_seqs | max_num_batched_tokens, vllm serve / LLM |
|---|---|---|
| 160 GiB and more | 1,024 | 16,384 / 16,384 |
| 70 GiB and more, except A100 and GB10 (DGX Spark) | 1,024 | 8,192 / 16,384 |
| everything else, A100 80GB included | 256 | 2,048 / 8,192 |
If the planner's "requests held at once" is above max_num_seqs, raise --max-num-seqs to use the memory. If it is below, the KV cache is the limit, and requests beyond it wait or trigger preemption.
What was this checked against?
vLLM's own code, and logs that people posted.
- vLLM's planning code, v0.33.0 and v0.34.0. The unmodified source files
kv_cache_interface.pyandkv_cache_planning.py, plus the capacity functions ofkv_cache_utils.py, were run with PyTorch replaced by a stub that only knows dtype sizes. On 40,000 random configurations per release (full attention, MLA, interleaved sliding window with one or two window sizes, all-sliding; hybrid manager on and off; 1 to 80 layers; blocks of 16, 32, 64 and 128 tokens) the planner returned the same block count, token capacity, concurrency, group count, start-or-refuse decision and estimated maximum model length. The harness was written again for v0.34.0, independently of the one used on 2026-11-12, and it found one difference, now fixed: with--disable-hybrid-kv-cache-manager, a model whose layers are all sliding-window with two different window sizes is refused by vLLM, and the planner used to compute it. - v0.34.0's measured sizing.
measure_kv_cache_bytes, taken fromextensible_kv_cache.pyas it is, returns the same bytes as the planner on 20,000 random inputs. What the planner cannot know is the input: how much stays resident and how large the transient peak is on your GPU. - The browser version returns the same results as
kvplan.pyon 6,032 random inputs (config.json files with both sizing modes, and log lines). - Public startup logs. vLLM prints the KV memory rounded to 0.01 GiB; for each log the planner's capacity over that rounding interval contains the logged value, and the concurrency matches to the printed digit:
| Log | KV memory, GiB | Logged capacity | Planner | Source |
|---|---|---|---|---|
| Qwen3-1.7B, RTX 3090, v0.15.1 | 16.65 | 155,904 / 3.81x at 40,960 | 155,824 to 155,920 / 3.81x | vLLM forum, 2026-02 |
| Qwen3-8B | 50.32 | 366,400 / 8.95x at 40,960 | 366,368 to 366,448 / 8.95x | LMCache FAQ |
| Qwen3-32B, TP=2, H100 | 33.66 | 275,760 / 6.73x at 40,960 | 275,696 to 275,776 / 6.73x | LMCache FAQ |
| Llama-3.1-70B, TP=4, H100 | 32.06 | 420,208 / 3.21x at 131,072 | 420,144 to 420,272 / 3.21x | LMCache FAQ |
| Llama-3.2-3B, T4, max_model_len 8192 | 5.83 | 54,544 / 6.66x at 8,192 | 54,528 to 54,624 / 6.66x | vLLM forum, 2026-06 |
| Llama-3.2-3B, T4, max_model_len 4096 | 5.85 | 54,752 / 13.37x at 4,096 | 54,720 to 54,816 / 13.37x | vLLM forum, 2026-06 |
| Llama-3.2-3B, T4, max_model_len 16384 | 5.78 | 54,096 / 3.30x at 16,384 | 54,064 to 54,160 / 3.30x | vLLM forum, 2026-06 |
| Gemma 3 4B, A100 80GB, v0.29, LLM class | 58.33 | 729,735 / 22.27x at 32,768 | 729,735 to 729,861 / 22.27x | SOTAAZ, 2026-10 |
All eight logs are from releases before v0.34.0, so the planner column is the "v0.33.0 and earlier" setting (blocks of 16 tokens). We have not found a public v0.34.0 startup log yet. The T4 logs are from an older engine that prints blocks; capacity there is blocks × 16. The Gemma 3 4B run used the LLM class on an A100 (8,192 batched tokens, so 16,384 in flight).
What changed between versions?
| Since | Change |
|---|---|
| v0.6.5 (2024-12) | gpu_memory_utilization counts this instance only; before, memory used by other processes was subtracted from the KV cache |
| v0.8.4 (2025-04) | the "does not fit" error prints an estimated maximum model length |
| v0.9.1 (2025-06) | Available KV cache memory line; startup stops when less than the budget is free |
| v0.10.2 (2025-09) | --kv-cache-memory-bytes |
| v0.14.0 (2026-01) | --max-model-len -1 picks the longest context that fits |
| v0.20.0 (2026-04) | default gpu_memory_utilization 0.9 → 0.92; the estimated CUDA graph memory is subtracted from the KV memory by default (VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS=0 turns it off; the variable exists from v0.18.0, off by default until here) |
| v0.20.1 (2026-05) | GPU KV cache size = concurrency × max_model_len; before, blocks ÷ groups × block size, which understated models with sliding-window layers |
| v0.26.0 (2026-07) | sliding-window layers reserve window − 1 + concurrent batches × max_num_batched_tokens; before, one batch |
| v0.28.0 (2026-08) | the two capacity lines became one; GPUs of 160 GiB and more get 16,384 batched tokens |
| v0.34.0 (2026-11) | default block 16 → 64 tokens; the extensible KV cache is on by default on CUDA and ROCm and sizes the cache from the memory free after CUDA graph capture and warmup (new log line Memory after warmup); default gpu_memory_utilization is 1.0 with it, 0.92 without; with it, less free memory than the budget no longer stops startup; the "does not fit" error ends with a different hint |
Read from the release tags of the vLLM repository. On releases older than v0.26.0 the config tab can differ for sliding-window models; the log tab does not depend on the version.
Limits
- No GPU was used. The KV side is checked against vLLM's code and public logs; the non-KV memory (activation peak, CUDA graphs) is your input, because vLLM measures it rather than computes it. Start once, read
Memory after warmup: ... KV cache blocks (X GiB)(v0.34.0 with the extensible KV cache) orAvailable KV cache memory(estimate-based sizing and older releases), and put it in the "KV memory" field. - The config tab covers full attention, MLA, interleaved and all-sliding window models, tensor parallel and fp8 or 16-bit KV. It refuses models it cannot reproduce instead of guessing. Pipeline parallel, decode context parallel, draft models for speculative decoding and encoder-decoder models are not covered.
- Models whose vLLM class builds its attention layers differently from the generic rules here (custom sliding-window patterns, KV sharing between layers) can differ. The result table shows the layer counts it assumed; compare them with the model card.
- With the extensible KV cache the final block count is also capped by the address range reserved before warmup, and with several GPUs every rank uses the smallest count; the planner computes one GPU and does not model the reservation.
- Attention backends can raise the block size above the default for some head sizes. That changes rounding by at most one block per group and request; set "Block size" if your log says otherwise.
- "Requests held at once" ignores prefix caching, which lets requests with a common prefix share blocks, so real servers often hold more.
Questions
How does vLLM calculate "Maximum concurrency"?
It divides the number of KV cache blocks by the blocks one request of max_model_len tokens needs. The blocks come from the KV memory: total GPU memory times gpu_memory_utilization, minus the weights, the activation peak of a profiling pass and the CUDA graph estimate, cut into blocks of 64 tokens (16 up to v0.33.0). For a full-attention model one request needs ceil(max_model_len / block size) blocks. From v0.34.0 on CUDA and ROCm the memory is measured after warmup instead of estimated, and gpu_memory_utilization defaults to 1.0.
Does lowering --max-model-len reduce vLLM's GPU memory use?
No. vLLM still takes total memory times gpu_memory_utilization and gives everything left after the weights to the KV cache. A shorter max_model_len only means each full-length request needs fewer blocks, so the logged concurrency goes up. To use less memory, lower --gpu-memory-utilization or set --kv-cache-memory-bytes.
Is "Maximum concurrency" the limit on simultaneous requests?
No. It is how many requests fit if every one of them grows to max_model_len. Blocks are handed out as tokens are processed, so shorter requests share the pool and more of them run together, up to --max-num-seqs (256 or 1,024 by default, depending on the GPU). When the pool runs out, the scheduler preempts a running request and recomputes it later.
How much KV cache does one token take in vLLM?
For standard attention: 2 x layers x KV heads x head dimension x bytes per element. Llama-3.1-8B (32 layers, 8 KV heads, 128 dims, 16-bit) takes 128 KiB per token; --kv-cache-dtype fp8 halves it; tensor parallel divides the KV heads per GPU. DeepSeek-style MLA stores one latent vector per layer (kv_lora_rank + qk_rope_head_dim values). Sliding-window layers keep only the window plus the tokens in flight.
Why does vLLM say the model's max seq len needs more KV cache than is available?
One request of max_model_len tokens must fit in the KV cache, with one block held back. If it does not, vLLM stops and prints the estimated maximum model length that would fit. Pass that value (or --max-model-len -1 from v0.14.0) as the context length, raise --gpu-memory-utilization, use --kv-cache-dtype fp8, or spread the model over more GPUs.
Sources
- vLLM v0.34.0 source: v1/worker/extensible_kv_cache.py (
measure_kv_cache_bytes, margins), config/cache.py (block size,resolved_gpu_memory_utilization), config/vllm.py (when the extensible KV cache is on), docs/configuration/optimization.md (GPU Memory Utilization). - vLLM v0.33.0 source: v1/worker/utils.py (
request_memory), v1/worker/gpu_worker.py (determine_available_memory), v1/kv_cache_interface.py (page sizes, per-request blocks), v1/core/kv_cache_planning.py (groups, blocks, fit check), v1/core/kv_cache_utils.py (capacity log line), config/cache.py, config/vllm.py (tokens in flight, hybrid manager), engine/arg_utils.py (batch defaults), model_arch_config_convertor.py (how config.json is read), v1/core/sched/scheduler.py (preemption). - vLLM docs: Conserving memory, Optimization and tuning.
- Hugging Face transformers 5.22.2, configuration classes for Gemma 2, Gemma 3, gpt-oss, Qwen2, Qwen3, Mistral, Llama, Phi-3 and DeepSeek-V3 (class defaults and
layer_types). - Logs: vLLM forum #2332 (2026-02), #2724, Max_model_len vs GPU memory usage (2026-06), #2604 (2026-04); LMCache FAQ; SOTAAZ, llama.cpp vs vLLM, part 1: memory (2026-10-20).
- vLLM GitHub issue #27017, [Doc]: KV Cache Memory allocations: the questions this page answers.
- Hugging Face, google/gemma-3-4b-it discussion #14, Not enough parameters in 4b config.json.