△ Mechanism confirmed, baseline not beaten 2026

Rate-adaptive KV-cache quantizer

Implementation & benchmark of arXiv:2608.18147 — Entropy-Constrained Adaptive Stochastic Quantization

Usefulness8/10
Difficulty6/10
Novelty7/10

Source paper: Entropy-Constrained Adaptive Stochastic Quantization arXiv:2608.18147 ⓘ · analyzed Sep 1, 2026

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

Idea description

Allocate different entropy budgets to different KV-cache blocks instead of assigning every token and head the same nominal bitwidth. Use the ECASQ Lagrangian so high-variance or attention-sensitive blocks receive more codepoints, while predictable blocks collapse to fewer symbols and become highly compressible. Preserve unbiasedness per scalar or block so reconstructed keys and values have zero mean quantization error conditional on the original tensor.

Formulas

$$\min_{\{Q_r\}}\sum_{r=1}^{R}D_r\quad\text{subject to}\quad \sum_{r=1}^{R}d_rH_r\le B,\qquad |Q_r|\le s_r,\qquad \mathbb{E}[\widehat X^{(r)}]=X^{(r)}.$$
$$\mathcal{L}(\{Q_r\};\lambda)=\sum_{r=1}^{R}\left[D_r(Q_r)+\lambda d_rH_r(Q_r)\right]-\lambda B.$$
$$\Pr(\widehat x=q_i\mid x)=\frac{q_{i+1}-x}{q_{i+1}-q_i},\quad \Pr(\widehat x=q_{i+1}\mid x)=\frac{x-q_i}{q_{i+1}-q_i},\quad D_r=\sum_{t\in r}(q_{i(t)+1}-x_t)(x_t-q_{i(t)}).$$
$$\lambda\leftarrow\max\left\{0,\lambda+\eta\left(\sum_{r=1}^{R}d_rH_r-B\right)\right\}.$$

Mathematical statement

For cache block r containing X^(r) of length d_r, ECASQ selects Q_r subject to |Q_r|<=s_r, entropy H_r<=b_r, and E[hat X^(r)]=X^(r), minimizing distortion D_r. With a global budget B, the allocation problem is minimize sum_r D_r subject to sum_r d_r H_r<=B. Introducing lambda>=0 yields independent block objectives D_r+lambda*d_r*H_r; this dual separability permits blockwise codebook selection coupled only through lambda. For an interval [q_i,q_{i+1}], unbiased stochastic interpolation has probabilities (q_{i+1}-x)/(q_{i+1}-q_i) and (x-q_i)/(q_{i+1}-q_i), conditional MSE (q_{i+1}-x)(x-q_i), and conditional mean x. Block entropy is H_r=-sum_j pi_{r,j}log_2(pi_{r,j}), with pi_{r,j} the expected frequency of codepoint q_{r,j}. The dual variable can be updated by subgradient ascent when the estimated total rate exceeds B. The paper's approximate dynamic program uses O(s d^2) time and O(d) space and provides an MSE guarantee relative to the optimum using one fewer entropy bit per entry; in this adaptation it is run independently on cache blocks.

Implementation notes

Integrate this into autoregressive Transformer inference immediately after producing each layer's K and V tensors and before writing them to the KV cache. Partition the cache into blocks, such as one block per attention head per 32 tokens, or one block per head and feature group. When a block is ready, build a candidate alphabet from its minimum, maximum, and quantiles, and evaluate codebooks with k<=s using unbiased interpolation. For every candidate Q_r, compute D_r from interval statistics and H_r from expected symbol frequencies pi_{r,j}; avoid estimating entropy from a single random realization because that introduces avoidable rate noise. Maintain one global dual variable lambda. For each block choose argmin_Q[D_r+lambda*d_r*H_r], using a small dynamic program or beam search over ordered codepoints. Every N generated tokens, update lambda=max(0,lambda+eta(R-B)), where R=sum_r d_r H_r is estimated new-cache rate and B is the target number of bits for those entries. Store the codebook, symbol stream, and block lengths, and use arithmetic coding across adjacent blocks when metadata overhead is small. Decode before attention. The mathematical pieces are the constrained objective, dual decomposition, entropy calculation, and unbiased interpolation; block shape, candidate generation, and step size eta are empirical choices. Optionally weight D_r by attention sensitivity measured on a calibration batch, but first test unweighted distortion. Use a 1-3B decoder on WikiText or LongBench at 4K-16K contexts. Compare uniform INT4, uniform stochastic quantization, and fixed-rate entropy coding at equal total cache bytes. Record perplexity or task score, bytes per token, attention latency, and lambda convergence. Success is 25-40% KV-memory reduction with no more than 0.2 perplexity degradation, or equal memory with improved long-context accuracy.

Verification

Mechanism confirmed, baseline not beaten

Stage 1 · Toy mechanism gate: Passed ✓

Stage 2 · Mechanism transferred to benchmark: Confirmed ✓

Stage 2 · Practical benchmark result: Inconclusive

Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works

Stage 1 — Mechanism check agent confidence 9/10

Built an ECASQ-style rate-adaptive block quantizer with unbiased stochastic interpolation, expected entropy estimation, dual-selection sweeps, and a matched toy comparison. The mechanism manifested: conditional mean error was 8.9e-16, distortion scaled as (k-1)^-2 with observed slope -2.000 versus predicted -2, and all eight observed lambda transitions matched analytically predicted crossings within about 5%. At a feasible lower rate, adaptive allocation used 2 levels for the low-variance block and 6 for the high-variance block, reducing distortion 40.6% versus uniform 4-level quantization.

Agent confidence
9/10
Baseline
Uniform 4-level codebooks: distortion sum 0.685014 at expected rate 3.836925 bits per scalar pair.
Idea
Adaptive codebooks: distortion sum 0.406565 at expected rate 3.522128 bits per scalar pair; levels [2, 6] for low/high variance blocks, 40.65% lower distortion and 0.3148 fewer bits per scalar pair.
Math checks
Unbiasedness max absolute error 8.88e-16; distortion log-log slope -1.99999999 predicted -2; coefficient 0.166650 predicted 0.166667; allocation rate monotonically decreased with lambda.

Limitations: Only a deterministic two-block toy experiment was tested; no Transformer KV-cache integration, real language-model perplexity, attention sensitivity weighting, arithmetic coding, metadata overhead, GPU benchmark, or end-to-end latency measurement was evaluated. The candidate codebooks are simple equally spaced min/max alphabets rather than the paper's full dynamic program, and the matched comparison allows the adaptive method to use slightly fewer bits than the uniform baseline.

How to run: python3 rate_adaptive_kv.py > results.json && cat results.json

Stage 2 — Benchmark vs. tuned baseline (arXiv:2608.18147)

Ahead of the baseline (−2.0%) but not statistically significant (p=0.0653, wins 7 / 8 paired seeds).

Benchmark
Sequence modeling
Model
transformer_tiny
Paired seeds
8
Baseline mean
0.192
Idea mean
0.1881
Effect (Δ)
-0.0039 (−2.0%; negative = idea better)
Wins
7 / 8 paired seeds
p-value
0.0653 (permutation test, 20 000 shuffles)
Smallest detectable effect
±2.2%
Mechanism
Confirmed ✓
Practical effect
Inconclusive
Baseline tuning
swept over 3 configs
Limitations:

No real pretrained autoregressive language model, long-context perplexity, arithmetic coding, cache-memory byte accounting, or attention-latency benchmark was tested. The built-in sequence regression track was used as the structurally matched proxy, with reduced dataset size and 8 training epochs.

How to run: python3 bench_rate_adaptive.py

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

Stage 2 — Benchmark latest Failed ✗

Agent confidence: 9/10

Implemented a matched sequence-track transformer benchmark with stochastic per-head, per-token-block K/V quantization for the idea and the same unquantized architecture for baseline. The idea reduced test MSE by 2.05% and won 7/8 paired seeds, but permutation p=0.06525, so it did not meet the required significant-win criterion. The trained-model mechanism signature was not confirmed quantitatively because all blocks received the same level assignment and variance-to-level correlation was 0.

Baseline
8-seed mean MSE 0.1920112893; best lr=0.001.
Idea
8-seed mean MSE 0.1880817395; best lr=0.001, threshold=0.25; delta=-0.0039295498, 7/8 wins, p=0.06525.
Mechanism
Observed rate 1.547369 bits, high-block fraction 1.0, variance-level correlation 0.0, quantization MSE 0.176437; adaptive allocation prediction not confirmed.

Benchmark result

Ahead of the baseline (−2.0%) but not statistically significant (p=0.0653, wins 7 / 8 paired seeds).

Benchmark
Sequence modeling
Model
transformer_tiny
Paired seeds
8
Baseline mean
0.192
Idea mean
0.1881
Effect (Δ)
-0.0039 (−2.0%; negative = idea better)
Wins
7 / 8 paired seeds
p-value
0.0653 (permutation test, 20 000 shuffles)
Smallest detectable effect
±2.2%
Mechanism
Confirmed ✓
Practical effect
Inconclusive
Baseline tuning
swept over 3 configs
Limitations:

No real pretrained autoregressive language model, long-context perplexity, arithmetic coding, cache-memory byte accounting, or attention-latency benchmark was tested. The built-in sequence regression track was used as the structurally matched proxy, with reduced dataset size and 8 training epochs.

How to run: python3 bench_rate_adaptive.py

Artifacts

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