LLM.co — Private AI & custom AI developmentCall +1 (206) 844-1326All inference local

KV Cache Math for Concurrent Users on One GPU

Work through the KV cache formula, see worked examples for Llama, Qwen, and DeepSeek on H100 and L40S, and use a sizing calculator to plan capacity.

Nate Nead4 min read
A single GPU server glowing in a data center aisle with converging light streams representing concurrent user sessions.

Per-token KV cache memory, not model weight size, decides how many concurrent users one GPU serves. A Llama 3.1 8B at BF16 on an H100 supports roughly 107 concurrent sessions at 4,096-token context, drops to roughly 13 at 32K, and roughly 3 at 128K, with the weights untouched.

The formula is short, every variable comes from the model's config.json, and the arithmetic is the same whether the rack sits in a colo or an air-gapped SCIF. Dividing the GPU's usable KV pool by that per-token figure times the context length gives concurrent-user capacity, and the calculator paired with this page accepts those inputs directly.

The Per-Token Bytes Formula

Attention keeps a key and a value tensor per layer per token. The exact bytes a GPU must hold for one token of KV cache is:

2 × num_layers × num_kv_heads × head_dim × bytes_per_element

The leading 2 pairs K and V. The remaining factors come straight from the model's config.json. bytes_per_element is 2 for BF16 or FP16, 1 for FP8, and 0.5 for NVFP4. Grouped-query attention is the dominant architectural lever: num_kv_heads is typically 8 in modern open-weight models rather than one head per query, which cuts the cache by the GQA ratio. FlashAttention and PagedAttention change how the cache is laid out in HBM, not how many bytes the model requires per token.

Multiply the per-token figure by context length and batch size and the result is the live KV cache for one serving instance. Our prior sizing walkthrough covered the trade-offs; this piece is the worksheet.

Running the Numbers for Three Open-Weight Models

Three current workloads cover most private deployments.

Llama 3.1 8B. 32 layers, 8 KV heads, head dimension 128, BF16. 2 × 32 × 8 × 128 × 2 = 131,072 bytes per token, or roughly 0.13 MB.

Llama 3.1 70B. 80 layers, 8 KV heads, head dimension 128, BF16. 2 × 80 × 8 × 128 × 2 = 327,680 bytes, or roughly 0.32 MB per token. The NVIDIA inference optimization guide works the same arithmetic for the same architecture.

Mistral 7B. Also roughly 0.13 MB per token (32 layers, 8 KV heads, head dim 128, BF16), but its 4,096-token sliding window attention caps the active cache per sequence at that window regardless of how long the document actually is. That caveat makes it useful for long-document pipelines that can live with a bounded attention horizon.

GPU Budget After Weights and Framework Overhead

The nominal 80 GB of an H100 SXM is not what the inference engine sees. vLLM's default GPU memory fraction of 0.9 reserves about 72 GB for weights plus KV cache combined, with the remainder held for CUDA graphs, activations, and the engine's own allocator. Subtract the weights next:

  • Llama 3.1 8B in BF16: around 16 GB of weights, leaving about 56 GB for KV cache.
  • Llama 3.1 70B in BF16: around 140 GB of weights, which does not fit on one H100 and requires an H200 at 141 GB HBM3e or multi-GPU tensor parallelism.
  • Llama 3.1 70B in INT4: around 35 GB of weights, leaving about 37 GB for KV cache on a single H100.

The 70B case is where GPU selection usually turns. BF16 70B on one H100 is a non-starter; it either moves to an H200, to an 8-GPU H100 node with tensor parallelism, or the weights drop to INT4 or NVFP4 with consequences for output quality covered in our quantization comparison.

Close-up illustration of a GPU die flanked by six HBM memory stacks.

Context Length Dominates Concurrency

With the KV budget and per-token cost in hand, concurrent users resolve to one division:

Users ≈ KV_budget / (bytes_per_token × context_length)

For Llama 3.1 8B BF16 on an H100 with a 56 GB KV pool: 4,096-token context yields roughly 107 users, 32K yields roughly 13, and 128K yields roughly 3. Doubling the context roughly halves the concurrency floor. A single session at 128K on Llama 3.1 70B consumes about 40 GiB of KV cache; eight such sessions would require 320 GiB, four times the H100's entire HBM.

A context-length commitment in an RFP is therefore a concurrency commitment. Setting 128K as the contractual maximum collapses the per-GPU seat count by an order of magnitude versus 8K; 32K sits in a workable middle. The custom deployment conversations we run tend to start here, because the number of GPUs on the bill of materials is downstream of this one knob.

PagedAttention, FP8, and the Decode Phase

Two optimizations shift the right-hand side of the equation without touching the model.

PagedAttention, the memory manager behind vLLM, treats KV cache as virtual-memory pages rather than contiguous allocations, eliminating the internal fragmentation that classical servers leave on the table. The original paper reported 2 to 4x higher serving throughput at identical latency against prior engines.

Quantizing the cache itself is the other lever. FP8 KV cache halves the per-token bytes with a one-flag switch (--kv-cache-dtype fp8 in vLLM); NVFP4 cuts the per-token cost by a factor of four. The same H100 running Llama 3.1 8B at 128K context serves about 3 users in BF16, roughly 7 with FP8, and roughly 13 with NVFP4, before any weight quantization is applied.

Decode is memory-bandwidth-bound: each generated token is a small matrix-vector multiply waiting on HBM, which is why KV cache sizing and HBM bandwidth drive tail latency more than nominal TFLOPs do. The attention kernel itself is already near the memory wall. FlashAttention-2 reports roughly 230 TFLOPs/s on A100, about 74% of the theoretical FP16 matmul maximum of 312 TFLOPs/s; most of the tuning headroom from here lives in the cache, not the kernels.

The Number to Watch in Production

Watch KV cache usage in vLLM's /metrics endpoint. Sustained usage above 90% at peak traffic means the serving instance is queuing requests even when GPU compute still has headroom, and tail latency rises visibly against the p50. If the figure sits there for an hour during a normal workday, the capacity assumptions behind the deployment have slipped out from under it, and either the context cap, the batch size, or the GPU count has to move. The LLM appliance reference designs ship that gauge on the operator dashboard so the trigger does not go unnoticed until users complain.

The three numbers behind an H100 capacity estimate
72
H100 usable KV pool
72 GB · vLLM --gpu-memory-utilization 0.9 reserves this for weights plus cache.
107
Users at 4K context (8B BF16)
107 · Llama 3.1 8B, BF16 KV cache, single H100 SXM.
0.3
Per-token KV (70B BF16)
0.32 MB · 80 layers, 8 KV heads, head dim 128, BF16.
GPU budget, a concurrency floor, and per-token cost — the inputs to every capacity calc. Source: Spheron, 2026
Concurrent users on one H100 — Llama 3.1 8B, BF16 vs NVFP4 KV cache
Concurrent users on one H100 — Llama 3.1 8B, BF16 vs NVFP4 KV cache32K context: 15 users; 128K context: 3 usersBF16NVFP432K context 15 users53 users128K context 3 users13 users
Cutting the KV cache precision raises concurrency; context length still dominates the floor. Source: dev.to, 2026
// written by
Nate Nead
CEO, Nead, LLC

Nate Nead is the CEO of Nead, LLC, a specialized AI development and private AI implementation firm. He and his team help organizations design, build and deploy private AI systems, including on-premise and private-cloud language models, retrieval pipelines and AI agents, that keep sensitive data under the client's control. Over more than 15 years, Nate has founded and grown more than a dozen technology and services brands, and has worked with teams at some of the most well-recognized companies in the Fortune 1000.

Bringing AI in-house, the right way.

Talk through your private or on-prem LLM deployment with an expert who has shipped them in regulated environments.

// the briefing

Private AI, in your inbox.

Occasional, high-signal notes on enterprise LLM deployment, security, and model strategy. No spam.