Learn AI Math

Key Cache

What is Key Cache?

In one sentence: The key cache is the part of the KV cache that stores the keys for all previous tokens.

New tokens compare their queries with these stored keys to decide what to pay attention to. Storing them avoids recalculating keys for every step.

What does Key Cache look like?

When writing token 1,001, the model checks its query against 1,000 cached keys.

Why does Key Cache matter?

It is half of the memory cost of the KV cache.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.