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
- The prompt is split into a prefix and suffix.
- KV-states are computed and saved for the prefix.
- When the same prefix is requested again, the states are loaded from the cache.
- 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 |