Last week I wrote about why an H100 only writes about 200 tokens a second for a single user. The short answer was memory bandwidth: the GPU has to read every weight for every token.

A few people replied with the same follow-up. What about the KV cache? One of them had even measured it on his own card and asked whether my calculator accounted for it.

It didn't. So this post is the answer, and it turned out to be a stranger number than the first one.

If every user fills the context window, one H100 running Meta's Llama 3.1 8B can serve three people.

What the KV cache is

A language model writes one token at a time. To pick the next token, it has to look back at everything that came before it in the conversation.

Doing that from scratch for every token would be painfully slow. So the model keeps notes. For every token it has already seen, it stores a small block of numbers, called keys and values, at every layer. Next time it needs to look back, it reads the notes instead of redoing the work.

Those notes are the KV cache. It is what makes chat fast enough to use.

The catch is that the notes live in GPU memory, and they grow with every token in the conversation. Yours and the model's.

How big is one token?

You can work this out from the model's public config file. For Llama 3.1 8B:

  • 32 layers
  • 8 key/value heads per layer
  • 128 numbers per head
  • 2 of them, one for keys and one for values
  • 2 bytes per number in FP16
32 × 8 × 128 × 2 × 2 = 131,072 bytes

About 131 KB of GPU memory for every single token in the conversation.

That doesn't sound like much. A sentence is maybe 20 tokens, so 2.6 MB. Fine.

Now fill the context window

Llama 3.1 supports a context of 131,072 tokens. That is roughly a 300 page book.

131,072 tokens × 131,072 bytes ≈ 17 GB

Seventeen gigabytes. For one user. For one conversation.

Here is the part that made me check my math twice. The model itself, all 8 billion weights in FP16, takes about 16 GB.

So one person with a full context window takes up as much GPU memory as the entire model.

The H100 budget

An H100 SXM has 80 GB of memory.

80 GB total
− 16 GB for the weights
= 64 GB left for conversations

64 ÷ 17 ≈ 3.7

Three users. The fourth one doesn't fit.

This is one of the most powerful and expensive chips you can put in a data center, and in the worst case it holds three conversations.

It depends on how long people talk

Most chats are nowhere near the full window, and that changes everything.

Context per userKV cache per userUsers on one H100
2,000 tokens0.26 GB~240
8,000 tokens1.1 GB~59
32,000 tokens4.3 GB~14
131,072 tokens17 GB3

Same GPU. Same model. Anywhere from 3 to 240 people depending on one variable.

That is the real takeaway. When you plan capacity for a model, the model size is the easy part. It is a fixed cost you pay once. The context length is what decides how many people you can actually serve.

It also makes each user slower

In the last post, the speed ceiling came from reading 16 GB of weights for every token.

But the model reads the KV cache for every token too. So a user at full context makes the GPU read about 16 GB of weights plus 17 GB of their own cache.

3,350 GB/s ÷ 16 GB ≈ 209 tokens per second (short chat)
3,350 GB/s ÷ 33 GB ≈ 101 tokens per second (full context)

A long conversation doesn't just take more room. It roughly halves the best speed that user can get. If you've ever felt a chat slow down as it got longer, this is a big part of why.

Why this explains a lot of pricing and product decisions

Once you see the number, a few things in the industry stop looking arbitrary.

Long context costs more. A provider serving you a huge context is giving you memory that could have held dozens of shorter chats.

Prompt caching exists. If a thousand users share the same long system prompt, storing its KV cache once instead of a thousand times is an enormous saving.

Long-context models often run on separate servers. For a model shaped like this one, a million tokens of context would need about 131 GB of cache. That doesn't fit on a single H100 at all.

Apps summarize old messages. Trimming the history isn't only about quality. It is about getting memory back.

How serving systems fight back

None of these make the cache disappear. They make it smaller or smarter.

  • Paging. Don't reserve the full window up front. Hand out memory in small blocks as the conversation grows. This is the idea behind PagedAttention in vLLM.
  • Prefix sharing. Store the cache for a shared prompt once and let many users point at it.
  • Smaller numbers. Keep the cache in 8 bits instead of 16 and it takes half the space.
  • Fewer heads. Llama 3.1 already does this. It has 32 attention heads but only 8 key/value heads. Without that trick, the cache would be four times bigger: about 69 GB for one full conversation, which wouldn't leave room for even a single user next to the weights.
  • Offloading. Move the cache for idle conversations to CPU memory or disk, and bring it back when the user returns.

What I built

I extended my calculator. You give it a model, a GPU, a context length and a precision. It tells you:

  • KV cache per token and per user
  • how many users fit next to the weights
  • the speed ceiling for a user at that context length
  • what changes with a shared prefix or an 8-bit cache

Where the simple math is wrong

These are ceilings on a napkin, so here is what they leave out.

  • Real servers keep some memory free for activations and overhead, so you fit a little less than the math says.
  • Almost nobody uses the full window. The "three users" case is the worst case, not a typical day.
  • Paging and sharing mean real systems do noticeably better than a naive count.
  • I'm rounding. The weights are closer to 16.1 GB and a full cache closer to 17.2 GB.

The exact figure will vary. The shape won't: memory per user grows in a straight line with context, and that line is steep.

The takeaway

Model size tells you whether a model fits on a GPU. Context length tells you how many people you can serve with it.

Before you size a deployment, multiply your typical context by the bytes per token. It takes ten seconds, and it will tell you more than the parameter count ever will.

Sources

  • Meta, Llama 3.1 8B config.json: 32 hidden layers, 8 key/value heads, head dimension 128, 131,072 max positions.
  • NVIDIA H100 SXM specifications: 80 GB HBM3, 3.35 TB/s memory bandwidth.
  • All user counts and speed ceilings are my own calculations from those numbers.