Skip to content

Prompt Caching

Definition

Prompt Caching is an inference optimization technique where KV-states for recurring prompt prefixes are computed once and reused in subsequent requests. This reduces the time to first token and API call costs.

How It Works

  1. The prompt is split into a prefix and suffix.
  2. KV-states are computed and saved for the prefix.
  3. When the same prefix is requested again, the states are loaded from the cache.
  4. Only states for the new suffix are computed.

Comparison with Other Techniques

Technique Area of Application Effect
Prompt Caching Repeating system prompts Reducing latency and cost
Prefix Caching Common prefixes in batches Accelerating batching
KV-Cache Quantization Cache compression Reducing memory

See Also

← All Terms