Papers › LongRoPE2: Near-Lossless LLM Context Window Scaling

LongRoPE2: Near-Lossless LLM Context Window Scaling

27 Feb 2025arXiv:2502.20082archive 2025-07-28

Ning Shang, Li Lyna Zhang, Siyuan Wang, Gaokai Zhang, Gilsinia Lopez, Fan Yang, Weizhu Chen, Mao Yang

LongRoPE2 is a novel approach that extends the effective context window of pre-trained large language models (LLMs) to the target length, while preserving the performance on the original shorter context window. This is achieved by three contributions: (1) a hypothesis that insufficient training in higher RoPE dimensions contributes to the persistent out-of-distribution (OOD) issues observed in existing methods; (2) an effective RoPE rescaling algorithm that adopts evolutionary search guided by "needle-driven" perplexity to address the insufficient training problem; (3) a mixed context window training approach that fine-tunes model weights to adopt rescaled RoPE for long-context sequences while preserving the short-context performance with the original RoPE. Extensive experiments on LLaMA3-8B and Phi3-mini-3.8B across various benchmarks validate the hypothesis and demonstrate the effectiveness of LongRoPE2. Remarkably, LongRoPE2 extends LLaMA3-8B to achieve a 128K effective context length while retaining over 98.5% of short-context performance, using only 10B tokens -- 80x fewer than Meta's approach, which fails to reach the target effective context length. Code will be available at https://github.com/microsoft/LongRoPE.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2502.20082")

Code

Syntology Ran 3 of 10 code samples harvested from 1 repository linked to this paper; 7 have no recorded run. Of those that ran: 3 ran with no contract checked.

By repository: official repository: 10 samples from 1 repository, 3 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/longrope officialmentioned in paperpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 3 ran; 0 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

3ran
7unverified

Licence: 0 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from microsoft/longrope. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

find_correction_dim microsoft/longrope/rope/yarn.py official repository ran fingerprinted MIT (permissive) · 3c92c963bb0cbb73 · report
find_correction_range microsoft/longrope/rope/yarn.py official repository ran MIT (permissive) · 763ecb554c17d2fe · report
linear_ramp_mask microsoft/longrope/rope/yarn.py official repository ran MIT (permissive) · 5034871c1d2783cf · report
calc_str_length microsoft/longrope/evaluation/passkey.py official repository unverified MIT (permissive) · da8a809332ae045e · report
forward_llama_for_causal_lm microsoft/longrope/utils/save_memory/llama_forward.py official repository unverified MIT (permissive) · d7e644e2e49cb75f · report
forward_llama_model microsoft/longrope/utils/save_memory/llama_forward.py official repository unverified MIT (permissive) · d5c3d6911b2d1f5e · report
generate_answer microsoft/longrope/evaluation/passkey.py official repository unverified MIT (permissive) · f2a976adb1d0806e · report
generate_prompt microsoft/longrope/evaluation/passkey.py official repository unverified MIT (permissive) · d69527b1fc981538 · report
main microsoft/longrope/utils/tokenize_dataset.py official repository unverified MIT (permissive) · 6db116407605786c · report
rescale microsoft/longrope/evolution/search.py official repository unverified MIT (permissive) · 674a35c5aad84dd5 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

ADOPT

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections