Explainer: how the KV cache makes ChatGPT faster — and memory-hungry

udmrzn · x · 2026-12-01

A thread breaking down how Transformers generate text: input is split into tokens, embedded as vectors, and attention heads compare each token against earlier ones with learned weights, layer by layer, until the next token is predicted. To speed things up, models store earlier attention results in a KV cache and reuse them — but the cache grows with conversation length, eating memory. The piece covers two mitigation strategies: letting multiple heads share stored data, and compressing the cache. Based on the "Understanding Transformers" paper explainer.

Original post →

More from Infra

Infra channel →