[KongchangAI]
· 2 min read· 1,041 words

AutoCache: Agent-Driven Automatic Search for LLM Prefix Cache Compression

AutoCache: Agent-Driven Automatic Search for LLM Prefix Cache Compression

AutoCache uses agents to automatically search for compression recipes, achieving 291x KV cache and 222x hybrid cache compression.

The article introduces the AutoCache framework, aimed at solving the problem of frequent evictions and expensive recomputation in prefix cache due to limited capacity in large model inference serving. Traditional compression methods rely on engineers manually combining quantization, decomposition, entropy coding, and other techniques, which are hard to generalize to diverse architectures, and recurrent states of hybrid models are often overlooked. AutoCache lets agents automatically explore the combinatorial space of compression and reconstruction programs, generating compression recipes for specific models, datasets, and accuracy targets. On the RULER benchmark with 32K context, Qwen3.5-9B achieves 291.1x KV cache compression, far exceeding the strongest baseline of 16.0x; it also exploits the low-rank structure of recurrent states to compress total cache to 222.6x. The article argues this demonstrates the potential of automatically discovered compression algorithms in LLM serving systems.

Title

AutoCache: Agent-Driven Automatic Search for LLM Prefix Cache Compression

Meta Description

AutoCache uses agents to automatically search for LLM prefix cache compression schemes, achieving 291.1x KV cache compression on Qwen3.5-9B and extending to hybrid model recurrent states for 222.6x total cache compression, significantly improving storage efficiency.

Article Content

In large model inference serving, prefix cache avoids redundant prefill computation by reusing already-computed KV states, thereby reducing first-token latency. However, as context length and the number of reusable prefixes grow, limited cache capacity leads to frequent evictions and expensive recomputation, making storage efficiency a key bottleneck. More complexly, modern hybrid architecture models maintain recurrent states and sliding window states in addition to KV cache, requiring compression strategies to simultaneously consider model architecture, workload characteristics, and reconstruction costs.

AutoCache Overview

Limitations of Traditional Compression Methods

Manually designing compression schemes proves inadequate when facing diverse model architectures and workloads. Engineers typically need to tune combinations of quantization, decomposition, or entropy coding techniques for specific models and datasets—a time-consuming process that is hard to generalize. Especially when models adopt hybrid architectures, recurrent state compression is almost ignored, leaving overall cache occupancy persistently high.

The KV states that prefix cache relies on refer to the Key and Value tensors already computed per layer's attention during autoregressive inference. As sequences grow longer, these tensors expand linearly, becoming the dominant consumer of GPU memory; the so-called "reuse" means storing the KV results of a shared prefix so that subsequent requests hitting it can skip prefill. Mainstream KV cache compression approaches include quantization (representing values with lower bits), factorization (decomposing large matrices into products of low-rank matrices), entropy coding (lossless or near-lossless encoding according to distribution), and retaining high precision only for highly salient entries. These methods each trade off accuracy versus speed; used alone, compression ratios are limited, while combined use depends heavily on specific models and data distributions—precisely the root cause making manual tuning hard to scale.

AutoCache: Automatically Discovering Compression Recipes with Agents

The AutoCache framework from the research community proposes a new approach: letting an agent automatically explore the combinatorial space of compression and reconstruction programs. Given a model, dataset, and accuracy target, AutoCache systematically combines factorization, quantization, entropy coding, and protection strategies for highly salient cache entries to generate compression recipes tailored to specific scenarios. It not only optimizes existing methods but also discovers compression opportunities specific to data and model architectures.

According to the paper, on the RULER benchmark with 32K context, AutoCache achieves 291.1x KV cache compression on the Qwen3.5-9B model, while the strongest baseline in the evaluation reaches only 16.0x. This order-of-magnitude improvement stems from the agent finding combinations that are difficult for humans to design.

The "agent" here is a programmatic searcher that can call tools, read intermediate metrics, and make iterative decisions: it treats candidate compression transformations (quantization bit width, decomposition rank, encoding method, protection thresholds, etc.) as actions, uses measured reconstruction error and compression ratio as feedback, and progressively assembles a complete pipeline rather than generating an answer in one shot. RULER is a mainstream benchmark for evaluating long-context capabilities, including tasks like multi-hop retrieval and aggregation, often used to test whether compressed models can still correctly utilize remote information; 32K refers to an input length of approximately thirty-two thousand tokens. Compression ratio is calculated as original cache bytes divided by compressed bytes; 291.1x means the space previously holding one prefix can now accommodate about 291.

Extending to Recurrent States of Hybrid Models

More notably, AutoCache can seamlessly extend compression to the recurrent states of hybrid models. By discovering and exploiting previously untapped low-rank structures in recurrent states, AutoCache achieves 222.6x compression of total cache memory footprint. This means prefix cache storage efficiency can be greatly improved, thereby supporting longer contexts or more concurrent requests under the same hardware conditions.

Hybrid architectures refer to models that intersperse linear attention, state space models (such as the Mamba family), or sliding window attention between Transformer layers. Such models maintain two types of incremental states beyond KV cache: recurrent states are fixed-dimension hidden states accumulated over time, responsible for compressing historical information; sliding window states retain only KV within the most recent window. They do not grow linearly with context but can accumulate significant occupancy with concurrent requests and layers, and once evicted typically cannot be cheaply recovered by recomputation like KV, incurring higher reconstruction costs. When compressing recurrent states, low-rank structure means the effective rank of the state matrix is far below its nominal dimension, so matrix decomposition can approximate it without significant information loss—this is the key basis for AutoCache achieving additional compression on hybrid models.

Impact on LLM Serving Systems

The significance of AutoCache lies not only in numerical breakthroughs but in demonstrating the potential of automatically discovering compression algorithms: tailoring compression strategies to model architectures and workloads makes prefix cache more feasible in real deployments. As model architectures become increasingly diverse, such automated methods are expected to become standard tools for LLM inference optimization.

For AI engineers and system architects, AutoCache suggests a new path: rather than manually tuning parameters, build agents to search for optimal cache compression schemes. In the future, we may see more similar work bringing agents into system optimization, driving continuous improvements in LLM serving efficiency.

One-line Summary

AutoCache uses agents to automatically search for compression recipes, achieving 291x KV cache and 222x hybrid cache compression.

Paragraph Summary

The article introduces the AutoCache framework, aimed at solving the problem of frequent evictions and expensive recomputation in prefix cache due to limited capacity in large model inference serving. Traditional compression methods rely on engineers manually combining quantization, decomposition, entropy coding, and other techniques, which are hard to generalize to diverse architectures, and recurrent states of hybrid models are often overlooked. AutoCache lets agents automatically explore the combinatorial space of compression and reconstruction programs, generating compression recipes for specific models, datasets, and accuracy targets. On the RULER benchmark with 32K context, Qwen3.5-9B achieves 291.1x KV cache compression, far exceeding the strongest baseline of 16.0x; it also exploits the low-rank structure of recurrent states to compress total cache to 222.6x. The article argues this demonstrates the potential of automatically discovered compression algorithms in LLM serving systems.

#AutoCache#prefix cache#KV cache compression#LLM inference#agent-based optimization#hybrid models#recurrent states#Qwen3.5-9B
Share:

Related articles