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 · DOI

Abstract

Rotary Position Embeddings (RoPE) have become the standard for encoding sequence order in modern Large Language Models (LLMs). However, standard implementations discard the imaginary component of the complex-valued dot product during attention calculation, leading to irreversible information loss. We introduce RoPE++, a dual-component attention mechanism that re-incorporates this lost information. By utilizing the sine-based imaginary component, RoPE++ significantly improves long-context modeling and allows models to maintain performance while utilizing 50% less KV cache compared to standard RoPE.

1. Introduction

Modern LLMs like Llama 3 rely on RoPE to represent token positions as rotations in a complex plane. While mathematically elegant, the final attention score calculation typically only retains the real part (based on a cosine function) and discards the imaginary part (based on a sine function). This paper argues that this practice ignores a mathematical tool naturally suited for capturing long-range dependencies. The real component favors local context and decays quickly, whereas the imaginary component provides a more stable, global view of the sequence.

2. Architectural Implementation

RoPE++ treats the previously discarded imaginary component as a new group of attention heads computed in parallel with the real ones. The researchers propose two primary configurations to balance performance and efficiency:

  • RoPE++$_{EH}$ (Equal Head): This configuration maintains the same number of attention heads as standard RoPE but halves the QKV parameters and the KV cache. This provides a significant boost to inference efficiency without sacrificing performance.
  • RoPE++$_{EC}$ (Equal Cache): This version keeps the cache size identical to standard RoPE but doubles the effective number of attention heads by utilizing both real and imaginary components.
Architectural comparison of standard Grouped Query Attention (GQA) with RoPE versus the proposed RoPE++ configurations (EC and EH).

3. Theoretical Foundation: The Sine Advantage

The core innovation of RoPE++ lies in the functional difference between the real and imaginary components. Mathematically, "Real Attention" follows a $\cos(\theta \Delta t)$ curve, while "Imaginary Attention" follows a $\sin(\theta \Delta t)$ curve.

Comparison of Real and Imaginary Attention components, showing the slower decay of the sine integral function compared to the cosine integral function.

As shown in Figure 1, the imaginary component's characteristic curve decays much more slowly than the real component's curve. This "hardwires" imaginary heads to attend to distant tokens, effectively acting as a global attention mechanism that complements the local focus of standard RoPE. Furthermore, RoPE++ improves length extrapolation; by exposing dimensions to the full range of sine values ($\pm 1$) during training, the model becomes more stable when processing sequences longer than its training window.

4. Experimental Evaluation

The authors validated RoPE++ using models ranging from 376M to 1.5B parameters trained on the DCLM-Baseline-1.0 corpus. Evaluation spanned standard short-context benchmarks (WikiText, LAMBADA, HellaSwag) and specialized long-context benchmarks (RULER, BABILong) up to 64k tokens.

Key Results

  • Efficiency Breakthrough: RoPE++$_{EH}$ achieved results comparable to vanilla RoPE while using 50% less KV cache, allowing for longer contexts on existing hardware.
  • Superior Accuracy: RoPE++$_{EC}$ consistently outperformed vanilla RoPE across benchmarks. On the RULER benchmark, it maintained high accuracy at 64k context lengths where vanilla RoPE performance began to degrade.
  • Functional Specialization: Visualization confirmed that "Real" heads focus on local context (the diagonal), while "Imaginary" heads attend to global information and "attention sinks" at the start of the sequence.

5. Conclusion and Future Work

RoPE++ demonstrates that the imaginary component of rotary embeddings is a primary driver for long-range reasoning. While the method requires training from scratch or significant continued pre-training, it offers a more expressive and efficient foundation for long-context LLMs. Future research may explore the utility of these sine-based components in bidirectional-attention models and diffusion-based language modeling.

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