Action-Angle Key Caches: Quantizing Keys Where Rotary Embeddings Become Addition

Large language models store a "key" and a "value" vector for every past token so they do not recompute them at each generation step. At long context lengths this key-value cache, not the model weights, fills GPU memory. For Llama-2-7B at 32K tokens and batch 16, the weights take 14 GB and the cache takes 256 GB (Eigen Attention). Keys are hard to compress because of rotary position embeddings (RoPE), the scheme most current models use to encode token position. RoPE splits each key into 2D pairs of channels and rotates each pair by an angle proportional to the token's position, with a different speed per pair. After rotation, keys sweep around circles, which creates the moving outliers that defeat ordinary quantization and low-rank compression (PolarQuant, EliteKV, Palu).

This note proposes storing each key before rotation, in polar coordinates per channel pair: a radius and a phase angle. In those coordinates, applying RoPE is exact and almost free, because it amounts to adding a position-dependent offset to the stored phase. Before rotation, phases also cluster tightly around a per-head center (TriAttention), so they can be coded as small deviations using very few bits. In plain terms, we quantize keys in the coordinates where position acts most simply, and we spend bits on radius versus phase according to a closed-form estimate of how much each error moves the attention score.

Core Claim

Mathematically, RoPE is an action of a torus, one circle per channel pair, on key space. In geometric mechanics such an action has natural "action-angle" coordinates. The actions are the squared radii of the pairs. They form the momentum map: position never changes them. The angles live on a circle and are shifted rigidly by the action.

Three facts from that viewpoint turn into design rules. First, the position action is a pure translation of the angles, so a cache stored in pre-rotation polar form commutes with RoPE. No reconstruction kernel of the kind Palu needs (Palu) is required. Second, the action is not free: wherever a pair's radius is zero, the circle fixes the point and the phase is undefined. The space of radii therefore splits into strata by which radii vanish, as in singular reduction theory (The stratified spaces of a symplectic lie group action). Near that boundary, phase bits are wasted and should be dropped. Third, the subgroup traced by token position, with angle $m\theta_i$ in pair $i$, winds densely around the torus when the frequencies are incommensurable. This is the textbook non-proper action of the isotropy-properness literature (The symplectic reduced spaces of a Poisson action). So position can never be "quotiented away", and the angles must be kept. Over a finite context, however, only pairs whose angle wraps at least once behave like the dense case. Slow pairs stay on an arc, which behaves like the unwrapped covering line studied by Montaldi and coauthors (Symplectic group actions and covering spaces).

The claim to test is this. A key quantizer built on pre-rotation action-angle coordinates, with stratum-aware phase dropping and frequency-dependent bit allocation, keeps long-context accuracy at about 3 effective bits per key element. At that budget we expect post-rotation polar quantization to degrade, because it cannot exploit phase concentration.

Mechanism

Take query pair $i$ with radius $a_i$ and pre-rotation phase $\alpha_i$, and key pair $i$ with radius $b_i$ and phase $\beta_i$, at relative distance $\Delta$. The attention logit is

$$\ell = \sum_i a_i b_i \cos(\psi_i), \qquad \psi_i = \alpha_i - \beta_i + \Delta\theta_i ,$$

where $\theta_i$ is the RoPE frequency of pair $i$. Small key errors $\delta b_i$ and $\delta\beta_i$ change the logit by $\delta\ell_i \approx a_i(\delta b_i \cos\psi_i + b_i\,\delta\beta_i \sin\psi_i)$. Averaging over the empirical distribution of $\psi_i$ gives the expected squared logit error per pair:

$$\mathbb{E}[\delta\ell_i^2] \approx \mathbb{E}[a_i^2]\left(c_i\,\sigma_{b,i}^2 + s_i\, b_i^2\,\sigma_{\beta,i}^2\right),$$

Here $c_i = \mathbb{E}[\cos^2\psi_i]$ and $s_i = \mathbb{E}[\sin^2\psi_i]$, and $\sigma^2$ are the quantizer error variances, each shrinking as $2^{-2\cdot\text{bits}}$ under uniform quantization.

The formula has a direct reading. For fast pairs, $\psi_i$ spreads over the whole circle and $c_i \approx s_i \approx 1/2$, so radius and phase matter equally. For slow pairs with concentrated queries and keys, $\psi_i$ stays near a fixed value. If that value is near zero, phase error is cheap and radius error is expensive. This is SQuat's principle of making error orthogonal to the query directions (SQuat), but expressed on the circle rather than in a flat subspace.

Bits are assigned by reverse water-filling over these weights under a fixed budget. Allocation is per head and per pair from a calibration pass, so the storage layout stays static. When a token's $b_i$ falls below a threshold $\tau$, the pair sits on the zero-radius stratum and we store only the radius. The resulting logit error is bounded by $a_i\tau\pi$. Phases are stored as deviations from the per-head center measured in calibration. At decode time, the logit is a sum of $a_i b_i$ times a cosine looked up from a table indexed by quantized phase plus $\Delta\theta_i$. This extends PolarQuant's lookup-table decoding to pre-rotation storage.

Relation to Prior Work

PolarQuant supplies the main method, and our proposal changes it. PolarQuant converts each post-rotation channel pair to radius and angle, removes zero-point metadata (4.16 effective bits versus about 5.08 for KIVI at nominal 4 bits), and decodes with lookup tables (PolarQuant). Its angles are rotated by position and are close to uniform, so it cannot code them compactly. It also treats every pair alike. We move to pre-rotation phases, code them relative to a center, drop phases on the zero-radius stratum, and allocate bits by the error formula above.

TriAttention motivates the phase coding. It found that pre-rotation queries and keys concentrate around nonzero centers, and it uses this to score tokens for eviction (TriAttention). We use the same concentration for quantization instead, which is a different compression axis that can be stacked with its eviction.

SQuat supplies the error-shaping principle: residuals orthogonal to the query subspace preserve logits (SQuat). It works in flat space, ignores rotation, and computes the subspace online from prompt queries. Our version is a static, per-frequency weighting.

EliteKV and Palu constrain the design. Both show that rotation breaks linear low-rank factorization and pay for workarounds, either by uptraining after frequency selection (EliteKV) or by online key reconstruction (Palu). We sidestep low-rank structure on keys entirely.

The geometry papers act as a lens, not as theorems we need. Stratification (The stratified spaces of a symplectic lie group action), non-properness (The symplectic reduced spaces of a Poisson action), and the covering picture (Symplectic group actions and covering spaces) each predict a concrete design rule: drop phases near zero radius, never quotient out position, and treat slow pairs as linear. We do not claim new results in symplectic geometry.

Values are out of scope. They are not rotated, and prior work finds them hard to compress geometrically (ThinK, PolarQuant). Values will be quantized with a standard per-token scheme held fixed across all compared methods.

Research Program

The first stage is measurement. On Llama-3.1-8B and Qwen3-8B, we collect pre-rotation keys and queries on calibration text. For every head and pair we measure the radius distribution, the fraction of tokens below candidate thresholds $\tau$, the circular spread of phases (TriAttention's mean resultant length), and the empirical $c_i$ and $s_i$ over relative distances up to the context length. This tells us whether slow pairs really show $s_i \ll c_i$ and whether the zero-radius stratum is populated enough to matter. If $s_i \approx c_i$ everywhere, the frequency-aware part of the proposal fails cheaply, and we report that.

The second stage builds the quantizer: calibration-time bit allocation, centered phase coding, a stratum flag folded into the radius code, and a fused decode kernel that adds $\Delta\theta_i$ to the quantized phase and reads cosines from a table. The third stage evaluates accuracy, memory and speed against the baselines below. It also tests stacking with TriAttention eviction, to check that the savings multiply as the orthogonal-compression thesis predicts (CommonKV).

Baselines

The naive reference is the full-precision (FP16) cache, together with plain per-channel scalar quantization of post-rotation keys at the same effective bit budget, metadata included. Every method uses the same value quantizer and the same models, prompts, decoding settings and calibration set of a few hundred sequences. Every method receives the same small grid search over its own hyperparameters on a held-out split.

The strongest competitor is PolarQuant (PolarQuant). It already uses polar coordinates and lookup-table decoding, so it isolates exactly what pre-rotation storage and allocation add. Its paper reports an effective 4.16 bits versus about 5.08 for KIVI 4-bit, and a 1.27× query-key speedup on an A800 up to 128K context. It states that 4-bit PolarQuant matched FP16 on LongBench, but no reported LongBench score was found on Lacuna. We will therefore rerun it with our harness at 4, 3 and about 2.5 effective bits. Beating it means retaining at least FP16 LongBench and RULER averages within one point at 3 effective bits where PolarQuant does not, or matching its accuracy at about 0.5 fewer effective bits, with decode latency no worse.

SQuat is the strongest error-shaping competitor (SQuat). It reports 2.17× to 2.82× peak memory reduction and 2.45× to 3.60× throughput over FP16. We found no reported LongBench or GSM8K score on Lacuna for it. It is rerun at matched bits, including the time it spends computing the query subspace from the prompt.

Three ablations isolate our ingredients: (a) pre-rotation polar coding with uniform bits and no stratum handling; (b) adding stratum dropping; (c) adding frequency-aware allocation. A fourth ablation, pre-rotation Cartesian quantization with mean-centering per channel, tests whether the circle coordinates matter at all.

Why not just…?

Why not just quantize pre-rotation keys in ordinary Cartesian coordinates, after subtracting the per-channel mean? This is the most serious threat. Concentration around a center can be exploited in Cartesian coordinates too, and RoPE can then be applied after dequantization. Polar storage has two advantages in principle. The nonnegative radius needs no zero point, which was PolarQuant's metadata saving. And rotation becomes phase addition, so decoding stays a table lookup rather than a dequantize-then-rotate step. The accuracy advantage is not guaranteed, so ablation (d) is decisive. If centered Cartesian matches our method at equal bits and equal latency, the contribution shrinks to a kernel convenience, and we will report it that way.

Why not just run PolarQuant with more bits on the angle? PolarQuant's post-rotation angles are spread by position, so every extra angle bit is spent on uniform-looking data. Pre-rotation centered phases should need fewer bits for the same angular error. The measurement stage tests this directly by comparing the circular spread of pre- and post-rotation phases. The PolarQuant runs at 3 and 2.5 bits test it end to end.

Why not just prune low-magnitude channel pairs, as ThinK does? ThinK removes key channels whose query-weighted magnitude is small (ThinK). That resembles our stratum rule, but it operates per channel and statically, while our rule acts per token and per pair. If the zero-radius fraction turns out to be concentrated in the same fixed pairs for all tokens, ThinK-style pruning plus PolarQuant would capture the same saving. Ablation (b), compared with a ThinK-pruned PolarQuant at matched bits, settles this point.

Why not just evict tokens instead? Eviction attacks a different axis. TriAttention reports 32.9% versus 17.5% for R-KV on AIME25 at equal memory, and full-attention accuracy at 10.7× less memory (TriAttention). We expect the two to combine rather than compete, and we test that.

Proposed Experiments

Accuracy is measured on LongBench, on the subsets used by SQuat (Qasper, QMSum, MultiNews, TREC, TriviaQA, SAMSum, LCC, RepoBench-P) (LongBench). It is also measured on RULER at 4K to 128K (RULER), on GSM8K few-shot chain of thought, and on AIME25 with 32K-token generation on Qwen3-8B. Efficiency is reported as effective bits including all metadata, peak memory, and query-key and end-to-end decode latency at 32K, 64K and 128K.

The decisive checks are four, in order of how quickly they can kill the idea. First, the measured $s_i$ versus $c_i$ split across frequencies: if slow pairs show no radius-phase asymmetry, the allocation rule has no basis. Second, the centered-Cartesian ablation at 3 bits. Third, the RULER curve versus PolarQuant at 2.5 to 3 effective bits beyond 32K, which is where post-rotation outliers should hurt most. Fourth, a stacking run of our quantizer with TriAttention eviction on AIME25. That run tests whether accuracy stays near TriAttention's own while memory drops by roughly the product of the two compression ratios.