Latest / The Practical AI Digest / KV Cache Compression: The Memory Wall Nobody Talks About
Transcript
- 0:00Here is something that will sound completely
- 0:02counterintuitive if you have been following the AI hardware
- 0:06race. The biggest bottleneck in
- 0:09running large language models right now is not compute.
- 0:13It is not the number of GPU's you have, it is memory.
- 0:17Specifically, it is a data structure called the KV cache.
- 0:21And if you are running any kind of production LLM system, it is
- 0:25almost certainly the thing that is quietly eating your budget,
- 0:28throttling your throughput, and limiting how many users you can
- 0:31actually serve. I am MO and this is the
- 0:35practical AI digest. Today.
- 0:38We are talking about KV cache compression, the memory wall
- 0:42that nobody in the industry wants to have an honest
- 0:45conversation about, and two recent breakthroughs that might
- 0:48actually change the game. Let me set the stage with a
- 0:51number that should make you uncomfortable.
- 0:54A single instance of a large language model processing
- 0:58100,000 tokens of context can consume 40 gigabytes of GPU
- 1:03memory just for the KV cache alone.
- 1:06That is roughly half the high bandwidth memory on an
- 1:10enterprise grade GPU like the A-100.
- 1:13Not the model weights, not the activations, just the cache of
- 1:17keys and values that the attention mechanism needs to
- 1:20look back at previous tokens. And that is for one user, one
- 1:24request. Now multiply that by the number
- 1:27of concurrent users you need to serve, and you start to
- 1:30understand why inference costs are where they are.
- 1:34The reason this happens goes back to how Transformers work at
- 1:37a fundamental level. Every time a model generates a
- 1:41new token, it needs to attend to all the previous tokens in the
- 1:45sequence. The naive approach would be to
- 1:47recompute the attention for every single previous token on
- 1:51every generation step, which would be catastrophically
- 1:54expensive. So instead we cache the key and
- 1:58value projections from each layer for each token and reuse
- 2:02them. That is the KV cache.
- 2:05It is a brilliant optimization that makes autoregressive
- 2:09generation tractable, but it comes with a cost that scales
- 2:12linearly with sequence length, linearly with the number of
- 2:17layers, and linearly with the hidden dimension.
- 2:21For a 70 billion parameter model with 80 layers, you are looking
- 2:26at about a MB per token per layer.
- 2:29At 100,000 tokens, that is 8 gigabytes per layer times 80
- 2:33layers. The math gets ugly fast.
- 2:36This is what infrastructure people call the memory wall, and
- 2:41it is not a theoretical concern. WEK published an analysis in
- 2:46April 2026 framing this as the defining infrastructure
- 2:51challenge of the current AI generation.
- 2:54Their argument is sharp and I think correct.
- 2:57Organizations have been throwing GP US at the inference problem,
- 3:02but GP US do not solve a memory bandwidth bottleneck.
- 3:06You can have all the floating point operations per second in
- 3:09the world, and if your attention mechanism is waiting on memory
- 3:13reads from a bloated KV cache, you are memory bound.
- 3:17The GPU cores are sitting idle waiting for data, and you are
- 3:21paying for that idle time at GPU prices.
- 3:24The practical impact hits in three ways.
- 3:27Throughput goes down because you can fit fewer concurrent
- 3:31requests in memory. Latency goes up because memory
- 3:34access patterns get less cache friendly as the KV cache grows,
- 3:39and cost goes up because you need more GPUs not for compute,
- 3:44but for memory. This is why a company serving a
- 3:48chatbot to 1,000,000 users is not spending most of its
- 3:51inference budget on matrix multiplications, it is spending
- 3:55it on storing and fetching the conversational context for each
- 3:58user. And there is a compounding
- 4:01dynamic that makes this worse. Over time, as models get larger
- 4:06and context windows get longer, the KV cache grows in both
- 4:10dimensions simultaneously. A model with twice the layers
- 4:14and twice the context window has four times the KV cache.
- 4:19Meanwhile, GPU memory has been growing linearly, roughly
- 4:23doubling every two to three years.
- 4:26The KV cache is growing quadratically while the hardware
- 4:29is growing linearly. That is the definition of a
- 4:33wall. There is also a subtlety here
- 4:35that gets lost in the benchmarks.
- 4:37The memory wall does not just affect peak memory, it affects
- 4:41memory bandwidth utilization. Modern GPU's like the H-100 have
- 4:46enormous compute throughput over a petaflop of FP8, but their
- 4:51memory bandwidth tops out around 3 terabytes per second.
- 4:55When your attention mechanism has to read a 40 GB KV cache for
- 4:59every single generated token, you are doing 40 gigabytes times
- 5:03the number of attention heads of memory reads per token.
- 5:07At 3 terabytes per second, that is over 13 milliseconds per
- 5:11token just for memory access. For comparison, the actual
- 5:15matrix multiplications take a fraction of that.
- 5:19The model is literally waiting for data, not crunching numbers.
- 5:23This is why you see companies like Rock building custom chips
- 5:26with massive on chips RAM, why Cerebras has their wafer scale
- 5:30approach, and why even Nvidia's Blackwell architecture
- 5:33prioritizes memory bandwidth over raw flops.
- 5:37The industry has figured out that compute is abundant, memory
- 5:41is scarce, and the KV cache is where that scarcity hurts the
- 5:45most. So what do you actually do about
- 5:48it? The field has been working on
- 5:51this hard, and 2025 and early 2026 have produced some
- 5:56genuinely promising approaches. I want to walk through two of
- 6:00them in detail because they represent fundamentally
- 6:03different strategies, and understanding why they work
- 6:06tells you something important about where inference
- 6:09optimization is heading. The first is KVTC, which stands
- 6:14for KV Cache Transform Coding. This was published at ICLR 2026,
- 6:20and it takes an approach borrowed from signal processing,
- 6:24specifically from how we compress images and video.
- 6:28The insight is elegant. The raw key and value vectors in
- 6:32the KV cache have significant statistical redundancy.
- 6:36Adjacent tokens tend to produce similar key vectors because the
- 6:41underlying representations change gradually.
- 6:44Different attention heads within the same layer often encode
- 6:48partially overlapping information, and the
- 6:51distribution of values across the hidden dimension is highly
- 6:55non uniform, with some dimensions carrying much more
- 6:59information than others. KVTC exploits all three of these
- 7:03redundancies in a pipeline. First, it applies PCA based
- 7:08feature decorrelation to remove the cross dimension
- 7:11correlations. This is essentially rotating the
- 7:15coordinate system so that each dimension is as independent as
- 7:19possible, which is exactly what transform coding does in JPEG
- 7:23and video codecs. Then it applies adaptive
- 7:26quantization, allocating more bits to high variance dimensions
- 7:31and fewer bits to low variance ones.
- 7:34And finally it runs entropy coding on the quantized values
- 7:38to squeeze out the remaining statistical redundancy.
- 7:41The results are striking. On standard reasoning
- 7:44benchmarks, KVTC achieves up to 20 times compression with
- 7:49negligible accuracy loss. On some specific workloads it
- 7:54hits 40 times or higher. And critically, it is training
- 7:57free. You do not need to fine tune the
- 8:00model. You do not need calibration
- 8:02data. You apply it at inference time
- 8:05and it works. The compression and
- 8:08decompression are fast enough that the time spent compressing
- 8:12is more than offset by the memory bandwidth you save on
- 8:15cache reads. 20 times compression on a 40 GB KV cache
- 8:21means you are down to 2 gigabytes.
- 8:25That changes the economics of inference entirely.
- 8:28You could serve 10 times as many concurrent users on the same
- 8:32hardware, or you could extend your context window by an order
- 8:35of magnitude without adding GPU's.
- 8:38There is a nuance in the KVTC approach that I think is
- 8:41underappreciated. The PCA rotation step is not a
- 8:45one-size-fits-all transformation.
- 8:48The authors compute the principal components per layer
- 8:51and per attention head because different layers encode
- 8:54fundamentally different kinds of information.
- 8:57Early layers tend to capture syntactic and positional
- 9:00patterns where the key vectors cluster tightly.
- 9:04Middle layers handle semantic composition, where the variance
- 9:07is distributed more evenly. Late layers handle task specific
- 9:11reasoning, where a few dimensions dominate.
- 9:14By adapting the transform per layer, KVTC avoids the common
- 9:19trap of compression methods that work well on average but blow up
- 9:22on the layers that matter most for accuracy.
- 9:26The entropy coding step is also worth a closer look.
- 9:29After quantization, the distribution of quantized values
- 9:33is highly non uniform. Some quantization bins are hit
- 9:36far more often than others, and that non uniformity is free
- 9:40compression if you exploit it. KVTC uses arithmetic coding, the
- 9:45same family of algorithms that powers modern video codecs like
- 9:48H265, to squeeze out this remaining redundancy.
- 9:53The overhead of the coding itself is negligible because the
- 9:56decoder runs on the GPU's tensor cores during the attention
- 10:00computation. You are effectively getting free
- 10:03compression from statistical structure that was always there,
- 10:06but nobody was bothering to exploit.
- 10:09One more thing about KVTC that surprised me.
- 10:12The authors show that their compression actually improves
- 10:15cache locality. In some cases, the compressed
- 10:18cache entries are smaller, which means more of them fit in the
- 10:22GPU's L2 cache during the attention pass.
- 10:26This creates A virtuous cycle where compression reduces memory
- 10:29footprint, which improves cache hit rates, which reduces memory
- 10:33bandwidth pressure, which speeds up the attention computation
- 10:36beyond what the raw compression ratio would predict.
- 10:39The measured speed up is sometimes higher than the
- 10:42compression ratio alone would explain, and this locality
- 10:46effect is why the second breakthrough is Turboquant from
- 10:51Google Research, also at ICLR 2026.
- 10:55Turboquant takes a different approach.
- 10:58Instead of the full transform coding pipeline, it focuses
- 11:02specifically on quantization, but does it in a mathematically
- 11:06novel way that eliminates the accuracy penalties that previous
- 11:10quantization methods suffered from.
- 11:14The key innovation is a technique called polar quant.
- 11:17Traditional quantization methods need to store per block
- 11:21normalization constants, scaling factors that map the quantized
- 11:25integers back to the original floating point range.
- 11:29These constants take up space and introduce error at the
- 11:32boundaries between blocks. Polar quant eliminates them
- 11:36entirely by representing values in polar coordinates where the
- 11:40magnitude and angle can be quantized independently with
- 11:44tighter bounds. It sounds like a small change,
- 11:47but it removes an entire class of quantization artifacts.
- 11:51On top of Polar Quant, Turboquant adds something called
- 11:55Quantize Johnson Lindenstrauss, or QJL.
- 11:59This is a dimensionality reduction technique that
- 12:02projects the key vectors into a lower dimensional space while
- 12:06preserving the relative distances between them, which is
- 12:10what the attention mechanism actually cares about.
- 12:13The Johnson Lindenstrauss lemma guarantees that random
- 12:16projections preserve distances with high probability, and
- 12:20Turboquan shows that you can quantize the projected vectors
- 12:23to very low bit widths without violating this guarantee.
- 12:27The combined result is 3 bits per element in the KV cache.
- 12:32That is a six times memory reduction on NVIDIA H-100 GPU's.
- 12:38The attention computation itself gets up to 8 times faster
- 12:41because the compressed cache fits better in the GPU's on chip
- 12:45memory hierarchy. And here's the part that made me
- 12:48sit up. 0 measurable accuracy degradation, not small
- 12:53degradation, not acceptable degradation. 0 on long bench, on
- 12:58needle in haystack tests, on standard reasoning benchmarks.
- 13:02No calibration data required, no fine tuning.
- 13:06You apply it at inference time and it just works.
- 13:09Now you might be wondering how GULO validated the 0 degradation
- 13:13claim, because that sounds too good to be true and honestly
- 13:17when I first read it I was skeptical too.
- 13:20But the key is in how attention actually works.
- 13:23The attention mechanism computes dot products between query
- 13:27vectors and key vectors, then uses those scores to weight the
- 13:31value vectors. What matters for the output is
- 13:34not the exact values of the keys, but the relative ordering
- 13:38of the dot product scores. If your compression preserves
- 13:41the ranking, the ARD Max, the softmax distribution, then the
- 13:46output is functionally identical.
- 13:48Polar quant and QJL are designed specifically to preserve these
- 13:53relative distances, and the empirical results confirm that
- 13:57the preserved ordering translates to preserved output
- 14:00quality across a wide range of tasks.
- 14:03There is also a practical consideration that the paper
- 14:06addresses what happens at the boundaries when you compress mid
- 14:10sequence. Do you get artifacts at the
- 14:12transition between compressed and uncompressed cache entries?
- 14:16Turboquan handles this by compressing the entire cache
- 14:19uniformly so there are no boundary effects.
- 14:22Every entry gets the same treatment, which means the
- 14:25compression is invisible to the model.
- 14:29I want to be clear about why this matters beyond the obvious
- 14:32memory savings. The memory wall is not just a
- 14:36cost problem, it is a capability ceiling.
- 14:39Today the practical limit on context length for most
- 14:42production deployments is not the models advertised context
- 14:46window, it is how much KV cache memory you can afford.
- 14:51A model that advertises 1,000,000 token context window
- 14:55but requires a TB of KV cache memory at that length is not
- 15:00really a million token model for anyone running real workloads.
- 15:04KV cache compression directly translates into longer usable
- 15:08context at the same hardware cost.
- 15:11It also changes the calculus on model architecture.
- 15:16One of the reasons mixture of experts models are popular is
- 15:20that they reduce the per token compute cost, but they do not
- 15:23reduce the KV cache size because every token still needs full key
- 15:28and value projections across all layers.
- 15:31With aggressive KV cache compression, dense models become
- 15:35more competitive again because their main disadvantage, higher
- 15:38memory usage per token gets compressed away.
- 15:42I also want to put this in an economic frame because the
- 15:45dollar amounts clarify the urgency in a way that technical
- 15:49metrics sometimes do not. A single H-100 GPU costs roughly
- 15:54$30,000, or about $4.00 per hour on the major cloud providers.
- 16:00If your KV cache is consuming half the GPU memory, then half
- 16:05of that $4.00 per hour is going to store in context, not
- 16:09generating tokens. For a company running 100 GPUs
- 16:14for inference, that is $200 per hour, roughly $175,000 per month
- 16:21just on KV cache memory. A six times compression from
- 16:26Turboquant cuts that to under 30,000.
- 16:29A 20 times compression from KVTC cuts it to under 9000.
- 16:34These are not theoretical savings.
- 16:36They are the difference between an inference deployment that is
- 16:39economically viable and one that is hemorrhaging money.
- 16:43And it compounds. When you free up GPU memory from
- 16:47KV cache, you can fit more concurrent requests for GPU,
- 16:52which means you need fewer GPU's for the same throughput.
- 16:56Fewer GPUs means less data center power, less cooling,
- 17:00fewer network switches, less operational overhead.
- 17:04The KV cache is the first domino.
- 17:07Compress it and everything downstream gets cheaper.
- 17:11So what does the practitioner playbook look like?
- 17:13If you are running inference in production today, let me give
- 17:17you 5 concrete things. Benchmark your KV cache memory
- 17:21usage per request at your actual workload lengths.
- 17:25Not the models maximum context. Your actual 50 and P99 context
- 17:30lengths. Most teams I have talked to do
- 17:33not know this number and it is the single most important metric
- 17:37for capacity planning. Evaluate KVTC or Turboquant on
- 17:42your specific model and workload.
- 17:44Both are training free and can be tested without modifying your
- 17:47model. KBTC gives higher compression
- 17:50ratios but with more computational overhead.
- 17:54Turboquant gives lower compression but with faster
- 17:58decompression and 0 accuracy risk.
- 18:01The right choice depends on whether you are memory bound or
- 18:04compute bound. If you are not ready for a
- 18:07compression library, start with the low hanging fruit sliding
- 18:11window attention on your KV cache where you only keep the
- 18:15most recent end tokens plus a few anchor tokens from the
- 18:19beginning. This is not as principled as the
- 18:22compression approaches, but it is trivial to implement and gets
- 18:25you meaningful memory savings for conversational workloads.
- 18:29Set up memory observability. You should be tracking KV cache
- 18:33size per request, peak memory usage for GPU, and the ratio of
- 18:37KV cache memory to total GPU memory utilization.
- 18:42If that ratio is above 50%, you are leaving throughput on the
- 18:45table. Plan for the convergence,
- 18:49Google's official turboquant implementation is expected in
- 18:52the second quarter of 2026, and the major inference frameworks
- 18:57VLLM, Tensor, RTLLM, and the rest will integrate these
- 19:02techniques within a release cycle or two.
- 19:04The teams that understand the memory wall now will be ready to
- 19:08deploy compression the day it ships in their stack.
- 19:12The teams that do not will be 6 months behind paying six times
- 19:16more for memory than they need to and do not sleep on the 2nd
- 19:21order effects. Once KV cache compression is
- 19:25standard, the entire model serving landscape shifts.
- 19:30Longer context windows become practical on smaller hardware.
- 19:35Edge deployment of large models becomes feasible.
- 19:38The cost per query drops enough that use cases that were
- 19:41previously uneconomical. Real time document analysis
- 19:45always on coding assistance with full repository context.
- 19:50Persistent multi turn agents that remember everything.
- 19:53All of those become commercially viable.
- 19:56The memory wall is not just a technical constraint, it is a
- 20:00capability gate and we are about to open it.
- 20:05There is one more thing I want to address because I know some
- 20:08of you are thinking it. What about multi query attention
- 20:12and grouped query attention? These are architectural changes
- 20:16that share key and value heads across multiple query heads and
- 20:20they do reduce KV cache size. GQA with eight groups instead of
- 20:26full multi head attention cuts the KV cache by the number of
- 20:30query heads divided by the number of key value groups.
- 20:34Lama 3, Gemma 2 and most recent models use some form of this.
- 20:39But here is the thing. GQA is an architectural decision
- 20:43made at training time. You cannot retrofit it onto an
- 20:46existing model. And even with GQA the KV cache
- 20:49still scales linearly with sequence length.
- 20:52At long enough context you hit the wall again.
- 20:57The compression techniques I have been talking about, KVTC
- 21:01and Turboquant, work on top of whatever attention architecture
- 21:05the model uses. They are complementary, not
- 21:07competing a model with GQA plus turboquant gets the benefits of
- 21:13both. The memory wall is real, it is
- 21:16expensive, and it is solvable. The research is ahead of the
- 21:20production tooling right now, but that gap is closing fast.
- 21:25Most important thing you can do today is stop thinking about
- 21:28inference optimization as a compute problem and start
- 21:32thinking about it as a memory problem, because the GPU is not
- 21:37your bottleneck, The KV cache is.
- 21:41That's the one for this episode in MO.
- 21:44This is the practical AI digest. If you got something out of
- 21:48this, send it to one person who'd actually use it.
- 21:52No subscribe campaign, no rating farm, just one person.
- 21:56See you on the next one.