Inference systems · Research feature

Every Cache Entry Earns Its Place: Global Allocation of Resolution and Coverage for KV Cache Compression

Therefore, we propose GraceKV, a global approach for the allocation of resolution and coverage in KV cache compression, and formulate the compression process as a global resource allocation problem under a fixed cache budget.

Adapted from research by Haolin Tian, Yuzhe Liu, Tonghan Wang.

arXiv preprint revision · 2026-10-10 · Attribution & reuse
In this article
Editorial illustration of optical fibers.

Authors’ overview

As large language models (LLMs) process increasingly long contexts, KV cache storage and repeated access have become a major bottleneck. Existing KV cache compression methods rely on predefined, fixed compression rules and are typically developed around either token eviction or merging. As a result, cache resources can neither flow freely across layers, heads, and context slots, nor be jointly allocated to balance local resolution and information coverage. Therefore, we propose GraceKV, a global approach for the allocation of resolution and coverage in KV cache compression, and formulate the compression process as a global resource allocation problem under a fixed cache budget. GraceKV treats each layer-KV-head-slot combination as an atomic unit and builds a prototype tree. Leaf nodes correspond to token-level KV entries, while each internal node uses a single prototype to compress the KV space covered by its children. A set of non-overlapping nodes in the tree forms the representation of an atomic unit. Adding the root of a new tree expands information coverage, whereas splitting a selected node improves local resolution. All candidate actions compete globally for a shared cache budget. Finally, the nodes retained across all trees form the compressed KV cache. This process adaptively determines the allocation of cache resources among atomic units globally and the balance between resolution and coverage. GraceKV requires no additional training, and the entire compression and inference process is performed on the GPU. Systematic experiments across diverse long-context tasks and compression ratios show that GraceKV ranks first in 25 of 32 settings and remains robust up to 128-fold compression. These results validate the effectiveness of global budget allocation in coordinating information coverage and local resolution.

Introduction

Applications such as long-document understanding and complex reasoning continually push LLMs to process longer contexts. To avoid redundant computation during autoregressive generation, LLMs cache the Key and Value associated with each context token in the KV cache. As context length grows, the storage footprint of the KV cache increases linearly and is repeatedly accessed at every decoding step, leading to continuously growing GPU memory usage and memory-access overhead. These costs have become a major bottleneck limiting the efficiency and scalability of long-context inference.

To alleviate this bottleneck, KV cache compression has been widely studied. Existing methods mainly follow two directions: token eviction and KV merging. The former retains a subset of tokens according to importance scores and removes the rest, whereas the latter aggregates multiple KV entries into a small number of prototypes, trading lower local representation resolution for broader information coverage. Moreover, existing methods typically rely on predefined, fixed compression rules. Although subsequent studies introduce adaptivity at the layer or head level, they still require the allocation granularity or local cache quotas to be specified in advance. Consequently, this “first constrain the representation form and local quota, then make compression decisions” paradigm prevents the limited post-compression cache resources from jointly coordinating local resolution and information coverage, or from flowing freely across layers, attention heads, and context regions. Therefore, enabling limited cache resources to be adaptively allocated to more valuable places, thereby organizing and retaining contextual information more effectively, is central to efficient long-context inference.

Therefore, we propose GraceKV, a global approach for the allocation of resolution and coverage in KV cache compression, and formulate the compression process as a global resource allocation problem under a limited budget. To coordinate local resolution and information coverage within a unified representation space, GraceKV first partitions the context into slots through curvature-guided semantic segmentation. It then treats each layer-KV head-slot combination as an atomic unit and constructs a progressively refinable prototype tree for each atomic unit. The root uses a single prototype to represent the entire slot, each internal node uses one prototype to compressively represent the contiguous interval covered by its subtree, and the leaves correspond to the token-level K/V entries. A set of non-overlapping nodes in the tree thus constitutes a cache representation of the atomic unit at a particular resolution. Based on this representation, GraceKV defines two basic operations: Add admits the root of a new tree to expand information coverage, whereas Split refines a selected node to improve local resolution in a covered region. Accordingly, whether a region is covered and, if so, at what resolution it is represented can both be uniformly expressed by a set of nodes in the prototype tree.

Models and Datasets

We evaluate GraceKV on two representative long-context benchmarks, LongBench and RULER, covering six subtasks in total. We evaluate Qwen2.5-3B-Instruct, Qwen2.5-7B-Instruct, and Qwen2.5-14B-Instruct; Llama-3.1-8B-Instruct; and Mistral-7B-Instruct-v0.3. The main results use Qwen2.5-7B-Instruct, while the ablation study additionally includes Llama-3.1-8B-Instruct. Complete cross-backbone results are reported in Appendix E.1.

Limitations

Achieving globally optimal allocation requires searching an exponentially large space, making it difficult to satisfy the latency requirements of online inference. GraceKV therefore adopts global greedy allocation and uses the singleton floor to mitigate the underestimation of non-smooth gains, thereby approximating the globally optimal solution. However, this strategy still cannot guarantee global optimality in the combinatorial optimization sense. In addition, prototype-tree construction introduces one-time latency and peak memory overhead, which could be further reduced through low-level and hardware-specific optimizations.

Motivation and Novelty

GraceKV first partitions the long context into a set of contiguous slots, based on which it constructs a progressively refinable prototype tree for every layer–KV-head–slot atomic unit. This partition determines not only the intervals covered by the tree roots, but also which tokens may initially share a low-resolution representation. The slot boundaries should therefore be placed near structural transitions in the contextual representation, rather than being determined solely by a predefined uniform length.

Uniform segmentation is simple, but it may separate regions whose representations evolve continuously or place representationally heterogeneous neighboring regions in the same slot. The former produces unnecessary tree roots and cache entries, whereas the latter requires a coarse prototype to approximate multiple incompatible representation patterns, increasing the distortion introduced by KV merging. Explicit punctuation and document delimiters provide another possible partition signal, but they depend strongly on the input format and do not directly indicate whether the model’s internal representation has changed. Token surprisal primarily reflects local prediction difficulty or rarity and likewise does not necessarily correspond to a structural boundary.

We instead view the hidden states of consecutive tokens as a discrete trajectory in the representation space and identify candidate boundaries from changes in its direction. Intuitively, when neighboring hidden states evolve smoothly along similar directions, they are more likely to admit a shared low-resolution prototype. When the trajectory changes direction sharply, merging across that position is more likely to mix different representation structures. GraceKV therefore uses multi-layer, multi-scale hidden-state curvature as its primary structural signal and token surprisal only as an auxiliary signal for local information transitions.

To the best of our knowledge, GraceKV is the first KV cache compression method to use multi-layer, multi-scale hidden-state trajectory curvature to construct contiguous textual slots for multi-resolution KV cache compression. This claim concerns the specific structural role of curvature in constructing the shared slot partition, rather than the broader use of curvature for language-model analysis or token compression.

Why Curvature for Slot Boundaries

Curvature and token importance serve fundamentally different roles in GraceKV. The subsequent value flow estimates whether a region is useful for the current task, whereas curvature-guided segmentation determines which neighboring tokens should not be forced to share an initially coarse representation. The former answers whether a region is worth preserving; the latter identifies where a low-resolution representation should be structurally separated. We therefore do not directly use attention scores, token relevance, or multi-hop values to determine the shared slot partition, as doing so would make the structural decomposition itself depend entirely on the current question’s local attention pattern.

Curvature is particularly suitable for this purpose because it measures a change in the direction of representation evolution, rather than only the distance between neighboring states. Hidden states may move by a relatively large distance while continuing along a consistent direction, in which case the underlying representation pattern remains smooth. Conversely, a sequence of individually small changes may still contain a strong structural transition when their directions change sharply. Segmentation based only on adjacent embedding distance cannot distinguish these two cases as directly.

Curvature and surprisal also provide complementary information. Surprisal measures the difficulty of predicting the current token. Rare entities, numbers, special symbols, or unusual surface forms may all produce high surprisal without defining a structural boundary. Curvature instead compares the directions of the hidden-state trajectory on the two sides of a position and is therefore more directly related to a transition between local representation patterns. GraceKV consequently assigns surprisal a relatively small auxiliary weight rather than allowing it to dominate the partition.

The multi-layer, multi-scale formulation further prevents the partition from depending on a single representation depth or neighborhood size. Small windows respond to local transitions, whereas larger windows capture broader structural changes. Intermediate and deeper layers expose representation changes at different abstraction levels. Subtracting the cross-layer, cross-scale standard deviation suppresses peaks that are not stable across these views.

Global Allocation vs. Global Optimality

An empty frontier means that the entire slot is dropped at the corresponding layer and KV head. A frontier containing only the root represents the complete slot using one coarse prototype. Expanding frontier nodes progressively improves local resolution, while full expansion to token-level leaves recovers the original K/V entries.

Accordingly, Add measures the gain obtained by changing a region from complete removal to coarse coverage, whereas Split measures the gain obtained by replacing one coarse prototype with a finer set of child prototypes. Because the two operations use the same value, distortion, sensitivity, and physical-entry units, coverage and resolution can directly compete under one shared budget.

Consequently, the number of physical cache entries eventually assigned to each layer, KV head, or context slot is an emergent result of global competition among its candidate operations, rather than a pre-specified compression ratio or local quota.

Global optimality is a stronger and fundamentally different requirement. It would require searching over all valid frontier combinations of all prototype trees and identifying the joint representation with the maximum total utility under the shared budget. GraceKV does not claim such combinatorial optimality. In other words, global describes the scope of resource competition, whereas optimal describes an exact solution guarantee over the complete discrete search space. GraceKV implements the former and efficiently approximates the latter.

Difficulty of Exact Global Optimization

The difficulty of exact optimization does not arise only from the number of candidate operations. Each prototype tree contains a combinatorial number of valid frontiers under ancestor constraints, while the choices made across different trees are coupled by the shared cache budget.

The first term corresponds to retaining the parent node, while the second term corresponds to expanding the parent and jointly selecting frontiers from all child subtrees. Even for a balanced binary tree, this quantity grows rapidly with tree depth. Salient-token extraction may additionally create three-way branches, further enlarging the valid-frontier space.

An exact dynamic program would generally need to include the cache budget as an additional state dimension and repeatedly merge the non-dominated cost–utility states of different trees. Its cost depends not only on the numerical budget but also on the number of non-dominated frontiers retained for every subtree. In online long-context inference, such optimization overhead can become comparable to, or even outweigh, the decoding savings obtained from cache compression.

GraceKV therefore does not attempt to solve the exact combinatorial problem online. Instead, it uses a global greedy allocator based on marginal utility per physical entry. This converts an intractable joint-frontier search into a sequence of priority-queue operations while preserving global resource competition across layers, KV heads, and context regions.

Cross-Backbone Results

To examine whether GraceKV depends on a particular model architecture, family, or parameter scale, we further evaluate it on four additional backbones: Llama-3.1-8B-Instruct, Qwen2.5-14B-Instruct, Mistral-7B-Instruct-v0.3, and Qwen2.5-3B-Instruct. These models cover the Qwen, Llama, and Mistral families and parameter scales from 3B to 14B. All methods follow the same evaluation protocol, mandatory-region definition, and physical KV-entry budget used in the main experiments. Tables 4–7 report every evaluated compression ratio and cache budget. FullKV is shown as the uncompressed reference and is excluded from the ranking among compressed-cache methods. The best and second-best compressed-cache results in each column are highlighted in bold and underlined, respectively.

Across the 128 model–task–budget settings, GraceKV ranks first in 85 settings and second in another 26, placing among the top two in 111 settings. These results span three model families and parameter scales from 3B to 14B, indicating that the allocation mechanism is not tied to a single backbone family or model scale.

The same trend extends beyond question answering. GraceKV ranks among the top two in 21 of 24 summarization settings and 22 of 24 few-shot settings. The absolute gaps on summarization are generally smaller, as these tasks place greater emphasis on broad contextual coverage and are therefore less sensitive to exact local representations. Nevertheless, GraceKV remains competitive across these task categories and obtains the highest score in many moderate- and high-compression settings. This pattern shows that its performance extends beyond question answering to tasks emphasizing broader contextual coverage.

RULER further reveals the different representation requirements of aggregation and retrieval. Retrieval requires accurate localization of one or more original evidence positions, and GraceKV ranks first in 12 of 16 settings and second in four more. In contrast, aggregation favors broad and relatively uniform coverage, where coarse-merging methods are often more competitive. These results indicate that GraceKV’s clearest advantage lies in tasks requiring precise evidence localization, while the preferred coverage–resolution balance remains task dependent.

Equal-Budget Interpretation

GraceKV defines one cache-budget unit as one physically stored K/V pair at a particular layer and KV head. Regardless of whether a cache entry represents an original token, an exact singleton, or a prototype of a contiguous interval, it participates in decoding as one physical cache position.

These allocation decisions are made once during post-prefill construction. The retained frontier entries, including exact floor-selected singleton leaves and the other prototype nodes retained along their tree paths, together with the recent window, are then uniformly materialized as physical K/V cache entries, and subsequent generation directly operates on the compressed cache.

The three methods retain similar numbers of physical entries and therefore exhibit decoding latency and primary K/V storage within the same range. This result shows that the multi-resolution prototypes of GraceKV do not introduce decoding computation proportional to the size of the original prototype trees. The trees are used only to determine the final cache representation and are not retained or traversed during generation.

Accordingly, under an identical physical-entry budget and a unified decoding implementation, compressed-cache methods generally exhibit similar steady-state memory and decoding costs. The principal distinction of GraceKV is not the use of additional decoding computation, but its ability to organize the same number of entries more effectively by jointly allocating information coverage and local resolution.

Amortization and Break-Even Analysis

The estimated break-even lengths are longer than the typical outputs of the evaluated LongBench and RULER tasks. Therefore, these benchmarks primarily demonstrate the memory reduction and post-construction decoding characteristics of GraceKV rather than single-query end-to-end latency gains. Importantly, the reduction in physical KV-cache memory takes effect immediately after compression and does not depend on reaching the latency break-even point.

As the context length increases, FullKV must read an increasingly large number of historical K/V entries at every decoding step, whereas the physical cache size of GraceKV remains constrained by the specified budget. Longer contexts therefore tend to produce larger per-token savings and allow the one-time construction cost to be amortized over fewer generated tokens.

These reuse cases preserve the question-conditioned prefill state used to construct the final cache. GraceKV should not directly reuse the same compressed cache for an arbitrary new question over the same document. A new question may change the direct token relevance, multi-hop relevance, and layer–KV-head sensitivity, which can alter both the selected singleton anchors and the subsequent global allocation.

A promising extension is to reuse only the question-independent construction results across different questions. For example, curvature-guided slot boundaries, candidate prototype trees, and interval statistics could be cached for a document, while the question-conditioned relevance, sensitivity, singleton-floor selection, and global allocation are recomputed for each new question. This would preserve question adaptivity while avoiding repetition of the most expensive structural construction stages. Another possible direction is to construct query-robust caches using relevance signals aggregated over multiple representative questions, although such a setting requires separate evaluation.