Skip to content
inference.academy

glossary/memory/prefix-caching

Prefix caching

also automatic prefix caching, prompt caching

Keeping the KV cache of a prompt's beginning after its request finishes, so the next request that starts the same way skips computing it. Attention over a prefix depends only on the prefix, so the cache is identical for anyone who sends those tokens. System prompts shared by every user and the earlier turns of a conversation are the two big wins. The first token then costs a cache lookup instead of a prefill.


80%

Of prefill compute saved after eleven requests in the explainer: eight users, two system prompts of 2K tokens, three turns each.


See it happen


Related