Audited (legacy) 2026

Entropy-Budgeted Contiguous KV Pooling

Implementation & benchmark of arXiv:2608.25533 — Constrained Maximum Entropy Contiguous Aggregations

Usefulness6/10
Difficulty5/10
Novelty7/10

Source paper: Constrained Maximum Entropy Contiguous Aggregations arXiv:2608.25533 ⓘ · analyzed Aug 29, 2026

AI-generated research hypothesis, automatically tested. Not peer-reviewed.

Idea description

Use the attention probability distribution over an ordered context to choose contiguous token groups whose pooled attention masses have entropy as close as possible to a prescribed upper budget R. Replace the corresponding key/value vectors by one weighted representative per group, preserving token order and reducing the KV-cache length from n to m. Unlike unconstrained token merging, the entropy constraint gives a direct control knob over how concentrated or diffuse the retained attention allocation may be.

Formulas

$$\max_{q\in CA(p)} H(q)\quad\text{subject to}\quad H(q)\le R.$$
$$q_k=\sum_{i=b_{k-1}+1}^{b_k}p_i,\qquad 0=b_0<b_1<\cdots<b_m=n.$$
$$H(q)=-\sum_{k=1}^{m}q_k\log_2 q_k,$$
$$\Delta(a,b)=h(a)+h(b)-h(a+b),\qquad h(x)=-x\log_2 x,\qquad H(\text{after merge})=H(\text{before merge})-\Delta(a,b).$$

Mathematical statement

The paper defines a probability vector p=(p_1,...,p_n), where p_i>=0 and sum_i p_i=1, and a contiguous aggregation q=(q_1,...,q_m) induced by boundaries 0=b_0<b_1<...<b_m=n: q_k=sum_{i=b_{k-1}+1}^{b_k}p_i. Its optimization problem is max_{q in CA(p)} H(q) subject to H(q)<=R, with Shannon entropy H(q)=-sum_{k=1}^m q_k log_2(q_k), using 0 log 0=0. A merge of adjacent masses a and b changes entropy by Delta(a,b)=h(a)+h(b)-h(a+b), where h(x)=-x log_2 x; because merging categories cannot increase entropy, each contiguous merge has Delta(a,b)>=0. The paper reports that one efficient approximation has objective error at most h(p^downarrow_{floor(2^R)+1}), where p^downarrow_j is the j-th largest entry of p and h is binary entropy. We use this bound as a conservative diagnostic when the attention distribution has a small tail beyond the effective budget 2^R.

Implementation notes

Integrate this at transformer inference between attention-score computation and KV-cache insertion. For a query or a small group of queries, compute attention probabilities p over the n context positions. Choose a target number of retained groups m and an entropy ceiling R. Each group is a contiguous interval; replace its keys and values by K'_k=(sum_{i in group k} p_i K_i)/(q_k+epsilon) and V'_k=(sum_{i in group k} p_i V_i)/(q_k+epsilon), while storing q_k and the interval boundaries. For an exact small-model prototype, enumerate all boundary tuples b_1,...,b_{m-1}, compute q and H(q), discard partitions with H(q)>R, and select the feasible partition with largest H(q). This costs O(C(n-1,m-1)nm) and is suitable for n<=32. For the scalable version, initialize singleton blocks and perform n-m adjacent merges. At each step calculate Delta for every neighboring pair, tentatively apply each candidate, and retain the merge producing the largest final entropy among candidates satisfying H<=R; use a two-step lookahead when the immediate merge overshoots the budget. Cache partitions at chunk boundaries or compute them from averaged attention over heads to amortize overhead. The formulas above are computed exactly; the only empirical choices are m, R, whether p is per-head or averaged, and whether K/V pooling uses attention weights or uniform weights. First test on a 1-2B decoder on WikiText-103 or C4 with context length 2048, comparing full KV attention, uniform contiguous pooling, and a standard heuristic such as importance-based eviction. Sweep m in {256,512,1024} and R in {log2(m)/2, log2(m)*0.75, log2(m)}. Measure perplexity at equal retained-cache size, attention-output cosine error, decode throughput, and peak KV memory. Success is at least 1.5x decode speed or 2x lower KV memory at a fixed perplexity degradation, with the entropy-bound diagnostic correlating with the observed error.

Verification

Audited (legacy)

Stage 1 · Toy mechanism gate: Passed ✓

Stage 2 · Mechanism transferred to benchmark: Not tested

Stage 2 · Practical benchmark result: Not run

Methodology: Toy-system gate first; the benchmark stage runs only after a pass. How verification works

Stage 1 — Mechanism check agent confidence 7/10

Built an exact contiguous entropy-constrained KV pooling prototype with attention-mass-weighted K/V representatives and stored log-mass priors. The merge identity held to 4.9e-17 numerical error, all 40 tail-bound diagnostics passed, and entropy pooling reduced mean cosine error from 0.2024 to 0.0723 versus uniform pooling at the same 16-to-6 cache reduction. This is a promising accuracy signal, but exact partition search is too slow for deployment and throughput was not directly measured.

Agent confidence
7/10
Baseline
Uniform contiguous pooling: mean cosine error 0.2024, p95 0.2881, theoretical cache/score reduction 2.67x, partition overhead 0.0035 s over 30 trials.
Idea
Entropy-constrained exact pooling: mean cosine error 0.0723, p95 0.1288, mean pooled entropy 2.5021 bits under R=3.0, theoretical cache/score reduction 2.67x, partition overhead 8.53 s over 30 trials; merge identity error 4.9e-17 and 0/40 tail-bound diagnostic violations.

Limitations: Only synthetic single-query attention was tested with n=16, d=24, m=6 and 30 trials. No real transformer, language-model perplexity, multi-head attention, long-context setting, memory measurement, or end-to-end decode throughput was measured; exact enumeration is exponential and unsuitable beyond small n, although a basic greedy merge implementation is included.

How to run: python3 entropy_kv_pooling.py

Verdict computed by deterministic test code from paired-seed statistics — not by the language model.

Super-audit (legacy) latest Failed ✗

Agent confidence: 9/10

Implemented and reproduced approximate entropy-budgeted contiguous KV pooling on harder structured synthetic attention at lengths 64 and 128 across three seeds, comparing uniform, importance, greedy, beam, and exact search. Greedy and beam substantially reduced cosine error versus uniform, but partition selection was hundreds to thousands of times slower than uniform, so the required wall-clock win did not survive; the practical hypothesis is rejected despite the accuracy signal.

Baseline
Uniform: n=64 cosine error 0.158384 +/- 0.051156, partition time 0.000187 +/- 0.000039 s; n=128 error 0.048425 +/- 0.006115, time 0.000273 +/- 0.000032 s. Importance: n=64 error 0.107697 +/- 0.061573, time 0.000130 +/- 0.000011 s; n=128 error 0.040708 +/- 0.002265, time 0.000134 +/- 0.000002 s.
Idea
Greedy: n=64 cosine error 0.054634 +/- 0.012803, entropy 2.806552 +/- 0.037914 bits, time 0.134166 +/- 0.001059 s; n=128 error 0.009474 +/- 0.003177, entropy 3.453509 +/- 0.041296 bits, time 0.567790 +/- 0.030087 s. Beam width 8: n=64 error 0.043694 +/- 0.006782, time 0.730875 +/- 0.024464 s; n=128 error 0.009851 +/- 0.003152, time 3.898725 +/- 0.240105 s. Retained fraction was 25%, giving a 4x attention-cost proxy reduction. Exact n=16 ablation error was 0.030703 +/- 0.028712 at 0.211628 +/- 0.014475 s.
Seeds
3, 17, 29; means and sample standard deviations over three seeds
Limitations:

Only structured synthetic attention was used; no pretrained transformer, language-model perplexity, real text dataset, GPU decode throughput, peak VRAM, or end-to-end cache benchmark was tested. Exact search remains exponential, while approximate methods were evaluated as CPU partition-selection prototypes.

How to run: python3 supercheck.py

Artifacts

Implementation overview ⬇ Download all as ZIP 7 files · code, reports and structured results