In 2022, asking a model to read a million tokens would have needed more than 130 terabytes of GPU memory on top of its weights — roughly 1,700 H100 graphics cards for a single conversation. Four years later, DeepSeek’s V4.1-Flash holds the same million tokens in 890 megabytes, about one percent of one H100. A new explainer published today traces the six ideas that made the difference, and the trade each one demanded.

The post, by Ximo Guanter on three.dev, works through the arithmetic step by step. It landed on r/LocalLLaMA on Tuesday, where it drew more than 300 upvotes in under two hours. The headline number is a 150,000-fold drop.

Four numbers decide the bill#

A transformer turns text into tokens, and each token leaves behind keys and values in every layer — a record of what it was, so the model does not have to recompute it when it generates the next token. That record is the KV cache, the memory that grows with the conversation. Its size is four numbers multiplied together: entries per token, layers that keep a cache, numbers per entry, and bytes per number.

Take Meta’s Llama 1 65B, from February 2023: 80 layers, 64 attention heads per layer, 128 numbers for each key or value, at 2 bytes each. That is 2.5 MB per token, or 2.5 TB for a million of them. But before 2022 the cache was not even the biggest problem. The attention scores were: one score for every pair of tokens, about 1.1 trillion scores for a million tokens, computed 64 heads at a time — 128 TB of numbers the model used once and threw away. Scores plus cache: 130.5 TB.

The first cut was free#

FlashAttention, by Tri Dao and colleagues in 2022, got rid of the score table. It splits the queries, keys, and values into tiles small enough for the GPU’s fast on-chip memory, computing the scores one tile at a time — made and used on the chip, never written to main memory. Same computation, different order, no change to the model: one move took the total from 130.5 TB to 2.5 TB, 52 times less.

Every cut after that one changed what the model computes. Grouped-query attention, from Google in 2023, split the heads into groups that share one key and value: Llama 2 70B, from July 2023, has 8 groups and 2,048 numbers per entry — 320 GB for a million tokens. The more aggressive version, multi-query attention from 2019, shared a single key and value across all 64 heads — 40 GB, but the heads could no longer each look for something different.

DeepSeek’s multi-head latent attention, in its V2 paper in 2024, shrank the entry further while giving every head keys and values of its own: it stores neither. Every head computes its key and value from the same token vector, so the model caches a compressed latent version of it — 512 numbers, plus 64 for position — and each head expands it back when needed. DeepSeek-V3, from December 2024, has 61 layers and 128 heads: a million tokens take 68.6 GB, fitting in one H100 with 11 GB to spare.

A tall server rack shrinking step by step into a single tiny glowing chip
AI-generated illustration: from a rack of servers to a single chip — the timeline of the shrinking cache.

Then the squeezing started#

The next number to fall was bytes per number. Attention does not need much precision — a score that is slightly off still ranks the same tokens first — so DeepSeek-V3.2, from late 2025, stores its latents in 8 bits instead of 16. But V3.2 also added DeepSeek Sparse Attention, which only looks at the 2,048 most relevant tokens instead of all million, and that needs an indexer with its own small key for every token — 8 GB back. Net result: 46.9 GB.

DeepSeek-V4, released in April 2026 with a million-token context, attacked the one number nobody had touched: entries per token. In one kind of layer, four consecutive tokens are averaged into a single entry; in the other, 128 tokens become one. The originals are thrown away — the same idea as shrinking a photo, where four neighboring pixels become one and the picture still reads fine, but you cannot zoom back in. Detail matters most in the most recent text, so every layer also reads the latest 128 tokens unmerged. With 41 layers keeping caches, V4-Flash lands at 3.4 GB — almost 14 times smaller than V3.2.

Four caches for forty layers#

The last number is the count of layers that cache. In every model so far, each layer built a cache of its own, and V4-Flash has 41 of them. In DeepSeek-V4.1-Flash, from September 2026, only four do: one layer builds a cache, and the layers after it read that cache instead of making their own. The model has 40 layers and four caches — three in the lower half, each shared by six layers, and one shared by the whole upper half.

Sharing saves so much that V4.1 can undo most of V4’s merging. The lower-half caches merge 2 tokens per entry where V4 merged 4, and the upper-half cache does not merge at all — every token has an entry of its own again. V4.1 also cuts the bytes once more, from 8 bits to 4, training with the 4-bit cache in place so the weights learn to work with it. The result: 890 MB, about 1% of an H100, and almost four times smaller than V4-Flash, with less merging.

A dark data center aisle with rows of server racks and one small glowing chip
AI-generated illustration: the cache is now small enough to be a file — written to disk, or streamed across a data center.

Why it matters#

The smaller cache changes what providers do with it. At 2.5 TB, a provider had to free a cache the moment a conversation went quiet. At 890 MB it is a file that can be written to an SSD or streamed through a data center’s network. That is a big part of why you can rent a million-token context window today, and why providers can keep a conversation’s memory around and charge less when you send the same text again. Other labs have taken the same ideas, or different turns: GLM-5, Kimi K2, and Mistral Large 4 all use latent attention, Google’s Gemma models interleave sliding-window layers with a few full ones, and Qwen3-Next and Kimi Linear replace most attention layers with linear attention, whose memory does not grow with the conversation at all.

What to watch#

Two caveats, which the Reddit thread’s top comments were quick to raise. First, the timeline follows different models — Llama 1 to Llama 2 to DeepSeek’s V3 line — not one model shrinking, so the 150,000-fold figure compares across architectures rather than tracking a single system’s improvement. Second, every cut after FlashAttention trades a little quality for a lot of memory; whether that cost bites at a full million tokens in real use is the open question.

The other open question is which turn wins: shared caches and merging, or linear attention that drops the growth entirely. Either way, the million-token conversation has gone from a data center’s worth of memory to a rounding error on a single card.

Sources: three.dev, “GPU memory for 1M tokens of context, from standard attention to DeepSeek-V4.1-Flash” (November 24, 2026); r/LocalLLaMA, “How the memory for 1M tokens shrank from 130TB to 890MB” (November 24, 2026)