RACE: RoPE-Aligned Attention Compression Based on Query-Key Activation Energies
Organizations: MIT CSAIL · MIT-IBM Computing Research Lab
Abstract
Head-dimension compression can reduce the memory required by the key-value (KV) cache, but existing methods often reconstruct full-dimensional representations during inference, adding significant decoding FLOPs overhead. We formalize the design considerations for converting pretrained attention into a natively reduced-dimensional form that reduces both KV-cache storage and attention computation using a calibration set. Specifically, we consider reductions that (1) apply a shared projection to queries and keys so that they remain in a common reduced feature space, (2) derive this projection jointly from query and key activations to better preserve their interaction, and (3) are compatible with the pretrained RoPE transformation. To obtain a reconstruction-free realization of this reduction, we restrict it to coordinate selection and theoretically show that RoPE compatibility then holds if and only if complete rotary pairs are retained. Building on this characterization, we introduce RACE, a post-training method that selects rotary pairs using their joint query-key activation energy. We theoretically show that this criterion minimizes a separable, calibration-dependent upper bound on post-RoPE query-key product approximation error. The resulting reductions are folded into the model weights and require neither runtime reconstruction nor specialized kernels. Across three model families and different compression levels, RACE outperforms structured pruning and remains competitive with reconstruction-based methods on language-modeling, zero-shot, and long-context tasks. At 50% KV-cache retention and 256K context, RACE reduces total inference FLOPs by 47.8%, yielding 1.79x higher throughput, 43.2% lower time-to-first-token (TTFT), and 28.1% lower allocated GPU memory in comparison to an uncompressed model.
Figures & tables
| Excecution | Q/K Reduction Criterion | Efficiency | ||||||||
| Method | Reconst- ruction free | Custom- Kernel free | Fwd.-only Calibration | Shared Q/K Map | Joint Q/K Signal | Native RoPE | KV Cache Retained | Attn. Params Retained | Prefill FLOPs | Decode FLOPs |
| Attention ( Vaswani et al., 2017 ) | - | - | - | - | - | - | 100% | 100% | 1 | 1 |
| EigenAttention ( Saxena et al., 2024 ) | ✗ | ✓ | ✓ | ✗ | ✓ | ✗ | 50% | 69.8% | 0.75 | 11.42 |
| PALU ( Chang et al., 2025 ) | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | 50% | 58.3% | 0.75 | 21.92 |
| Thin Keys ( Yao et al., 2026 ) | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | 75% | 50% | 0.75 | 0.75 |
| RAP ( Xin et al., 2026 ) | ✓ | ✓ | ✗ | ✓ | ✗ | ✓ | 50% | 50% | 0.5 | 0.5 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Total Inference TFLOPs | TTFT (ms) | Prefill T.put (tok/sec) | Decode T.put (tok/sec) | Total T.put (tok/sec) | GPU Memory (GB) | |
| Eager | 3.973 | 41.051 | 13937 | 45.186 | 224.44 | 5.884 |
| SDPA | 3.973 | 28.854 | 17755.36 | 56.864 | 282.904 | 5.882 |
| Flash Attention 3 | 3.973 | 34.170 | 15054 | 46.23 | 230.127 | 5.882 |
| Completion | Reasoning | Knowledge QA | Understanding | Truth | Specialized Knowledge | |||||||||||||||
| Method | KV Cache | QK Dim. | V Dim. | Wiki (ppl) | lambada | hella | piqa | wino | arc_e | sciq | obqa | arc_c | boolq | race | truth fulqa | college _CS | college_ Phy | prof _law | HS_ psych | Avg |
| Qwen2.5 7B | ||||||||||||||||||||
| Base | 100% | 128 | 128 | 10.976 | 0.706 | 0.795 | 0.784 | 0.707 | 0.759 | 0.960 | 0.460 | 0.495 | 0.845 | 0.418 | 0.524 | 0.700 | 0.480 | 0.529 | 0.897 | 0.671 |
| 87.50% | 112 | 112 | 11.438 | 0.696 | 0.791 | 0.771 | 0.703 | 0.772 | 0.954 | 0.456 | 0.504 | 0.839 | 0.421 | 0.457 | 0.710 | 0.500 | 0.511 | 0.881 | 0.664 | |
| 87.50% | 96 | 128 | 11.080 | 0.693 | 0.797 | 0.780 | 0.711 | 0.782 | 0.956 | 0.462 | 0.514 | 0.844 | 0.414 | 0.516 | 0.700 | 0.490 | 0.512 | 0.883 | 0.670 | |
| 75% | 96 | 96 | 12.290 | 0.687 | 0.782 | 0.756 | 0.703 | 0.777 | 0.953 | 0.460 | 0.508 | 0.838 | 0.414 | 0.411 | 0.660 | 0.451 | 0.486 | 0.868 | 0.650 | |
| KV Cache Retained | Narrative QA | Qasper | Multifield QA | Hotpot QA | Wikimqa | Musique | gov_report | qmsum | multi_news | trec | triviaqa | samsum | passage _count | passage_ retrieval_en | lcc | repobench | Average | |
| Llama3.2 3B Instruct. | ||||||||||||||||||
| Uncompressed | 100% | 21.25 | 39.89 | 50.06 | 47.31 | 36.75 | 19.15 | 33.91 | 23.5 | 26.64 | 71 | 88.41 | 42.62 | 8.5 | 75 | 52.01 | 52.5 | 43.03 |
| 87.5% | 24.81 | 33.42 | 49.61 | 47.52 | 36.52 | 17.9 | 33.95 | 23 | 26.98 | 73 | 90.47 | 42.91 | 4 | 63.5 | 51.26 | 53.9 | 42.05 | |
| 75% | 22.2 | 30.79 | 45.3 | 40.44 | 35.29 | 15.96 | 32.88 | 22.73 | 25.77 | 71 | 87.78 | 41.16 | 3.5 | 58.5 | 44.34 | 44.45 | 38.88 | |
| RACE | 50% | 11.45 | 15.08 | 25.46 | 22.86 | 20.01 | 15.52 | 21.44 | 20.5 | 20.97 | 59.5 | 78.45 | 35.32 | 1.18 | 5.75 | 34.83 | 35.91 | 26.51 |
| 87.5% | 23.49 | 32.55 | 46.14 | 41.67 | 36.7 | 14.63 | 30.91 | 22.6 | 26.31 | 68.5 | 87.58 | 40.96 | 4.5 | 45 | 49.3 | 52.24 | 38.94 | |
| Tokens /Precision Retained | RACE KV Cache Reatained | Total KV Cache Retained | wikitext | hellaswag | piqa | arc_challenge | boolq | mmlu_ college_cs | Average |
| H20 (Token Compression) | |||||||||
| 100% | 50% | 12.66 | 0.66 | 0.85 | 0.48 | 0.82 | 0.72 | 0.706 | |
| 75% | 37.5% | 15.8 | 0.65 | 0.83 | 0.45 | 0.81 | 0.63 | 0.674 | |
| 512 (50%) | 50% | 25% | 17.44 | 0.62 | 0.79 | 0.44 | 0.74 | 0.43 | 0.604 |
| 100% | 25% | 13.62 | 0.66 | 0.85 | 0.48 | 0.79 | 0.66 | 0.688 | |
| 75% | 18.75% | 16.12 | 0.65 | 0.83 | 0.45 | 0.78 | 0.63 | 0.668 | |
| KV Cache Retained | Selection Criteria | wikitext | piqa | wino | acr_c | sciq | arc_easy | boolq | race | mmlu_cs | mmlu_phy | Avg |
| Joint QK Energy (RACE) | 13.88 | 0.74 | 0.67 | 0.46 | 0.93 | 0.70 | 0.77 | 0.42 | 0.48 | 0.35 | 0.61 | |
| Magnitude | 14.58 | 0.74 | 0.64 | 0.44 | 0.89 | 0.68 | 0.71 | 0.41 | 0.37 | 0.25 | 0.57 | |
| Random | 14.95 | 0.71 | 0.63 | 0.45 | 0.89 | 0.67 | 0.65 | 0.39 | 0.35 | 0.25 | 0.55 | |
| Gradient Fisher | 14.58 | 0.76 | 0.66 | 0.44 | 0.87 | 0.69 | 0.74 | 0.41 | 0.38 | 0.25 | 0.58 | |
| Attention Score | 14.13 | 0.74 | 0.66 | 0.44 | 0.92 | 0.69 | 0.75 | 0.40 | 0.40 | 0.27 | 0.59 | |
| Energy Q only | 14.02 | 0.75 | 0.66 | 0.45 | 0.93 | 0.69 | 0.75 | 0.42 | 0.40 | 0.32 | 0.60 |
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 269 papers