NoHairCache:一次校准的KV缓存驱逐只需一个幂律指数

媒体报道 Hugging Face Papers 原文语言:中文

NoHairCache提出统一的幂律驱逐公式,校准一次的衰减指数α可跨数据集迁移,在WikiText、PG19和arXiv上实现最低困惑度并保持高QA准确率。

全文

NoHairCache: Calibrate-Once KV Cache Eviction with One Power-Law Exponent

Shuyang Xiang

Abstract

The decay exponent α\alpha in KV-cache eviction is an intrinsic property of the model: calibrated once on a single corpus, it transfers directly across domains. Attention-based accumulation (H2O) and recency-based sliding windows (StreamingLLM) are two dominant eviction frameworks, often treated as unrelated, but we show that they are the two endpoints of a single power-law family: by scoring each token as si=Ai⋅(t−i)−αs_{i}=A_{i}\cdot(t-i)^{-\alpha}, where AiA_{i} is cumulative attention and α\alpha controls the age penalty, H2O and StreamingLLM correspond to α=0\alpha=0 and α→∞\alpha\to\infty, respectively (with StreamingLLM additionally hard-coding an attention-sink patch).

The no-hair mechanism of Xiang (2026) bounds the admissible range of α\alpha, and the measured exponents agree: calibrating once on WikiText yields [0.556,0.822][0.556,0.822] for a representative model (Qwen2.5-1.5B-Instruct). The per-model ranges are consistent across five models (410M–1.5B) and independently match the optimal regions from perplexity sweeps.

NoHairCache achieves the lowest perplexity across three datasets (WikiText, PG19, and arXiv) without per-dataset tuning, outperforming both H2O and StreamingLLM (p<0.05p<0.05 on all three datasets, with 0.060.06–0.100.10 PPL gains over StreamingLLM at budget 512512). On downstream four-way multiple-choice QA, it matches or outperforms StreamingLLM across all nine (task, budget) cells, retaining 98.2%98.2\% of full-cache accuracy on NarrativeQA at 25%25\% retention versus 91.1%91.1\% for StreamingLLM; per-cell McNemar tests are not significant, so QA is corroborating only. We release our calibration script and drop-in scorer upon publication.

1 Introduction

Long-context inference is often bottlenecked at generation time: every decoded token has to attend to the entire KV cache, causing memory usage to grow linearly and, as a result, total attention compute to scale quadratically with sequence length. Caching every past key-value pair is therefore untenable, making token eviction unavoidable. The question now is: by what criterion should tokens be evicted?

Existing eviction policies rely on diverse scoring heuristics: accumulated attention (H2O) (Zhang et al., 2023), recency windows (StreamingLLM) (Xiao et al., 2024), observation-window pooling (SnapKV) (Li et al., 2024b), query-aware relevance (Quest) (Ge et al., 2024), or even random selection. Two paradigms dominate in practice: accumulation-based methods (e.g., H2O) and recency-based methods (e.g., StreamingLLM) (Zhang et al., 2023; Xiao et al., 2024). Although power-law decay of token influence has been observed empirically (Lin and Tegmark, 2017; Xiang, 2026), these two paradigms remain disconnected heuristics without a unified parameterization.

In this work, we show that they are in fact opposite endpoints of a single power-law family. By scoring each cached token ii at decoding step tt as

si=Ai⋅(t−i)−α,s_{i}=A_{i}\cdot(t-i)^{-\alpha}, (1)

where AiA_{i} denotes cumulative attention and α≥0\alpha\geq 0 governs the age penalty, we are able to unify both strategies under a single framework. The H2O and StreamingLLM scoring rules then correspond to the endpoints α=0\alpha=0 and α→∞\alpha\to\infty, respectively (StreamingLLM additionally hard-codes an attention sink). Consequently, designing an eviction policy reduces from choosing between competing heuristics to identifying the decay exponent α\alpha of this family, which we calibrate per layer.

The exponent is an intrinsic property of the model architecture rather than the input data distribution. Measuring α\alpha for each model once on a single calibration corpus (e.g., WikiText-103) yields consistent means and bulk ranges across models (such as Qwen2.5-1.5B and Pythia-1.4B), although the detailed layer-wise profiles are only partly preserved; the measured values align closely with optimal perplexity sweeps, and each model’s frozen α\alpha transfers unchanged to distinct domains like PG19 and arXiv.

To ground α\alpha theoretically, we draw on the empirical no-hair mechanism established in our prior work (Xiang, 2026), which shows that a prompt’s hidden-state influence on position tt decays as t−αt^{-\alpha}, with α\alpha bounded layer-wise within [0.2,0.7][0.2,0.7] by attention-dilution geometry. The theorem constrains the exponent within a family but does not select the family itself.

Building on this insight, we introduce NoHairCache, a lightweight, drop-in scorer that replaces the scoring function of top-kk eviction policies with our power-law formulation based on offline-calibrated, per-layer α\alpha values, incurring only a single scalar multiplication per eviction step over H2O. In summary, we make the main following contributions:

•

Intrinsic, Calibrate-Once Decay Profiles. We demonstrate that the per-layer decay exponent α\alpha is an intrinsic property of the model rather than the corpus: across five models its mean lies in 0.6020.602–0.6630.663, and a single offline calibration transfers without re-tuning across WikiText, PG19, arXiv, cache budgets, and downstream QA. We further show why hidden-state influence avoids the softmax recency bias that underestimates α\alpha in attention-mass proxies.

•

Unified Power-Law Framework. We relate accumulation-based (H2O) and recency-based (StreamingLLM) KV-cache eviction as opposite endpoints (α=0\alpha=0 and α→∞\alpha\to\infty) of a single power-law decay family si=Ai⋅(t−i)−αs_{i}=A_{i}\cdot(t-i)^{-\alpha}; the family is a modeling choice, not a consequence of the no-hair theorem, which only constrains the exponent within a family.

•

Lightweight Drop-In Algorithm (NoHairCache). We propose a training-free, plug-and-play eviction scorer that integrates per-layer calibrated exponents into standard top-kk eviction pipelines with negligible overhead (a single scalar multiplication per step over H2O).

•

Cross-Domain and Downstream Gains. Across three corpora (WikiText, PG19, arXiv) and three long-context QA benchmarks (NarrativeQA, HotpotQA, Qasper), NoHairCache improves perplexity with statistical significance (paired Wilcoxon p<0.05p<0.05 on every dataset), while on QA it is never worse than StreamingLLM (e.g., retaining 98.2%98.2\% of full-cache accuracy on NarrativeQA at a 25%25\% cache budget vs. 91.1%91.1\% for StreamingLLM) though the gains are not statistically significant (per-cell McNemar).

Echoing the “no-hair” principle in black hole physics, which argues that complex objects collapse down to just a few fundamental parameters, our findings suggest that the seemingly complex behavior of KV cache eviction policies is largely governed by a single intrinsic power-law form, whose exponent profile is fixed once per model. Rather than designing increasingly intricate heuristics, future cache compression methods can build directly on this unified power-law formulation with a one-time, per-model calibration.

Organization.

We organize this work as follows. Sec. 2 reviews prior work on long-context degradation, attention mechanics, and KV-cache compression. Sec. 3 introduces the unified score family and its limiting cases, gives the power-law form, and presents the calibration-and-eviction algorithm. Sec. 4 reports the measured exponents across models and scales, confirms them against perplexity sweeps, and evaluates cross-dataset transfer, budget regimes, cross-model robustness, and downstream QA. Finally, Sec. 5 discusses limitations, and Sec. 6 concludes.

2 Related Work

Our work bridges theoretical analyses of information propagation in Transformers with practical memory management for long-context inference. We build our contributions across three primary lines of research.

Long-Context Degradation and Instruction Drift.

A well-documented failure mode of autoregressive language models is the gradual erosion of early context and system instructions over extended generation horizons (Li et al., 2024a; Liu et al., 2024). Even when prompts remain within the nominal context window, models exhibit recency bias and fail to retrieve or adhere to initial constraints. To stabilize infinite-length generation, Xiao et al. (2024) identified the phenomenon of attention sinks, which is, the disproportionate allocation of attention mass to initial tokens, and proposed retaining them alongside a local sliding window. Subsequent theoretical work by Barbero et al. (2025) suggests that these sinks act as a mechanism to prevent over-mixing across layers. Training-dynamics measurements in Xiang (2026) show that prompt forgetting sets in much earlier in training (roughly 0.3–1B tokens) than sink formation, so sinks are neither the initial cause of forgetting nor a reliable proxy for prompt retention.

Attention Mechanics, Over-Squashing, and Information Flow.

Understanding how information travels across tokens and layers has been extensively studied through norm-based decompositions (Kobayashi et al., 2020) and attention flow graphs (Abnar and Zuidema, 2020). Dong et al. (2021) showed that pure self-attention suffers from doubly exponential rank collapse with depth, while Noci et al. (2022) analyzed signal propagation at initialization using mean-field theory. Along the sequence axis, Barbero et al. (2024) formalized over-squashing in decoder-only Transformers, bounding the sensitivity of final representations to distant tokens. Complementing this, Nakanishi (2025) observed that softmax distributions flatten as context length grows (“attention fading”) and proposed length-dependent logit scaling (Scalable-Softmax). Furthermore, natural language itself exhibits power-law decay in long-range mutual information (Lin and Tegmark, 2017). The conditional no-hair theorem of Xiang (2026) provides an asymptotic bound of O⁡(P​(log⁡t)L−1/t)O(P(\log t)^{L-1}/t) on prompt offset decay, isolating the exact roles of direct attention dilution and multi-layer token relay. We take its finite power-law exponent as the quantity to calibrate here.

KV Cache Eviction and Compression.

To mitigate the memory bottleneck of long contexts, numerous heuristics have been proposed to evict unimportant tokens from the KV cache during inference. Heavy-Hitter Oracle (H2O) (Zhang et al., 2023) greedily retains tokens with the highest cumulative attention scores, exploiting the sparsity of attention weights. Similarly, ScissorHands (Liu et al., 2023) leverages the persistence of pivotal tokens across decoding steps, while SnapKV (Li et al., 2024b) selects clustered important KV positions based on observation windows. Other approaches allocate cache budgets non-uniformly across layers, such as PyramidKV (Zhang et al., 2024), or select tokens by query-aware relevance (Ge et al., 2024).

Unlike these isolated heuristics or rigid sliding-window policies (Xiao et al., 2024), our theoretical framework unifies KV cache eviction under a single power-law score family parameterized by the decay exponent α\alpha. We prove that H2O (α=0\alpha=0) and pure sliding windows (α→∞\alpha\to\infty) are merely boundary extremes of this continuum. Crucially, because α\alpha is governed by architectural dilution and relay dynamics rather than corpus-specific statistics, it exhibits strong cross-dataset generalizability—allowing a single measured α\alpha to serve as a reusable parameter across the datasets and tasks we test.

3 NoHairCache: Theory and Algorithm

3.1 The Score Family and Limiting Cases

The admissible range of α\alpha.

To establish the valid range of α\alpha, we first formalize how a prompt’s effect decays over generation steps.

Following Xiang (2026), we take two minimally differing prompts x,x′x,x^{\prime} and feed each with the same continuation cc. At layer ll and generation step tt, the prompt offset is defined as

Δl​(t,c)=hl​(x′∘c,t)−hl​(x∘c,t),\Delta_{l}(t;c)=h_{l}(x^{\prime}\circ c,t)-h_{l}(x\circ c,t),

which can be considered as the difference between the two residual-stream hidden states at the same position. Its norm ‖Δl​(t,c)‖\|\Delta_{l}(t;c)\| measures how much of the prompt still affects the model’s internal state after tt steps. In this sense we call it the prompt’s influence. To form an influence profile comparable across coordinates, we average the offset over continuations, normalize each coordinate by its spread across continuations in the first window, and take the root mean square:

𝒮l​(t)=[1d​∑j=1d(𝔼c​Δl,j​(t,c))2σl,j2]1/2,\mathcal{S}_{l}(t)=\left[\frac{1}{d}\sum_{j=1}^{d}\frac{\big(\mathbb{E}_{c}\,\Delta_{l,j}(t;c)\big)^{2}}{\sigma_{l,j}^{2}}\right]^{1/2},

where Δl,j\Delta_{l,j} is coordinate jj of Δl\Delta_{l}, dd is the hidden width, 𝔼c\mathbb{E}_{c} averages over the continuations shared by the prompt pair, and σl,j\sigma_{l,j} is the standard deviation of hl,jh_{l,j} across those continuations in the first window (pooled over both prompts, so no coordinate dominates by scale). This profile decays approximately as a power law, that is, 𝒮l​(t)∝t−α\mathcal{S}_{l}(t)\propto t^{-\alpha}. We give now the no-hair result of Xiang (2026):

Theorem 1 (No-hair bound, Xiang (2026)).

For trained Transformer language models, the power-law decay exponent of token influence satisfies α∈[0.2, 0.7]\alpha\in[0.2,\,0.7] for the bulk of layers asymptotically in depth while boundary layers of finite-depth models may lie outside this interval.

The bound is therefore a statement about the bulk of layers rather than every layer: measured bulk ranges agree with it, while boundary layers in some models exceed it (Table 1).

Remark.

Here, the word “trained” means the released checkpoints our calibration script loads (Pythia-410M/1B at step143000, the other three at default revisions). Models with randomly initialized weights do not show this property. However, w emake no claim about partially trained model. Refer to Xiang (2026) for more details.

Note that Theorem 1 constrains α\alpha within the power-law family but does not select the family itself (Sec. 3.2). Its role in this paper is thus motivational: it tells us which range of α\alpha is worth measuring. Whether and where a given model realizes an exponent in this range remains an empirical question and we measure it across five models in Sec. 4.2 and confirm the measured value against downstream PPL in Sec. 4.3.

To bridge our theoretical dilution results with practical KV cache management, we introduce a unified view of eviction policies. Specifically, for the hh-th attention head in layer ll, the attention matrix is

A(l,h)=softmax⁡(Q(l,h)​K(l,h)⊤dk+M),A^{(l,h)}=\mathrm{softmax}\!\left(\frac{Q^{(l,h)}K^{(l,h)\top}}{\sqrt{d_{k}}}+M\right), (2)

where dkd_{k} is the head dimension and MM the causal mask. We write aτ(l,h)​(i):=Aτ,i(l,h)a^{(l,h)}_{\tau}(i):=A^{(l,h)}_{\tau,i} for the weight assigned by the query at position τ\tau to the key at position ii. The cumulative historical importance of token ii at step tt is Ai(l,h)​(t)=∑τ=itaτ(l,h)​(i)A^{(l,h)}_{i}(t)=\sum_{\tau=i}^{t}a^{(l,h)}_{\tau}(i), and its age is di​(t)=t−id_{i}(t)=t-i, the number of decoding steps elapsed since token ii was generated.

We now propose the unified score family for KV-cache eviction that combines historical importance with distance-induced dilution. In its most general form the exponent may depend on the layer,

si(l,h)​(t)=Ai(l,h)​(t)⋅(t−i)−α(l),α(l)≥0.s^{(l,h)}_{i}(t)=A^{(l,h)}_{i}(t)\cdot(t-i)^{-\alpha^{(l)}},\qquad\alpha^{(l)}\geq 0. (3)

A single scalar α\alpha is the special case α(l)=α\alpha^{(l)}=\alpha for all layers. Throughout the theoretical discussion α\alpha denotes a generic exponent and every statement below holds pointwise for each layer upon setting α=α(l)\alpha=\alpha^{(l)}. Per-layer α(l)\alpha^{(l)} is the default while scalar α\alpha is used for analysis and as a deployment tier. Eviction is per-head, unlike StreamingLLM. Two axes are separate: age-penalty shape (α=0\alpha=0 vs. α→∞\alpha\to\infty) and exponent granularity (scalar vs. per-layer). Here, Ai(l,h)​(t)A^{(l,h)}_{i}(t) captures the accumulated historical importance, while (t−i)−α(l)(t-i)^{-\alpha^{(l)}} (or (t−i)−α(t-i)^{-\alpha} in the scalar case) models the accessibility penalty under dilution. This family seamlessly connects existing heuristics (Figure 1) and the two propositions below are stated for a uniform exponent and hold for each layer pointwise upon setting α=α(l)\alpha=\alpha^{(l)}:

Proposition 1 (α=0\alpha=0 recovers the H2O scoring term).

For any sequence length tt and token position i<ti<t, setting α=0\alpha=0 yields si​(t,0)=Ai​(t)s_{i}(t;0)=A_{i}(t), the Heavy-Hitter Oracle (H2O) scoring term.

Proof.

The proof comes directly from the definition: si​(t,0)=Ai​(t)⋅1=Ai​(t)s_{i}(t;0)=A_{i}(t)\cdot 1=A_{i}(t). ∎

Proposition 2 (α→∞⟹\alpha\to\infty\implies Sliding Window).

Assume the historical importance ratio Ai​(t)/Aj​(t)A_{i}(t)/A_{j}(t) is bounded in (0,∞)(0,\infty) for all i≠ji\neq j. There exists a finite threshold α∗>0\alpha^{*}>0 such that for all α>α∗\alpha>\alpha^{*}, the score si​(t,α)s_{i}(t;\alpha) is strictly monotonic with respect to token age, recovering a pure sliding window policy.

Proof.

For any two positions i<ji<j, we have t−j<t−it-j<t-i. The score ratio can be written as:

si​(t,α)sj​(t,α)=Ai​(t)Aj​(t)⋅ρi​jα,\frac{s_{i}(t;\alpha)}{s_{j}(t;\alpha)}=\frac{A_{i}(t)}{A_{j}(t)}\cdot\rho_{ij}^{\alpha}, (4)

where ρi​j=t−jt−i∈(0,1)\rho_{ij}=\frac{t-j}{t-i}\in(0,1). Taking the natural logarithm of both sides:

ln⁡(si​(t,α)sj​(t,α))=ln⁡(Ai​(t)Aj​(t))+α​ln⁡ρi​j.\ln\left(\frac{s_{i}(t;\alpha)}{s_{j}(t;\alpha)}\right)=\ln\left(\frac{A_{i}(t)}{A_{j}(t)}\right)+\alpha\ln\rho_{ij}. (5)

Since ρi​j<1\rho_{ij}<1, we have ln⁡ρi​j<0\ln\rho_{ij}<0. As α→∞\alpha\to\infty, the second term dominates, driving the logarithm to −∞-\infty, and thus sisj→0\frac{s_{i}}{s_{j}}\to 0. Consequently, for any fixed pair i<ji<j, there exists a threshold αi​j=ln⁡(Ai/Aj)−ln⁡ρi​j\alpha_{ij}=\frac{\ln(A_{i}/A_{j})}{-\ln\rho_{ij}} beyond which siα∗\alpha>\alpha^{*}. ∎

Remark (The Attention Sink is Orthogonal).

According to Proposition 2, taking the limit α→∞\alpha\to\infty gives a pure sliding window without an attention sink, because a power-law score inherently penalizes position 00 as t−α→0t^{-\alpha}\to 0. Thus the scoring component of StreamingLLM corresponds to the α→∞\alpha\to\infty endpoint, but the full policy additionally hard-codes an attention-sink patch; a single value of α\alpha alone cannot reproduce that mechanism. We therefore treat α\alpha as a continuous parameter for decay shape and hard-coded sinks as orthogonal architectural patches where α\alpha is uniform across layers.

Figure 1: One score family, three policies. (a) The relative score si/Ai=(t−i)−αs_{i}/A_{i}=(t-i)^{-\alpha} versus token age, from the H2O endpoint (α=0\alpha=0) through a finite power law to the StreamingLLM endpoint (α→∞\alpha\to\infty). Markers show where a fixed eviction threshold is crossed. (b) A finite α\alpha lets an old, high-attention token outrank a recent, low-attention one until the crossover αc=ln⁡(Aold/Arecent)/ln⁡(dold/drecent)\alpha_{c}=\ln(A_{\rm old}/A_{\rm recent})/\ln(d_{\rm old}/d_{\rm recent}) with Aold/Arecent=16A_{\rm old}/A_{\rm recent}=16 and dold/drecent=64d_{\rm old}/d_{\rm recent}=64, αc≈0.67\alpha_{c}\approx 0.67, inside the measured range.

3.2 Why Power-Law over Exponential Decay

Notice that we parameterize token-value decay within the power-law family s⁡(t)=t−αs(t)=t^{-\alpha} rather than the exponential family e−λ​te^{-\lambda t}. This is a modeling choice rather than a consequence of the no-hair theorem: the theorem constrains the exponent α∈[0.2,0.7]\alpha\in[0.2,0.7] within the power-law family. We choose the power-law family for two reasons.

•

No characteristic length. Exponential decay introduces a characteristic scale 1/λ1/\lambda beyond which token value collapses. This would impose an artificial “age cutoff” on attention dilution. Attention dilution in long contexts exhibits no such natural cutoff. Instead, a token’s relevance decays gradually without a preferred time scale. Power-law decay is scale-free and matches this natural behavior. For example, setting 1/λ=1001/\lambda=100 causes exponential weights to plummet by nearly four orders of magnitude from t=100t=100 to t=1000t=1000 (e−1≈0.37e^{-1}\!\approx\!0.37 vs. e−10≈4.5×10−5e^{-10}\!\approx\!4.5\times 10^{-5}), whereas a power law with α=0.5\alpha=0.5 decays by only a factor of 10≈3.16\sqrt{10}\!\approx\!3.16 across the same tenfold span.

•

Tail-safe retention. Because exponential decay collapses rapidly, old tokens are effectively zeroed out and may be evicted even when they still carry residual global context. Power-law decay falls slowly, so an old-but-relevant token survives eviction as long as its score remains above the budget threshold. For instance, early anchor tokens, such as system prompts, entity definitions, or task constraints defined thousands of steps ago, retain non-negligible scores under a heavy tail rather than being purged in favor of transient local context.

3.3 Calibration and Eviction Algorithm

The decay exponents are an intrinsic property of the model, not of the dataset or task, so we can calibrate it once and reuse for other dataset or tasks. On this basis, we formulate NoHairCache as a two-stage procedure of offline calibration and online KV-cache eviction (Algorithm 1, Figure 2). Following Xiang (2026), for each pair of minimally differing prompts with a shared continuation cc we record the prompt offset δl​(t,c)=‖hl​(x′∘c,t)−hl​(x∘c,t)‖\delta_{l}(t;c)=\|h_{l}(x^{\prime}\circ c,t)-h_{l}(x\circ c,t)\|, aggregate the squared offsets over prompts and continuations into a root-mean-square influence profile 𝒮l​(t)\mathcal{S}_{l}(t) over logarithmically spaced (“octave”) windows t∈{16,32,…,1024}t\in\{16,32,\dots,1024\}, and fit α(l)=−slope⁡{log⁡𝒮l​(t),log⁡t}\alpha^{(l)}=-\mathrm{slope}\{\log\mathcal{S}_{l}(t),\log t\} (since the influence decays as 𝒮l​(t)∝t−α(l)\mathcal{S}_{l}(t)\propto t^{-\alpha^{(l)}}, the log–log slope is −α(l)-\alpha^{(l)}).

Algorithm 1 NoHairCache: Offline Calibration and Online KV Eviction

1: Model with LL layers and HH heads per layer, calibration prompt pairs 𝒫cal\mathcal{P}_{\text{cal}} (default 100100 pairs per axis across 44 axes, each pair being two minimally differing prompts with 88 shared continuations), KV budget BB, optional preset αfixed\alpha_{\text{fixed}}.

2: Frozen per-layer exponents {α(l)}l=1L\{\alpha^{(l)}\}_{l=1}^{L} (or a scalar α\alpha) and evicted KV cache at each decoding step tt.

3: Stage 1: Offline Calibration (Run Once per Model)

4: if αfixed\alpha_{\text{fixed}} is not specified then

5: Run forward passes on 𝒫cal\mathcal{P}_{\text{cal}} with shared continuations to record prompt offsets δl​(t,c)\delta_{l}(t;c) and the influence profile 𝒮l​(t)\mathcal{S}_{l}(t) across octave windows.

6: Fit α(l)=−slope⁡{log⁡𝒮l​(t),log⁡t}\alpha^{(l)}=-\mathrm{slope}\{\log\mathcal{S}_{l}(t),\log t\} (or aggregate to a scalar α\alpha).

7: else

8: Set α←αfixed\alpha\leftarrow\alpha_{\text{fixed}} (e.g., α=1/2\alpha=1/2).

9: end if

10: Freeze the exponents in the model configuration; precompute per-layer age-decay tables Dl​[d]=d−α(l)D_{l}[d]=d^{-\alpha^{(l)}} for d≥1d\geq 1 (a shared table D⁡[d]=d−αD[d]=d^{-\alpha} in the scalar case).

11: Stage 2: Online Eviction (At Decoding Step tt)

12: for layer l=1,…,Ll=1,\dots,L and head h=1,…,Hh=1,\dots,H do

13: Update cumulative attention score Ai(l,h)​(t)A^{(l,h)}_{i}(t) for active cache positions i≤ti\leq t.

14: if cache size exceeds budget BB then

15: for each candidate token ii in cache do

16: Compute score si(l,h)​(t)←Ai(l,h)​(t)⋅Dl​[t−i]s^{(l,h)}_{i}(t)\leftarrow A^{(l,h)}_{i}(t)\cdot D_{l}[t-i].

17: end for

18: Evict lowest-scoring tokens (subject to any fixed sink/window policy if configured) to maintain budget BB.

19: end if

20: end for

Figure 2: NoHairCache pipeline corresponding to Algorithm 1. Stage 1 runs once per model: prompt offsets δl​(t,c)\delta_{l}(t;c) are aggregated into influence curves 𝒮l​(t)\mathcal{S}_{l}(t), whose log–log slope gives the per-layer exponent via α(l)=−slope⁡(log⁡𝒮l,log⁡t)\alpha^{(l)}=-\mathrm{slope}(\log\mathcal{S}_{l},\log t). The frozen exponents and per-layer age tables Dl​[d]=d−α(l)D_{l}[d]=d^{-\alpha^{(l)}} are reused at every decoding step. Stage 2 scores cached tokens with si(l,h)​(t)=Ai(l,h)​(t)​Dl​[t−i]s^{(l,h)}_{i}(t)=A^{(l,h)}_{i}(t)\,D_{l}[t-i] and evicts the lowest-scoring ones.

Online efficiency and deployment tiers.

Once the exponents are frozen, precomputing d−α(l)d^{-\alpha^{(l)}} into per-layer age-indexed lookup tables avoids repeated exponentiation during decoding: scoring a token requires only one table lookup and one multiplication. Compared to H2O (α=0\alpha=0), the incremental online overhead is just one multiplication per scored entry at eviction steps. In practice, the framework supports three deployment tiers under a single configuration switch: (i) the theoretical default α=1/2\alpha=1/2 with zero calibration cost, (ii) a single frozen scalar α\alpha calibrated offline, and (iii) per-layer α(l)\alpha^{(l)} calibrated offline for finer layer-wise granularity.

Calibration is not hyperparameter tuning.

Like LayerNorm’s running statistics, α\alpha is a structural model quantity estimated once and read at inference, not tuned per downstream task. We calibrate once per model on WikiText-103 and keep it frozen across all datasets, budgets, and benchmarks.

4 Experiments and Results

In this section, we evaluate the NoHairCache algorithm introduced in Sec. 3.3. We first describe the setup, then examine the measured exponents, verify them against perplexity sweeps, and test cross-dataset transfer, budget regimes, cross-model robustness, and downstream QA.

4.1 Setup

Models and calibration.

We evaluate on autoregressive language models from the Pythia and Qwen families, including Pythia-410M, Pythia-1B, Pythia-1.4B, Qwen2.5-0.5B, and Qwen2.5-1.5B-Instruct (denoted Qwen2.5-1.5B below). All α\alpha calibrations are performed once on the WikiText-103 validation split using 100100 prompt pairs per axis across 44 axes (detail, para, lang, unrelated). Each pair consists of two minimally differing prompts, and both prompts are teacher-forced with the same 88 shared continuations, i.e. 1616 forward passes per pair and 4×100×16=6,4004\times 100\times 16=6{,}400 passes in total (the subsequent bootstrap resampling and power-law fitting take only a few seconds). On a MacBook with an Apple M3 chip and 36​GB36\,\text{GB} unified memory (MPS backend, octave windows up to 10241024 tokens), a full calibration run takes approximately 20.3​min20.3\,\text{min} for Pythia-410M (2323 layers), 49.8​min49.8\,\text{min} for Pythia-1B (1515 layers), 67.4​min67.4\,\text{min} for Pythia-1.4B (2424 layers), and 78.6​min78.6\,\text{min} for Qwen2.5-1.5B (2727 layers), scaling roughly linearly with the number of pairs and continuations and with maximum window length (timings reported for four of the five models and Qwen2.5-0.5B calibration follows the same procedure). However, our framework scales to larger models and context windows for readers with greater compute budgets.

Evaluation protocol.

We evaluate perplexity across WikiText-103, PG19, and arXiv on 5050 sequences of 2,0482{,}048 tokens per dataset with a streaming chunk size of 128128. KV-cache eviction is simulated via an attention mask, which is mathematically equivalent to physically cropping key and value entries while avoiding RoPE position-index bookkeeping artifacts.

4.2 Measured α\alpha across Models and Scales

Table 1 reports the measured exponent across five models and two architectures: three Pythia variants (410M, 1B, 1.4B) and two Qwen variants (0.5B, 1.5B), spanning a 3×3\times parameter range.

The per-model mean α\alpha lies between 0.6020.602 and 0.6630.663 (coefficient of variation under 4%4\%), and the per-model bulk intervals all fall inside [0.533,0.676][0.533,0.676]. Two observations follow. First, α\alpha does not drift with scale: the three Pythia means are 0.6370.637, 0.6630.663, and 0.6340.634 for 410M, 1B, and 1.4B, and the two Qwen means are 0.6020.602 and 0.6200.620 for 0.5B and 1.5B—the Pythia means are non-monotonic in scale, and the Qwen mean rises by only 0.0180.018. Second, α\alpha does not drift with architecture: the Qwen means are slightly lower than the Pythia means (0.6020.602–0.6200.620 vs. 0.6340.634–0.6630.663) but still fall within the Pythia per-layer range.

The layer structure is only partly preserved (Figure 3): in every model the first two layers carry the highest exponent and the middle layers are comparatively flat, but the final layers do not show a consistent rebound across models; the full per-layer profile for Qwen2.5-1.5B is listed in Table 9 (Appendix A).

The one systematic scale effect we observe is in the upper end of the range: Qwen-0.5B, the smallest model, has an upper bound of only 0.7090.709, barely above the no-hair bound of 0.70.7, whereas Qwen-1.5B reaches 0.8220.822. For Pythia, by contrast, the upper bound is flat across scales (0.8960.896–0.9020.902). We have no explanation for this architecture-dependent difference; note that Qwen-0.5B and Pythia-410M have the same depth (23 measured layers) yet very different upper bounds. The mean α\alpha, a scalar summary of the calibrated profile, is unaffected by this effect and stays within 0.6020.602–0.6630.663 across the full scale range.

We read these observations as evidence that the mean α\alpha is a property of the training dynamics rather than of a particular depth, width, or architecture: depth varies from 1515 to 2727 across our models, width from 896896 to 20482048, yet the mean exponent moves by less than 0.070.07 in absolute terms. This is consistent with the attention-dilution mechanism of Xiang (2026), which is a property of the attention operation itself and should not depend on the specific architecture.

Table 1: Measured decay exponent across five models and two architectures. “Bulk” is the range of the middle layers after removing the first and last four measured layers; layers without a valid fit are excluded, so the layer count may differ from the official depth by one.

Architecture Model α\alpha mean α\alpha range Bulk

Pythia 410M 0.6370.637 [0.576,0.898][0.576,0.898] [0.576,0.676][0.576,0.676]

Pythia 1B 0.6630.663 [0.597,0.896][0.597,0.896] [0.611,0.640][0.611,0.640]

Pythia 1.4B 0.6340.634 [0.563,0.902][0.563,0.902] [0.563,0.643][0.563,0.643]

Qwen 0.5B 0.6020.602 [0.533,0.709][0.533,0.709] [0.533,0.656][0.533,0.656]

Qwen 1.5B 0.6200.620 [0.556,0.822][0.556,0.822] [0.556,0.667][0.556,0.667]

Figure 3: Measured per-layer exponent α(l)\alpha^{(l)} (hidden-state influence, detail axis) for all five models, plotted against normalised depth l/Ll/L. The means span only 0.6020.602–0.6630.663, and the no-hair interval [0.2,0.7][0.2,0.7] is shaded. Boundary layers carry the highest exponent in every model while the middle layers are comparatively flat, as discussed in Sec. 4.2.

4.3 The Measured α\alpha Agrees with the PPL Optimum

Before evaluating the full system, we verify that the measured α\alpha is the right value to deploy. An α\alpha-sweep on downstream perplexity, that is, a diagnostic sweep, not a deployment-time calibration, varies α\alpha from 0.10.1 to 4.04.0 on all three evaluation datasets (Figure 4, Table 2). The PPL-optimal exponent falls in [0.6,0.8][0.6,0.8] on every dataset, overlapping the hidden-state measurement [0.556,0.822][0.556,0.822] of Sec. 4.2. The curve is flat on this interval and rises monotonically for α>1\alpha>1, so the plateau is a genuine optimum rather than a boundary artifact of the sweep range. The coarse 0.10.1-step grid resolves the arXiv minimum to 4.0684.068, and refining α\alpha or using the per-layer vector lowers it by a further 0.0020.002 PPL (Table 3) without moving the optimum. As α\alpha grows, PG19 PPL approaches the StreamingLLM endpoint (17.36017.360 at α=4.0\alpha=4.0 versus 17.39517.395), confirming the α→∞\alpha\to\infty limit of Proposition 2 empirically while remaining far below the H2O endpoint. Three datasets and the hidden-state measurement therefore agree on where α\alpha lives, and all are consistent with a finite power-law exponent without assuming a specific range. The sweep uses a global scalar for clarity and the per-layer variant used in Table 4 differs by at most 0.040.04 PPL (Table 3). The full NoHairCache pipeline, with α\alpha frozen at the measured value, is evaluated below.

Table 2: α\alpha-sweep on WikiText validation, 50 sequences, budget =512=512, evaluated on all three datasets with the same calibration. PPL is flat on [0.6,0.8][0.6,0.8] and rises monotonically for α>1\alpha>1 on every dataset. The three per-dataset minima (WikiText and PG19 at α=0.8\alpha=0.8, arXiv at α=0.6\alpha=0.6–0.70.7 on this grid, to within the 0.0020.002 PPL refinement in Table 3) all lie inside the hidden-state measurement range [0.556,0.822][0.556,0.822]. This is a diagnostic sweep, not a deployment-time calibration: it varies a single frozen α\alpha across all layers.

α\alpha WikiText PG19 arXiv

0.10.1 10.54110.541 19.29719.297 4.6284.628

0.20.2 10.18610.186 18.53818.538 4.4254.425

0.30.3 9.9209.920 17.93517.935 4.2314.231

0.40.4 9.7329.732 17.34917.349 4.0934.093

0.50.5 9.6989.698 17.28817.288 4.0714.071

0.60.6 9.6669.666 17.27117.271 4.068

0.70.7 9.6669.666 17.26717.267 4.068

0.80.8 9.662 17.266 4.0734.073

1.01.0 9.6669.666 17.26817.268 4.0834.083

1.51.5 9.6879.687 17.29317.293 4.1034.103

2.02.0 9.6989.698 17.32117.321 4.1204.120

4.04.0 9.7259.725 17.36017.360 4.1494.149

Figure 4: α\alpha-sweep perplexity at budget 512512 on all three datasets (same calibration, diagnostic only). The grey band marks the hidden-state measurement range [0.556,0.822][0.556,0.822] and stars mark each dataset’s minimum. PPL is flat for α∈[0.6,0.8]\alpha\in[0.6,0.8] and rises for α>1\alpha>1, so the optimum is a finite power-law exponent rather than a boundary artifact. This is the raw data behind Table 2.

How sensitive is the result to how α\alpha is set?

Table 3 varies the calibration strategy while holding everything else fixed. A single global scalar matched to the measured mean (α=0.61\alpha=0.61), the per-layer vector, and a randomly shuffled per-layer vector all land within 0.040.04 PPL of each other on every dataset. The theory default α=0.5\alpha=0.5 is slightly worse than the global-scalar and shuffled variants on all three datasets. On PG19 it is marginally better than the per-layer row (17.28817.288 vs 17.30517.305), which itself sits slightly above the other calibrated variants. The result is therefore insensitive to the granularity of calibration: a single scalar matched to the measured mean suffices, and the per-layer structure contributes only a second-order correction. We report the per-layer variant throughout as the principled choice, noting that on this fixed evaluation slice the differences among calibrated variants are small and do not change the conclusions, and that the global scalar is in fact slightly better on WikiText and PG19. This is consistent with α\alpha being a coarse-grained model property rather than a per-layer tuning knob.

Table 3: Calibration sensitivity at budget =512=512, Qwen2.5-1.5B. All rows use the same score family, only how α\alpha is obtained differs. Global, per-layer, and shuffled per-layer are within 0.040.04 PPL. The theory default α=0.5\alpha=0.5 is slightly worse than the global and shuffled variants on every dataset. “Shuffled per-layer” randomly permutes the α(l)\alpha^{(l)} vector across layers.

Calibration WikiText PG19 arXiv

Theory default (α=0.5\alpha=0.5) 9.6989.698 17.28817.288 4.0714.071

Global scalar (α=0.61\alpha=0.61) 9.6649.664 17.27117.271 4.0664.066

Per-layer α(l)\alpha^{(l)} 9.6919.691 17.30517.305 4.0664.066

Shuffled per-layer 9.6729.672 17.28317.283 4.0664.066

4.4 Cross-Dataset Generalization

The comparison is stable across corpora: with α\alpha frozen from WikiText at budget =512=512 (Table 4), NoHairCache attains the lowest perplexity on every dataset, outperforming StreamingLLM (α=∞\alpha=\infty) by 0.0570.057/0.0900.090/0.1040.104 PPL on WikiText/PG19/arXiv and also beating H2O (α=0\alpha=0). Against StreamingLLM: WikiText 9.6919.691 vs 9.7489.748 (p=0.0059p=0.0059), PG19 17.30517.305 vs 17.39517.395 (p=0.0218p=0.0218), arXiv 4.0664.066 vs 4.1704.170 (p<0.001p<0.001). Against H2O the margins are larger (−1.07-1.07, −2.39-2.39, and −0.72-0.72 PPL respectively). A paired Wilcoxon signed-rank test over the 50 sequences confirms both comparisons on every dataset: NoHairCache beats StreamingLLM on 34/33/4434/33/44 of 50 sequences, and beats H2O on 50/50/5050/50/50 sequences (p<10−14p<10^{-14} on all three datasets). We attribute H2O’s poor performance to cumulative attention being dominated by early high-frequency filler tokens, so middle-context content is crowded out of the top-kk regardless of dataset.

Table 4: Cross-dataset generalization at budget =512=512. α\alpha calibrated on WikiText only (Qwen2.5-1.5B), used unchanged on all three datasets. NoHairCache is the lowest-PPL method on every row. Δ\Delta and pp are NoHairCache vs StreamingLLM (Wilcoxon signed-rank, 50 sequences).

Dataset H2O NoHairCache StreamingLLM Δ\Delta pp

WikiText 10.76410.764 9.691 9.7489.748 −0.057-0.057 0.0059

PG19 19.69619.696 17.305 17.39517.395 −0.090-0.090 0.0218

arXiv 4.7864.786 4.066 4.1704.170 −0.104-0.104 <<0.001

4.5 Budget Curves

Table 5 and Figure 5 report PG19 with six budgets from 32 to 1024. NoHairCache wins when 6–25% of tokens are retained, ties StreamingLLM near full cache (>50%>50\% retained), and loses only below ≈6%\approx 6\% retention (budget ≤64\leq 64), where the pure-recent strategy is optimal. H2O is worst at every budget. The crossover point moves with distribution: PG19 at ≈128\approx 128, WikiText at ≤32\leq 32, and arXiv at ≈64\approx 64 (Appendix B).

Table 5: PG19 budget curve (Qwen2.5-1.5B, α\alpha from WikiText calibration). The crossover between StreamingLLM and NoHairCache occurs between 64 and 128 (≈3\approx 3–6%6\% retained). Below it, StreamingLLM’s pure-recent strategy wins. Above it, NoHairCache wins. Near full cache the two nearly tie, with NoHairCache still slightly ahead. H2O is worst at every budget.

Budget Retained (%) H2O NoHairCache StreamingLLM

3232 1.51.5 24.70524.705 21.84521.845 21.042

6464 3.13.1 23.77023.770 20.15820.158 19.919

128128 6.26.2 22.62122.621 18.746 18.89318.893

256256 12.512.5 21.22721.227 17.830 17.99017.990

512512 25.025.0 19.69619.696 17.305 17.39517.395

10241024 50.050.0 18.08818.088 17.006 17.02517.025

Figure 5: KV-budget curves for Qwen2.5-1.5B with α\alpha calibrated on WikiText only (shaded: budgets where NoHairCache beats StreamingLLM). NoHairCache dominates at moderate compression, nearly ties near full cache (still slightly ahead), and loses only at the tightest budgets. The crossover shifts with the dataset (PG19 ≈128\approx 128, arXiv ≈64\approx 64, WikiText ≤32\leq 32). Raw numbers: Table 5 and Appendix B.

4.6 Cross-Model Verification

Table 6 reports Pythia-1.4B on all three datasets at budgets 128 and 512, using Pythia’s own per-layer α\alpha measured on WikiText only. NoHairCache wins every cell on this model. For WikiText and PG19 the margin is larger at budget 128 (−0.23-0.23 and −0.32-0.32) than at 512 (−0.06-0.06 and −0.12-0.12), consistent with the budget-curve finding that the advantage is largest under moderate compression. For arXiv the two budgets are comparable (−0.081-0.081 at 128, −0.094-0.094 at 512), consistent with arXiv’s earlier crossover (≈64\approx 64).

Table 6: Cross-model verification on Pythia-1.4B. α\alpha calibrated on WikiText only. NoHairCache wins every cell and the margin is lar

正文以来源语言显示。

参考来源

← 返回每日AI报告