<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Memory on Le Site de François</title><link>https://lesitedefrancois.be/en/tags/memory/</link><description>Recent content in Memory on Le Site de François</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 François</copyright><atom:link href="https://lesitedefrancois.be/en/tags/memory/index.xml" rel="self" type="application/rss+xml"/><item><title>KV cache (Key-Value Cache)</title><link>https://lesitedefrancois.be/en/ai/kv-cache/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://lesitedefrancois.be/en/ai/kv-cache/</guid><description>&lt;p&gt;The &lt;strong&gt;KV cache (key-value cache)&lt;/strong&gt; is the stored result of the &lt;strong&gt;attention&lt;/strong&gt; layers for tokens already processed in a sequence. During &lt;strong&gt;autoregressive decode&lt;/strong&gt;, each new token only needs a forward pass that depends on prior context; recomputing keys and values for all earlier tokens every step would be wasteful. The cache therefore holds, per layer and per sequence, the &lt;strong&gt;K&lt;/strong&gt; and &lt;strong&gt;V&lt;/strong&gt; tensors produced when those tokens were first seen (during &lt;strong&gt;prefill&lt;/strong&gt; for the prompt, then extended one token at a time during decode). The objective is lower &lt;strong&gt;time per output token&lt;/strong&gt; and lower FLOPs; the cost is &lt;strong&gt;GPU memory&lt;/strong&gt;: cache size grows with batch × layers × heads × sequence_length × head_dim, and is often the limit on concurrent sessions or context length before model weights fill VRAM.&lt;/p&gt;</description></item></channel></rss>