Runtime

KV Cache

KV cache improves ongoing generation speed by reusing prior computation instead of recalculating everything from scratch.

Grounded in this concept — answers stay short and honest.

Key terms

KV cacheAutoregressive generationFirst-token latency
Step 1 of 4

Without cache

Each generation step revisits prior context. Compute work repeats.

Ongoing latency: higher

With cache

Earlier states are cached and reused. Only new work is computed.

Ongoing latency: lower · Memory: higher

Compute saved

Prior states reused

Memory cost

Cache grows with context

First token

Largely unchanged

Business impact

How this shapes cost, speed, risk, and control.

Ongoing latency

Materially lower

Especially visible in chat and long-form generation.

Throughput

Higher

More requests per GPU when long contexts are involved.

Memory use

Higher

GPU memory is the limiting resource; cache sizing becomes a planning item.

First-token delay

Unchanged

Cache mostly helps ongoing tokens, not the first one.

What can go wrong

Common failure modes to watch for when this concept shows up in production.

Assuming cache fixes everything

KV cache helps ongoing generation. It does not speed up model quality or first-token latency.

Memory pressure at scale

Long contexts and large batches can exhaust GPU memory if cache sizing is ignored.

Cache invalidation surprises

Changes in prompt structure or tool output can invalidate reuse assumptions.

Related concepts