Your Query Is My Key: Halving Attention Parameters via Cross-Head Cyclic Rings

Sidharth S SarXiv 2026

TL;DR

Inside every Transformer attention head hides a mathematical redundancy: Query and Key matrices never act alone, only as a combined product. By arranging attention heads in a circle where each head owns just one matrix and borrows its neighbor's matrix as a partner, this paper cuts Query-Key parameters, matrix multiplications, and optimizer memory in half. Best of all, it avoids breaking the directional nature of attention—holding its own against standard Transformers on small-scale benchmarks.

What Problem Does This Paper Address?

If you have ever stared at the equations of a Transformer late at night, you might have noticed something curious about how tokens score one another. Each attention head learns two separate projection matrices—a Query ($W_Q$) and a Key ($W_K$)—yet the network’s loss function only ever sees them multiplied together as $U = W_Q W_K^\top$. Just as $2 \times 6$ and $3 \times 4$ both equal $12$, infinitely many matrix pairs yield the exact same attention scores.

Why pay the memory and compute bill for two matrices per head if only their product matters? While popular efficiency tricks like Multi-Query Attention (MQA) and Grouped-Query Attention (GQA) shrink memory by sharing Keys and Values across heads, the Query-Key pairing itself usually stays untouched.

If you try the obvious shortcut—tying them directly so $W_Q = W_K$ within a head—you crash into two mathematical walls:

  1. The Asymmetry Wall: Because dot products are commutative, the attention score matrix becomes symmetric. Token A must care about Token B equally as much as Token B cares about Token A, destroying directional retrieval.
  2. The Sign Wall: The matrix becomes positive semi-definite, meaning tokens can never have negative self-similarity scores.

The puzzle: Can we delete half the Query-Key matrices without losing directional, arbitrarily signed attention?

Methods

First, the author builds a clean theoretical foundation by deriving an exact, entry-wise gradient identity ($W_Q^\top G_{W_Q} = G_{W_K}^\top W_K$) from basic matrix calculus, proving how gradients behave along this redundant space.

To actually cut parameters without hitting the symmetry and sign walls, the paper introduces Cross-Head Cyclic Rings. Instead of giving each of the $H$ heads its own $W_Q$ and $W_K$ (requiring $2H$ matrices), each head $h$ owns just one projection matrix, $W_h$. It computes its projected representation $Z_h = X W_h$ once, applies standard Rotary Position Embeddings (RoPE), and then shares around a ring:

  • Head $h$ uses its own projection $Z_h$ as its Query.
  • It borrows its neighbor's projection, $Z_{(h+1) \bmod H}$, to act as its Key.
Standard attention pairs two matrices per head, whereas the cyclic ring arranges one matrix per head in a loop, cutting query-key parameters by 50%.

Each projection is computed once and used twice (as head $h$'s query and head $h-1$'s key). One matrix multiplication (GEMM) per head replaces two, halving Query-Key parameters and Adam optimizer states while keeping attention directional because $W_h \neq W_{h+1}$. (Note: Despite the name, this head-wiring is completely unrelated to "Ring Attention," which is a distributed context-parallelism method.)

Datasets

Rather than inventing custom benchmarks, the author evaluates cyclic rings on established, small-scale diagnostic tasks:

  • Multi-Query Associative Recall (MQAR): Synthetic key-value retrieval sequences from the Zoology benchmark that directly stress-test attention pathways.
  • Character-Level Language Modeling: A real-text 276 KB corpus (vocabulary size 146, 5.12M training tokens).
  • Formal Expressiveness Battery: Tasks testing the Chomsky hierarchy and structural reasoning—including regular languages (first, parity, cycle3), context-free parentheses matching (dyck2) following the FLaRe protocol, scaled-down ListOps (from Long Range Arena), and length-generalization probes.

Key Insights and Ideas

  • Sharing beats tying: Tying $W_Q = W_K$ inside a single head traps scores in a symmetric Gram matrix. Sharing projections across neighboring heads breaks that symmetry for free.
  • Restricting the family, not reparameterizing: A cyclic ring is not mathematically identical to standard paired attention—because matrices are chained in a loop, the set of functions it can represent is slightly more constrained. Yet empirically, that constraint barely dents performance at small scales.
  • Delayed "Grokking": On associative recall tasks, models undergo a sudden phase transition ("grokking") from near-random guessing to near-perfect accuracy. The cyclic ring hits the same high accuracy ceiling, it just takes roughly 500 to 1,500 extra training steps to get that lightbulb moment.
Fig. 3. MQAR accuracy during training in a scaled-down reference run (S=4, V=64, D=64, H=4, batch 64, lr 7 × 10−4, 2500 steps, 3 seeds; bold lines are means). Both models cross from about 0.2 to above 0.9 between steps 1000 and 2000, and the cyclic model transitions later. Chance is 1/64.

Key Results

Tested inside a 2-layer LLaMA-style Transformer across 3 random seeds:

  • Exact Savings: On a 32-head, 512-dimension microbenchmark, Query-Key parameters drop by 50.0% (1,048,576 to 524,288), cutting total model parameters by 9.5% and shrinking fp32 weights plus Adam states by 6.0 MiB. (Extrapolated theoretically to a 7B-class 32-layer model, this would save ~0.5B parameters and ~6 GiB of parameter/optimizer memory).
  • Associative Recall: Across 8 configurations of sequence length and width, whenever both models crossed the 0.98 accuracy threshold, the gap between standard and cyclic attention was tiny ($\le 0.004$).
  • Language Modeling: At 16 heads, validation cross-entropy was nearly indistinguishable (1.1891 paired vs. 1.2012 cyclic, or 1.1965 when reinvesting saved parameters into the feed-forward layer). At 32 heads, cyclic actually edged out paired (1.187 vs. 1.212).
  • Expressiveness: Across 408 experimental cells, cyclic attention matched standard attention's strengths (near 1.000 on first and dyck2, ~0.65 on ListOps) and mirrored its known theoretical blind spots (near-chance on global-counting tasks like parity).

Limitations and Future Work

The author is refreshingly candid about what these numbers don't prove:

  • Scale and Context: Every test was run on small 2-layer models with short sequences ($T \le 256$) on dual RTX A4000 GPUs. The 7B memory figure is strictly an unmeasured math extrapolation.
  • Optimization Speed: Because cyclic rings sometimes grok 500–1,500 steps later than paired heads, training efficiency under tight compute budgets at scale is an open question.
  • Untested Combinations: Compatibility with KV-cache savers like MQA and GQA—and alternative wiring topologies like nearest-neighbor pairs—was left for future testing on larger models and longer contexts.

Summary updated

BibTeX
@misc{s2026your,
  author = {Sidharth S S},
  title = {{Your Query Is My Key: Halving Attention Parameters via Cross-Head Cyclic Rings}},
  year = {2026},
  eprint = {2611.38680},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.38680},
}
Figure