← Retour au blog
tech 7 June 2026

Speculative KV Coding: Losslessly Compressing KV Cache by Up to ~4×

Speculative KV coding presents an innovative solution to reduce the size of KV caches, crucial for large language models. Discover how this method optimizes resource usage while maintaining data integrity.

Article inspired by the original source
Speculative KV coding: losslessly compressing KV cache by up to ~4× ↗ fergusfinn.com

Introduction

You're likely familiar with the challenges posed by Key-Value (KV) caches in large language models. As model contexts grow, storing and managing these caches become critical issues. This is where Speculative KV coding comes in, offering a promising method to losslessly compress these caches by up to four times.

Why Compress KV Caches?

In a context where language models are expanding, KV caches play a crucial role by trading compute for memory. This allows the model to avoid recalculating operations it has already performed. However, this approach leads to significant increases in the storage and transfer needs of cache data, which can quickly become a bottleneck.

Traditional Approaches and Their Limitations

Traditionally, cache compression could be done "lossily" by reducing bit width, as seen with TurboQuant. This method, while effective, incurs a quality loss that is difficult to estimate in advance. Lossless compression, on the other hand, ensures total data integrity but requires more sophisticated methods.

Speculative KV Coding: A New Approach

Speculative KV coding uses a lighter predictor model to estimate what the target model's cache will be with the same input. Using an arithmetic coder, the true cache is then encoded at a bitrate determined by how well the predictor fits the target. This method draws inspiration from speculative decoding (Leviathan et al., 2022), where the predictor runs in parallel on both encode and decode sides.

Preliminary Results

Initial tests show that speculative KV coding can significantly reduce cache sizes, up to four times on a base already compressed in FP8. This translates to a roughly equivalent eight-fold compression from the original raw size.

Applications and Benefits

This drastic reduction has significant implications for the efficiency of language models. It allows for longer contexts to be handled with fewer resources, crucial for real-time applications and agentic workflows.

Real-World Examples

Take the example of a language model used for online assistance. With speculative KV coding, it's possible to maintain high performance levels while significantly reducing infrastructure costs.

Conclusion

Speculative KV coding represents a major advancement in the management of KV caches for language models. By offering lossless compression with increased efficiency, it paves the way for new resource optimization possibilities.

Let's discuss your project in 15 minutes.

KV cache compression lossless predictor model language models
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call