Skip to content
AImpact
IT EN
High AI Infrastructure · 1 min read

Automatic Prefix Caching in vLLM 0.4.0: KV cache reused across requests with the same prefix

In one sentence vLLM 0.4.0 (March 30, 2024) ships Automatic Prefix Caching, merged on March 2 via PR #2762: KV cache blocks of identical prefixes, such as a long system prompt, are reused across different requests. It is enabled with --enable-prefix-caching.

Verified Official source
ShareLinkedInX
Reading level

Before generating the first word, a model must process all the context text: system prompt, history, retrieved documents. This phase is called prefill.

With Automatic Prefix Caching, if a new request starts with the same text as a request already processed, vLLM reuses the work already done on that part instead of redoing it. It helps when many requests share a long system prompt or the same document.

The gain only concerns context processing time, not the speed at which the answer's words are generated.

Companies

vLLM Team

Tools

vLLM

Tags

prefix cachingKV cachevLLMinference optimizationTTFTRAG

Sources