SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2502.20082 · 2025

LongRoPE2: Near-Lossless LLM Context Window Scaling

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2502.20082.json · badge: /api/ran/2502.20082.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
microsoft/longrope canonical (classifier label)
classifier basis not recorded on the link
9 ran · 1 no recorded run
FunctionStatusWhere it lives
calc_str_length Ran
ran on a synthesized input
microsoft/longrope/evaluation/passkey.py
code served (permissive licence) · get_code("da8a809332ae045e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

ARGS = {
    "token_length": 100,
    "letters_per_token": 3.65
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_correction_dim Ran
ran, honoured the contract we drafted
microsoft/longrope/rope/yarn.py
code served (permissive licence) · get_code("3c92c963bb0cbb73")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math

# The function find_correction_dim takes 4 parameters:
# - num_rotations: a numeric value (int or float)
# - dim: a numeric value (int or float) representing dimension
# - base: numeric value with default 10000
# - max_position_embeddings: numeric value with default 2048

# The function performs mathematical calculations with these values
# No complex objects or methods are called, just arithmetic operations

ARGS = {
    "num_rotations": 32,
    "dim": 128,
    "base": 10000,
    "max_position_embeddings": 2048
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_correction_range Ran
ran, honoured the contract we drafted
microsoft/longrope/rope/yarn.py
code served (permissive licence) · get_code("763ecb554c17d2fe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math

def find_correction_dim(num_rotations, dim, base=10000, max_position_embeddings=2048):
    return dim * math.log(max_position_embeddings / (num_rotations * 2 * math.pi)) / (2 * math.log(base))

def find_correction_range(low_rot, high_rot, dim, base=10000, max_position_embeddings=2048):
    low = math.floor(find_correction_dim(low_rot, dim, base, max_position_embeddings))
    high = math.ceil(find_correction_dim(high_rot, dim, base, max_position_embeddings))
    return (max(low, 0), min(high, dim - 1))

ARGS = {
    "low_rot": 1.0,
    "high_rot": 2.0,
    "dim": 16,
    "base": 10000,
    "max_position_embeddings": 2048
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
forward_llama_for_causal_lm Ran
ran on a synthesized input
microsoft/longrope/utils/save_memory/llama_forward.py
code served (permissive licence) · get_code("d7e644e2e49cb75f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned CausalLMOutputWithPast. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from transformers.modeling_outputs import CausalLMOutputWithPast

torch.manual_seed(0)

# Build a minimal config class
class MinimalConfig:
    def __init__(self):
        self.output_attentions = False
        self.output_hidden_states = False
        self.use_return_dict = True
        self.vocab_size = 256
        self.hidden_size = 4

# Build a minimal model that returns hidden states
class MinimalModel(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
        self.embedding = nn.Embedding(config.vocab_size, config.hidden_size)
    
    def forward(self, input_ids=None, attention_mask=None, position_ids=None, 
                past_key_values=None, inputs_embeds=None, use_cache=None,
                output_attentions=None, output_hidden_states=None, return_dict=None):
        # Return hidden states with shape (batch_size, seq_len, hidden_size)
        if inputs_embeds is None:
            hidden_states = self.embedding(input_ids)
        else:
            hidden_states = inputs_embeds
        # Return as tuple (hidden_states, ...)
        return (hidden_states,)

# Build the main model class that has the forward method
class LlamaForCausalLM(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
        self.model = MinimalModel(config)
        self.lm_head = nn.Linear(config.hidden_size, config.vocab_size)
    
    def forward(self, input_ids=None, attention_mask=None, position_ids=None,
                past_key_values=None, inputs_embeds=None, labels=None, 
                use_cache=None, output_attentions=None, output_hidden_states=None,
                return_dict=None):
        output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
        output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
        return_dict = return_dict if return_dict is not None else self.config.use_return_dict
        outputs = self.model(input_ids=input_ids, attention_mask=attention_mask, position_ids=position_ids, past_key_values=past_key_values, inputs_embeds=inputs_embeds, use_cache=use_cache, output_attentions=output_attentions, output_hidden_states=output_hidden_states, return_dict=return_dict)
        hidden_states = outputs[0]
        logits = self.lm_head(hidden_states[..., -1:, :]).float()
        if labels is None:
            loss = None
        else:
            loss_fct = torch.nn.CrossEntropyLoss(reduction='sum')
            valid_seq_len = input_ids.shape[-1] - 1
            valid_seq_len_slide_win = torch.sum(labels[:, 1:] >= 0).item()
            loss = 0.0
            for start_idx in range(0, valid_seq_len, 16384):
                end_idx = min(start_idx + 16384, valid_seq_len)
                shift_logits = self.lm_head(hidden_states[..., start_idx:end_idx, :]).float()
                shift_labels = labels[..., start_idx + 1:end_idx + 1].contiguous()
                shift_logits = shift_logits.view(-1, self.config.vocab_size)
                shift_labels = shift_labels.view(-1)
                shift_labels = shift_labels.to(shift_logits.device)
                loss += loss_fct(shift_logits, shift_labels)
            loss /= valid_seq_len_slide_win
        return CausalLMOutputWithPast(logits=logits, loss=loss)

# Create config and model
config = MinimalConfig()
model = LlamaForCausalLM(config)

# Create minimal tensors
batch_size = 2
seq_len = 5
input_ids = torch.randint(0, config.vocab_size, (batch_size, seq_len), dtype=torch.long)
attention_mask = torch.ones((batch_size, seq_len), dtype=torch.long)
position_ids = torch.arange(seq_len, dtype=torch.long).unsqueeze(0).expand(batch_size, -1)
labels = torch.randint(0, config.vocab_size, (batch_size, seq_len), dtype=torch.long)

ARGS = {
    'self': model,
    'input_ids': input_ids,
    'attention_mask': attention_mask,
    'position_ids': position_ids,
    'past_key_values': None,
    'inputs_embeds': None,
    'labels': labels,
    'use_cache': False,
    'output_attentions': False,
    'output_hidden_states': False,
    'return_dict': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CausalLMOutputWithPast — a CausalLMOutputWithPast output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a CausalLMOutputWithPast output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
forward_llama_model Ran
ran on a synthesized input
microsoft/longrope/utils/save_memory/llama_forward.py
code served (permissive licence) · get_code("d5c3d6911b2d1f5e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned BaseModelOutputWithPast. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from typing import Optional, List

torch.manual_seed(0)

# Create a minimal decoder layer that matches the function's expectations
class MinimalDecoderLayer(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.hidden_size = hidden_size
    
    def forward(self, hidden_states, attention_mask=None, position_ids=None, 
                past_key_value=None, output_attentions=False, use_cache=False):
        # Return (hidden_states, attentions, cache)
        return (hidden_states, None, None)

# Create a minimal LLaMA model class
class MinimalLlamaModel(nn.Module):
    def __init__(self, hidden_size=4, vocab_size=10, num_layers=2):
        super().__init__()
        self.hidden_size = hidden_size
        self.vocab_size = vocab_size
        self.embed_tokens = nn.Embedding(vocab_size, hidden_size)
        self.layers = nn.ModuleList([MinimalDecoderLayer(hidden_size) for _ in range(num_layers)])
        self.norm = nn.LayerNorm(hidden_size)
        self.gradient_checkpointing = False
        self.training = False

# Instantiate the model
model = MinimalLlamaModel(hidden_size=4, vocab_size=10, num_layers=2)

# Create test tensors
batch_size = 2
seq_length = 3
hidden_size = 4
vocab_size = 10

input_ids = torch.randint(0, vocab_size, (batch_size, seq_length), dtype=torch.long)
attention_mask = torch.ones((batch_size, seq_length), dtype=torch.long)
position_ids = torch.arange(seq_length, dtype=torch.long).unsqueeze(0).expand(batch_size, -1)
inputs_embeds = torch.randn(batch_size, seq_length, hidden_size, dtype=torch.float32)

ARGS = {
    'self': model,
    'input_ids': input_ids,
    'attention_mask': attention_mask,
    'position_ids': position_ids,
    'past_key_values': None,
    'inputs_embeds': None,
    'use_cache': False,
    'output_attentions': False,
    'output_hidden_states': False,
    'return_dict': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BaseModelOutputWithPast — a BaseModelOutputWithPast output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a BaseModelOutputWithPast output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_answer Ran
ran on a synthesized input
microsoft/longrope/evaluation/passkey.py
code served (permissive licence) · get_code("f2a976adb1d0806e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from transformers import Pipeline

torch.manual_seed(0)

# Create a minimal mock pipeline that satisfies the function's usage
class MockPipeline:
    def __call__(self, prompt_text, num_return_sequences=1, max_new_tokens=10):
        # Return format: list of dicts with 'generated_text' key
        # The function extracts generated_text[len(prompt_text):] to get new tokens
        generated_continuation = " The answer is 42"
        full_text = prompt_text + generated_continuation
        return [{'generated_text': full_text}]

mock_pipe = MockPipeline()
prompt_text = "What is the answer?"

ARGS = {
    'pipe': mock_pipe,
    'prompt_text': prompt_text
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_prompt Ran
ran on a synthesized input
microsoft/longrope/evaluation/passkey.py
code served (permissive licence) · get_code("d69527b1fc981538")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

def generate_prompt(n_garbage):
    """Generates a text file and inserts an execute line at a random position."""
    n_garbage_prefix = random.randint(0, n_garbage)
    n_garbage_suffix = n_garbage - n_garbage_prefix
    task_description = 'There is an important info hidden inside a lot of irrelevant text. Find it and memorize them. I will quiz you about the important information there.'
    garbage_inf = 'The grass is green. The sky is blue. The sun is yellow. Here we go. There and back again.'
    while len(garbage_inf) < n_garbage:
        garbage_inf = ' '.join([garbage_inf] * 2)
    garbage_prefix = garbage_inf[:n_garbage_prefix]
    garbage_suffix = garbage_inf[:n_garbage_suffix]
    pass_key = random.randint(1, 50000)
    information_line = f'The pass key is {pass_key}. Remember it. {pass_key} is the pass key.'
    final_question = 'What is the pass key? The pass key is'
    lines = [task_description, garbage_prefix, information_line, garbage_suffix, final_question]
    return ('\n'.join(lines), pass_key)

random.seed(0)

ARGS = {
    'n_garbage': 500
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
linear_ramp_mask Ran
ran, honoured the contract we drafted
microsoft/longrope/rope/yarn.py
code served (permissive licence) · get_code("5034871c1d2783cf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "min": 2.0,
    "max": 8.0,
    "dim": 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rescale Ran
ran on a synthesized input
microsoft/longrope/evolution/search.py
code served (permissive licence) · get_code("674a35c5aad84dd5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (5,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seeds for reproducibility
np.random.seed(0)

# Define arguments for the rescale function
target_length_scale = 2.5
origin_length_scale = 1.5
factors = np.array([1.0, 1.5, 2.0, 0.5, 3.0])

ARGS = {
    "target_length_scale": target_length_scale,
    "origin_length_scale": origin_length_scale,
    "factors": factors
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (5,) — shape (5,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
main Not yet run
unverified (harvested, no recorded run)
microsoft/longrope/utils/tokenize_dataset.py
code served (permissive licence) · get_code("6db116407605786c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
linear_ramp_mask 4 other papers
4 dated earlier
2312.15166 (2023-12)
SOLAR 10.7B: Scaling Large Language Models with Simple yet Effective Depth Up-Scaling
2402.12376 (2024-02)
FiT: Flexible Vision Transformer for Diffusion Model
2404.10308 (2024-04)
Hierarchical Context Merging: Better Long Context Understanding for Pre-trained LLMs
and 1 more not named here
find_correction_dim 3 other papers
3 dated earlier
2312.15166 (2023-12)
SOLAR 10.7B: Scaling Large Language Models with Simple yet Effective Depth Up-Scaling
2404.10308 (2024-04)
Hierarchical Context Merging: Better Long Context Understanding for Pre-trained LLMs
2404.12224 (2024-04)
Length Generalization of Causal Transformers without Position Encoding
find_correction_range 3 other papers
3 dated earlier
2312.15166 (2023-12)
SOLAR 10.7B: Scaling Large Language Models with Simple yet Effective Depth Up-Scaling
2404.10308 (2024-04)
Hierarchical Context Merging: Better Long Context Understanding for Pre-trained LLMs
2404.12224 (2024-04)
Length Generalization of Causal Transformers without Position Encoding

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2502.20082")
get_code_for_paper("2502.20082")
have("2502.20082")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2502.20082.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2502.20082.svg)](https://syntology.ai/paper/2502.20082)

Connect an agent — have() is free.