Manuscript Offprint
arXiv:2610.03135Page-EntroKV: Hardware-Aligned, Entropy-Weighted KV-Cache Eviction under Grouped-Query Attention
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Long-context inference in autoregressive language models is limited by the key-value (KV) cache. The cache grows with context length, and every decoded token streams the full cache through memory. Most dynamic eviction methods score token importance per query head and choose tokens independently. This fits poorly with grouped-query attention (GQA), where several query heads share one physical KV buffer: if the heads choose different tokens, the serving engine must keep the union of their selections, inflating the cache by up to the group ratio r. A simple arithmetic average does not fix this—it dilutes the specialized retrieval heads that carry factual recall.
We introduce Page-EntroKV, a formal framework for KV-cache eviction that works at the level GQA serving actually uses. Heads in each physical group are pooled with weights derived from sink-isolated collision (Rényi-2) entropy—one inner product per head, computed once at prefill with no calibration—so sink heads cannot be mistaken for retrieval heads. The pooled scores are mapped onto PagedAttention page frames, and eviction runs at the hardware tuple . We formalize the union overhead ratio and intra-group disagreement, prove an exact identity linking them for two-head groups, and give two-sided bounds for general ratios. We prove that group-level pooling preserves the eviction budget exactly, derive a finite-context needle-retention guarantee that arithmetic-mean pooling provably violates, characterize the temperature limits of the entropy-weighted family, and give exact per-layer cross-group page accounting.
On a pilot architecture (Qwen2.5-1.5B-Instruct, r=6, 28 layers), head-independent replay inflates the cache by up to at a 2% budget—with the theoretical certificate firing in the large majority of measured cells—while Page-EntroKV holds the union overhead at exactly 1,000 across 1,008 pooled measurements. Across a 1,008-observation head census, sink isolation inverts the sink-to-context weight ordering from a unearned sink advantage to a deficit. In pilot-scale needle retrieval, entropy-weighted pooling retains the needle where arithmetic-mean pooling collapses (100% vs. 0% under the pooled-selection criterion at a 20% budget); strict all-layer retention is reported as a limitation. Retained cardinality is exact for every page size, preliminary runs show representative QA and code tasks remain solvable at 20% retention, and the mechanism ablations are certified over all 56 of 56 layer-group pairs with zero skipped layers. Larger-model, long-context, and serving phases are pre-registered and in progress.
Keywords: Grouped-Query Attention, PagedAttention, KV-cache compression, Attention entropy, Inference serving, Formal analysis
1. Introduction
Long-context large language models (LLMs) are now deployed for multi-turn agentic workflows, repository-scale code synthesis, and multi-document legal discovery [29, 30, 4]. Context windows have grown to match, but long-context use remains fragile: reliability degrades with input position [31]. At context lengths of 32k to 128k tokens, decoding hits a hardware boundary: every decoded token streams the entire key-value (KV) cache from GPU high-bandwidth memory (HBM) into on-chip SRAM, so the decode phase is strictly memory-bound and its cost grows linearly with context length [9, 7]. At practical batch sizes the KV cache alone can occupy most of the accelerator's memory, capping concurrency and decoding throughput.
Production architectures respond by sharing KV buffers across query heads. Grouped-query attention (GQA) [3]—adopted by Llama-3.1, Qwen-2.5, and Mistral [4, 5, 6]—partitions logical query heads into physical KV groups, shrinking the cache by the ratio . In serving runtimes such as vLLM [7], these groups are materialized as block-partitioned tensors of shape : the sharing is the memory layout itself, not an implementation detail.
This physical layout breaks a core assumption behind prevailing eviction heuristics. Policies such as H2O [10], SnapKV [11], and Scissorhands [12] compute token importance per query head and select top-k sets independently. Sibling heads in a GQA group share one physical buffer, so the engine must store the union of their selections—up to the intended budget. We formalize this penalty as the union overhead ratio (UOR) and connect it exactly to measurable intra-group disagreement (Proposition 1). Arithmetic mean pooling fails from the other direction: it dilutes specialized retrieval heads [24], averaging a needle token attended to with mass by one head down to , below eviction thresholds.
Page-EntroKV follows three design principles, each chosen against a specific alternative. Pooling at the physical-group level rather than the head level preserves GQA's memory sharing and keeps the budget exact; head-level selection cannot do both, because the engine stores whatever union the heads produce. Discrete attention entropy—one inner product per head—separates sharp retrieval heads from diffuse background heads, so weighting heads by inverse entropy amplifies exactly the signals that mean pooling destroys; evaluating that entropy on sink-isolated distributions keeps attention-sink heads from being mistaken for retrieval heads. Projecting importance onto discrete PagedAttention page frames before eviction, rather than selecting tokens first, makes the compression decision coincide with the hardware allocation tuple and eliminates internal fragmentation and cache-unrolling overhead. Figure 1 shows the resulting architecture.
The contributions of this paper are formal, algorithmic, implementational, and pilot-validated:
• Architectural formulation. We formalize the GQA structural constraint in dynamic KV-cache eviction through two metrics—the union overhead ratio and intra-group disagreement—linked by an exact identity for two-head groups and sandwiched two-sidedly at every ratio (Section 3).
• Algorithmic design. We design entropy-weighted group pooling around discrete sink-isolated Rényi-2 attention entropy, together with a page-frame mapping that evicts exactly at the tuple (Section 4).
• Theoretical guarantees. We prove strict budget preservation (UOR 1), a finite-context needle-retention bound under head specialization with sink isolation, the temperature degeneracies of the pooling family, and page-level union accounting (Section 5).
• Reference implementation and pilot validation. We provide a complete PyTorch reference implementation, an instrumented harness, and a pilot validation on Qwen2.5-1.5B-Instruct confirming the structural core on real text—with every deviation, exclusion, and pending item disclosed (Section 6).
This is a formulation-and-theory paper with a pilot-scale empirical tier. The architectural guarantees hold by construction; the pilot of Section 6 validates the structural core on real text at small scale; the full pre-registered sweep—long context, larger models, and serving—is in progress and disclosed item by item in Section 6.5.
The remainder of this paper is organized as follows. Section 2 reviews related work. Section 3 formalizes the problem and its structural metrics. Section 4 presents the Page-EntroKV design. Section 5 develops the theoretical analysis. Section 6 reports the pilot validation and the remaining pre-registered protocol. Section 7 delimits scope and limitations, and Section 8 concludes. Section Appendix A summarizes notation, Section Appendix B tabulates the guarantee-to-evidence mapping, Section Appendix C collects the full step-by-step derivations, and Section Appendix D gives the reference implementation.
2.1. Attention efficiency and architectural evolution
Multi-head attention (MHA) [1] pairs every query head with private key-value buffers. Multi-query attention (MQA) [2] collapses all heads onto a single shared buffer. GQA [3] interpolates between the two, cutting KV memory by the group ratio r at negligible quality cost, and is now standard in production models [4, 5, 6]. A separate line compresses KV states into low-rank latent vectors, as in the multi-head latent attention (MLA) of DeepSeek-V2 [32]. These works fix the static allocation of KV memory. Page-EntroKV addresses the complementary dynamic problem: deciding at inference time which allocated entries to keep.
2.2. Inference serving engines
IO-aware kernel design minimizes HBM traffic. FlashAttention [27] tiles attention computation on-chip; FlashAttention-2 adds flash-decoding, improving parallelism for long sequences and decode workloads [28]. On the systems side, vLLM's PagedAttention [7] partitions the KV cache into fixed-size blocks managed by a block table and reaches near-zero fragmentation at high concurrency. Orca raises utilization further through iteration-level scheduling and continuous batching [8]. Roofline analyses [9] establish the memory-bound character of decoding. These engines assume the cache is fully materialized; they define the physical layout to which any compression policy must conform. Page-EntroKV treats the page table as a first-class citizen and evicts at exactly the granularity the engine allocates.
2.3. Dynamic KV-cache eviction
H2O [10] retains tokens with the largest accumulated attention scores. StreamingLLM [13] preserves attention sinks and a sliding window. Scissorhands [12] exploits the persistence of token importance. SnapKV [11] compresses the pre-fill cache using observation windows. PyramidKV [15] allocates layer-wise budgets following a pyramidal information funnel. Quest [16] performs query-aware sparse selection. FastGen [14] selects per-head compression policies from observed attention patterns, adapting the operator while staying at
Input context — long-form text ( tokens).
Transformer layer l prefill attention. Produces per-head distributions .
Sink-isolated entropy estimation & entropy-weighted group pooling. Quantifies head dispersion via sink-isolated over the observation window; Boltzmann weights pool heads at the physical GQA group, eliminating union overhead (UOR 1) and preventing needle dilution.
Block-max page mapping. Importance scores are aggregated onto physical pages , and the top- pages are selected per group at the hardware tuple .
vLLM PagedAttention engine. Physical layout ; zero internal fragmentation, group-level UOR , strict budget of k tokens per group.
Figure 1: Page-EntroKV pipeline overview. Sink-isolated entropy-weighted pooling at the physical GQA group level, followed by block-max mapping onto PagedAttention page frames, aligns the eviction decision with the engine's physical memory layout.
head-level granularity. Ada-KV [17] works on the budget side of the same GQA structure: it reallocates the per-head eviction budgets within a group adaptively, so the union of head-level selections respects the group budget instead of a uniform per-head quota k. Ada-KV decides how much each head may keep; it does not change which entries survive—selection remains per-head on raw attention scores, with no selection-side guarantee comparable to the needle-retention bound of Theorem 4.
All of these methods score importance at the (layer, head) or (layer, token) granularity. Under shared buffers, independent head-level selections inflate memory by up to unless a budget allocator compensates—which is the compensation Ada-KV supplies—and per-head scores cannot be materialized without unrolling the cache. Page-EntroKV attacks the inflation at its source: pooling before selection makes the union semantics of GQA harmless by construction, and eviction runs at page granularity.
A concurrent entropy-based method, EntroKV [18], applies attention entropy at a different decision point. There, Shannon entropy allocates per-layer compression budgets—how much each layer keeps—as a plug-and-play front-end, with offline calibration of a mean-entropy statistic . Page-EntroKV applies sink-isolated Rényi-2 entropy on the selection side—which pages survive within each physical group—requires no calibration, and carries the guarantees proved here: group-level UOR (Theorem 3) and finite-context needle retention (Corollary 2). The two mechanisms sit at different points in the pipeline (budget allocation versus within-group selection); no combination of the two is studied here. Table 1 positions Page-EntroKV against these families, and against channel-dimension and routing alternatives, along the axes that the GQA layout makes salient.
2.4. Mechanistic head specialization
Pruning studies showed early that many attention heads are redundant [25, 26]. Retrieval heads carry long-context factuality mechanistically [24]. DuoAttention [19] statically classifies retrieval versus streaming heads and applies heterogeneous compression—but it classifies offline, at the granularity of the attention computation, and needs a calibration corpus. Page-EntroKV weights heads within each physical GQA group at runtime, using measured sink-isolated entropy, needs no calibration, and preserves the physical sharing structure of GQA.
3. Problem formulation and background
We first fix notation (Table A.8 in Section Appendix A), then characterize the decode-phase memory wall, the physical layout of GQA serving engines, and the structural metrics that quantify why head-independent eviction fails.
3.1. The decode-phase memory wall
Decoding runs in two distinct execution regimes. Prefill processes the input prompt via compute-bound matrix–matrix products. Autoregressive decoding emits one token per step: self-attention over historical tokens streams the key–value (KV) cache from high-bandwidth memory (HBM) into on-chip SRAM, reducing the computation to memory-bound matrix–vector products.
Let denote batch size, transformer layers, logical query heads, physical KV heads, head dimension, sequence length, and bytes per element ( for FP16). Defining the GQA ratio , the computational work per decode step is , while HBM data traffic is . The arithmetic intensity is derived as:
which yields FLOP/Byte for 16-bit precision on an architecture. The hardware ridge point on an
Table 1: Qualitative structural comparison of KV-cache eviction approaches under physically shared GQA buffers. = supported; = partially; = not supported; n/a = not applicable: the method is not a token-eviction policy (channel-dimension pruning or quantization) or is a context-routing architecture.
| Method | Importance granularity | GQA-union aware? | Eviction granularity | Strict budget guarantee? | Calibration -free? |
|---|---|---|---|---|---|
| H2O [10] | ✕ | token | (union ) | ✓ | |
| StreamingLLM [13] | position | ✓ (uniform) | token | ✓ (static) | ✓ |
| Scissorhands [12] | ✕ | token | ✕ | ✓ | |
| SnapKV [11] | ✕ | token | ✕ | ✓ | |
| FastGen [14] | per-head policy | ✕ | token | ✕ | (profiling) |
| PyramidKV [15] | , layer budget | ✕ | token | (layer-wise) | ✓ |
| Quest [16] | query/page | ✕ | page | (query-dep.) | ✓ |
| Ada-KV [17] | , adaptive budget | (budget-side) | token | ✓ (adaptive) | ✓ |
| EntroKV [18] | , entropy layer budget | ✕ | token | (layer-wise) | (offline) |
| DuoAttention [19] | head class | (head-level) | head/token | ✕ | (offline) |
| Channel-dimension and routing alternatives (included for completeness): | |||||
| ThinK [20] | channel (query-guided) | n/a | channel | (fixed ratio) | ✓ |
| KIVI [21] | n/a (2-bit K/V quant.) | n/a | n/a | n/a | ✓ |
| QuaRot [22] | n/a (rot. + 4-bit) | n/a | n/a | n/a | ✓ |
| InfLLM [23] | query-key block routing | (block-level) | block | ✓ (training-free) | |
| Page-EntroKV (ours) | group | ✓ | page | ✓ (Theorem 3) | ✓(runtime entropy) |
NVIDIA H100 SXM5 accelerator (989.5 TFLOP/s dense FP16; 3.35 TB/s HBM3 bandwidth) is:
demonstrating that decoding operates at of peak compute, strictly memory-bandwidth bound. The total physical KV cache capacity required is:
which for Llama-3.1-70B (, , ) with at reaches . These figures are architectural constants plus arithmetic; they motivate the compression problem this paper addresses.
3.2. GQA mechanics and paged memory layout
Let denote token representations. For query head , mapped to physical group , the attention probability vector at a given decode step is:
where is the probability simplex. MHA corresponds to [1], MQA to [2], and GQA to [3]. In vLLM, the physical KV cache is partitioned into non-contiguous page blocks of fixed capacity tokens:
A logical block table maps . Fused CUDA kernels access memory per tuple; eviction at sub-page granularity therefore causes internal fragmentation or cache-unrolling overhead.
3.3. Quantifying the structural breakdown
Definition 1 (Retention set and union overhead ratio). Let be the set of token indices selected by head under per-head budget , with ties broken deterministically by token index so that is a single well-defined set. For physical group , the union overhead ratio under head-independent selection is:
Definition 2 (Intra-group Jaccard disagreement index). The pairwise disagreement between sibling heads is:
The two metrics are not independent. For a two-head group they determine each other exactly; for general , they sandwich the inflation two-sidedly (Theorem 1). This gives Definitions 1 and 2 operational content: measured Jaccard disagreement among sibling heads implies a quantifiable memory penalty for any head-independent policy.
Proposition 1 (Exact UOR–disagreement identity, ). Let and . Then:
Proof. Let and . By inclusion–exclusion, . By definition , so . Thus . Dividing by yields Eq. (8).
Remark 1 (Response curve of the identity). The map from disagreement to overhead is strictly increasing, , and strictly convex, , on : the memory penalty accelerates as sibling selections diverge. Reference points: (complete consensus) gives UOR = 1.0; gives UOR = 1.33; gives the exact budget overshoot; (orthogonal attention) gives the worst case UOR = 2.0 for .
Corollary 1 (Elementary Bonferroni certificate). Let and . By Bonferroni's inequality:
Eq. (9) certifies a twofold inflation (UOR ) whenever -yielding for and for .
Proof. by Bonferroni, and . Summing over the pairs gives , and dividing by yields the bound; the clamp is UOR from Definition 1. The threshold follows by solving for .
Theorem 1 (GQA inflation sandwich bound). For general , with and as in Corollary 1, the union overhead ratio is bounded by:
Proof. Lower bound. Let and define the coverage degree for . Exchanging the order of summation and splitting the double sum into diagonal and off-diagonal terms,
where . Cauchy–Schwarz on and the all-ones vector gives , hence . From one gets , so . Since is strictly concave (), Jensen's inequality gives ; substituting this upper bound into the denominator yields the lower bound of Eq. (10).
Upper bound. For any pair , , so sub-additivity and the map above give , i.e., . The pair is arbitrary, so the bound holds with the maximizing pair; the outer is the natural boundary from Definition 1.
The full eight-step derivation of Theorem 1 appears in Section Appendix C.1.
Table 2: The two disagreement certificates compared. The sandwich certificate of Theorem 1 strictly widens the certified-inflation regime; it is also naturally tight at consensus, where the Bonferroni form needs its clamp.
| Bonferroni (Corollary 1) | Sandwich (Theorem 1) | |
|---|---|---|
| 2× threshold (r=4) | ||
| 2× threshold (r=8) | ||
| At (disjoint) | r (exact, tight) | r (exact, tight) |
| At (consensus) | clamp to 1 | 1 (naturally tight) |
Tightness and threshold synchronization.. The lower bound is tight at both extremes: at (pairwise disjoint selections) it evaluates to , the exact worst case, and at (identical selections) to 1, the exact best case. The upper bound is tight at the disjoint extreme; at perfect alignment it evaluates to for —mathematically valid, though loose relative to the true limit of 1.0, because the pairwise profile does not see higher-order overlap structure. Table 2 compares the two certificates.
Under Theorem 1, twofold inflation (UOR ) is certified up to -yielding for and for -a strictly wider certification range than the Bonferroni threshold of Corollary 1. When siblings fully disagree (), they attend to essentially disjoint token sets and UOR : a cache inflation for Llama-3.1-8B () and an inflation for architectures.
4. The Page-EntroKV methodology
Page-EntroKV aligns KV-cache eviction with the hardware-physical structure of GQA serving. Algorithm 1 states the complete decision procedure. Section 4.1 fixes the entropy machinery behind the pooling weights, Section 4.2 derives group pooling, page mapping, and eviction, and Section 4.3 covers integration in vLLM.
4.1. Sink-isolated discrete Rényi attention entropy
The pooling weights of Page-EntroKV come from a discrete entropy family evaluated on sink-isolated attention distributions. This subsection fixes the definitions and the suppression guarantee the rest of the paper relies on.
Definition 3 (Discrete generalized Rényi attention-entropy). For and :
Writing for brevity, taking limits establishes the
Table 3: Why : on-chip cost and numerical behavior of the three entropy orders for one head with positions. Collision entropy is the only order that reduces to a single dot product with a bounded logarithm argument.
| Shannon () | Collision () | Min-entropy () | |
|---|---|---|---|
| Definition | |||
| On-chip primitive | 1 dot product + 1 ln | -way max + 1 ln | |
| FP16 stability | cancellation as | stable; argument in (0, 1] | plateau ties |
| Spike sensitivity | logarithmic scaling | quadratic amplification of spikes | ignores shape below peak |
entropy family:
\mathcal {H} _ {\infty} (\mathbf {A}) = - \ln \max _ {t} \mathbf {A} (t) \tag {min-entropy}. \tag {15}We fix for three reasons: collision entropy is a single inner product per head, it is numerically stable in FP16 (Remark 7), and it amplifies attention spikes while suppressing background tail mass. Table 3 makes the computational contrast concrete; the limit-order proofs appear in Section Appendix C.3.
Definition 4 (Sink-isolated collision entropy). Let denote the set of attention-sink tokens, taken as the first token positions, following the convention of StreamingLLM [13]. Under the non-degeneracy hypothesis (a head concentrated entirely on is handled by the implementation clamp; Remark 7), the sink-isolated attention distribution on non-sink positions is:
and the sink-isolated collision entropy is .
Without isolation, an attention-sink head that concentrates most of its mass on has very low raw collision entropy and would receive the same large Boltzmann weight as a genuine retrieval head, misdirecting the pooled mass toward the sink tokens. The next theorem makes the separation quantitative: isolation drives the sink head's weight to zero at a controllable rate while the retrieval head's weight stays bounded away from zero.
Theorem 2 (Sink head suppression). Let and . Consider two head types: (i) a pure sink head concentrating mass on (with ) and a uniform residual over the non-sink positions; (ii) a retrieval head with mass at a non-sink needle (with ) and zero sink mass. Under sink isolation, the sink head has , hence exactly, and its Boltzmann factor is:
whereas the retrieval head maintains and factor : its weight is bounded away from zero for every .
Proof. For the sink head, the residual is uniform: on all non-sink positions, so and ; its factor is . For the retrieval head, zero sink mass makes isolation the identity, so and the factor is at least . For contrast, the raw collision entropy of the sink head tends to —also —so raw entropy cannot separate the two types; the separation is created by the isolation step, not by the entropy family alone.
Remark 2 (Why isolation, not the entropy family, does the work). For the pure sink head of Theorem 2, the two regimes contrast sharply. Raw collision entropy is evaluated over all tokens, where and hence : the sink head receives an Boltzmann weight and masquerades as a sharp retrieval head, stealing group attention mass. Sink-isolated entropy is evaluated strictly over the non-sink tokens, where and hence : the weight decays as and the head is suppressed. This holds for every order , since the raw power sum for any fixed —no choice of entropy order separates the two head types on the raw distribution. The separation is created entirely by the conditional renormalization of Eq. (16).
Definition 5 (Prefill observation window). The sink-isolated collision entropies used for head weighting are evaluated over the prefill observation window , the final tokens of the prompt with (the observation-window convention of SnapKV [11]):
where the restriction is renormalized over the window (the normalization constant is part of the configuration and is recorded with it). The entropies—and hence the pooling weights of Eq. (20)—are computed once, at the end of prefill, and remain fixed for the entire auto-regressive generation lifecycle.
4.2. Hardware-aligned group pooling and paged mapping
The union overhead dilemma.. If selection occurs independently per query head with , the engine must retain the union , with

Figure 2: Page-EntroKV mechanism for an architecture such as Llama-3.1-8B: entropy-weighted pooling with sink-isolated entropy amplifies the retrieval head , suppresses diffuse heads , , and the attention-sink head , and maps the result onto physical PagedAttention blocks.
[1, r] as defined in Eq. (6), exactly determined by disagreement at (Proposition 1) and sandwiched at every ratio (Theorem 1): an 800% memory expansion for architectures when selections diverge, causing out-of-memory faults.
Needle dilution under arithmetic mean pooling.. Naive mean pooling assigns
The needle’s pooled mass drops by exactly for , independent of ; for the pooled score is , below common eviction thresholds.
Entropy-weighted group pooling.. Page-EntroKV replaces mean pooling with entropy-weighted group pooling:
Low-entropy retrieval heads receive exponentially larger weights; diffuse streaming heads and attention-sink heads are suppressed, the latter by Definition 4 and Theorem 2. Pooling runs once per physical KV group—matching how GQA shares memory. The pooled output stays a convex combination of probability vectors, and that property is exactly what the budget guarantee of Theorem 3 requires. With , Eq. (20) reduces to raw collision entropy. The temperature interpolates the entire family of group aggregators; we characterize it exactly:
Proposition 2 (Temperature monotonicity and limits). Let be defined by Eq. (20). (i) is non-increasing in (strictly decreasing when the entropies are distinct), for every . (ii) (arithmetic mean pooling). (iii) is the uniform weight on the set of entropy minimizers—one-hot for a unique minimizer.
Proof. is a softmax of the scores , which is strictly increasing in its score; hence is non-increasing in the entropy (strictly under distinct values). (ii) The entropies are bounded by , so every exponential tends to 1 and . (iii) Multiplying numerator and denominator by , every exponent is , equals 0 exactly at the minimizers, and for each .
Proposition 2 also motivates the failure-mode fallback of Section 7: when intra-group entropies are indistinguishable, Proposition 2 (i) loses its bite, the entropy signal carries no information, and the operator can switch to max-over-heads aggregation without changing the budget guarantee—which depends only on pooling before selection (Theorem 3).
Discrete physical block-frame aggregation.. Token scores are aggregated onto physical page frames via max-reduction, and the eviction operator selects the top pages at the hardware tuple :
(Page-level retention sets are distinguished from the token-level selection sets of Definition 1 by their group subscript.)
Why block-max rather than block-mean reduction.. Aggregating page importance by the within-page mean instead of the max dilutes exactly the pages the framework exists to protect. With B = 16, a page holding a single needle token of pooled mass 0.95 and fifteen near-zero tokens scores 0.95/16 = 0.0594 under block-mean—a 93.75% in-page dilution—while block-max preserves 0.95. A diffuse page of sixteen 0.06-mass tokens then outranks it (0.06 > 0.0594) and evicts the needle page. Block-max is also exactly scale-invariant in B: it preserves the peak coordinate regardless of page size, whereas block-mean attenuates every sharp page by 1/B. These figures are illustrative arithmetic, not measurements; Lemma 1 makes the corresponding guarantee formal.
Proposition 3 (Budget initialization and exact conservation). With total budget , the per-layer token budget and static per-group page quota are:
(i) Under the floor quotas alone, exact conservation ( ) holds iff . (ii) With largest-remainder (Hamilton) rounding over the fractional remainders —allocating +1 page to the largest-remainder layer-groups—exact conservation holds iff divides , in which case at most extra page-groups suffice. (iii) Otherwise the residual tokens—less than one page-group—is unavoidable at page granularity.
Proof. Page allocation is quantized in tokens per layer-group, so is always a multiple of ; it equals iff divides , which proves (ii)'s necessity and (iii). For (i): with uniform budgets, , so all floors sum to iff the quotient is an integer. For (ii)'s sufficiency: writing , the floor sum is and the deficit is distributed as +1 allocations to the largest-remainder layers, restoring .
The full derivation, including worked numerical cases on Llama-3.1-8B geometry, appears in Section Appendix C.5.
Page-level retention across groups.. Because PagedAttention blocks are shared across the groups of a sequence, per-group retention sets are materialized by the engine as their per-layer union. Proposition 4 gives the exact accounting.
Proposition 4 (Engine-level page accounting). Let be the layer page union, where each is given by Eq. (22). Then, unconditionally:
The lower bound is attained iff all groups select identical page sets; the upper bound iff selections are pairwise disjoint.
Proof. By Eq. (22), each group retains exactly pages (exact TopK cardinality), so for every ; the union contains any single member, giving the lower bound. The union of sets of cardinality each has cardinality at most . The equality conditions are immediate.
The page-union ratio, taken relative to the per-group retention cardinality , lies in and equals one whenever the per-group pooled page profiles coincide. Proposition 4 states the guarantee at the level where it holds—per layer, across the groups, on top of the per-group guarantee of Theorem 3—and quantifies the residual overhead exactly; the pilot measures it in Section 6.3. The full proof, including both equality conditions and the page-union ratio formalism, appears in Section Appendix C.6.
Algorithm 1: The Page-EntroKV decision procedure.
Input: per layer ; ; ; ;
Output: retention masks for all
// Budget initialization (prefill only)
1 ; // Eq. (23)
// Page quotas are static for the entire generation lifecycle.
// Sink-isolated entropy, pooling, and page mapping
2 for to do
3 for to do
4 over ,
5 // Definitions 4 and 5
6
// Eq. (20)
7 // Eq. (21)
8 // Eq. (22)
9 // Eq. (22)
10 end
11 end
12 evict every per layer (Proposition 4); free blocks to the vLLM pool
4.3. Systems integration in vLLM
Page-EntroKV never materializes intermediate attention matrices in global DRAM. Entropy estimation, Boltzmann weighting, and page reduction are fused into two kernels executing in on-chip SRAM (Fig. 3). Kernel 1 computes QK dot-products, sink-isolated collision entropies, and Boltzmann weights in FP16 registers, then performs the group reduction in shared memory. Kernel 2 applies the block-table mapping, runs the max-reduction per physical page, and performs two-pass radix top- selection, emitting the retention mask without DRAM materialization. Unreferenced blocks return to the vLLM free-page pool immediately. Section Appendix D gives the PyTorch reference implementation.
5. Theoretical analysis
Two guarantees carry the framework. The memory bound of Theorem 3 holds by construction, for any attention pattern; the needle-retention result of Theorem 4 holds under explicit head-specialization assumptions. The remaining results give the finite-context form, a concrete instantiation, and the on-chip cost of the design.
Theorem 3 (Strict physical memory bounds and union elimination). Under head-independent top-k eviction, physical memory consumption satisfies:
Under Page-EntroKV group-level pooling, , guaranteeing group-level UOR( .
Proof. Under head-independent selection, each selects with . Because the KV buffer is physically shared, the engine allocates . The union contains any member set, so
Step 1 — vLLM scheduler (decode step i). Initiates the auto-regressive cycle; passes the static per-layer page quotas (fixed at prefill, Eq. (23)) and active page-table pointers to the worker queue.
Step 2 — fused kernel 1: flash-entropy reduction (on-chip SRAM).
• QK dot-products: .
• Sink-isolated collision entropy in FP16 registers: .
• Boltzmann weights: .
• Group reduction in shared memory: .
Step 3 — fused kernel 2: block-max + two-pass top-K page selector.
• Physical block mapping: .
• Max-reduction: .
• Radix top- selection → retention mask with exact cardinality (Remark 6).
Step 4 — zero-copy physical block reclamation. Unreferenced blocks return to the vLLM free page pool immediately: group-level UOR , zero DRAM copies, zero internal fragmentation.
Figure 3: Hardware-level execution flow of the fused Page-EntroKV kernels within the vLLM decoding loop.
; sub-additivity gives , and trivially ; hence Eq. (25). In Page-EntroKV, pooling occurs prior to selection: because and , is a convex combination of probability vectors, so is itself a valid probability vector. Selection is performed on this single pooled vector: . By the exact cardinality property of TopK on a single vector—with deterministic tie-breaking— under all attention configurations, guaranteeing . The union semantics that produce the upper regime of Eq. (25) are eliminated by construction, for every overlap profile of Section 3.3.
Theorem 4 (Needle retrieval preservation under head specialization). Suppose Group(g) contains exactly one retrieval head with at a non-sink position , and sink-isolated collision entropy . Suppose each of the sibling heads has near-maximal sink-isolated entropy: there exist constants , independent of , with
Both canonical background cases satisfy Eq. (26) with : uniformly diffuse heads, and attention-sink heads whose residual mass is spread (Theorem 2); the constant permits mildly concentrated residuals. Then:
(i) Under arithmetic mean pooling, as .
(ii) Under entropy-weighted pooling with sink-isolated entropies and temperature : .
Proof. Write for the sink mass of sibling , so that for non-sink ; in particular —this is where the hypothesis enters, since is defined only off .
Part (i): arithmetic mean collapse.. For each sibling, Eq. (26) gives , hence and . Therefore
which equals for ; at the representative this is 0.11875—below common eviction thresholds.
Part (ii): entropy-weighted pooling asymptotics.. Let . The retrieval head satisfies . Each sibling satisfies, by Eq. (26), ; collecting these, for any fixed and . Hence and . All pooled mass at is bracketed by the retrieval head's contribution below and the total head mass above:
and both outer terms converge to , giving
The asymptotic statement becomes concrete—and checkable against any deployment—in finite context:
Corollary 2 (Finite-context retention bound). Under the assumptions of Theorem 4, for every finite :
and as .
Proof. By the weight bound of Theorem 4,
Remark 3 (Scope of the assumptions and boundary cases). Theorem 4 gives a sufficient condition under which entropy-weighted pooling provably dominates arithmetic mean pooling: siblings must have near-maximal sink-isolated entropy. Three boundary cases delimit it. First, the needle is assumed non-sink: excludes a needle inside the sink region—the first prompt positions—which the theorem does not cover. Second, the result extends to multiple retrieval heads: pooling preserves the convex combination of their masses rather than a single head's mass; siblings with intermediate entropy transition smoothly per Proposition 2. Third, when every head in a group has near-identical high entropy, no head satisfies the retrieval-head premise; the weights degenerate toward uniform (Proposition 2 ii), and the max-over-heads fallback of Section 7 is the designated mitigation.
Remark 4 (Concrete instantiation at 128k context). For an group, , uniformly diffuse siblings (), a retrieval head with sink-isolated entropy (at least half of its non-sink mass on the needle), , and (so ): and , so (rounded )—numerically negligible at 128k context. Under mean pooling the same needle's score is , an 87.5% attenuation (Theorem 4 i). These figures follow from the stated assumptions by arithmetic; they involve no measurement. The step-by-step instantiation and the 4k–128k scaling table appear in Section Appendix C.9.
Lemma 1 (Page-frame monotonicity). Let contain . Under max-reduction (Eq. (22)), .
Proof. Since : . For any , let . Then . Therefore tops the priority queue.
Proposition 5 (Computational complexity of on-chip pooling). Evaluating entropy-weighted group pooling and block-max mapping across heads for sequence length T and block size B requires
operations. When pooling is fused with the block-max reduction and processed page-by-page, the on-chip intermediate storage is words of register/shared memory per active page plus accumulated page scores, and the stage adds no global DRAM traffic beyond the attention computation that produces .
Proof sketch. Sink-isolated collision entropy per head is an inner product over the non-sink positions, accumulated tile-by-tile; softmax weights cost . The pooled vector need never be materialized: for each page , is computed from the attention rows of the group already resident in on-chip tiles, costing multiply-accumulates and comparisons in total. The top- selection over the page scores per group costs (or with radix selection, Remark 6). The weights ( words) and page scores ( words) reside in shared memory, so no intermediate tensor is written to DRAM.
Remark 5 (Shared-memory footprint). For a threadblock processing one GQA group with ratio r, page size B, and head dimension : the attention tile for one page requires FP16 elements (256 bytes for r=8, B=16); the group's Q rows and the page's K tile require FP16 elements (6,144 bytes for r=8, B=16, ); and running page-score accumulators require bytes. The per-SM shared-memory footprint is bounded by
i.e., 6,432 bytes for , , , —well within the 228 KB shared-memory limit of an H100 SM. The full page-score tensor, however, is FP32 values—256 KB for , , —which exceeds that limit; the kernel therefore processes the sequence in segments of pages per invocation, accumulating partial maxima in registers and writing final page scores to global memory in one coalesced pass. These are design specifications derived from architecture constants, not measurements.
Remark 6 (Radix top-K selection at 128k context). For and , each group holds pages; a full bitonic sort costs comparisons and a sort buffer that does not fit a single threadblock. The design instead uses two-pass radix selection: pass 1 builds a histogram of page scores quantized to 16-bit fixed point (65,536 bins of 2 bytes, segmented across four threadblocks of 16,384 bins, 32 KB per block) and identifies the -th largest threshold in ; pass 2 scans all pages and retains those exceeding the threshold. Ties at the quantized threshold are broken deterministically by page index, and any deficit relative to is filled in index order, so the retained cardinality is exactly and the guarantee of Theorem 3 is preserved. Selection cost drops from to with a small constant. As above, these are design specifications, not measurements.
Remark 7 (FP16 numerical stability and degenerate sinks). The collision-entropy argument lies in for any probability vector (Cauchy–Schwarz below, pointwise mass above), so its logarithm is well defined without catastrophic cancellation; the entropies themselves lie in
[0, ]. The -guard is applied inside the logarithm only, never inside the power, which preserves the normalization that the weighting and proofs rely on. For the power sum can never vanish: subadditivity of gives , so the guard is likewise never load-bearing. For the sink-isolated variant, a head whose mass is entirely concentrated on has an all-zero residual; the reference implementation clamps the renormalization denominator, which assigns such a head maximal entropy and hence vanishing weight—the desired degenerate-case behavior.
6. Empirical validation: pilot results and pre-registered protocol
This paper’s guarantees are of two kinds, and the evidence differs accordingly. The architectural guarantees—UOR 1 under pooling (Theorem 3) and the per-layer union bounds (Proposition 4)—hold by construction. Everything else requires measurement. This section reports a pilot validation executed against the pre-registered protocol, discloses every deviation from it, and marks precisely which protocol items remain pending. Two governance principles govern all reporting. First, claims follow tables: the abstract, introduction, and conclusion assert only what a table, figure, or theorem supports. Second, aggregates are recomputable: every summary below is transcribed from the released per-cell logs.
6.1. Pilot setup and measurement governance
The pilot runs on Qwen2.5-1.5B-Instruct (L=28, , , r=6) in native FP16, loaded with eager attention so that per-head probability vectors are exposed for entropy computation—the capture requirement the protocol already anticipates, since fused kernels do not expose attention distributions. Pages are simulated over the model's cache with logical blocking at B=16. Hardware: a single NVIDIA T4 GPU; seeds are fixed per run and recorded in the released logs.
The pre-registered Phase 1 names Llama-3.1-8B (r=4) under vLLM on an A100-80 GB with contexts to 128k. The pilot deviates on four points, stated explicitly: (i) model: Qwen2.5-1.5B (r=6) for single-GPU capture feasibility; (ii) runtime: HuggingFace transformers with eager attention, page quotas simulated at B=16 rather than read from a vLLM block manager; (iii) scale: contexts across the measurement suite, needle-recall horizons , and budgets rather than the 4k-128k sweep; (iv) serving: no vLLM serving measurements yet. The pilot is therefore a validation tier of the structural core, not the pre-registered sweep.
Three rules were applied to every table below. Coverage certification: the certified ablation run covers 56 of 56 layer-group pairs (100%) with zero NaN-skipped layers, so every reported ablation statistic is computed on the full population; captured head populations are non-degenerate (minimum sibling attention variance ). NaN policy: attention-capture rows with non-finite entries under FP16 are zeroed and counted rather than silently dropped. Excluded-task rule: evaluation runs that faulted (eleven of fifteen LongBench subsets returned exactly 0.00% under an answer-extraction fault, and one data file was missing) are excluded, never reported as zeros (Section 6.4). The pre-registered serving closure check applies only to vLLM rows and is deferred with the serving phase.
6.2. Structural validation
The harness replays head-independent top-k selection over the model’s actual GQA groups on real long-context text, under three scorers (H2O accumulated attention, last-row attention, and SnapKV-style observation-window scores), and measures the disagreement and union statistics of Definitions 1 and 2. Table 4a summarizes the by-scorer replay: inflation is present in every measured cell (frac(UOR > 1) = 1.0 throughout), the distribution is heavy-tailed (means of 2.3–3.0× with maxima up to 5.10× at the smallest budget), and the two certificates separate exactly as Table 2 predicts—the sandwich certificate of Theorem 1 certifies twofold inflation in the large majority of cells (cert_T), while the elementary Bonferroni certificate of Corollary 1 (cert_1) fires only near full disagreement and vanishes first as the budget grows. The pooled Page-EntroKV row is exact: UOR ≡ 1.0000 across 1,008 pooled measurements, matching the by-construction guarantee of Theorem 3. Table 4b reports the coarse cell-level sweep over five budget fractions from the 2,240-row log, showing the same heavy tail (UOR_max from 4.75× at k/T=0.02 down to 2.33× at 0.40) and the same certificate pattern. Figure 4 plots observed UOR against disagreement with the Cauchy–Schwarz lower envelope of Theorem 1 and the worst-case ceiling r.
6.3. Mechanism ablations
All ablation statistics below come from the certified run: coverage of 56/56 layer-group pairs (100%), zero NaN-skipped layers, and zero entropy-bound violations.
Sweeping over nearly three orders of magnitude, the maximum within-group weight falls monotonically from 0.963 at to 0.173 at , against the arithmetic-mean limit : a residual gap of 0.0068 at the hottest temperature (Table 5a, Fig. 5a). The within-group weight dispersion shrinks in lockstep (standard deviation ): as grows the group's weights converge to uniform, the softening that Proposition 2(i)–(ii) predicts.
Across , every measured entropy lies within the admissible range , with zero violations, and the entropy support contracts monotonically as grows (Table 5b)—the ordering property of the Rényi family. Weight profiles are sharpest near ( and ) and flatten at the extreme orders ( at ; at ), supporting the choice .
Across all pairings of pooling operator {entropy-weighted, max, mean} and block size , the realized TopK cardinality equals the quota exactly—UOR in all 192 operator-block cells (1,008 pooled measurements overall)—confirming that the guarantee of Theorem 3 is invariant to the aggregator, as
Theorem 1

Figure 4: Empirical union overhead ratio versus intra-group Jaccard disagreement (r=6, Qwen2.5-1.5B pilot, Section 6.2). Blue: observed head-independent selections (SnapKV-style replay). Red dashed: the Cauchy–Schwarz lower envelope of Theorem 1. Green: Page-EntroKV's pooled selection, UOR 1 by construction (Theorem 3). Dotted: the worst-case orthogonal ceiling r. The observed tail approaches the envelope at high disagreement.
Proposition 2 implies. The page-level union ratio (Proposition 4) concentrates at its lower endpoint: mean 1.0, max 1.0, within the bound .
Within retained page frames (B=16), pooled attention mass is concentrated rather than uniform: slot 0 holds 14.4% of mass against the 6.25% uniform-slot baseline, with secondary concentrations at slots 8 and 10 (Fig. 6). This is descriptive evidence that block-max aggregation (Eq. (22)) tracks real in-page skew—the motivation for page-granular rather than token-granular eviction.
Head populations typed by sink mass across three probes (1,008 layer-head observations: n=152 sink, n=47 retrieval, n=809 contextual) show the masquerade pattern of Definition 4 and Theorem 2: under raw collision entropy the sink population sits at low entropy, overlapping the left flank of the retrieval population, and under sink isolation the sink mass shifts right while the retrieval population stays low (Fig. 7). At the operator level, isolating the sink cuts the sink head's Boltzmann weight from 0.303 to 0.116 while the contextual head's weight rises from 0.144 to 0.176, inverting their relative ordering from a unearned sink advantage to a deficit (Fig. 8). The retrieval population remains the smallest class (n=47); the population-level distributional claim is reported as pilot-scale evidence, not a settled characterization.
6.4. Retrieval and downstream feasibility
Table 6 reports needle retention under two success criteria, because they answer different questions and were measured in separate runs. Under the pooled-selection criterion—a trial counts as retained if the needle's page survives the pooled-selection eviction decision, with no requirement across layers—entropy-weighted pooling retains the needle at 100% across all pilot contexts and depths while arithmetic-mean pooling retains it at 0%: the dilution mechanism of Eq. (19) is directly observable. Under the strict all-layer criterion—the needle's page must survive in every layer—both methods fail at depths 25–75% (weighted recall 0–33% across strict variants; mean pooling 0% throughout), and both retain trivially at depth 100%, where the needle sits in the final pages that the quota never evicts. Every zero cell was verified as a genuine eviction: in 30 of 30 zero cells the needle page's rank fell below the retention quota in the layer that dropped it. The uncompressed cache retains the needle at all depths under both criteria, so the failures are budget effects, not harness artifacts.
The theorem’s premise was measured, not assumed. On the strict-criterion pilot ( ), needle attention mass is —roughly two orders of magnitude above the uniform floor —with measured sink-isolated retrieval entropy nats and pooled needle mass . The retrieval-head premise therefore holds directionally at pilot scale, but the strong regime the theorem asymptotes to is not reached: pooled mass of cannot top a 20% quota in every one of 28 layers. The strict-criterion failures at depths 25–75% are the pilot-scale face of this gap, and closing it (per-layer budget scaling, or criteria matched to the mass distribution) is the first item of the pending sweep. Depth-0 needles fall inside the sink region, which Definition 4 isolates and Remark 3 explicitly excludes
Table 4: Head-independent replay vs. pooled selection (Qwen2.5-1.5B-Instruct, , , ). (a) Per-scorer replay: counts cells where the Bonferroni certificate (Corollary 1) certifies UOR ; where the sandwich certificate (Theorem 1) does; -frac is the fraction of cells with measured UOR . (b) Coarse cell-level sweep (2,240 logged group measurements; NaN rows zeroed and counted per Section 6.1). Pooled Page-EntroKV row: 1,008 measurements, zero layers skipped.
| (a) By scoring method | |||||||
|---|---|---|---|---|---|---|---|
| Scorer | k/T | UOR | UORmax | frac(UOR>1) | cert1 | certT | ≥ 2-frac |
| H2O (accum.) | 0.02 | 2.849 | 5.100 | 1.000 | 62 | 290 | 0.879 |
| H2O (accum.) | 0.05 | 2.442 | 4.471 | 1.000 | 22 | 112 | 0.820 |
| H2O (accum.) | 0.10 | 2.292 | 3.971 | 1.000 | 6 | 65 | 0.769 |
| Last-row | 0.02 | 2.982 | 4.600 | 1.000 | 21 | 329 | 0.960 |
| Last-row | 0.05 | 2.703 | 3.961 | 1.000 | 6 | 196 | 0.933 |
| Last-row | 0.10 | 2.460 | 3.471 | 1.000 | 0 | 70 | 0.885 |
| SnapKV (obs.) | 0.02 | 2.869 | 5.000 | 1.000 | 66 | 306 | 0.887 |
| SnapKV (obs.) | 0.05 | 2.469 | 4.549 | 1.000 | 23 | 116 | 0.824 |
| SnapKV (obs.) | 0.10 | 2.317 | 3.961 | 1.000 | 7 | 71 | 0.790 |
| Page-EntroKV (pooled) | all | 1.0000 | 1.0000 | 1,008 measurements (Theorem 3) | |||
| (b) Cell-level budget sweep (2,240-cell log) | |||||||
| k/T | UOR | UORmax | cert1 | certT | |||
| 0.02 | 1.107 | 4.75 | 0.031 | 0.926 | 10 | 16 | |
| 0.05 | 1.094 | 4.04 | 0.030 | 0.893 | 6 | 16 | |
| 0.10 | 1.084 | 3.73 | 0.029 | 0.870 | 1 | 16 | |
| 0.20 | 1.071 | 3.23 | 0.028 | 0.827 | 0 | 16 | |
| 0.40 | 1.045 | 2.33 | 0.025 | 0.727 | 0 | 0 | |
from the theorem. The engine path reproduces the Corollary 2 bound to floating-point tolerance under a synthetic premise-satisfied construction (Fig. C.9a); on real text at pilot scale the premise is unsatisfied and pooling degenerates toward the mean (Fig. C.9b), consistent with Table 6. On premise-holding layers the measured bound deficit shrinks from at to at —the monotone decay the corollary predicts—while the absolute premise gap keeps the real-text pooled mass orders below the bound at pilot scale.
Table 7 reports the four LongBench subsets that completed under the pilot harness at retention (20 samples per subset): representative QA and code tasks remain solvable (qasper , multifieldqa_en , lcc , repobench-p ). Three caveats bound the claim: the subsets are 20-sample slices, there is no uncompressed same-harness baseline yet, and the eleven subsets that faulted under an answer-extraction bug are excluded, not reported as zeros.
6.5. Remaining pre-registered protocol
The following protocol items are pre-registered and in progress; no claim about them is made anywhere in this paper:
-
Phase 1 scale-up: Llama-3.1-8B-Instruct (; ; ; ) [4] on a single NVIDIA A100-80 GB GPU under vLLM [7], with the serving tables (maximum stable batch, decoding throughput, time-to-first-token, inter-token latency) and the pre-registered closure check; extensions to Llama-3.1-70B, Qwen-2.5-7B, and Qwen-2.5-72B.
-
Long-context NIAH: the full sweep over at depths —needle-recall
horizons in the pilot are only—with reconciled success criteria across the pilot variants.
-
LongBench re-run: all fifteen subsets with a repaired evaluator and an uncompressed same-harness baseline.
-
Strict all-layer retention at scale: framed as the regime where the premise of Theorem 4 (1 - large) binds; to be tested in Phase 1, where retrieval heads are sharper and budgets are set per the instantiated error bound of Corollary 2.
-
Remaining ablations: block-size effects on recall and sink isolation on sink-sensitive task subsets.
6.6. Logging
All runs append to a CSV log with fields
experiment, model, method, budget, context, subset, metric, value, unit, hardware, seed, timestamp,
and every table in this paper is transcribed from that log: the structural replay (experiment_1_log.csv, 2,240 rows; the by-scorer replay behind Table 4a), the needle pilot (experiment_3_log.csv, 321 rows), the ablation logs (584 and 201 rows, with the certified run behind Table 5), the three-probe sink census (1,008 observations, behind Figs. 7 and 8), and the downstream summary (experiment_5_longbench_summary.csv). Broken runs are discarded from the workspace manifest and tagged as non-transcription sources. Headline quantities are defined at the table level and propagate through macros, so the abstract, tables, and conclusion cannot disagree.
Table 5: Certified mechanism ablations (Qwen2.5-1.5B pilot; coverage certification: 56/56 layer–group pairs, 100%; zero NaN-skipped layers). (a) Temperature sweep: is monotone in toward (Proposition 2). (b) Rényi order sweep at : every entropy lies in , zero violations. (c) Cardinality exactness (Theorem 3). (d) Page-union ratio (Proposition 4).
| (a) sweep | (b) sweep () | |||
|---|---|---|---|---|
| w std | : ; [] | |||
| 0.1 | 0.9632 | 0.3922 | 0.5 | 0.620; [3.530, 7.112] |
| 0.2 | 0.9105 | 0.3700 | 1.0 | 0.762; [1.820, 6.638] |
| 0.5 | 0.7502 | 0.2994 | 2.0 | 0.750; [1.091, 5.910] |
| 1.0 | 0.5501 | 0.2076 | 999 | 0.641; [0.624, 4.260] |
| 2.0 | 0.3656 | 0.1179 | violations of [0, ln T]: 0 | |
| 5.0 | 0.2407 | 0.0491 | ln T = 7.625 | |
| 10 | 0.2020 | 0.0246 | ||
| 25 | 0.1804 | 0.0099 | ||
| 50 | 0.1734 | 0.0049 | ||
(c) Cardinality: UOR in all operator-block cells; 1,008 pooled measurements. (d) Page-union ratio: mean 1.0, max 1.0; bound [1, ].

Figure 5: Ablation panels (Section 6.3; certified run: 56/56 layer–group pairs, zero layers skipped). (a) Temperature limits: maximum within-group weight decays monotonically toward the mean-pooling limit as grows, the empirical form of Proposition 2. (b) Rényi order sensitivity at : weight sharpness peaks near ; all entropies lie within with zero violations.
7. Discussion and limitations
Failure modes.. When all heads in a group exhibit near-identical high entropy (uniformly diffuse attention), the Boltzmann weights degenerate toward uniform (Proposition 2 ii), and Page-EntroKV reduces to mean pooling—re-opening the needle-dilution risk (Remark 3). The fallback sanctioned by Proposition 2 (iii) is to switch a group to max-over-heads pooling when intra-group entropy variance falls below a threshold; the switch is cost-neutral for the budget guarantee, which Theorem 3 ties only to pooling before selection.
Pilot limitations.. Three limitations scope the empirical tier. First, strict all-layer needle retention fails at pilot scale at depths 25–75%: the premise of Theorem 4 holds directionally but not in its strong regime, so pooled needle mass ( ) cannot top a 20% quota in every layer; the asymptotic guarantee and deployed budgets are reconciled only at Phase-1 scale (Section 6.5), and the two-regime check of Fig. C.9 delimits exactly where the guarantee binds. Second, needle-recall horizons are tokens; the 4k–128k sweep is pending. Third, the pilot covers a single model family (Qwen2.5-1.5B, r=6); cross-family generality is deferred to Phase 1, and no serving-level measurements exist yet.
Kernel overhead.. The reference implementation computes entropy, weights, pooling, and page reduction as separate operations. The two-kernel fused design of Section 4.3—warple-level dot products for sink-isolated collision entropy, register-resident weighting, page-by-page block-max, and in-kernel radix top-K selection (Proposition 5 and Remarks 5 and 6)—is what reaches the throughput characteristics the framework is designed for; its open-source release is future work.
Runtime configuration dependency.. The framework's guarantees are stated relative to the engine's block size and page table: scales with (Eq. (23)), the page-level union ratio is bounded by (Proposition 4), and selection cost scales with (Proposition 5). Deployments must pin the engine version and block size together with the eviction configuration; the protocol records both with every log.
Section 6.1 (S4): Conviction Mass across Page Slots (B = 16, r = 6)

Figure 6: Pooled attention mass across token offsets within retained page frames (Section 6.3; , pilot). Slot 0 concentrates of mass against the uniform-slot baseline, with secondary concentrations at slots 8 and 10: in-page skew that block-max aggregation is designed to capture, and a descriptive motivation for page-granular eviction.
Table 6: Needle retrieval under two success criteria (Qwen2.5-1.5B pilot, matched 20% physical budget). Pooled-selection criterion: retention requires the needle's page to survive the pooled eviction decision (no cross-layer requirement). Strict all-layer criterion: the needle's page must survive in every layer. Asterisk: weighted recall at depth 0 spans 0–33% across strict-variant runs. All zero cells verified as genuine evictions (30/30).
(a) Pooled-selection criterion
| Context T | 959 | 1469 | 1989 | 2499 |
|---|---|---|---|---|
| Arithmetic mean | 0.0% | 0.0% | 0.0% | 0.0% |
| Page-EntroKV | 100.0% | 100.0% | 100.0% | 100.0% |
(b) Strict all-layer criterion (recall by needle depth)
| Method | 0% | 25% | 50% | 75% / 100% |
|---|---|---|---|---|
| Uncompressed | 1.00 | 1.00 | 1.00 | 1.00 / 1.00 |
| Mean pooling (page) | 0.00 | 0.00 | 0.00 | 0.00 / 1.00 |
| Page-EntroKV | 0-0.33* | 0.00 | 0.00 | 0.00 / 1.00 |
Orthogonality to KV-cache quantization.. Page-EntroKV operates exclusively along the sequence dimension , selecting which pages to retain; low-bit KV quantization (KIVI [21], QuaRot [22]) operates along the channel dimension, reducing the bytes per stored element from 2 (FP16) to 0.5 (INT4). The two optimizations compose multiplicatively: a page budget yields a reduction along by construction, and INT4 yields a further along the element axis— combined relative to the uncompressed FP16 cache. The pooling and selection logic is unaffected by storage precision: importance scores are computed from attention probabilities during the QK dot product, which are accumulated in floating point regardless of the stored representation; quantization changes only the stored and tensors. This is a design-level composition argument, not a measured deployment result.
Scope boundary.. Page-EntroKV targets GQA architectures. It does not transfer directly to latent-compression designs such as multi-head latent attention [32], where KV states are collapsed into a shared latent vector and no per-token page structure exists to evict. For MHA () the union bound is vacuous; entropy-weighted pooling and page alignment remain applicable, but the memory benefit comes from page alignment rather than union elimination.
Table 7: Downstream feasibility (LongBench subsets that completed, 20% retention, 20 samples each; Qwen2.5-1.5B pilot). Scores are not comparable to published LongBench numbers (sample size, retention, and the absence of an uncompressed same-harness baseline). The remaining LongBench subsets are pending re-run after an evaluator fault; unscored subsets are excluded, not reported as zero.
| LongBench subset | Page-EntroKV score (%) |
|---|---|
| qasper | 38.60 |
| multifieldqa_en | 44.20 |
| lcc | 56.10 |
| repobench-p | 44.81 |
Empirical status.. The guarantees of Theorem 3 and Proposition 4 are architectural and hold by construction; the pilot confirms their measured form (exact cardinality in 192 of 192 operator–block cells; page-union ratio at the bound's lower endpoint). The pilot further supports the structural analysis on real text: heavy-tailed inflation up to with envelope-certified twofold overhead (Table 4), sink-isolation ordering inversion (Figs. 7 and 8), and the temperature and Rényi-order characterizations, certified over the full layer–group population (Table 5). Measured but pending full validation: pooled-criterion needle retention (Table 6a), downstream feasibility at retention (Table 7), and the strict all-layer regime, which fails at pilot scale for the premise reasons recorded in Section 6.4. Everything at Phase-1 scale—128k contexts, larger models, uncompressed baselines, and serving throughput—is pre-registered and pending (Section 6.5). Until those runs are logged, the appropriate reading is a formal framework whose structural core is pilot-validated, not an empirically validated serving system.
8. Conclusion
We presented Page-EntroKV, a formal framework for hardware-aligned KV-cache eviction that resolves the mismatch between head-independent eviction policies and physically shared GQA buffers. The framework formalizes the union overhead ratio and intra-group disagreement, proves their exact analytic relationship at , and bounds the inflation two-sidedly at every group ratio; it replaces head-level selection with sink-isolated entropy-weighted pooling at the physical group level; and it projects importance onto the discrete page frames that serving engines allocate, so eviction executes exactly at the tuple with strict, provable budget preservation and finite-context needle retention. A pilot validation on Qwen2.5-1.5B-Instruct confirms the structural core on real text—heavy-tailed union inflation with envelope-certified overhead, sink-isolation ordering inversion, exact pooled cardinality, and the certified temperature and Rényi-order characterizations—while the full-scale sweep proceeds under the pre-registered protocol. Future work: executing that protocol across model families, releasing the fused kernels, entropy-based inter-layer budget al-
(a) Raw : sink heads masquerade as sharp

(b) Sink-isolated : sink mass shifts right
Figure 7: Sink isolation separates head populations (Section 6.3; Qwen2.5-1.5B pilot; three probes, 1,008 layer–head observations: n=152 sink, n=47 retrieval, n=809 contextual). (a) Raw collision entropy: the sink population sits at low entropy and overlaps the left flank of the retrieval population—the masquerade that Theorem 2 predicts raw entropy cannot break. (b) Sink-isolated entropy: the sink mass shifts right while retrieval heads stay low. The dashed line marks the uniform-residual ceiling of Theorem 2; measured populations sit below it because real sink residuals are not uniform. Isolation inverts the sink-to-context weight ordering rather than driving any single weight to zero (Fig. 8).
location beyond the present uniform quotas, and training-time co-design of page-granular attention.
CRediT authorship contribution statement
Inbasekaran S.: Conceptualization, Methodology, Software, Validation, Formal analysis, Investigation, Data curation, Writing – original draft, Writing – review & editing, Visualization.
Declaration of competing interest
The author declares no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Declaration of generative AI and AI-assisted technologies in the writing process
During the preparation of this work the author used a generative-AI assistant for language editing and manuscript preparation. After using the tool, the author reviewed and edited the content as needed and takes full responsibility for the content of the published article.
Data availability
All experiment logs—the per-cell CSVs for the structural replay (2,240 rows), the by-scorer replay, the needle pilot (321 rows), the ablation studies (584 and 201 rows, including the certified run), the three-probe sink census (1,008 observations), and the downstream summary—the evaluation harness, and the figure-generation scripts are released at https://github.com/bruce12-glitch/PageEntro-KV. Summary tables in this paper are transcribed directly from those logs; broken runs are excluded from the manifest and are not transcription sources.
Appendix A. Notation
Table A.8 summarizes the symbols, architectural parameters, and systems notation used throughout the paper.
Appendix B. Master verification summary
Table B.9 maps every theoretical guarantee and hardware-geometry specification in the paper to its mathematical form, derived value or bound, systems-level impact, and the pilot evidence (or design-spec status) that backs it.
Appendix C. Step-by-step derivations
This appendix collects the full step-by-step derivations supporting the main-text results. Only elementary set algebra, Cauchy–Schwarz, Jensen’s inequality, and L’Hôpital’s rule are used.
Appendix C.1. The GQA inflation sandwich bound
Step 1 (coverage degrees). Let . For define the multiplicity : every retained token is selected by at least one head and at most , so .
Operator-level weight ordering (raw vs. sink-isolated)

Figure 8: Operator-level pooling weights under raw versus sink-isolated entropy, from the same 1,008-observation census as Fig. 7 (Section 6.3). Sink isolation lowers the sink head's weight from 0.303 to 0.116 and raises the contextual head's weight from 0.144 to 0.176, inverting the sink-to-context weight ratio from (raw: sink heads outweigh contextual heads without earning it) to (isolated: contextual heads dominate)—the empirical form of Theorem 2.
Step 2 (exact moments over U). Exchanging the order of finite summations,
and, using the indicator product rule and splitting the double sum into diagonal and symmetric off-diagonal pairs,
Step 3 (Cauchy–Schwarz). Applying Cauchy–Schwarz to and the all-ones vector,
and , so . Isolating and dividing by :
Step 4 (pairwise overlaps via Jaccard). Inclusion–exclusion gives , hence . Solving, , so
Step 5 (strict concavity and Jensen). satisfies and on : strictly concave. Under the uniform weights across the pairs,
Multiplying by bounds the denominator cross-term:
Step 6 (lower bound completed). Substituting Steps 4–5 into Step 3 (upper-bounding the denominator lower-bounds the fraction) and factoring r from numerator and denominator:
Step 7 (upper bound). Subadditivity gives , i.e., . To refine using pairwise data, isolate an arbitrary pair : , so and, by Step 4, for every pair. Taking the infimum over all pairs subtracts the maximal term, and intersecting with yields the upper bound of Eq. (10).
Step 8 (extremes and the certification threshold). : disjoint selections, both bounds equal —exact. : identical selections, the lower bound evaluates to —exact; the upper bound evaluates to for , valid but loose because the pairwise profile cannot see higher-order overlap. Solving gives the certification threshold .
Table A.8: Symbols and notation used throughout the paper.
| Symbol | Definition |
|---|---|
| Number of transformer layers, . | |
| Logical query heads; physical KV heads. | |
| GQA group ratio (query heads per physical KV buffer). | |
| Hidden dimension; head dimension (). | |
| Current sequence length (). | |
| PagedAttention block size (tokens per page, e.g. ). | |
| Number of allocated physical blocks. | |
| Set of physical pages; page frame . | |
| Attention probability vector, head , layer . | |
| Token-level top- selection set of head (Definition 1); page-level retention sets are distinguished by their group subscript. | |
| Pairwise intersection size; Jaccard similarity and disagreement; mean pairwise similarity (Definition 2 and Corollary 1). | |
| Sink token set (); sink-isolated attention distribution (Definition 4). | |
| Discrete Rényi entropy of order . | |
| Collision entropy (Rényi ): . | |
| Sink-isolated collision entropy. | |
| Prefill observation window and its bound (); entropies for head weighting are evaluated over (Definition 5). | |
| Total KV capacity; uniform per-layer budget (Eq. (23)). | |
| Pages retained per physical group in layer (Eq. (23)). | |
| Group() | Set of query-head indices mapping to KV group . |
| Entropy-weighted importance of head within its group. | |
| Group-level pooled attention. | |
| Importance of page in group , layer . | |
| Page-level retention set of group , layer . | |
| UOR() | Union overhead ratio under head-independent top-. |
| Group-pooling temperature (Eq. (20)). |
Appendix C.2. The elementary Bonferroni bound
The full inclusion–exclusion expansion of truncated after the second-order sum is a strict lower bound (second-order Bonferroni): . Since by subadditivity of the pairwise union, summing over all pairs and using gives . Dividing by and clamping with UOR (the union contains any single head's selections) yields Eq. (9). Non-trivial inflation requires , i.e., ; twofold certification requires , i.e., for and for .
Appendix C.3. Limit orders of the Rényi family
Write , and .
Part 1: Shannon . , so and : the ratio is a form. Both functions are continuously differentiable and , so L'Hôpital's rule applies once exists. Termwise differentiation via (with the continuous extension as ) gives . As , the denominator tends to 1 and each , so .
Part 2: collision . Direct substitution: . The self-inner product is the collision probability.
Part 3: min-entropy . Let and with multiplicity ; on the complement, strictly. Factoring out of the power sum and using :
As : each , so the inner logarithm tends to ; ; and . Hence .
Appendix C.4. Sink head suppression
Step 1 (conditional distribution). Partition into and with . By normalization, , so the renormalized residual is a valid distribution on (for ).
Step 2 (pure sink residual). For a sink head with and uniform residual, off , so on all non-sink positions.
Step 3 (norm). .
Table B.9: Master verification summary of Page-EntroKV theoretical guarantees and hardware geometry (Tables 4–7; Figs. 4–8).
| Guarantee | Mathematical form | Value / bound | Systems impact | Validated by | |
|---|---|---|---|---|---|
| Arithmetic intensity | Decode phase memory-bound | Architectural constant | constant | ||
| H100 ridge point | Eq. (2) | Decode at < 1.5% of peak | Architectural constant | constant | |
| Cache footprint | Eq. (3) | Linear HBM capacity | Architectural constant | constant | |
| Exact | Disagreement implies inflation | Table 4 certificates | |||
| Bonferroni certificate | Elementary certificate | Table 4 () | |||
| Sandwich bound | Tight at extremes | Two-sided inflation bound | Table 4 (); Fig. 4 | ||
| Rényi family | Shannon / collision / min-entropy limits | Dot-product evaluation | Table 5b (zero violations) | ||
| Sink suppression | Sink ordering inverted | No sink masquerade | Figs. 7 and 8 | ||
| Mean dilution | Exact drop | Mean pooling failure mode | Table 6a (mean 0%) | ||
| Temperature limits | ; hot limit one-hot | Monotone in | Interpolates aggregators | Table 5a (certified) | |
| Budget conservation | Eq. (23) + Hamilton rounding | Exact iff | Static page quotas | Table 5c (exact cardinality) | |
| Engine page accounting | Per-layer cross-group | Residual overhead bounded | Table 5d (PUR 1.0) | ||
| Memory guarantee | Union overhead eliminated | Table 4 pooled row | |||
| Needle preservation | pooled mass | Premise-gated | Retrieval signal preserved | Table 6; Fig. C.9 | |
| Finite bound | Non-asymptotic error budget | Table C.10 and Fig. C.9 | |||
| Page monotonicity | block-max preserves argmax page | Exact | Token to page linkage | Design property | |
| Fused complexity | On-chip | No DRAM intermediates | Design specification | ||
| Shared-memory footprint | 6,432 Bytes (, ) | Fits H100 SM (228 KB) | Design specification | ||
| Radix top-K | two-pass 16-bit histogram | Exact cardinality | Design specification | ||
| FP16 stability | guard inside only; clamped denominator | No ; degenerate sinks suppressed | Table 5b (zero violations) |
Step 4 (entropy)... as .
Step 5 (sink weight decay)... With : .
Step 6 (retrieval weight floor)... For a retrieval head with , , and sink mass : , so and , giving for all .
Step 7 (normalized suppression)... since all kernels are non-negative. Taking with : the sink head's normalized weight vanishes.
Appendix C.5. Budget initialization and exact conservation
Step 1 (dimensional decomposition). In PagedAttention, memory is allocated as physical blocks of capacity . Under GQA, the query heads partition into groups sharing per-group quotas . Total capacity: . The quota divisor is (not or ): is the layer's total token budget across all buffers, so each buffer receives , and each page stores tokens.
Step 2 (fractional residuals)... The unquantized page target per group is , decomposed as with and .
Step 3 (unadjusted conservation condition)... . Exact conservation iff , which (each ) holds iff for all , i.e., .
Step 4 (deficit integrality). Define . Under page-vector budgets, both terms are integers, so ; and with , giving .
Step 5 (largest-remainder restoration). Sort layers by residual magnitude, (ties broken by canonical layer index), and set for , otherwise. Then , so , with zero internal fragmentation.
Numerical cases (Llama-3.1-8B geometry: , , , ; granularity ; full-model granularity 4,096). Case A (divisible, ): 32,768 mod 4,096 = 0; ; pages, ; conservation exact. Case B (non-divisible, target 35,000): the nearest hardware-aligned budget is ; ; , for all ; pages. Apportionment: layers receive 9 pages, layers receive 8; verification: —exact conservation, zero fragmentation.
Appendix C.6. Engine-level page accounting
Step 1 (exact per-group cardinality). By Eq. (22) with deterministic tie-breaking, for every group.
Step 2 (lower bound). Each , so by monotonicity .
Step 3 (lower-bound equality). If all groups select the identical set , the union is and . Conversely, if with each of the same cardinality, each : all selections are identical.
Step 4 (upper bound). By Boole's inequality, .
Step 5 (upper-bound equality). If the selections are pairwise disjoint, finite additivity gives . Conversely, if some page lies in two selections, it is counted at least twice in the sum but exactly once in the union, so equality forces pairwise disjointness.
Step 6 (page-union ratio). satisfies : it tends to 1 when groups attend to shared regions (system prompts, preambles, shared code) and to when groups specialize into independent subspaces.
Appendix C.7. Strict physical memory bounds
Step 1 (union semantics). All sibling heads read the same physical slice , so a shared buffer cannot store token for one head while freeing it for another: the engine materializes and . Steps 2–3 (bounds under head-independent selection). Subset inclusion plus cardinality monotonicity gives , with equality iff all heads select identical sets. Subadditivity gives , and gives ; hence , with equality iff selections are pairwise disjoint and . Dividing by : .
Steps 4–5 (pooling preserves the simplex). (softmax outputs) and (ratios of positive exponentials), so . For normalization, interchange the finite summations and factor the weights:
Hence : a convex combination of probability vectors is a probability vector.
Step 6 (exact cardinality and page extension). Sorting via a permutation of in non-increasing order, the selection set contains exactly pairwise distinct indices because is a bijection (ties broken by canonical index): for every attention configuration, temperature, and group ratio, so . The token-level guarantee extends to pages verbatim: block-max reduces the pooled vector to scalar page scores, and page-level TopK retains exactly frames per group.
Appendix C.8. Needle retrieval preservation
Step 1 (residual formulation). For each head, for non-sink , and .
Step 2 (sibling coordinates vanish, part i). From Eq. (26), , so and, since , ; by the squeeze theorem the limit is zero for all . Mean pooling therefore satisfies .
Step 3 (retrieval kernel floor). gives, after multiplying by (which reverses the inequality) and exponentiating, for all .
Step 4 (sibling kernel sum vanishes). Each ; defining , the coefficient is -independent and the power term vanishes, so .
Step 5 (weights converge). after dividing by ; the ratio is sandwiched between zero and , so and .
Step 6 (squeeze on the needle). with the sibling term sandwiched between zero and : both brackets converge to , giving the limit .
Appendix C.9. Finite-context retention bound
Step 1 (weight floor). satisfies and for , ; replacing by its floor and by its ceiling preserves the lower bound: .
Step 2 (minorization). The sibling term ; dropping it gives .
Step 3 (deficit closed form). Writing the bound as and isolating, .
Step 4 (monotone decay). , and by the chain rule : the bound tightens as context grows.
Step 5 (exact instantiation and scaling; arithmetic, not measurement). With (7 siblings), , , , , and : ; ; . Because at , . In FP32, ; since , the pooled needle signal is numerically indistinguishable from exact single-head selection in FP32 registers. Table C.10 tabulates the closed-form bound across deployment contexts.
Two-regime mechanism check.. Figure C.9 exercises the corollary’s mechanism end-to-end in the two regimes the pilot spans. Panel (a) is a synthetic construction that satisfies the premises of Theorem 4 exactly (a needle head at mass with near-maximal-entropy siblings), run through the full engine path: the measured pooled needle mass coincides with the bound to within at every context length, up to and including 128k. Panel (b) is the real-text pilot regime on Qwen2.5-1.5B-Instruct eager-attention captures at : the measured best-head needle mass is rather than 0.95, the premise is unsatisfied, and entropy-weighted pooling degenerates toward arithmetic-mean pooling (Proposition 2 ii), with the two pooled masses within a factor 1.06 of each other. Both panels appear together deliberately: panel (a) alone could be misread as an empirical claim, whereas the pair delimits precisely where the guarantee binds and where it does not yet.
Appendix C.10. Page-frame monotonicity
Steps 1–3 (exact equality at the target page). The pages form a disjoint partition of , so lies in a unique . By definition of the maximum, ; conversely gives . The squeeze gives the identity : block-max preserves the peak coordinate exactly, independent of .
Step 4 (dominance over other pages). For any (disjoint from , so ), let be the local maximizer. Then , with strict inequality when is the unique global maximizer.
Step 5 (retention for any quota). Sorting page scores in non-increasing order, the maximal page occupies the first rank; for any budget , : the page containing the global attention peak is unconditionally retained.
Appendix C.11. On-chip execution and the FP16 guard
Argument bounds.. For : the collision argument is at most 1 (single-coordinate concentration) and at least (uniform), so and the logarithm never sees a zero argument.
Guard placement.. The guard must sit inside the logarithm and never inside the power: expanding , the context-dependent term corrupts the normalization and breaks the convexity that Theorem 3 relies on. Guarding inside the logarithm leaves the distribution untouched.
Degenerate all-sink clamping.. If , the residual denominator is zero and is undefined. The implementation clamps to : the residual coordinates stay 0, so and —maximal entropy. Under , : the degenerate head's pooling weight vanishes, preventing all-sink heads from diluting genuine retrieval signals.
Appendix D. Reference implementation
Listing 1 gives the PyTorch reference implementation of the Page-EntroKV engine: sink isolation (Definition 4), discrete Rényi entropy with the -guard applied inside the logarithm only (preserving normalization; cf. Remark 7), Boltzmann weighting over sibling heads (Eq. (20)), group pooling (Eq. (21)), block-max page aggregation and top-K physical block selection (Eq. (22)). The listing evaluates entropies on the full non-sink sequence for clarity—the full-sequence instance of the observation-window restriction (Definition 5); the windowed instance follows by restricting the inputs to .
import torch import torch.nn as nn import torch.nn.functional as F
class PageEntroKVGroupPooler(nn.Module): """Entropy-weighted GQA group pooling + page mapping.
Entropy is computed on the sink-isolated distribution; the pooled output uses the RAW attention rows, so it remains a convex combination of probability vectors (the budget-preservation guarantee relies on this).
""
Corollary 2 mechanism check (appendix; , )
(a) Synthetic premise-satisfied regime ( )

(b) Real-text pilot regime (premise unsatisfied)
Figure C.9: Corollary 2 two-regime mechanism check (r=6, single used throughout, ). (a) Synthetic premise-satisfied regime: an engine-path construction with a needle head at mass and near-maximal-entropy siblings; the measured pooled needle mass coincides with the bound at every context length (raw gap ; markers offset by +0.01 vertically for visibility), verifying the mechanism end-to-end up to 128k. (b) Real-text pilot regime (premise unsatisfied): Qwen2.5-1.5B-Instruct eager-attention captures at ; the measured best-head needle mass is rather than 0.95, so the premise of Theorem 4 is not reached and entropy-weighted pooling degenerates toward arithmetic-mean pooling (Proposition 2 ii), the pooled and mean masses agreeing to within a factor 1.06. The two panels together delimit where the guarantee binds; neither panel alone is interpretable.
Table C.10: Non-asymptotic scaling of the finite-context bound (Corollary 2) across deployment contexts ( , , , , ). All entries are arithmetic instantiations of the closed-form bound—not measurements.
| T | Non-sink N | D(T) | Δ(T) | Ratio | ||
|---|---|---|---|---|---|---|
| 4k | 4,092 | 0.949998 | 0.118750 | 8.00× | ||
| 8k | 8,188 | 0.949999 | 0.118750 | 8.00× | ||
| 16k | 16,380 | 0.949999 | 0.118750 | 8.00× | ||
| 32k | 32,764 | 0.950000 | 0.118750 | 8.00× | ||
| 64k | 65,532 | 0.950000 | 0.118750 | 8.00× | ||
| 128k | 131,068 | 0.950000 | 0.118750 | 8.00× |
def init(self, num_query_heads=32, num_kv_heads=8, block_size=16, tau_g=0.5, alpha=2.0, sink_size=4): super().init( self.num_query_heads = num_query_heads self.num_kv_heads = num_kv_heads self.group_size = num_query_heads // num_kv_heads self.block_size = block_size self.tau_g = tau_g self.alpha = alpha self.sink_size = sink_size
def renyi_entropy(self, attn): # eps inside log ONLY: preserves sum(p) = 1 eps = 1e-12 if self.alpha == 1.0: return -torch.sum( attn * torch.log(attn + eps), dim=-1) s = torch.sum(torch.pow(attn, self.alpha), dim=-1) return (1.0 / (1.0 - self.alpha)) * torch.log (s + eps)
@torch.inference_mode() def forward(self, attn_weights, num_retained_blocks): """[B, H_Q, T] -> bool mask [B, H_KV, num_blocks].""" Bsz, H_Q, T = attn_weights.shape sink_mask = torch.zeros( T, dtype=torch.bool, device=attn_weights.device)
42 sink_mask[:min(self.sink_size, T)] = True
43 attn_nonsink = attn_weights.masked_fill(
44 sink_mask.unsqueeze(0).unsqueeze(0), 0.0)
45 attn_nonsink = attn_nonsink / attn_nonsink.
sum(
46 dim=-1, keepdim=True).clamp(min=1e-12)
47 ent = self.renyi_entropy(attn_nonsink)
48 grouped = attn_weights.view(
49 Bsz, self.num_kv_heads, self.group_size,
T)
50 ent_g = ent.view(Bsz, self.num_kv_heads,
51 self.group_size)
52 weights = F.softmax(-ent_g / self.tau_g,
53 dim=-1).unsqueeze(-1)
54 pooled = (weights * grouped).sum(dim=2)
55 pad = (self.block_size - T % self.block_size)
56 % self.block_size
57 if pad:
58 pooled = F.pad(pooled, (0, pad))
59 nb = pooled.shape[-1] // self.block_size
60 pages = pooled.view(
61 Bsz, self.num_kv_heads, nb,
62 self.block_size).max(dim=-1).values
63 idx = torch.topk(pages, num_retained_blocks,
64 dim=-1).indices
65 mask = torch.zeros_like(pages, dtype=torch.
66 bool)
66 mask.scatter_(-1, idx, True)
67 return mask
Listing 1: PyTorch reference implementation of the Page-EntroKV engine, with sink-isolated entropy weighting.
References
[1] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, I. Polosukhin, Attention is all you need, in: Advances in Neural Information Processing Systems, 2017.
[2] N. Shazeer, Fast transformer decoding: One write-head is all you need, arXiv preprint arXiv:1911.02150 (2019).
[3] J. Ainslie, J. Lee-Thorp, M. de Jong, Y. Zemlyanskiy, F. Lebrón, S. Sanghai, GQA: Training generalized multi-query transformer models from multi-head checkpoints, in: Proceedings of EMNLP, 2023.
[4] A. Dubey, A. Jauhri, A. Pandey, et al., The Llama 3 herd of models, arXiv preprint arXiv:2407.21783 (2024).
[5] A. Yang, B. Yang, B. Zhang, et al., Qwen2.5 technical report, arXiv preprint arXiv:2412.15115 (2024).
[6] A. Q. Jiang, A. Sablayrolles, A. Mensch, et al., Mistral 7B, arXiv preprint arXiv:2310.06825 (2023).
[7] W. Kwon, Z. Li, S. Zhuang, Y. Sheng, L. Zheng, C. H. Yu, J. E. Gonzalez, H. Zhang, I. Stoica, Efficient memory management for large language model serving with Paged Attention, in: Proceedings of SOSP, 2023.
[8] G.-I. Yu, J. S. Jeong, G.-W. Kim, et al., Orca: A distributed serving System for transformer-based generative models, in: Proceedings of USENIX OSDI, 2022.
[9] R. Pope, S. Douglas, A. Chowdhery, et al., Efficiently scaling transformer inference, in: Proceedings of Machine Learning and Systems (MLSys), 2022.
[10] Z. Zhang, Y. Sheng, T. Zhou, et al., H2O: Heavy-hitter oracle for efficient generative inference of large language models, in: Advances in Neural Information Processing Systems, 2023.
[11] Y. Li, Z. Huang, et al., SnapKV: LLM knows what you are looking for before generation, arXiv preprint arXiv:2404.14469 (2024).
[12] Z. Liu, A. Desai, F. Liao, et al., Scissorhands: Exploiting the persistence of importance hypothesis for LLM KV cache compression at test time, in: Advances in Neural Information Processing Systems, 2023.
[13] G. Xiao, Y. Tian, B. Chen, S. Han, M. Lewis, Efficient streaming language models with attention sinks, in: International Conference on Learning Representations (ICLR), 2024.
[14] S. Ge, et al., Model tells you what to discard: Adaptive KV cache compression for large language models, in: International Conference on Learning Representations (ICLR), 2024.
[15] Z. Cai, Y. Zhang, B. Gao, et al., PyramidKV: Dynamic KV cache compression based on pyramidal information funneling, arXiv preprint arXiv:2406.02069 (2024).
[16] J. Tang, Y. Yang, J. Lin, et al., Quest: Query-aware sparsity for efficient long-context LLM inference, in: International Conference on Learning Representations (ICLR), 2025.
[17] Y. Feng, et al., Ada-KV: Optimizing KV cache eviction via adaptive budget allocation for grouped-query attention, arXiv preprint arXiv:2407.11550 (2024).
[18] EntroKV: Entropy-guided dynamic budget allocation for KV-cache compression, under review (2025).
[19] G. Xiao, Y. Tian, B. Chen, S. Han, M. Lewis, DuoAttention: Efficient long-context LLM inference with retrieval and streaming heads, in: Advances in Neural Information Processing Systems, 2024.
[20] Y. Yang, Z. Liu, C. Wang, C. Deng, M. Zhang, K. Zhao, X. Zheng, W. Zhang, Y. Gao, B. C. Ooi, Z. Zhang, N. V. Chawla, ThinK: Thin Kertia for Faster KV Cache Compression in Large Language Models, in: Proceedings of ACL, 2024.
[21] C. Liu, Y. Shen, H. Yin, L. Liu, KIVI: A tuning-free asymmetric 2-bit quantization for KV cache, in: Advances in Neural Information Processing Systems, 2024.
[22] S. Ashkboos, A. Mohtashami, M. L. Croci, B. Li, P. K. Aithal, M. Jaggi, D. Alistarh, T. Pethick, M. E. Peters, QuaRot: Outlier-free 4-bit inference in rotated large language models, in: Advances in Neural Information Processing Systems, 2024.
[23] C. Xiao, P. Zhang, X. Han, G. Xiao, Y. Lin, Z. Zhang, Z. Liu, S. He, W. Han, S. Tang, B. He, Q. Zhu, X. Zhang, M. Sun, InfLLM: Training-free long-context extrapolation for LLMs with an efficient context memory, arXiv preprint arXiv:2402.04617 (2024).
[24] W. Wu, Y. Wang, G. Xiao, H. Peng, S. Han, Retrieval head mechanistically explains long-context factuality, arXiv preprint arXiv:2404.15574 (2024).
[25] P. Michel, O. Levy, G. Neubig, Are sixteen heads really better than one?, in: Advances in Neural Information Processing Systems, 2019.
[26] E. Voita, D. Talbot, F. Moiseev, R. Sennrich, I. Titov, Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned, in: Proceedings of ACL, 2019.
[27] T. Dao, D. Y. Fu, S. Ermon, A. Rudra, C. Ré, FlashAttention: Fast and memory-efficient exact attention with IO-awareness, in: Advances in Neural Information Processing Systems, 2022.
[28] T. Dao, FlashAttention-2: Faster attention with better parallelism and work partitioning, arXiv preprint arXiv:2307.08691 (2023).
[29] Y. Bai, X. Yuan, J. Chang, et al., LongBench: A bilingual, multitask benchmark for long context understanding, arXiv preprint arXiv:2308.14508 (2023).
[30] C.-P. Hsieh, S. Sun, S. Kriman, et al., RULER: What's the real context size of your long-context language models?, arXiv preprint arXiv:2404.06654 (2024).
[31] N. F. Liu, K. Lin, J. Hewitt, A. Paranjape, M. Bevilacqua, F. Petroni, P. Liang, Lost in the middle: How language models use long contexts, Transactions of the Association for Computational Linguistics (2024).
[32] DeepSeek-AI, DeepSeek-V2: A strong, economical, and efficient mixture-of-experts language model, arXiv preprint arXiv:2405.04434 (2024).