<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kv-Cache on Le Site de François</title><link>https://lesitedefrancois.be/en/tags/kv-cache/</link><description>Recent content in Kv-Cache 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/kv-cache/index.xml" rel="self" type="application/rss+xml"/><item><title>Context window</title><link>https://lesitedefrancois.be/en/ai/context-window/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://lesitedefrancois.be/en/ai/context-window/</guid><description>&lt;p&gt;The &lt;strong&gt;context window&lt;/strong&gt; is the maximum span of tokens—input prompt plus model-generated output—that an &lt;strong&gt;LLM&lt;/strong&gt; can process in a single forward pass chain without truncating or sliding attention. It is set by &lt;strong&gt;model architecture&lt;/strong&gt; (positional encoding limit, e.g. 8K, 128K, 1M+ in newer models) and by practical &lt;strong&gt;VRAM&lt;/strong&gt; on the serving &lt;strong&gt;GPU&lt;/strong&gt;, because the &lt;strong&gt;KV cache&lt;/strong&gt; scales with total sequence length. Its objective is to bound memory and compute: longer windows enable whole documents, multi-turn chat history, and large &lt;strong&gt;RAG&lt;/strong&gt; payloads in one shot, but cost more on every &lt;strong&gt;prefill&lt;/strong&gt; and &lt;strong&gt;decode&lt;/strong&gt; step. APIs expose this as &lt;code&gt;max_tokens&lt;/code&gt;, context limits, or model cards; exceeding it yields errors or silent truncation.&lt;/p&gt;</description></item><item><title>Decode</title><link>https://lesitedefrancois.be/en/ai/decode/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://lesitedefrancois.be/en/ai/decode/</guid><description>&lt;p&gt;&lt;strong&gt;Decode&lt;/strong&gt; is the second stage of &lt;strong&gt;LLM inference&lt;/strong&gt;: after &lt;strong&gt;prefill&lt;/strong&gt; has stored keys and values for the prompt, the model generates &lt;strong&gt;one new token per forward pass&lt;/strong&gt;, appends it to the sequence, extends the &lt;strong&gt;KV cache&lt;/strong&gt;, and repeats until a stop condition (EOS token, max length, or API limit). Its objective is fluent continuation—answer text, code, or tool-call JSON—at acceptable &lt;strong&gt;inter-token latency&lt;/strong&gt; and cluster &lt;strong&gt;throughput&lt;/strong&gt; (tokens per second across many concurrent sessions). Decode drives the “typing” experience in chat UIs; prefill drives how long users wait before the first character appears.&lt;/p&gt;</description></item><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><item><title>Prefill</title><link>https://lesitedefrancois.be/en/ai/prefill/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://lesitedefrancois.be/en/ai/prefill/</guid><description>&lt;p&gt;&lt;strong&gt;Prefill&lt;/strong&gt; is the first stage of &lt;strong&gt;LLM inference&lt;/strong&gt; after a user (or &lt;strong&gt;RAG&lt;/strong&gt; pipeline) submits a prompt: the model runs a forward pass over &lt;strong&gt;all input tokens at once&lt;/strong&gt; (or in chunked blocks for very long contexts) to compute hidden states and populate the &lt;strong&gt;KV cache&lt;/strong&gt; for every layer. Its objective is to prepare context the model will attend to during generation; the user-visible metric is often &lt;strong&gt;time to first token (TTFT)&lt;/strong&gt;, which is dominated by prefill for long prompts. Prefill is &lt;strong&gt;compute-intensive&lt;/strong&gt; (large matrix multiplies across the full sequence) compared with &lt;strong&gt;decode&lt;/strong&gt;, which adds one token at a time. In chat, each new user message typically triggers a new prefill over the accumulated conversation (unless caching optimizations apply).&lt;/p&gt;</description></item></channel></rss>