kv-cache

5 posts

REQUEST TO TOKENS · 06

Paged Attention: Virtual Memory for the KV Cache

How serving engines hand out KV cache memory in 16-token blocks instead of reserving the maximum, how the same blocks let requests share a prompt, and what that saves in memory and time to first token.

REQUEST TO TOKENS · 03144 KiBPER TOKEN36 LAYERS × KEY, VALUE

The KV Cache, Sized: What the Formula Says and What Your Engine Gives You

Compute what each token of KV cache costs from a model's config, then predict the capacity vLLM reports at startup, and see where the two differ.

REQUEST TO TOKENS · 041 LAYER IN 4 KEEPS EVERY TOKEN

When Most Layers Stop Caching: Hybrid, Sliding, and Sparse Attention, Sized

Why a 27B model holds 262k tokens of context on a 24 GB GPU: what hybrid, sliding-window, and sparse attention store and read per token, on real models.

REQUEST TO TOKENS · 10ABFIRST TOKEN: 2.26 s → 0.28 s

Prefix Caching: When It Pays and How to Design Prompts for It

Why a repeated prompt can cost almost nothing, how vLLM and SGLang find shared prefixes, what breaks a hit, and how to structure prompts for agents and chat.

QUANTIZATION · 10BF16 · 498K TOKENSFP8 · 975K4-BIT · 1.84MSAME TOKENS, FEWER BYTES

Quantizing the KV Cache: FP8 and Below

Seven KV cache formats in vLLM, from FP8 to 3-bit, on one model: how many more tokens fit, what long-context recall loses, and why speed follows the kernel.