LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens

Yiran Ding, L. Zhang, Chengruidong Zhang, Yuanyuan Xu, Ning Shang +3 more
2/12/2026

No official code found. Best implementation: microsoft/LongRoPE (289 stars, MIT, last commit 2025-10-28). 1 more below.

Abstract

Large context window is a desirable feature in large language models (LLMs). However, due to high fine-tuning costs, scarcity of long texts, and catastrophic values introduced by new token positions, current extended context windows are limited to around 128k tokens. This paper introduces LongRoPE that, for the first time, extends the context window of pre-trained LLMs to an impressive 2048k tokens, with up to only 1k fine-tuning steps at within 256k training lengths, while maintaining performance at the original short context window. This is achieved by three key innovations: (i) we identify and exploit two forms of non-uniformities in positional interpolation through an efficient search, providing a better initialization for fine-tuning and enabling an 8x extension in non-fine-tuning scenarios; (ii) we introduce a progressive extension strategy that first fine-tunes a 256k length LLM and then conducts a second positional interpolation on the fine-tuned extended LLM to achieve a 2048k context window; (iii) we readjust LongRoPE on 8k length to recover the short context window performance. Extensive experiments on LLaMA2 and Mistral across various tasks demonstrate the effectiveness of our method. Models extended via LongRoPE retain the original architecture with minor modifications to the positional embedding, and can reuse most pre-existing optimizations.

View on arXivView PDF

Code Implementations(2)

microsoft/LongRoPECommunity100%
MIT

LongRoPE is a novel method that can extends the context window of pre-trained LLMs to an impressive 2048k tokens.

28922PythonFeb 15, 202411 months agoMIT
jshuadvd/LongRoPECommunity78%

Implementation of the LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens Paper

15413Python, DockerfileMar 6, 20242 years ago
aiartificial-intelligenceattention-is-all-you-needattention-mechanismsdeep-learning+14 more

Similar Papers

Cite this paper

@article{ding2026longrope,
  title  = {LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens},
  author = {Yiran Ding and L. Zhang and Chengruidong Zhang and Yuanyuan Xu and Ning Shang and Jiahang Xu and Fan Yang and Mao Yang},
  year   = {2026},
  eprint = {2402.13753},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2402.13753},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.13753.svg)](https://codeofpaper.com/paper/2402.13753)

Discussion