NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs

Xiaoran Liu, Yuerong Song, Zhigeng Liu, Zengfeng Huang, Qipeng Guo, Zhaoxiang Liu, Shiguo Lian, Ziwei He, Xipeng Qiu

TL;DR

Standard Rotary Position Embeddings (RoPE) in Large Language Models (LLMs) compute attention using complex mathematics but discard the imaginary half of the result. This paper introduces RoPE++, an architectural extension that re-incorporates this discarded imaginary component to create a dual-component attention score. This approach significantly improves long-context performance and offers a pathway to halve KV cache memory requirements.

The Problem: Discarding Valuable Phase Information

To understand the sequential order of words, modern LLMs like LLaMA rely on Rotary Position Embeddings (RoPE). RoPE operates by treating attention queries and keys as complex numbers, rotating them in a complex plane based on their absolute position in the text.

However, standard RoPE implementations take a mathematical shortcut: after multiplying these complex vectors, they retain only the real part of the result and completely discard the imaginary part. The authors of this paper recognized that throwing away this imaginary component means losing valuable phase information. By ignoring it, models lose relational details that are crucial for modeling long-context dependencies and extrapolating to sequence lengths beyond their initial training data.

Methods: Recovering the Imaginary

The authors propose RoPE++, an elegant extension that recovers the lost imaginary information to form a dual-component attention mechanism.

Mathematically, computing the imaginary attention is surprisingly straightforward: it requires rotating the query vector by $-90^\circ$ ($-\pi/2$) before applying the standard RoPE operations. This allows the model to compute both "real" and "imaginary" attention scores in parallel without requiring a fundamentally new architecture.

Real vs. Imaginary Attention in RoPE++

The authors introduce two practical configurations of RoPE++:

  • RoPE++$_{EH}$ (Equal Head): Keeps the total number of attention heads the same as a standard model, but splits them so half are real and half are imaginary. Because the heads are split, this configuration effectively halves the KV cache and QKV parameters, acting as a massive efficiency and memory optimization.
  • RoPE++$_{EC}$ (Equal Cache): Keeps the KV cache size identical to a standard model but doubles the number of attention heads by computing an imaginary head alongside every real head. This configuration maximizes performance under a fixed memory budget.

Key Insights and Ideas

  • A Natural Division of Labor: The researchers discovered that the real and imaginary parts of the attention score naturally focus on different linguistic features. The real attention exhibits strong semantic locality (focusing on nearby tokens). In contrast, the mathematics governing the imaginary attention (a sine integral function) decays much more slowly over distance, making it naturally predisposed to capture long-context, global dependencies.
  • Imaginary Heads Dominate Long Context: To prove that the imaginary heads do the heavy lifting for long texts, the authors added Gaussian noise to the model during testing. Corrupting the imaginary heads degraded long-context performance far more severely (dropping scores by over 8 points) than corrupting the real heads.
  • Implicit Extrapolation Boost: Standard RoPE struggles when it encounters sequence lengths longer than its training data because the model sees out-of-distribution positional values. Because RoPE++ utilizes both sine (imaginary) and cosine (real) functions, the model experiences the full mathematical range of positional embeddings much earlier in training. Consequently, its perplexity degrades much slower when pushed beyond its trained context window.

Key Results

The authors trained models from scratch at 376M, 776M, and 1.5B parameter scales on the DCLM-Baseline-1.0 corpus to validate their approach:

  • Massive Efficiency Gains: RoPE++$_{EH}$ achieved comparable or slightly better long-context performance than standard RoPE while using half the KV cache. This results in significantly lower memory costs and faster decoding speeds.
  • Superior Long-Context Performance: RoPE++$_{EC}$ consistently achieved the highest scores across long-context benchmarks like RULER and BABILong (up to 64k context lengths), proving that the imaginary heads add net-new capabilities to the model.
  • No Short-Context Penalty: Both RoPE++ variants outperformed standard RoPE on average across standard short-context benchmarks (such as HellaSwag, PIQA, and TruthfulQA).
  • Compatibility: RoPE++ can be seamlessly combined with existing long-context extension techniques like YaRN and Linear Positional Interpolation (PI), maintaining its performance edge over standard RoPE.

Limitations and Future Work

Unlike some length-extrapolation techniques that can be applied to existing models via fine-tuning, RoPE++ is a fundamental architectural change. It requires training a model from scratch to properly learn the real/imaginary head dynamics. Furthermore, while RoPE++ extrapolates better than standard RoPE, it is not a zero-shot silver bullet for infinite context; it still eventually degrades on unseen lengths and benefits from techniques like NTK-scaling for massive context window extensions.

Looking ahead, the authors note that the mathematical properties of the imaginary component show great promise for bidirectional-attention architectures, such as Diffusion Language Models, which they plan to explore in future work.

Summary updated

BibTeX
@inproceedings{liu2026beyond,
  author = {Xiaoran Liu and Yuerong Song and Zhigeng Liu and Zengfeng Huang and Qipeng Guo and Zhaoxiang Liu and Shiguo Lian and Ziwei He and Xipeng Qiu},
  title = {{Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=D5PJX02Jki},
}
Figure