TriAttention: Efficient Long Reasoning with Trigonometric KV Compression
Paper β’ 2604.04921 β’ Published β’ 112
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Author: C. Keasey | Affiliation: CKZ Data Labs Ltd
Paper: paper.md β Full research paper with analysis
Code: All compressors (PyTorch + MLX), evaluation suite, and raw results
All spectral pruning methods: 50.3 β 7.1 MB (7.1Γ compression, 86% saved)
TurboQuant-4bit: 1.0Γ (no savings in simulated-dequant mode)
| Method | AOP_mean | AOP_max | Rank |
|---|---|---|---|
| WaveletKV | 0.484 | 3.278 | 1 |
| WaveletTriAttn | 0.515 | 3.346 | 2 |
| WaveletFourierKV | 0.556 | 3.711 | 3 |
| FourierKV | 0.563 | 3.814 | 4 |
| TriAttentionKV | 0.579 | 3.698 | 5 |
| TurboQuant-4bit | 0.592 | 3.581 | 6 |
| Method | PPL_comp | ND-PPL | Rank |
|---|---|---|---|
| TurboQuant-4bit | 1.09 | +0.079 | 1 |
| WaveletTriAttn | 3.37 | +2.353 | 2 |
| TriAttentionKV | 4.45 | +3.421 | 3 |
| WaveletKV | 4.99 | +3.960 | 4 |
| WaveletFourierKV | 5.20 | +4.172 | 5 |
| FourierKV | 5.65 | +4.613 | 6 |
| Method | T1 AOP | T5 AOP | Drift | Profile |
|---|---|---|---|---|
| WaveletKV | 3.10 | 3.24 | +0.14 | Stable |
| WaveletTriAttn | 3.60 | 3.65 | +0.05 | Stable |
| TriAttentionKV | 3.35 | 3.41 | +0.06 | Stable |
| FourierKV | 3.54 | 3.91 | +0.37 | Increasing |
| WaveletFourierKV | 4.50 | 4.06 | β0.44 | Self-correcting |
| Method | Tok/s | Speedup | Token Match% |
|---|---|---|---|
| FourierKV | 33.2 | 1.07Γ | 3.1% |
| WaveletKV | 33.2 | 1.00Γ | 6.2% |
| WaveletFourierKV | 32.4 | 0.98Γ | 3.1% |
| WaveletTriAttn | 33.1 | 0.99Γ | 1.5% |
| TriAttentionKV | 33.0 | 1.03Γ | 3.1% |
| TurboQuant-4bit | 26.3 | 0.80Γ | 1.5% |
spectral_kv/
βββ __init__.py
βββ compressors.py # PyTorch/CUDA (FourierKV, WaveletKV, WaveletFourierKV, etc.)
βββ compressors_mlx.py # MLX for Apple Silicon
βββ metrics.py # AOP, spectral fidelity, reconstruction metrics
βββ benchmark.py # Synthetic + real model benchmark
βββ eval_comprehensive.py # Full 4-phase evaluation suite
results/
βββ eval_v3.json # Raw results from comprehensive evaluation
βββ benchmark_results.json # Synthetic benchmark results
paper.md # Full research paper
pip install torch transformers accelerate PyWavelets scipy tabulate
# Run comprehensive evaluation
python -m spectral_kv.eval_comprehensive
# Run synthetic benchmark
python -m spectral_kv.benchmark
Apache 2.0