betaFeedback

WorksComputer Science

SD-Cache: Learnable Memory Consolidation with State-Guided Dynamic Caching

Abstract

Large language models (LLMs) are increasingly deployed as persistent services that must reason over large volumes of external knowledge. Retrieval-augmented generation (RAG) grounds model responses in relevant documents, but the retrieved content must still be encoded and stored in the key-value (KV) cache. As this content accumulates, the cache grows linearly, increasing memory consumption and inference cost. Existing memory-compression methods address this problem either by retaining a subset of cached states or by learning context compressors that map documents to compact latent representations. Despite these advances, consolidating information under tight memory budgets while preserving its usefulness for future queries remains challenging. We investigate how the model's native KV states can be selectively consolidated into a fixed-size working memory without access to future queries. To this end, we introduce SD-Cache (State-guided and Dynamically updated Cache), a query-agnostic KV-memory consolidation framework that operates alongside a frozen generator LLM. SD-Cache learns to consolidate layer-wise KV states into fixed-size memory through selective anchor-based pooling and state-guided refinement, processing new contexts in a single forward pass without context-specific optimisation. Experiments on retrieval-augmented question answering and synthetic long-context benchmarks show that SD-Cache maintains competitive downstream performance under constrained memory budgets.

Introduction

Large language models (LLMs) have demonstrated remarkable capabilities as general-purpose systems, powering a wide range of applications, including virtual customer-service assistants [8], code generation [42], and mathematical problem solving [20, 27]. Many are deployed as interactive services that rely on retrieval-augmented generation (RAG) [26] to access evolving domain-specific knowledge, with retrieved content encoded and retained in the key-value (KV) cache.

This reliance on KV-cache storage creates a scaling bottleneck: the cache grows linearly with context length, increasing memory consumption and limiting inference throughput [17, 12]. These costs are compounded across successive interactions, where customer-service systems may repeatedly retrieve and re-encode overlapping policy documents and database records, increasing pre-fill latency [25, 40]. Context compression therefore offers a practical way to reduce the KV storage required for subsequent generation.

Existing KV-cache compression methods fall broadly into training-free and learning-based approaches. Training-free methods commonly retain a subset of KV states using positional heuristics [41] or attention-based importance estimates [46, 28]. Beyond token selection, context-specific optimisation constructs compact KV representations that approximate the attention behaviour of the original cache [47, 12]. Although these methods require no additional model training, they rely on predefined heuristics or context-specific optimisation. Under aggressive compression (e.g., above ×16\times16), tokenselection methods may suffer substantial information loss, as information carried exclusively by discarded states is lost rather than consolidated into the retained cache [5].

Learning-based approaches aim to amortise the cost of context processing across multiple queries through reusable compressed representations. These representations are either optimised for a specific corpus [12] or generated by shared compressors that can be applied to unseen documents [37, 7, 32]. Such compressors can encode documents as continuous embeddings [30] or generate document-specific parameter updates through hypernetworks [4, 18, 22]. However, approaches based on soft tokens or document-specific parameter updates learn alternative representations of the input context for subsequent reuse, rather than directly consolidating the layer-wise KV states already formed by the frozen LLM.

In neuroscience, memory consolidation refers to the time-dependent stabilisation and reorganisation of newly encoded memories into durable representations [38]. Inspired by this process, we explore context compression for RAG as a memory-consolidation problem. Specifically, we ask: Can we learn to maintain a fixed-size KV working memory by selectively consolidating contextual information, without access to future queries? To address this question, we introduce SD-Cache, a query-agnostic framework that augments a frozen generator LLM with an auxiliary Transformer-based network (Figure 1). SD-Cache learns a consolidation operation that dynamically constructs compact KV memory for new contexts in a single forward pass, without context-specific optimisation. Motivated by the clustering structure observed in per-head KV representations, we design an anchor-pooling module (APM) that initialises MM memory slots from the KV states of the first MM tokens and refines them through novelty-guided pooling and gated updates, progressively consolidating the sequence within a fixed memory budget. The resulting attention weights jointly pool the incoming keys and values, preserving key-value correspondence as the slots evolve. To capture key–value associations that slot-wise pooling may overlook, a recurrent state-guided correction module builds an associative state directly from the original KV states and uses it to refine the updated slots. SD-Cache thereby maintains a query-agnostic memory whose size remains fixed as the context grows. Our main contributions are:

Figure 1. Conceptual comparison of SD-Cache with existing training-free (e.g., KV cache eviction [28]) and learning-based compression (e.g., soft-token compression [30]) paradigms. SD-Cache instead learns to consolidate KV states into a fixed-budget memory, retaining model-native representations while supporting selective layer-wise updates.

  • We formulate query-agnostic KV-cache compression as a learnable memory-consolidation problem and introduce SD-Cache, which maintains a fixed memory budget while leaving the generator LLM frozen.

  • We develop a two-stage consolidation mechanism that combines anchor-based pooling to selectively integrate key–value pairs with state-guided correction to capture chunk-level key–value associations that slot-wise pooling may overlook.

  • We demonstrate on RAG-based question answering [36, 30] and synthetic long-context benchmarks [21, 44] that SD-Cache maintains strong downstream performance at high compression ratios.

Related Work

KV Cache Eviction Methods. KV cache eviction methods [41, 46, 33, 28, 3, 44, 16] formulate memory management as an active forgetting [10] problem, typically implemented through a scoring-and-selection rule. Given cached keys and values K,V∈RL×H×DK, V \in\mathbb{R}^{L \times H \times D}, where LL, HH, and DD denote the sequence length, number of KV heads, and per-head feature dimension, respectively, an eviction policy assigns each cache position ii an importance score si∈Rs_i \in\mathbb{R}. Under a budget of M<LM < L positions, the retained indices are selected as IM=TopM⁡({si}i=1L)I_M = \operatorname{TopM}(\{s_i\}_{i=1}^{L}), yielding K~=K[IM]\widetilde{K} = K[I_M] and V~=V[IM]\widetilde{V} = V[I_M]. Retention policies typically use positional [41], attention-based [46, 33, 28], or predictability-based signals [16]. Beyond retention criteria, cache budgets can be allocated unevenly across layers to accommodate differences in attention sparsity [3], while information from evicted tokens can be encoded into an auxiliary latent memory [44]. These strategies preserve selected token states or compensate for eviction losses, but do not learn to consolidate information from evicted states directly into the retained KV cache.

Learnable Context Compression Methods. Learnable compression maps a context X=(x1,…,xL)X = (x_1, \ldots, x_L) to a compact representation Z=fθ(X)=(z1,…,zM)Z = f_\theta(X) = (z_1, \ldots, z_M), where M≪LM \ll L and fθf_\theta is a trainable compressor. Many methods encode contexts into soft embeddings or memory tokens that condition subsequent generation [7, 14, 6, 37, 30]. Others operate directly on internal KV representations [12], including approaches that combine learned token selection with parameter-efficient adaptation to consolidate information into retained states [5]. Concurrent work uses per-layer compactors to synthesise compact KV states from the original cache [32]. While these approaches achieve context compression, our work focuses on learning to selectively consolidate incoming KV states into an existing memory under a fixed budget with a single pass.

Method

Given a frozen LL-layer Transformer, a context of length TT induces per-layer key and value states K(ℓ),V(ℓ)∈RHkv×T×dhK^{(\ell)}, V^{(\ell)} \in\mathbb{R}^{H_{\mathrm{kv}} \times T \times d_h} where ℓ=1,…,L\ell= 1, \ldots, L, HkvH_{\mathrm{kv}} denotes the number of KV heads and dhd_h the head dimension. We denote the full KV state induced by the context as C={(K(ℓ),V(ℓ))}ℓ=1L\mathcal{C} = \left\{(K^{(\ell)}, V^{(\ell)})\right\}_{\ell=1}^{L}. A memory consolidation operator transforms the growing KV state into a compact memory M={(K~(ℓ),V~(ℓ))}ℓ=1L\mathcal{M} = \left\{(\widetilde{K}^{(\ell)}, \widetilde{V}^{(\ell)})\right\}_{\ell=1}^{L}, where K~(ℓ),V~(ℓ)∈RHkv×M×dh\widetilde{K}^{(\ell)}, \widetilde{V}^{(\ell)} \in\mathbb{R}^{H_{\mathrm{kv}} \times M \times d_h} and M≪TM \ll T. Formally, we define a consolidation operator

Oϕ:C→M,M=Oϕ(C),(1)\mathcal{O}_{\phi}:\mathcal{C} \to\mathcal{M}, \qquad\mathcal{M} = \mathcal{O}_{\phi}(\mathcal{C}), \tag*{(1)}

which maintains a fixed memory budget while preserving the information required for future model computation. Given an unknown future query QQ, let YC=(y1,…,yN)=Decode⁡(pθ(⋅∣C,Q))Y_{\mathcal{C}} = (y_1, \ldots, y_N) = \operatorname{Decode}(p_{\theta}(\cdot\mid\mathcal{C}, Q)) denote the output produced by the frozen Transformer from the full KV state. The desired consolidated memory should induce model behaviour close to that obtained from the full KV state:

ϕ∗=arg⁡min⁡ϕ EQ∼DQ[−∑i=1Nlog⁡pθ(yi∣y<i,Oϕ(C),Q)],(2)\phi^{*} = \underset{\phi}{\arg\min}\ \mathbb{E}_{Q \sim D_Q}\left[-\sum_{i=1}^{N}\log p_{\theta}\left(y_i \mid y_{<i}, \mathcal{O}_{\phi}(\mathcal{C}), Q\right)\right], \tag*{(2)}

where DQD_Q denotes the distribution of future queries. Importantly, consolidation is designed to be query-agnostic: the future query QQ is not available to Oϕ\mathcal{O}_{\phi} when M\mathcal{M} is constructed, as depicted in Figure 2. Let Cs\mathcal{C}_s denote the KV states induced by the incoming context chunk at update step ss, and let Ms−1\mathcal{M}_{s-1} denote the consolidated memory retained from the preceding context. For the arriving context, we extend this formulation by allowing the operator to update the existing consolidated memory with newly observed KV states

Illustration of the SD-Cache method

Figure 2. Illustration of our SD-Cache method. The overall SD-Cache pipeline can be summarised in three major steps when starting from scratch: 1) initialise the memory with the KV states of the first MM document tokens, which serve as anchors; 2) selectively update the existing memory Ms−1\mathcal{M}_{s-1} as new context KV states Cs\mathcal{C}_s arrive, while maintaining a fixed budget of MM slots; and 3) use the updated memory Ms\mathcal{M}_s together with the system and user prompts to generate a response with the frozen decoder. The right panel details the memory update mechanism: OAPM\mathcal{O}_{\mathrm{APM}} performs novelty-guided pooling and gated slot updates, while OSGC\mathcal{O}_{\mathrm{SGC}} refines the pooled KV representations using an associative state accumulated from the original KV stream.

Ms=Oϕ(Ms−1,Cs),(3)\mathcal{M}_s = \mathcal{O}_{\phi}(\mathcal{M}_{s-1}, \mathcal{C}_s), \tag*{(3)}

where Oϕ=OSGC∘OAPM\mathcal{O}_{\phi} = \mathcal{O}_{\mathrm{SGC}} \circ\mathcal{O}_{\mathrm{APM}} and Ms\mathcal{M}_s remains constrained to a fixed budget of MM slots for all ss.

Anchor-Pooling Module (O-APM)

APM pools native KV states into compact memory slots, with its design motivated by the structured geometry of Transformer representations. As illustrated in Figure 3, key representations exhibit highly structured, head-specific geometry that remains readily identifiable across layers, with similar structure observed for query representations. These observations suggest that the model’s native KV states provide a natural basis for constructing compact memory representations. For clarity, we omit the layer and KV-head indices below and describe the update for a single set of KV states. At update step ss, let (K~s−1,V~s−1)(\widetilde{K}_{s-1}, \widetilde{V}_{s-1}) denote the current memory of MM slots, and let (Ks,Vs)(K_s, V_s) denote the KV states induced by Cs\mathcal{C}_s. APM follows a novelty-aware write procedure consisting of novelty estimation, anchor pooling, and selective slot update. We index the first update by s=1s = 1 and initialise M0\mathcal{M}_0 using the KV states of the first MM context tokens, which serve as the initial anchors.

Figure 3. Visualisation of the PCA projection [1] of pre-RoPE keys at layer 18 (Figure 3a) and comparison of the mean cosine similarities of keys and queries to their own-head centre and nearest other-head centre across layers (Figure 3b). The plots are produced using Qwen3-4B [42] with 9,204 natural-language tokens sampled from GoodWiki [9].

Coverage-Aware Novelty Estimation. Before modifying the memory, each incoming key first queries the existing memory to estimate how well it is already represented. For the key ksk_s in the incoming key states KsK_s, we compute qs=LayerNorm⁡(ks)\mathbf{q}_s = \operatorname{LayerNorm}(k_s) and reconstruct it from a stop-gradient copy of the current memory:

rs=Attn⁡(qs,sg⁡[K~s−1],sg⁡[K~s−1]).(4)\mathbf{r}_s = \operatorname{Attn}\left(\mathbf{q}_s,\operatorname{sg}[\widetilde{K}_{s-1}],\operatorname{sg}[\widetilde{K}_{s-1}]\right). \tag*{(4)}

A lightweight MLP then predicts a scalar novelty score from the incoming representation, its reconstruction, and their residual:

ns=MLP⁡nov([qs;rs;qs−rs]).(5)n_s = \operatorname{MLP}_{\mathrm{nov}}\left([\mathbf{q}_s;\mathbf{r}_s;\mathbf{q}_s-\mathbf{r}_s]\right). \tag*{(5)}

Intuitively, an incoming state that is already well represented by the existing anchors should require little additional memory capacity, whereas poorly reconstructed states provide stronger evidence for updating the memory. We stop gradients through the memory during this read operation to prevent the anchors from artificially increasing the reconstruction error to obtain a larger novelty score.

Novelty-Guided Pooling. The current memory keys initialise a set of write queries, Zs(0)=K~s−1Z_s^{(0)} = \widetilde{K}_{s-1}, which are refined by attending to the incoming keys. We update these queries using a stack of LpL_p Perceiver-style blocks ([23]). For the dd-th block,

Zs(d)=PerceiverBlock⁡(Q=Zs(d−1),K=Ks,V=Ks;bias⁡=λns).(6)Z_s^{(d)} = \operatorname{PerceiverBlock}\left(Q = Z_s^{(d-1)}, K = K_s, V = K_s; \operatorname{bias} = \lambda n_s\right). \tag*{(6)}

where λ\lambda is a learnable scalar. Each block consists of a pre-normalised cross-attention layer followed by a pre-normalised feed-forward network. The novelty scores nsn_s are added directly to the cross-attention logits, biasing the write queries towards incoming keys that are poorly represented by the current memory. After LpL_p blocks, Zs(Lp)Z_s^{(L_p)} forms the refined write queries used to pool the incoming KV states. We compute a single set of attention weights and apply it to both keys and values:

Ws=softmax⁡(Zs(Lp)KsTdh+λns),Kspool=WsKs,Vspool=WsVs.(7)W_s = \operatorname{softmax}\left(\frac{Z_s^{(L_p)}K_s^{\mathsf{T}}}{\sqrt{d_h}}+\lambda n_s\right),\quad K_s^{\mathrm{pool}}=W_sK_s,\quad V_s^{\mathrm{pool}}=W_sV_s. \tag*{(7)}

Using the same weights for both keys and values ensures that each pooled KV pair aggregates information from the same context positions.

Selective Slot Update. Finally, a shared per-slot gate determines how much newly pooled information is incorporated into each memory slot: gs=σ(MLP⁡gate([K~s−1;V~s−1;Kspool;Vspool]))∈(0,1)Mg_s=\sigma\left(\operatorname{MLP}_{\mathrm{gate}}\left([\widetilde{K}_{s-1};\widetilde{V}_{s-1};K_s^{\mathrm{pool}};V_s^{\mathrm{pool}}]\right)\right)\in(0,1)^M. The same gate is shared between the key and value of each slot, preserving their correspondence:

K~sp=(1−gs)K~s−1+gsKspool,V~sp=(1−gs)V~s−1+gsVspool.(8)\widetilde{K}_s^{\mathrm{p}}=(1-g_s)\widetilde{K}_{s-1}+g_sK_s^{\mathrm{pool}},\qquad\widetilde{V}_s^{\mathrm{p}}=(1-g_s)\widetilde{V}_{s-1}+g_sV_s^{\mathrm{pool}}. \tag*{(8)}

The gate is initialised to favour retaining the existing memory, allowing the slots to gradually learn to incorporate new information during training. The resulting (K~sp,V~sp)(\widetilde{K}_s^{\mathrm{p}},\widetilde{V}_s^{\mathrm{p}}) form the provisional consolidated memory produced by APM.

State-Guided Correction (O-SGC)

SGC complements APM with a compact associative state [43, 19] constructed directly from the original, uncompressed KV stream. Importantly, the state is updated from the raw KV states rather than from the pooled memory, providing an information path decoupled from the slot-pooling process. Within each KV head, the state St∈Rdh×dhS_t\in\mathbb{R}^{d_h\times d_h} represents a key-to-value associative map accumulated over the original stream. For each token tt in CsC_s, we first normalise its key as k^t=kt/∥kt∥2\hat{k}_t=k_t/\lVert k_t\rVert_2 and predict a data-dependent write strength βt=σ(wβTht+bβ)\beta_t=\sigma\left(\mathbf{w}_{\beta}^{\mathsf{T}}h_t+b_{\beta}\right), where hth_t denotes the corresponding hidden representation. Starting from S0=0S_0=0, the state first absorbs the MM anchor tokens with β=σ(bβ)\beta=\sigma(b_{\beta}), and the associative state is then updated using a gated delta rule [19]:

St=γtSt−1(I−βtk^tk^tT)+βtvtk^tT,γt=1−βt.(9)S_t=\gamma_tS_{t-1}\left(I-\beta_t\hat{k}_t\hat{k}_t^{\mathsf{T}}\right)+\beta_tv_t\hat{k}_t^{\mathsf{T}},\qquad\gamma_t=1-\beta_t. \tag*{(9)}

This update continuously absorbs key–value associations from the original KV chunk, while the coupled decay stabilises the state over long sequences. After processing the KV states, we use the resulting associative state SS to refine the updated slots (K~sp,V~sp)(\widetilde{K}^{\mathrm{p}}_s, \widetilde{V}^{\mathrm{p}}_s) produced by APM. Their keys are first normalised and used to query the state:

Rsv=S(K^s)T,K^s=K~sp∥K~sp∥2.(10)R^{\mathrm{v}}_s = S(\widehat{K}_s)^{\mathsf{T}}, \qquad\widehat{K}_s = \frac{\widetilde{K}^{\mathrm{p}}_s}{\lVert\widetilde{K}^{\mathrm{p}}_s\rVert_2}. \tag*{(10)}

Since SS defines only a key-to-value mapping, we use the same readout RsvR^{\mathrm{v}}_s to predict both key and value corrections through lightweight learned heads:

ΔVsS=Wℓ(v)Rsv,ΔKsS=Wℓ(k)Rsv,(11)\Delta V^{S}_s = W^{(v)}_{\ell} R^{\mathrm{v}}_s, \qquad\Delta K^{S}_s = W^{(k)}_{\ell} R^{\mathrm{v}}_s, \tag*{(11)}

where Wℓ(v)W^{(v)}_{\ell} and Wℓ(k)W^{(k)}_{\ell} are zero-initialised layer-specific projections. The corrected memory is then

K~s=K~sp+αk(ΔKsS)T,V~s=V~sp+αv(ΔVsS)T.(12)\widetilde{K}_s = \widetilde{K}^{\mathrm{p}}_s + \alpha_k(\Delta K^{S}_s)^{\mathsf{T}}, \qquad\widetilde{V}_s = \widetilde{V}^{\mathrm{p}}_s + \alpha_v(\Delta V^{S}_s)^{\mathsf{T}}. \tag*{(12)}

The state matrix SS is only maintained during the update and is discarded afterwards, leaving no additional persistent state beyond the compact KV memory.

Training Objective

We keep the parameters θ\theta of the underlying Transformer frozen and optimise only the parameters ϕ\phi of O\mathcal{O}. For each training example, we first decode the target sequence YC=(y1,…,yN)Y_C = (y_1, \ldots, y_N) using the full KV state CC. SD-Cache is then trained to reproduce this full-cache output using only the consolidated memory M\mathcal{M} with

L=−∑i=1Nlog⁡pθ(yi∣y<i,Q,M).\mathcal{L} = -\sum_{i=1}^{N} \log p_{\theta}(y_i \mid y_{<i}, Q, \mathcal{M}).

This objective encourages the estimated memory to preserve the information required to reproduce the behaviour of the full KV.

Experiments

Evaluation Protocols. Our primary benchmark is retrieval-augmented question answering (RA-QA) Benchmark [30]. The training data of this benchmark is taken from questions from multiple sources of QA datasets [30]1, which contain 453,000 samples. Similar to PISCO [30], we also use the response from a teacher model2 as the supervision signal of the next token prediction loss. The evaluation includes five popular QA datasets including: Natural Questions [24], TriviaQA (Joshi et al., 2017), PopQA [31], ASQA [39], and HotpotQA [45]. Our main evaluation metric is the answer matching accuracy in the QA context, which we define as correct prediction if the normalised label is found within the normalised prediction [30]. We adapt Mistral-7B-v0.2 (Jiang et al., 2023) as the backbone for this benchmark. We additionally report results on RULER [21] at a context length of 4096 to further evaluate the model’s long-context retrieval and reasoning capabilities, including needle-in-a-haystack (NIAH), multi-hop tracing, and frequency-based aggregation tasks. For this benchmark, we adapt and augment the RA-QA training data with synthetic retrieval, frequency, and tracking tasks, and use Qwen3-8B [42], Mistral-7B-v0.3 (Jiang et al., 2023), and Llama-3.1-8B [17] as generator backbones. Following the official protocol we score every task with the reference string_match implementation and report the unweighted mean over tasks as the aggregated score. Implementation details are provided in Appendix § 8.§ 1.

Results on RA-QA Benchmark

Tab. 1 compares SD-Cache with existing methods on five RA-QA datasets. At a compression ratio of 16×16\times, SD-Cache achieves the highest average accuracy among the compared compression methods, reaching 68.67% and outperforming PISCO by 0.73 percentage points (pp) at the same compression ratio. SD-Cache improves over PISCO on four of the five datasets, with the largest gains on ASQA and Natural Questions (+2.01 pp and +1.34 pp, respectively), while maintaining comparable performance on other datasets. Its average accuracy also remains within approximately 3 pp of the uncompressed Mistral-7B baseline. At 128×128\times compression, SD-Cache also outperforms

RateASQAHotpotQANQTriviaQAPOPQAAverage
Mistral-7B without Compression
Closed-book ([30])-51.0034.0046.0079.0029.0047.80
Full KV ([30])-74.0051.0069.0092.0070.0071.00
Compression Models
xRAG† ([6])x12834.0027.0032.0077.0033.0040.00
A.C.†‡ ([7])x457.0031.0035.0070.0024.0043.00
ICAE‡ ([14])x447.0029.0042.0078.0043.0048.00
DODO‡ ([35])x1052.0038.0048.0082.0047.0053.00
COCOM ([37])x1663.0046.0058.0089.0048.0061.00
PISCO⋆ ([30])x1671.0948.0664.5890.1765.8367.94
SD-Cache (Ours)x1673.1047.4865.9290.8166.0668.67
PISCO ([30])x12868.0046.0061.0089.0055.0063.80
SD-Cache (Ours)x12871.8444.7563.7389.5857.4165.46

Table 1. Answer-matching accuracy (%) on five RA-QA datasets ([30]). Using five retrieved documents per query, SD-Cache achieves the highest average accuracy among the compared compression methods at a 16×16 \times compression ratio. † methods limited to one context. ‡ methods using Llama-2 7B. ⋆ use official checkpoint to reproduce the results.

PISCO ([30]) by 1.66 pp in average accuracy, further highlighting its effectiveness under aggressive compression. These results indicate that SD-Cache preserves information useful for downstream question answering under substantial context compression.

Performance under Different Compression Ratios. We further investigate the effect of compression on answer-matching accuracy using Qwen3-4B-Instruct ([42]) on the Natural Questions (NQ) ([36]) development set. As shown in Figure 4a, SD-Cache’s advantage over Attention Matching ([47]) grows as the compression ratio increases. At 16×16 \times and 32×32 \times compression, SD-Cache achieves accuracies of 65.74% and 62.8%, exceeding Attention Matching by 4.24 pp and 11.0 pp. At 128×128 \times compression, the gap increases to 21.7 pp, with SD-Cache retaining 59.2% accuracy compared with 37.5% for Attention Matching. We further demonstrate the accuracy-memory trade-off between our method and Attention Matching ([47]) in its fastest configuration. We report Bjøntegaard-Delta rate ([2]) applied to KV-cache budgets (BD-KV) to measure the average relative change in KV budget at matched accuracy over the shared quality range, with negative values indicating memory savings. In Figure 4b, we plot the relative KV budget difference at matched accuracy, where negative values indicate lower KV requirements for SD-Cache. Over the shared Match range of 59.18%-66.89%, SD-Cache achieves a BD-KV of −58.70%. Its memory advantage decreases as the target accuracy increases and reverses near the upper end of this range. Details about BD-KV are provided in Appendix A.2. These results indicate that SD-Cache is particularly effective under tight memory budgets, but it falls slightly behind Attention Matching at the largest evaluated KV budget. One possible explanation is that learned compression may lose fine-grained information that could otherwise be retained when more KV cacapacity is available. This motivates exploring an adaptive hybrid method that combines selective KV retention with learned compression under a fixed memory budget in the future.

Figure 4. (a) Performance on RA-QA. (b) KV Cost at Equal Match Score. Performance comparison on NQ in RA-QA benchmark ([36]) under (4a) four compression settings (e.g., 1/8, 1/16, 1/32 and 1/128) and (4b) the average relative change in KV budget at matched accuracy.

Compaction Efficiency. We analytically estimate computational costs in TFLOPs [30], separating context preparation (Compact, including context pre-fill) from subsequent inference; Total sums both stages, shown in Table 3. On Mistral-7B, SD-Cache requires 1.79 TFLOPs for inference after preparation, while its compaction overhead increases the total cost to 13.95 TFLOPs, compared with 11.82 for Full KV and 12.88 for PISCO. On Llama-3.1-8B with a 4K context, SD-Cache requires 80.70 TFLOPs in total, substantially less than AM-fast (172.18), but more than SnapKV (68.53). For more results, please refer to Appendix § 9.§ 4. These estimates quantify the additional computation required to construct SD-Cache’s compact KV representations. When the prepared context can be reused across queries, this preparation cost can be amortised, yielding an average cost of I+C/NqI + C/N_q for NqN_q queries sharing the same context.

Computational cost (TFLOPs) ↓\downarrow
MethodInferenceCompactTotal
Mistral-7B / RAG-QA
FullKV1.7910.0311.82
AutoCompressor2.9810.4213.40
PISCO2.899.9912.88
SD-Cache (Ours)1.7912.1613.95
Llama-3.1-8B / 4K context
FullKV2.7465.9768.71
SnapKV2.4266.1168.53
AM-fast2.29169.90172.18
SD-Cache (Ours)2.4378.2780.70

Table 3. Analytical computational cost.

Results on RULER Benchmark

Tab. 2 reports the average accuracy across the 13 RULER tasks with a 4096 token context using Llama-3.1-8B [17]. SD-Cache achieves the highest reported accuracy at every non-zero cache reduction ratio. At 75% and 90% reduction, it surpasses the second-best method by 0.7 pp and 5.01 pp, respectively. Its advantage is particularly pronounced at the two highest reduction ratios: at 96.88% and 98.44%, SD-Cache achieves accuracies of 55.17% and 53.78%, exceeding KeyDiff [34], the strongest baseline with available results in these settings, by 20.48 pp and 37.20 pp, respectively. Furthermore, SD-Cache’s accuracy decreases by only 1.66 pp as the cache reduction increases from 93.75% to 98.44%. These results indicate that SD-Cache preserves useful information for long-context tasks even under severe KV cache compression. See Appendix § 9.§ 2 for results on additional backbones. These results highlight the value of learning to compress KV states while preserving task performance under tight memory budgets. Hence, a promising direction for future work is to combine learned consolidation with training-free token selection to draw on the complementary strengths of both approaches.

Ablation Studies and Analysis

Contributions of Individual Components. We first analyse the contributions of SD-Cache’s key components on Natural Questions (NQ) within the RA-QA benchmark, using Qwen3-4B-Instruct-25073 as the backbone at a fixed retention ratio of 1/16. A simple baseline that compresses text into soft tokens achieves a score of 61.72%. The anchor pooling module (APM) variant improves this score to 64.44%, yielding a gain of 2.72 pp. Incorporating state-guided correction (SGC) further increases the score to 65.74%, providing an additional gain of 1.3 pp. Full SD-Cache improves upon the soft-token baseline by 4.02 pp, highlighting the incremental contributions of APM compression and SGC.

Figure 6. Length generalisation on RULER QA with M=410M = 410 slots. RR: recurrent rolling; SCR: skip-connected rolling. “Iter” denotes the number of writes.

Length Generalisation under a Fixed Memory Budget. We evaluate length generalisation on RULER QA by increasing the context length from 4K to 8K and 16K while keeping the memory budget fixed at M=410M=410 slots. Starting from a model trained on 4K-token contexts with a single write, we compare current single write setting with two streaming strategies: recurrent rolling (RR), which passes the updated slots to the next write, and skip-connected rolling (SCR), which adds skip connections between subsequent writes. The two strategies perform similarly at 8K with two writes (26.7% vs. 25.7%), but diverge at 16K. RR degrades sharply and often produces gibberish responses, with accuracy falling to 9.9% after three updates and 1.7% after four. In contrast, SCR retains 28.5% and 26.9%, respectively. These results show that SD-Cache supports iterative writing, but maintaining accuracy across repeated updates remains challenging, motivating future work on more robust update strategies and training data tailored to multi-step writing.

Analysis of State-Guided Correction. To understand where SGC helps, we ablate guidance strength α\alpha and correction target using models trained on RA-QA (Louis et al. [30]) and evaluated on 201 NQ samples. We divide the experiments into two groups (Figure 5): 1) applying correction to KK, VV, both, or neither; and 2) retaining only the component of the applied key correction parallel (“rescale”) or orthogonal (“rotate”) to the provisional slot key K~\widetilde{K}, while keeping value correction unchanged. The parallel component scales the existing key, whereas the orthogonal component adjusts its direction. Most of the performance gain comes from key correction (ΔKS\Delta K^{S}). The “rotate” arm preserves this gain, while “rescale” performs worse than disabling correction. These results suggest that SGC improves query–slot matching primarily by adjusting slot-key directions.

Figure 5. State-guided correction ablations: correction targets (left) and parallel (“rescale”) versus orthogonal (“rotate”) key-correction components (right).

Discussion and Conclusion

We introduced SD-Cache, a learnable memory consolidation framework that maintains a budget-constrained KV cache through selective and state-guided updates. We then proposed an anchor-pooling module that compresses long KV sequences into a fixed number of memory slots while preserving key-value correspondence. We further introduced state-guided correction to refine the pooled KV representations using global key-value associations accumulated from the original KV stream, supporting access to relevant information during query decoding. Our method demonstrated competitive performance and computational cost compared with baselines on retrieval-augmented question answering and long-context benchmarks, covering tasks such as question answering, needle-in-a-haystack, variable tracing and aggregation. These results suggest that SD-Cache can be a valuable step towards learnable memory consolidation for LLMs.

Limitations and Future Work. A current limitation is that our method does not explicitly optimise layer-wise memory allocation, and maintaining performance across multi-step streaming updates remains challenging. Future work will explore adaptive allocation and more sophisticated reward functions to align memory updates with downstream task requirements. We will also investigate hybrid approaches combining learned consolidation with training-free token selection, alongside more robust update strategies and training data tailored to multi-step writing.

AI USE STATEMENT

In this work, we used generative AI tools to implement and edit Python code for the proposed method, create or modify scientific figures, prototypes of methodology diagrams, visualise examples and edit the manuscript to improve its clarity and readability. We also used AI tools to retrieve and identify related works. We did not use generative AI tools to generate synthetic datasets or to develop theoretical models. No other required-disclosure uses were applicable to this work. All AI-assisted outputs, including text, code, and figures, were reviewed by the authors, and the generated or modified code was tested for correctness. The authors take full responsibility for the final content of this work, including all text, claims, code, and other artefacts produced with the assistance of generative AI.

REPRODUCIBILITY STATEMENT

We support reproducibility by providing a detailed description of SD-Cache and its components in § 3. The appendix documents the model training details, hyperparameters and additional evidence used in our experiments. We also report the backbone models, datasets, memory budgets, and evaluation metrics for each benchmark. We will publicly release the source code, configuration files, and training and evaluation scripts in the camera-ready version.

Additional Details

Implementation Details

Our consolidation network follows the Perceiver architecture: the MM slot queries cross-attend to the key-value tensor through 8 pre-norm Perceiver like blocks, each with 8 cross-attention heads and a 4×4 \times FFN expansion, operating at the backbone’s key-value width. A single anchor pooling module (APM) is shared across all layers. Each layer also has a lightweight projector comprising copies of its frozen key and value projections, each initialised from the corresponding original weights and augmented with rank-16 LoRA adapters (α=32\alpha= 32). This amounts to approximately 142M trainable parameters, 1.7% of an 8B backbone, which remains frozen throughout. We set fixed correction strengths αv=αk=0.1\alpha_v = \alpha_k = 0.1. The computed memory slots are kept in pre-RoPE space; the ii-th slot is rotated at the position of the anchor token it was initialised from, and the query and generated tokens are positioned directly after the MM slots. We train for five epochs using AdamW [29] with a learning rate of 2×10−42 \times10^{-4}, a linear learning rate schedule with 3% warmup, and bf16 precision. Depending on the context length, we use effective batch sizes of 128 or 64, with corresponding per-device batch sizes of 4 or 1 and gradient accumulation. Training runs under DeepSpeed ZeRO-2 on four RTX 6000 Ada GPUs; the per-layer trunk calls are gradient-checkpointed, which leaves the computed gradients unchanged and is what fits the largest memory budget into 48 GB. For the experiments, we do not include KV-Distill [5] in our RULER [21] comparison because no public implementation was available at the time of our experiments, making faithful reproduction difficult. We also omit STILL [32] because its peak training memory requirements (e.g., 8×8 \times NVIDIA H200 GPUs) exceeded our available hardware budget.

BD-KV Computation

We adapt the Bjøntegaard-Delta rate metric [2] by using the nominal retained KV fraction as the rate variable and Match as the quality variable. While BD-Rate is typically applied in image and video compression, recent work has argued for its use to evaluate LLM compression methods [15]. For each method mm, we construct Piecewise Cubic Hermite Interpolating Polynomial (PCHIP [13]) interpolants gm(q)g_m(q) through the measured points (qi,log⁡10ri)(q_i,\log_{10} r_i), where qiq_i denotes Match and rir_i denotes the retained KV fraction. The relative KV difference at a target quality qq is

ΔKV(q)=100(10gours(q)−gbase(q)−1).(13)\Delta_{\mathrm{KV}}(q) = 100\left(10^{g_{\mathrm{ours}}(q)-g_{\mathrm{base}}(q)}-1\right). \tag*{(13)}

We restrict evaluation to the intersection of the observed quality ranges:

qmin⁡=max⁡{min⁡iqiours,min⁡jqjbase}.(14)q_{\min} = \max\left\{\min_i q_i^{\mathrm{ours}},\min_j q_j^{\mathrm{base}}\right\}. \tag*{(14)}
qmax⁡=min⁡{max⁡iqiours,max⁡jqjbase}.(15)q_{\max} = \min\left\{\max_i q_i^{\mathrm{ours}},\max_j q_j^{\mathrm{base}}\right\}. \tag*{(15)}

For qmax⁡>qmin⁡q_{\max} > q_{\min}, we compute

δˉ=1qmax⁡−qmin⁡∫qmin⁡qmax⁡[gours(q)−gbase(q)] dq,(16)\bar{\delta} = \frac{1}{q_{\max}-q_{\min}}\int_{q_{\min}}^{q_{\max}}\left[g_{\mathrm{ours}}(q)-g_{\mathrm{base}}(q)\right]\,\mathrm{d}q, \tag*{(16)}
BD-KV=100(10δˉ−1).(17)\mathrm{BD\text{-}KV} = 100\left(10^{\bar{\delta}}-1\right). \tag*{(17)}

For SD-Cache versus attention matching, the shared interval is [59.18, 66.89]% Match, yielding BD-KV = −58.70%. Negative values indicate a lower KV budget for SD-Cache at equal quality.

The solid curve shows ΔKV(q)\Delta_{\mathrm{KV}}(q), while the horizontal dashed line indicates BD-KV. This summary averages log-rate differences before converting back to a percentage; it is therefore not the arithmetic mean of the plotted percentage differences. We use the FAU-LMS bjontegaard4 implementation and do not extrapolate beyond the shared quality interval. KV cost is measured by the nominal token/slot budget, rather than total device memory; model weights and auxiliary state are excluded.

Additional Results

Low-Rank Structure within KV Heads

To examine the low-rank structure that motivates the anchor pooling module (APM), we analyse token variation within each KV head of Qwen3-4B Instruct. Each document contains 768 tokens, with the initial attention-sink position removed. We extract pre-RoPE keys from k_norm and values from v_proj across all 36 layers and 8 KV heads per layer (d=128d = 128). For each document and head, we subtract the mean token vector from each 767×128767 \times128 representation matrix and apply singular value decomposition (SVD) to the residuals. We accumulate the squared singular values in descending order and normalise by their total sum to obtain the cumulative explained variance. Centring is performed separately for each document because slot pooling summarises one context at a time. For each layer-head pair, we first average the curves over the 12 documents, then report the median and inter-quartile range across the 288 pairs. An isotropic Gaussian matrix of the same size undergoes the same centring and SVD steps as a reference. As shown in Figure 7, the median curves reach 90% explained variance at 43 directions for keys and 77 for values, compared with 103 for the isotropic reference. The concentrated key variation supports the motivation for APM, while the higher effective rank of values suggests that preserving their variation may require more capacity.

Figure 7. Visualisation of cumulative explained variance for mean-centred pre-RoPE keys (K) and values (V) in Qwen3-4B Instruct Yang et al., [42]. Curves are averaged over 12 documents per layer-head pair, where solid lines and shaded bands show the median and inter-quartile range across 288 pairs. The dashed curve shows an isotropic Gaussian reference of the same size. Dots mark 90% explained variance for K and V.

Additional Results on RULER Benchmark

We further evaluate SD-Cache on RULER-4K [21] using two additional backbones: Qwen3-8B [42] and Mistral-7B-v0.3 (Jiang et al., 2023). Table 4 and Table 5 report the average accuracy across the 13 RULER tasks with a 4096-token context. SD-Cache achieves the highest reported accuracy at every non-zero cache reduction ratio on both backbones.

ModelMethod0.00%90.00%93.75%96.88%98.44%
Qwen3 8BPyramidKV [3]95.3019.5015.209.352.31
Qwen3 8BSnapKV [28]95.3019.2015.229.252.33
Qwen3 8BTOVA [33]95.3024.7011.004.093.60
Qwen3 8BKeyDiff [34]95.3037.9025.4014.618.90
Qwen3 8BIndexMem [44]95.3046.20---
Qwen3 8BSD-Cache (Ours)95.3061.5559.8057.3256.39

Table 4. Average accuracy (%) across the 13 RULER-4K tasks [21] under different KV cache reduction ratios, using Qwen3-8B [42] as the base model. A reduction ratio of 0% denotes the full, uncompressed KV cache.

ModelMethod0.00%90.00%93.75%96.88%98.44%
Mistral 7B-v0.3PyramidKV [3]92.1019.9013.718.434.10
Mistral 7B-v0.3SnapKV [28]92.1019.8013.758.403.59
Mistral 7B-v0.3TOVA [33]92.1029.2014.936.673.77
Mistral 7B-v0.3KeyDiff [34]92.10-45.2626.6114.08
Mistral 7B-v0.3IndexMem [44]92.1041.50---
Mistral 7B-v0.3SD-Cache (Ours)92.1052.1747.1244.4137.23

Table 5. Average accuracy (%) across the 13 RULER-4K tasks [21] under different KV cache reduction ratios, using Mistral-7B (Jiang et al., 2023) as the base model. A reduction ratio of 0% denotes the full, uncompressed KV cache.

On Qwen3-8B [42], SD-Cache outperforms IndexMem [44] at 90% reduction and KeyDiff [34] at 93.75% reduction, the strongest available baselines in these settings, by 15.35 pp and 34.40 pp, respectively. At the two highest reduction ratios of 96.88% and 98.44%, SD-Cache achieves accuracies of 57.32% and 56.39%, exceeding KeyDiff by 42.71 pp and 47.49 pp, respectively. Its accuracy decreases by only 3.41 pp as the reduction increases from 93.75% to 98.44%, indicating robustness to increasingly aggressive compression.

On Mistral-7B-v0.3 (Jiang et al., 2023), SD-Cache achieves accuracies of 52.17% and 47.12% at 90% and 93.75% reduction, outperforming the same respective baselines by 10.67 pp and 1.86 pp. At 96.88% and 98.44% reduction, it achieves 44.41% and 37.23% accuracy, surpassing KeyDiff by 17.8 pp and 23.15 pp, respectively. These results suggest that SD-Cache preserves useful information under severe KV cache compression across different LLM backbones.

Task Group Analysis. We group the RULER-4K tasks into four categories: needle-in-a-haystack (NIAH), question answering (QA), variable tracking (VT), and aggregation (AGG), where AGG comprises common words extraction (CWE) and frequent words extraction (FWE). Figure 9 and Figure 8 present results on Qwen3-8B and Mistral-7B-v0.3, respectively, with VT and AGG reported jointly as VT+AGG. While KeyDiff shows competitive results on NIAH at 16× compression, SD-Cache outperforms all evaluated baselines across all three reported groups at 32× and 64× compression on both backbones. These results show that SD-Cache is generally more robust to aggressive KV cache compression than the other baselines.

Figure 8. RULER-4K [21] performance by task group on Mistral-7B-Instruct-v0.3 (Jiang et al., 2023) under different KV cache compression rates.

Figure 9. RULER-4K [21] performance by task group on Qwen3-8B [42] under different KV cache compression rates.

Ablation of the Novelty-Guided Write

We evaluate SD-Cache trained on RA-QA [30] with a Qwen3-4B-Instruct [42] backbone on 948 ASQA dev questions at a 16× compression ratio, using Match as the metric. Without retraining, we test three inference-time variants: removing the novelty bias, shuffling novelty scores across tokens within each passage, and replacing the slot gate with its layer-wise mean. To evaluate the validity of the novelty-guided write module, we additionally design a shuffling experiment that preserves the distribution of novelty scores but breaks their correspondence with the tokens, thereby testing whether assigning higher scores to the appropriate tokens matters. The full model achieves 71.5% Match, compared with 69.5% without the novelty bias, 67.2% with shuffled novelty scores, and 68.1% with a static gate. These results support the contributions of both token-specific novelty information and input-dependent slot gating.

Computational-cost estimation

In Table 6, we additionally report analytical estimates of computational cost under the RULER compression budgets. We count each multiply-accumulate as two FLOPs and treat attention products as dense rectangular matrix multiplications. The estimates cover major matrix operations and follow each method’s input formatting and generation procedures. They are not GPU measurements or dataset-wide averages. “Inference” (II) denotes question pre-fill and answer generation after preparation; “Compact” (CC) denotes context or representation preparation, including context pre-fill; and “Total” (TT) denotes first-use cost. For a fixed context whose prepared representation can be reused unchanged across questions, the amortised cost per question over RR questions is I+C/RI + C/R. This accounting does not imply that persistent reuse has been implemented for every method. For Llama3.1-8B-Instruct, the KV cache of the 4096-token context occupies 0.50 GiB (128 KiB per token in bf16). Reducing the context slots by 75%, 90%, 93.75%, 96.88% and 98.44% shrinks it to 0.125, 0.050, 0.031, 0.016 and 0.008 GiB, respectively, i.e. 4×4\times to 64×64\times smaller. The only exception is ExpectedAttention + AdaKV, whose masking implementation retains the full physical cache and therefore stays at 0.50 GiB.

Target context-slot reductionMethodInferenceCompactTotal
0.00%Full KV2.7465.9768.71
75.00%SnapKV2.4866.1168.59
75.00%KeyDiff2.4865.9768.45
75.00%ExpectedAttention + AdaKV52.7870.6573.43
75.00%AM-fast62.35188.75191.10
75.00%SD-Cache (Ours)2.5083.4685.96
90.00%SnapKV2.4366.1168.54
90.00%KeyDiff2.4365.9768.40
90.00%ExpectedAttention + AdaKV52.7870.6573.43
90.00%AM-fast62.30172.11174.41
90.00%SD-Cache (Ours)2.4579.3981.84
93.75%SnapKV2.4266.1168.53
93.75%KeyDiff2.4265.9768.39
93.75%ExpectedAttention + AdaKV52.7870.6573.43
93.75%AM-fast62.29169.90172.18
93.75%SD-Cache (Ours)2.4378.2780.70
96.88%SnapKV2.4166.1168.52
96.88%KeyDiff2.4165.9768.38
96.88%ExpectedAttention + AdaKV52.7870.6573.43
96.88%AM-fast62.27168.64170.91
96.88%SD-Cache (Ours)2.4277.3079.73
98.44%SnapKV2.4066.1168.51
98.44%KeyDiff2.4065.9768.37
98.44%ExpectedAttention + AdaKV52.7870.6573.43
98.44%AM-fast62.27168.21170.48
98.44%SD-Cache (Ours)2.4276.8179.23

Table 6. Estimated computational cost of Llama-3.1-8B-Instruct under the RULER compression budgets. We use a controlled workload of 4096 context tokens, 128 question tokens and 32 output tokens, with a batch size of one and no separate system prefix. These costs are not averaged over RULER evaluation samples. 5ExpectedAttention uses the AdaKV masking implementation associated with the archived accuracy results, which retains the full physical KV cache. Its costs are rounded analytical upper-bound estimates for successful execution paths with 1000 search iterations per call. 6AM-fast uses off-policy repeat queries and uniform budgets. Its costs include reference-query preparation and analytically estimated QR solver costs. Computational cost (TFLOPs) ↓

Figure 10. Distribution of estimated slot update strengths.

Non-uniform Layer Budget

To visualise the contribution of the slot update strength at each layer, we examine the learned gate values gg in Eq. (8) across all layers. The gate magnitudes exhibit a non-uniform distribution, with several intermediate layers showing stronger updates than the early and final layers. This suggests that SD-Cache learns to vary the degree of memory update across different layers. Motivated by this layer-wise heterogeneity, we further investigate whether the memory budget itself can be distributed non-uniformly across layers.

Our SD-Cache design naturally supports non-uniform layer-wise KV cache budgets, allowing different numbers of cache slots to be assigned to different layers. Specifically, we divide the layers into two early groups (layers 0-7 and 8-11), a middle group (layers 12-22), and a late group (layers 23-31), allocating 15.6%, 13.1%, 51.6%, and 19.7% of the total KV cache budget to these four groups, respectively. This allocation concentrates more capacity in the middle layers while preserving the same total budget as the uniform baseline. As shown in Figure 11, non-uniform allocation yields modest but consistent improvements across all five datasets, increasing the average Match score by 0.39 pp. The largest gains are observed on PopQA (Mallen et al., [31]) and NQ (Kwiatkowski et al., [24]), with improvements of 1.03 pp and 0.57 pp, respectively. These results highlight the flexibility of SD-Cache in supporting non-uniform layer-wise budgets, while leaving the exploration of more effective budget allocation strategies to future work.

Uniform vs. non-uniform layer budgets

Figure 11. Uniform vs. non-uniform layer budgets.

Memory Updates as the Context Changes

We use short fictional stories to examine whether SD-Cache’s answers reflect changes in the context. Each story introduces a fact and later updates it, with unrelated documents interleaved. We first write background documents that do not contain the answer into a fixed memory of M=40M=40 slots. The first story chunk contains background information, the initial fact and two unrelated documents; the subsequent chunk contains one update and one unrelated document. All chunks are written into the same slots. After each write, the frozen decoder answers the question using only the current memory. Figure 12 shows the text written at each step and the corresponding decoded answer. This example illustrates SD-Cache’s ability to adaptively update its memory as the context changes.

Figure 12. Visualisation of decoding from memory as the context changes. The top row shows the text written into memory at each step, with unrelated documents indicated in grey. The bottom row shows the first sentence of the answer generated by greedy decoding after each write, reproduced verbatim. Colours indicate successive states.

Consolidated Memory Visualisation

To examine what SD-Cache stores and how the frozen decoder uses it, we trace memory writes and decoder reads back to the context tokens. For WRITE, we sum each token’s contribution across slots using the anchor weights 1−g1-g and pooling weights gWgW in Eq. (8). For READ, we collect the decoder’s attention to the MM slots while generating the answer tokens, map query heads to their corresponding KV heads, and propagate the attention through the same pooling weights. As shown in Figure 13 and Figure 14, the READ maps place greater emphasis on answer-related content than the WRITE maps. These examples illustrate how SD-Cache consolidates information without knowing the question and allows the decoder to selectively access relevant content during decoding.

Visualisation of the information SD-Cache stores in memory and reads when answering question #456 from the KILT-NQ dev set

Figure 13. Visualisation of the information SD-Cache stores in memory and reads when answering question #456 from the KILT-NQ dev set.

Figure 14. Visualisation of the information SD-Cache stores in memory and reads when answering question #1443 from the KILT-NQ dev set.

References

  1. [1]Hervé Abdi and Lynne J Williams. Principal component analysis. Wiley interdisciplinary reviews: computational statistics, 2(4):433–459, 2010.
  2. [2]Gisle Bjontegaard. Calculation of average psnr differences between rd-curves. ITU SG16 Doc. VCEG-M33, 2001.
  3. [3]Zefan Cai, Yichi Zhang, Bofei Gao, Yuliang Liu, Yucheng Li, Tianyu Liu, Keming Lu, Wayne Xiong, Yue Dong, Junjie Hu, et al. Pyramidkv: Dynamic kv cache compression based on pyramidal information funneling. arXiv preprint arXiv:2406.02069, 2024.arxiv.org/abs/2406.02069
  4. [4]Rujikorn Charakorn, Edoardo Cetin, Shinnosuke Uesaka, and Robert Tjarko Lange. Doc-to-lora: Learning to instantly internalize contexts. arXiv preprint arXiv:2602.15902, 2026.arxiv.org/abs/2602.15902
  5. [5]Vivek Chari, Guanghui Qin, and Benjamin Van Durme. Kv-distill: Nearly lossless learnable context compression for llms. arXiv preprint arXiv:2503.10337, 2025.arxiv.org/abs/2503.10337
  6. [6]Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, and Dongyang Zhao. xrag: Extreme context compression for retrieval-augmented generation with one token. Advances in Neural Information Processing Systems, 37:109487–109516, 2024.arxiv.org/abs/2405.13792
  7. [7]Alexis Chevalier, Alexander Wettig, Anirudh Ajith, and Dami Chen. Adapting language models to compress contexts. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 3829–3846, 2023.arxiv.org/abs/2305.14788
  8. [8]Zina Chkirbene, Ridha Hamila, Ala Gouissem, and Unal Devrim. Large language models (llm) in industry: A survey of applications, challenges, and trends. In 2024 IEEE 21st International Conference on Smart Communities: Improving Quality of Life using AI, Robotics and IoT (HONET), pp. 229–234. IEEE, 2024.DOI
  9. [9]Euirim Choi. Goodwiki dataset. https://www.github.com/euirim/goodwiki, September 2023.
  10. [10]Ronald L Davis and Yi Zhong. The biology of forgetting—a perspective. Neuron, 95(3):490–503, 2017.DOI
  11. [12]Sabri Eyuboglu, Ryan Ehrlich, Simran Arora, Neel Guha, Dylan Zinsley, Emily Liu, Atri Rudra, James Y Zou, Azalia Mirhoseini, and Christopher Re. Cartidges: Lightweight and general-purpose long context representations via self-study. In International Conference on Learning Representations, volume 2026, pp. 42642–42687, 2026.
  12. [13]Frederick N Fritsch and Ralph E Carlson. Monotone piecewise cubic interpolation. SIAM Journal on Numerical Analysis, 17(2):238–246, 1980.
  13. [14]Tao Ge, Jing Hu, Lei Wang, Xun Wang, Si-Qing Chen, and Furu Wei. In-context autoencoder for context compression in a large language model. arXiv preprint arXiv:2307.06945, 2023.arxiv.org/abs/2307.06945
  14. [15]Cameron Gordon, Yiping Ji, Hemanth Saratchandran, Paul Albert, and Simon Lucey. SineloraΔ: Sine-activated delta compression. In Proceedings of the AAAI Conference on Artificial Intelligence, pp. 21333–21342, 2026.
  15. [16]Stephen Gould and Anton van den Hengel. Back from the future: Key-value cache management by counter-causal surprise. arXiv preprint arXiv:2607.27600, 2026.arxiv.org/abs/2607.27600
  16. [17]Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, et al. The llama 3 herd of models. arXiv preprint arXiv:2407.21783, 2024.arxiv.org/abs/2407.21783
  17. [18]David Ha, Andrew M. Dai, and Quoc V. Le. Hypernetworks. CoRR, abs/1609.09106, 2016. URL http://arxiv.org/abs/1609.09106.
  18. [19]Ali Hatamizadeh, Yejin Choi, and Jan Kautz. Gated deltanet-2: Decoupling erase and write in linear attention. arXiv preprint arXiv:2605.22791, 2026.arxiv.org/abs/2605.22791
  19. [20]Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the math dataset. arXiv preprint arXiv:2103.03874, 2021.
  20. [21]Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. Ruler: What’s the real context size of your long-context language models? arXiv preprint arXiv:2404.06654, 2024.arxiv.org/abs/2404.06654
  21. [22]Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.arxiv.org/abs/2106.09685
  22. [23]Andrew Jaegle, Felix Gimeno, Andy Brock, Oriol Vinyals, Andrew Zisserman, and Joao Carreira. Perceiver: General perception with iterative attention. In International conference on machine learning, pp. 4651–4664. PMLR, 2021.arxiv.org/abs/2103.03206
  23. [24]Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. Natural questions: a benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:453–466, 2019.DOI
  24. [25]Tiziano Labruna, Giovanni Bonetta, and Bernardo Magnini. Task-oriented dialogue systems through function calling. In Proceedings of the 15th International Conference on Recent Advances in Natural Language Processing-Natural Language Processing in the Generative AI Era, pp. 614–622, 2025.DOI
  25. [26]Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in neural information processing systems, 33:9459–9474, 2020.arxiv.org/abs/2005.11401
  26. [27]Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, et al. Solving quantitative reasoning problems with language models. Advances in neural information processing systems, 35:3843–3857, 2022.
  27. [28]Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyc Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen. Snapkv: Llm knows what you are looking for before generation. Advances in Neural Information Processing Systems, 37:22947–22970, 2024.arxiv.org/abs/2404.14469
  28. [29]Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. ArXiv, abs/1711.05101, 2017. URL https://api.semanticscholar.org/CorpusID:3312944.
  29. [30]Maxime Louis, Hervé Déjean, and Stéphane Clinchant. Pisco: Pretty simple compression for retrieval-augmented generation. In Findings of the Association for Computational Linguistics: ACL 2025, pp. 15506–15521, 2025.
  30. [31]Alex Mallen, Akari Asai, Victor Zhong, Rajarshi Das, Daniel Khashabi, and Hannaneh Hajishirzi. When not to trust language models: Investigating effectiveness of parametric and non-parametric memories. In Proceedings of the 61st annual meeting of the association for computational linguistics (volume 1: Long papers), pp. 9802–9822, 2023.
  31. [32]Charles O’Neill, Alex Sandomirsky, Harry Partridge, Mudith Jayasekara, and Max Kirkby. Still: Amortized kv cache compaction in a single forward pass. arXiv preprint arXiv:2606.07878, 2026.
  32. [33]Matan el Oren, Michael Hassid, Nir Yarden, Yossi Adi, and Roy Schwartz. Transformers are multi-state rnns. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 18724–18741, 2024.
  33. [34]Junyoung Park, Dalton Jones, Matthew Morse, Raghavv Goel, Mingu Lee, and Christopher Lott. Keydiff: Key similarity-based kv cache eviction for long-context llm inference in resource-constrained environments. Advances in Neural Information Processing Systems, 38:5983–6019, 2026.arxiv.org/abs/2504.15364
  34. [35]Guanghui Qin, Corby Rosset, Ethan Chau, Nikhil Rao, and Benjamin Van Durme. Dodo: Dynamic contextual compression for decoder-only lms. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 9961–9975, 2024.DOI
  35. [36]David Rau, Hervé Déjean, Nadezhda Chirkova, Thibault Formal, Shuai Wang, Stéphane Clinchant, and Vassilina Nikoulina. Bergen: A benchmarking library for retrieval-augmented generation. In Findings of the Association for Computational Linguistics: EMNLP 2024, pp. 7640–7663, 2024a.
  36. [37]David Rau, Shuai Wang, Hervé Déjean, and Stéphane Clinchant. Context embeddings for efficient answer generation in rag. arXiv preprint arXiv:2407.09252, 2024b.arxiv.org/abs/2407.09252
  37. [38]Larry R Squire, Lisa Genzel, John T Wixted, and Richard G Morris. Memory consolidation. Cold Spring Harbor perspectives in biology, 7(8):a021766, 2015.DOI
  38. [39]Ivan Stelmakh, Yi Luan, Bhuwan Dhingra, and Ming-Wei Chang. Asqa: Factoid questions meet long-form answers. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 8273–8288, 2022.arxiv.org/abs/2204.06092
  39. [40]Xin Tian, Yingzhan Lin, Mengfei Song, Siqi Bao, Fan Wang, Huang He, Shuqi Sun, and Hua Wu. Q-tod: A query-driven task-oriented dialogue system. In Proceedings of the 2022 conference on empirical methods in natural language processing, pp. 7260–7271, 2022.arxiv.org/abs/2210.07564
  40. [41]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations, volume 2024, pp. 21875–21895, 2024.arxiv.org/abs/2309.17453
  41. [42]An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, et al. Qwen3 technical report. arXiv preprint arXiv:2505.09388, 2025.arxiv.org/abs/2505.09388
  42. [43]Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, and Yoon Kim. Parallelizing linear transformers with the delta rule over sequence length. Advances in neural information processing systems, 37:115491–115522, 2024.arxiv.org/abs/2406.06484
  43. [44]Xintong Yang, Hao Gu, Binxing Xu, Lujun Li, Bei Liu, Jiacheng Liu, Qiyuan Zhu, Yike Guo, and Sirui Han. Indexmem: Learned kv-cache eviction with latent memory for long-context llm inference. arXiv preprint arXiv:2605.25475, 2026.arxiv.org/abs/2605.25475
  44. [45]Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D Manning. Hotpotqa: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the 2018 conference on empirical methods in natural language processing, pp. 2369–2380, 2018.arxiv.org/abs/1809.09600
  45. [46]Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, et al. H2O: Heavy-hitter oracle for efficient generative inference of large language models. Advances in neural information processing systems, 36:34661–34710, 2023.arxiv.org/abs/2306.14048
  46. [47]Adam Zweiger, Xinghong Fu, Han Guo, and Yoon Kim. Fast kv compaction via attention matching. arXiv preprint arXiv:2602.16284, 2026.arxiv.org/abs/2602.16284

Paper details

vlnc:W_t87hr95a
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

generative AI tools

View statement
Looking for related papers…
Contents