Rotated Tucker residual for outlier-resistant KV quantization
Implementation & benchmark of arXiv:2607.12550 — A JoLT for the KV cache: Near-lossless KV cache compression via joint Lagrangian allocation of Tucker ranks and a rotated residual for llms
Source paper: A JoLT for the KV cache: Near-lossless KV cache compression via joint Lagrangian allocation of Tucker ranks and a rotated residual for llms arXiv:2607.12550 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Use a low-rank Tucker reconstruction as a structured backbone and quantize only its residual after an orthogonal rotation. The rotation preserves residual energy but redistributes it across coordinates, reducing dynamic-range imbalance and making 2- or 4-bit uniform quantization less damaging than direct quantization of the original KV tensor.
Formulas
Mathematical statement
Let X be a layer's token-feature cache slice, ilde{X}(r_T,r_d) its partial Tucker reconstruction, and R=X- ilde{X} the discarded energy. Let Q be an orthogonal matrix or fast orthogonal transform satisfying Q^TQ=I, so Frobenius energy is preserved: ||QR||_F=||R||_F. For b in {2,4,8}, define Y=QR and quantize each block with symmetric uniform quantization Q_b(Y)=s clip(round(Y/s), -2^{b-1}, 2^{b-1}-1), where s=max_i|Y_i|/(2^{b-1}-1) is the block scale. Decode with \hat{X}= ilde{X}+Q^TQ_b(QR). The rotation cannot reduce the residual's Frobenius norm; its intended benefit is reducing coordinate outliers and block dynamic range, which lowers uniform-quantization error. For b=0, no residual is stored and \hat{X}= ilde{X}.
Implementation notes
Integrate this into the KV-cache write path for every layer and separately for K and V. Maintain Tucker factors for the selected backbone, compute the reconstructed block X_tilde, and form R=X-X_tilde for each incoming token block. Use a fixed fast orthogonal transform on the residual feature dimension: a normalized Hadamard transform is suitable when the feature width is a power of two, while a randomized orthogonal matrix can be used for an offline prototype. Partition the rotated residual into blocks of 64 or 128 values. For each block, compute s=max(abs(Y))/(2^(b-1)-1), store the scale s and integer codes clip(round(Y/s), -2^(b-1), 2^(b-1)-1). Decode by multiplying codes by s, applying the inverse orthogonal transform, and adding X_tilde. For b=0, skip residual storage and return only the Tucker reconstruction. Log block maxima, scale variance, residual MSE, and attention-output error before and after rotation; norm preservation is guaranteed mathematically, whereas quantization improvement must be measured. Start with a small one-layer test and then full Mistral-7B inference at equal residual bit-width and equal total bytes. Compare direct residual quantization, rotated residual quantization, direct 4-bit KV, and FP16 KV on perplexity, long-context retrieval, decode throughput, transform overhead, and peak memory. Success is lower cache reconstruction error and smaller perplexity degradation at 2- or 4-bit residual precision without making the transform bandwidth dominate attention.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
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 8/10
Built and numerically verified a rotated Tucker-residual quantization MVP. Frobenius norm preservation and the predicted Hadamard outlier-spreading law matched numerical results, while the toy benchmark showed a substantial 4-bit improvement but a 2-bit regression. The mechanism is real but conditional, so this does not establish a universal low-bit KV-cache win.
- Agent confidence
- 8/10
- Baseline
- Direct residual quantization relative MSE: 0.09237 at 2 bits, 0.01772 at 4 bits, and 5.44e-5 at 8 bits; max/RMS 18.10 and scale CV 1.185.
- Idea
- Rotated residual quantization relative MSE: 0.13435 at 2 bits, 0.002398 at 4 bits, and 7.38e-6 at 8 bits; max/RMS 6.50 and scale CV 0.579. Norm ratio was 1.0 to numerical precision across widths 8–64.
Limitations: This is a NumPy toy experiment with an SVD matrix low-rank backbone rather than full Tucker factors or a transformer KV cache. It does not test perplexity, attention-output error, throughput, memory, transform overhead, varying block sizes, randomized rotations, or end-to-end inference.
How to run: python3 rotated_tucker_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.12550)
No significant difference vs. the tuned baseline (+1.7%, p=0.309, wins 4 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.3801
- Idea mean
- 0.3865
- Effect (Δ)
- 0.0064 (+1.7%; negative = idea better)
- Wins
- 4 / 8 paired seeds
- p-value
- 0.309 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±3.0%
- Mechanism
- Not confirmed ✗
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
The benchmark is a small sequence-forecast transfer test rather than end-to-end transformer KV-cache inference. The backbone is a fixed low-rank projection rather than learned full Tucker factors. Perplexity, attention-output error, throughput, memory, block-size sensitivity, and larger pretrained models were not tested.
How to run: python3 rotated_tucker_bench.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
The matched sequence benchmark used the registered sequence track and canonical transformer_tiny architecture, with direct 4-bit residual quantization as baseline and Hadamard-rotated 4-bit residual quantization as the only intervention. The idea was slightly worse on test MSE (delta +0.006388) with permutation p=0.30895, so it does not meet the required significant-win criterion. Energy preservation held, but the trained-model mechanism signature was not confirmed because rotated peak/RMS increased rather than decreased.
- Baseline
- Best baseline lr=0.001; 8-seed test MSE mean 0.3800644465, std 0.0460539373.
- Idea
- Best idea lr=0.001; 8-seed test MSE mean 0.3864529058, std 0.0395443003; paired delta +0.0063884594; 4/8 paired wins; permutation p=0.30895.
Benchmark result
No significant difference vs. the tuned baseline (+1.7%, p=0.309, wins 4 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.3801
- Idea mean
- 0.3865
- Effect (Δ)
- 0.0064 (+1.7%; negative = idea better)
- Wins
- 4 / 8 paired seeds
- p-value
- 0.309 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±3.0%
- Mechanism
- Not confirmed ✗
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
The benchmark is a small sequence-forecast transfer test rather than end-to-end transformer KV-cache inference. The backbone is a fixed low-rank projection rather than learned full Tucker factors. Perplexity, attention-output error, throughput, memory, block-size sensitivity, and larger pretrained models were not tested.
How to run: python3 rotated_tucker_bench.py
Artifacts
- REPORT.md 1.9 KB View
- bench_report.json 4.2 KB View Raw
- report.md 1.4 KB View
- report_bench_2026-08-31T012811.md 5.2 KB View
- results.json 275.2 KB View Raw
- rotated_tucker_bench.py 6.0 KB View Raw
- rotated_tucker_experiment.py 5.6 KB View Raw