Skip to content
中文
← PostsKV Cache: Why AI Replies Get Faster

KV Cache: Why AI Replies Get Faster

KV Cache is the core mechanism behind fast LLM responses in long conversations: it caches intermediate computations for past tokens to avoid recomputing the entire context on every new token, trading GPU memory for speed while significantly cutting API costs.

2026年3月24日·991 words·5 min readRead Chinese original
KV Cache: Why AI Replies Get Faster

Have you ever noticed that when chatting with an AI, the first word often takes a moment to appear, but once it starts streaming, the rest of the reply flows out smoothly? The key technology behind this is called KV Cache.


How Does AI “Speak”?

Illustration 1

To understand KV Cache, you first need to know how large language models (LLMs) generate text.

An AI doesn’t compose an entire paragraph in one go. It predicts one token (word or subword) at a time, appends it to the end, and then predicts the next one in a loop.

For example, when an AI outputs “The weather is great today,” it actually goes through these steps:

  1. Sees the question → predicts “The”
  2. Sees “The” → predicts “weather”
  3. Sees “The weather” → predicts “is”
  4. Sees “The weather is” → predicts “great” …and so on, step by step.

Here’s the catch: every time the model predicts a new token, it has to reprocess everything that came before it. If a conversation is several hundred words long, those hundreds of words get recalculated over and over again.

Without KV Cache, the longer the conversation gets, the faster the compute load grows—not linearly, but closer to quadratically. Over a conversation of several thousand words, the wait time would become unbearable.

What Problem Does KV Cache Solve?

Illustration 2

The core idea behind KV Cache is intuitive: don’t compute the same thing twice.

Inside the model, processing each token produces intermediate calculation results (technically called Key and Value, or K and V). These results have a crucial property: the intermediate values for past content never change. Regardless of what new text gets generated later, the internal representation of the earlier words stays fixed.

KV Cache works like a seasoned customer support agent. After reading the product manual thoroughly before their shift, they can answer the first customer right away, and don’t need to flip through the manual again for the second or third customer—the knowledge is already in their head, ready to use.

With this in place, the model only needs to process the newest token at each step and reads the rest straight from the cache, dramatically speeding things up.

What Does This Mean for You?

As an everyday LLM user, KV Cache brings tangible improvements.

Replies are much faster. Benchmarks show that under the same conditions, a model with KV Cache takes about 9 seconds to generate a passage, compared to nearly 40 seconds without it. And that’s just for a single paragraph—the longer the conversation, the bigger the gap.

Long conversations don’t grind to a halt. Even after chatting with an AI for a long time, its response speed doesn’t noticeably degrade. Without KV Cache, as the word count piles up, the compute required for each new token would grow quadratically until the conversation becomes painfully slow.

Complex tasks become practical. Asking an AI to analyze a lengthy report, process a book, or carry on a deep multi-turn discussion—all of these finish within a reasonable time largely thanks to KV Cache.

Costs and Trade-offs

Illustration 3

If KV Cache is so effective, why not cache an unlimited amount of content?

Caching takes up memory, and that’s the main constraint.

Every cached token’s intermediate results occupy GPU memory (VRAM). VRAM is like a physical desk: the bigger the desk, the more files you can keep open at once, but there is always a limit. Cache too much, and you run out of space.

For large models, this overhead is substantial. Caching a single token (roughly half to one Chinese character, or part of an English word) takes around 2.5 MB of memory. A conversation of a few thousand words can easily consume over ten gigabytes of VRAM—roughly the equivalent of loading more than a dozen HD movies into memory at once.

This also explains a few phenomena you may have run into:

  • Why do AI models have a “context limit”? It’s not that the model has a bad memory, but that VRAM is finite. Once you exceed the limit, older content gets evicted to make room for new input.
  • Why do models supporting longer conversations cost more? Larger caches require better hardware, which naturally drives up the price.
  • Why does AI sometimes slow down when more people use it at the same time? Every user needs their own dedicated cache space; the more concurrent users there are, the tighter the resources get.

For developers, KV Cache also offers a very practical benefit: lower API costs.

Take an AI customer support bot, for example. Every new conversation starts by loading a fixed system prompt. Without KV Cache, whenever a new user sends a message, the model has to recompute that prompt from scratch. During peak hours with hundreds of concurrent users, that same prompt gets computed hundreds of times.

With KV Cache enabled, the computed results for the system prompt are cached and shared across all users. For every subsequent request, the model only processes the new user input. Many model providers charge significantly less—or even nothing—for cached input tokens. The longer the system prompt and the higher the call volume, the more money you save.

The same principle applies to a legal assistant’s clause library, a medical bot’s clinical guidelines, or an educational platform’s course knowledge base—whenever the system prompt is relatively static, KV Cache pays off.

To relieve VRAM pressure, engineering teams keep optimizing. One approach is having multiple “attention heads” share the same cache (GQA / MQA) to store data more compactly. Another is managing cache memory more dynamically (PagedAttention) so limited hardware can serve more users.

Illustration 4

It is these ongoing optimizations that allow today’s AI products to serve massive numbers of users at a reasonable cost.

At its core, KV Cache is a space-for-time trade-off—storing intermediate results that have already been computed so they don’t have to be calculated again. It isn’t magic; it’s just refusing to do wasted work.

Copyright

Author
XingKaiXin
Title
KV Cache: Why AI Replies Get Faster
Published
2026年3月24日

Licensed under CC BY-NC-ND 4.0 DEED.

XingKaiXinXingKaiXin

Stamp book

0 / 10
  • 初来乍到Visit for the first time
  • 颠倒世界Flip the world once
  • 手不释卷Read a post to the end
  • 愿者上钩Fish something out of the pond
  • 余音绕梁Play the record to the end
  • 手下留情Pinch Kaixin's cheek
  • 暗房一游See the photos in the darkroom
  • 误入歧途Find a page that doesn't exist
  • 夜深人静Drop by late at night
  • 终端潜行Successfully run cat or mcp call in the Agent shell

Stamps are kept only in this browser