ArXiv: 2403.00071

🎯 Pitch

RoPE-based LLMs fail on unseen long contexts not just from unseen position values, but because existing scaling methods force the model to interpolate between wavelengths it already knows on its most position-sensitive dimensions. By simply rounding each RoPE feature's wavelength to an integer, this approach eliminates that interpolation gap and delivers up to 14.76 absolute percentage point accuracy gains on synthetic position benchmarks while improving downstream long-context task performance—all with zero additional computation at inference time.


1. Executive Summary

This paper introduces Resonance RoPE, a novel method for improving context length generalization in Transformers equipped with Rotary Position Embedding (RoPE) by rounding each RoPE feature's wavelength to the nearest integer, thereby eliminating the feature interpolation gap on pre-critical dimensions between training and out-of-distribution positions (for example, when a model trained on length 64 is tested on length 128). The technique is evaluated on both a new synthetic benchmark—PosGen, designed to isolate position recognition failures from increasing token-generation difficulty—and on LLM-scale experiments with LLaMA2-Chat 7B and 13B combined with YaRN scaling. Applied atop YaRN, Resonance RoPE improves OOD accuracy by up to 14.76 absolute percentage points on PosGen subtasks and achieves a 1–2 point downstream average gain on L-Eval while lowering perplexity across all context lengths on GovReport and Proofpile, establishing that eliminating pre-critical interpolation is complementary to existing post-critical extrapolation methods but adds zero online computational cost.

2. Context and Motivation

The Core Problem: RoPE-Based Models Struggle with Unseen Long Sequences

Large Language Models (LLMs) deployed in production frequently encounter sequences longer than those seen during training. A model pre-trained on 4,096-token windows, for instance, will face 32,768-token documents in summarization tasks—tokens at positions 4,097 through 32,767 correspond to position indices the model never observed during pre-training. In models using Rotary Position Embedding (RoPE)—which includes LLaMA, LLaMA2, Mistral, Mixtral, and Code LLaMA—these unseen positions create a specific failure mode: the sinusoidal functions that encode positional information produce argument values (rotation angles mθjm\theta_j) that fall outside the numerical range experienced during training. This is formally called the train-short-test-long (TSTL) scenario, and it creates a measurable degradation in downstream task performance that is distinct from any difficulty increase inherent in processing longer texts.

The problem is both theoretically interesting and practically urgent. RoPE is not just one of several position encoding schemes—it is the dominant choice in the current open-weight LLM ecosystem (LLaMA family, Mistral family, Qwen, among others). Any improvement that makes RoPE-based models generalize better to unseen lengths immediately benefits a large fraction of deployed systems without requiring architectural changes. Understanding why RoPE fails on long sequences is also a fundamental question about how Transformers represent and generalize across position space—a question that connects to broader issues of OOD generalization in neural sequence models.

Two Distinct Failure Modes in TSTL, Only One of Which Is Well-Understood

The paper identifies a critical diagnostic gap in how the field has studied TSTL. When a model fails to generate the correct token at long context lengths, there are two distinct possible causes, and prior evaluation methods confound them:

  1. Increasing algorithmic difficulty of token generation. As sequences grow longer, the dependency structure of later tokens can become more complex—they may depend on more preceding tokens, or on tokens at farther distances. A model trained only on short sequences may simply never have learned the more complex dependency rules required for long sequences. This is a task learning failure, not a position encoding failure.

  2. Unrecognized new token positions. Even when the token generation rule is exactly the same at all positions, the model may fail because the position embedding values for OOD positions are novel—they differ from any embedding value the model saw during training. This is a position representation failure, and it is the target of all RoPE scaling methods.

The paper argues—persuasively—that existing evaluation strategies cannot separate these two failure modes. Perplexity-based long-context evaluation (PG19, GovReport, Proofpile) confounds them because the natural language difficulty of predicting the next token inherently varies with context position—later tokens in a document or code file genuinely require integrating more information, so models may show elevated perplexity even with perfect position representations. Existing synthetic TSTL benchmarks (Liu et al., 2023; Kazemnejad et al., 2023) similarly suffer because the generation rule for later tokens depends on more preceding symbols, making the task objectively harder at longer lengths. This confound means that previous work claiming to measure position embedding quality may in fact be measuring the model's ability to learn increasingly complex generation rules, muddying the attribution of observed failures. The paper states this directly in Section 5:

"Currently, neither perplexity-based evaluations nor synthetic TSTL evaluations can effectively distinguish these two failure patterns, since the token generation difficulty tends to increase with respect to the sequence length in these tasks."

This diagnostic gap is the motivation for the paper's PosGen benchmark, which ensures identical token-generation difficulty at all positions, so that any performance degradation on OOD positions can be attributed uniquely to position recognition failures. We will examine PosGen's design in detail in Section 5; for now, its role in motivating context is that it provides the analytical tool needed to precisely measure the phenomenon that Resonance RoPE addresses.

Prior Work: RoPE Scaling Only Addresses Post-Critical Dimensions

To understand what prior methods missed, we need a precise definition introduced by Liu et al. (2024) and adopted by this paper: the concept of critical dimensions in RoPE.

RoPE operates by partitioning the dd-dimensional query/key space into d2\frac{d}{2} independent 2-dimensional subspaces (Equation 1 in Section 3.1). Each subspace jj is associated with an angular frequency θj=b2j/d\theta_j = b^{-2j/d}, where bb is the rotary base (typically 10,000). Each frequency corresponds to a temporal wavelength λj=2πθj=2πb2j/d\lambda_j = \frac{2\pi}{\theta_j} = 2\pi b^{2j/d} (Equation 7), which describes how many tokens must elapse before the rotary angle mθjm\theta_j completes one full rotation and the RoPE feature returns to its starting value.

The wavelengths span a huge range. For LLaMA/LLaMA2 with d=128d = 128 per head and b=10,000b = 10,000, the smallest wavelength λ02π6.28\lambda_0 \approx 2\pi \approx 6.28 tokens, while the largest wavelength λ63210000126/128π54,410\lambda_{63} \approx 2 \cdot 10000^{126/128}\pi \approx 54,410 tokens. The critical dimension cc is defined as the boundary where λc1<L\lambda_{c-1} < L (wavelength shorter than training length—the feature completes multiple cycles during training) and λcL\lambda_c \geq L (wavelength reaches or exceeds the training length—the feature experiences less than one full cycle during training). For a model trained on L=4,096L = 4,096 tokens, the critical dimension falls roughly in the middle of the RoPE feature set.

RoPE dimensions behave fundamentally differently on OOD positions depending on which side of this boundary they fall:

  • Pre-critical dimensions (j<cj < c): λj<L\lambda_j < L, so the rotary angle mθjm\theta_j completes multiple full rotations during training. The model has seen all possible values of cos(mθj)\cos(m\theta_j) and sin(mθj)\sin(m\theta_j) during training—there is no value extrapolation. However, because the original λj\lambda_j values are generally non-integers (they involve 2π2\pi times a fractional power of 10,000), the rotary angles mθjm\theta_j for OOD positions m>Lm > L do not align with the discrete set of angles seen at training positions m{0,,L1}m \in \{0, \ldots, L-1\}. This creates a feature interpolation gap: the model must generalize to rotary angle values that lie between the ones it experienced, even though the absolute range of values is the same.

  • Post-critical dimensions (jcj \geq c): λjL\lambda_j \geq L, so the model has seen only a subset of the possible rotary angles on [0,2π)[0, 2\pi) during training. On OOD positions m>Lm > L, the model encounters entirely novel angle values outside the training range. This is value extrapolation, and it is widely recognized as the primary source of TSTL degradation.

The key insight is: prior work exclusively targeted the post-critical dimensions. Let us survey the major approaches:

Position Interpolation (Chen et al., 2023): Compresses all position indices by a factor ss so that the maximum test position sLsL maps to the maximum training position LL. This forces all RoPE features—both pre-critical and post-critical—to remain within the training value range, preventing post-critical extrapolation. The cost is that all position relationships are now "squeezed," which can hurt the model's ability to distinguish nearby tokens since all relative distances are effectively halved. Fine-tuning is required to recover performance, typically ~1,000 steps.

NTK-Aware scaling (bloc97, 2023; Xiong et al., 2023; Liu et al., 2024): Increases the rotary base from bb to sbs \cdot b, which stretches all wavelengths by a factor of ss. This pushes the critical dimension boundary outward, converting some post-critical dimensions into pre-critical ones. For dimensions that remain post-critical, the wavelength increase reduces (but may not eliminate) the extent of value extrapolation since the features now change more slowly with position. The key difference from Position Interpolation is that relative position information between nearby tokens is largely preserved because the rate of change of the rotary angle for pre-critical dimensions remains similar. This method works surprisingly well even without fine-tuning for moderate scaling factors (s8s \leq 8).

YaRN (Peng et al., 2024): The current state-of-the-art, and the baseline that this paper's large-scale experiments build upon. YaRN introduces NTK-by-parts scaling, which applies different strategies to different RoPE dimensions based on their wavelengths relative to the training length LL. For dimensions with very short wavelengths (λj<L/β\lambda_j < L/\beta, where β=32\beta = 32), no scaling is applied—these dimensions are left unchanged because they already generalize well. For dimensions with intermediate wavelengths (L/βλjL/αL/\beta \leq \lambda_j \leq L/\alpha, where α=1\alpha = 1), a gradual interpolation between no scaling and full NTK-aware scaling is applied. For dimensions with very long wavelengths (λj>L/α\lambda_j > L/\alpha), full NTK-aware scaling is applied. The paper describes this scheme in Section 3.3:

γj={1,if λj<L/β0,if λj>L/αL/λjαβα,otherwise\gamma_j = \begin{cases} 1, & \text{if } \lambda_j < L/\beta \\ 0, & \text{if } \lambda_j > L/\alpha \\ \frac{L/\lambda_j - \alpha}{\beta - \alpha}, & \text{otherwise} \end{cases} λj^=(1γj)sλj+γjλj\hat{\lambda_j} = (1 - \gamma_j)s\lambda_j + \gamma_j\lambda_j

This was a significant advance—by tailoring the scaling to each dimension's wavelength, YaRN achieves much better TSTL performance than uniform approaches, extending LLaMA2 to 64K context with only 400 fine-tuning steps.

The Missing Piece: Pre-Critical Interpolation

All three approaches—Position Interpolation, NTK-Aware, and YaRN—operate on the logic of preventing value extrapolation on post-critical dimensions. They differ in how they do it (compression vs. base modification vs. per-dimension scheduling), but they share the same objective and the same blind spot: they do not address the feature interpolation gap on pre-critical dimensions.

The paper identifies this gap through a careful analysis of what happens on pre-critical dimensions when wavelengths are non-integer, and makes a compelling case that this is not a second-order effect. Consider RoPE dimension jj with θj=b2j/d\theta_j = b^{-2j/d}. Its wavelength λj=2πb2j/d\lambda_j = 2\pi b^{2j/d} involves 2π2\pi and a fractional power of 10,000—a number that is almost never an integer. For example, in LLaMA2-7B with d=128d=128, the wavelength of feature j=6j=6 is approximately 2π1000012/1282π2.3714.912\pi \cdot 10000^{12/128} \approx 2\pi \cdot 2.37 \approx 14.91 tokens. The model sees this feature at training positions m=0,1,2,,4,095m = 0, 1, 2, \ldots, 4,095, where the rotary angles are mθ6=m2π/14.91m\theta_6 = m \cdot 2\pi/14.91. After each full rotation (every ~15 tokens), there is a phase shift—the rotary angle does not return to exactly the same value because the wavelength is not an integer divisor of the position increments. At position m=15m = 15, the angle is 152π/14.912π1.00615 \cdot 2\pi/14.91 \approx 2\pi \cdot 1.006, which differs by 0.0062π\sim 0.006 \cdot 2\pi from the angle at position m=0m = 0. This phase shift accumulates with each cycle.

As a result, when the model encounters OOD positions m>Lm > L, the rotary angles land at values that are interpolated between the discrete training angles. For a feature with wavelength ~14.91, the model saw approximately 4,096/14.91 ≈ 275 different angle values during training, but these 275 values are not uniformly spaced—they include subtle phase shifts. An OOD position at m=5,000m = 5,000 will produce an angle that lies between two training angles with a potentially different local spacing than the model has learned to handle. This is a generalization problem: the model must interpolate to new values in a highly non-linear feature space (sine and cosine), which is known to be difficult for neural networks when the training set does not provide dense coverage.

The paper formalizes this observation through the feature gap metric (Equation 8 in Section 4):

hi(f~)=maxxXminm{0,,L1}n{L,,L1}f~(x,m)if~(x,n)ih_i(\tilde{f}) = \max_{{\bm{x}}\in\mathbb{X}} \min_{\substack{m\in\{0,\cdots,L-1\}\\n\in\{L,\cdots,L'-1\}}} |\tilde{f}({\bm{x}},m)_i - \tilde{f}({\bm{x}},n)_i|

This metric asks: for each feature dimension ii, what is the maximum distance between an OOD position's feature value and the closest training position's feature value? If the feature gap is zero, every OOD position produces a feature vector that exactly matches some training position's feature vector—there is no novel feature value to generalize to, only familiar values in new sequential patterns. If the gap is large, the model must interpolate or extrapolate in the feature space.

On pre-critical dimensions with non-integer wavelengths, this gap is non-zero. For LLaMA/LLaMA2 with b=10,000b=10,000 and L=4,096L=4,096, the paper reports that over half of all RoPE features are pre-critical dimensions, and all of them have non-integer wavelengths, and consequently all of them have non-zero feature gaps on OOD positions. This is a massive set of dimensions where the model faces an unnecessary generalization challenge—unnecessary because, as the paper shows, the gap can be reduced to zero by a trivial rounding operation.

How This Paper Positions Itself

The paper's positioning is clear from its motivation: prior work on RoPE scaling addresses the extrapolation problem on post-critical dimensions, but there exists a separate, unaddressed interpolation problem on pre-critical dimensions that affects over half of all RoPE features. Resonance RoPE is proposed as a universal drop-in improvement that eliminates the pre-critical interpolation gap and is compatible with all post-critical scaling methods, including YaRN, NTK-Aware, and Position Interpolation. The improvement requires zero online computation cost (the wavelength rounding is done once when computing Θ~\tilde{\Theta} from Θ\Theta) and no additional fine-tuning beyond what the base scaling method already requires.

This compatibility is crucial: Resonance RoPE does not compete with or replace YaRN or NTK-Aware scaling. It improves them by handling the pre-critical dimensions that they leave untouched. The paper explicitly states in Section 7 (Conclusion) and the Limitations section that Resonance RoPE does not solve post-critical extrapolation—it must be combined with a method that does—and the experiments demonstrate this combination (Resonance YaRN) as the top-performing configuration.

Why This Discovery Was Not Obvious

Three aspects of the RoPE design interact to make this problem non-obvious:

  1. Exact periodicity seems like it would hurt, not help. One might reasonably assume that making RoPE features exactly periodic with integer wavelengths would reduce positional distinguishability—if λj=15\lambda_j = 15, then position mm and position m+15m+15 produce identical RoPE features for that dimension, potentially creating ambiguity. The paper addresses this implicitly: (a) all pre-critical dimensions together only repeat after their least common multiple, which for LLaMA2 is greater than 7×10517 \times 10^{51} tokens (Section 4, after Theorem 1), meaning the full position encoding remains effectively unique; (b) the model already handles repeated feature values on pre-critical dimensions because the original non-integer wavelengths produce near-repetitions at regular intervals (every ~15 tokens in the example above)—the shift from "almost but not quite the same" to "exactly the same" removes the interpolation burden without introducing a new ambiguity problem.

  2. The conceptual framework requires distinguishing pre-critical from post-critical. Prior to Liu et al. (2024), there was no established vocabulary or conceptual boundary for discussing wavelength-dependent behavior in RoPE. The critical dimension concept is the intellectual prerequisite for identifying pre-critical interpolation as a distinct phenomenon requiring a distinct solution. YaRN already classifies dimensions by wavelength (short/medium/long), but it does so to prescribe different amounts of post-critical extrapolation prevention, not to identify a separate generalization gap that persists even after extrapolation is prevented.

  3. The dominant approach of "just avoid novel values" misses the interpolation issue. The field's mental model for RoPE failure has been: OOD positions produce unseen rotary angle magnitudes → the model cannot handle unseen magnitudes → compress or stretch to keep angles within the training range. This model works for post-critical dimensions where the angles genuinely exceed training bounds. But for pre-critical dimensions, the angles are already within the training range in magnitude—they are just at unseen discrete values within that range. The distinction between extrapolation (values outside the training interval) and interpolation (values between training points within the interval) is subtle, and the field's language and methods had not previously separated them.

The paper's contribution is thus both conceptual (identifying pre-critical interpolation as a distinct failure mode) and practical (providing a zero-cost solution that integrates with existing methods). The synthetic PosGen benchmark provides the clean experimental apparatus needed to verify that the improvement is genuinely due to better position recognition, not a confounding effect of easier token generation rules—a verification that was impossible with prior benchmarks.

3. Technical Approach

This is primarily a methods paper whose core idea is that RoPE-based transformers suffer from a previously unidentified generalization gap on pre-critical position embedding dimensions—where non-integer wavelengths cause a feature interpolation problem between training and OOD positions—and that rounding each RoPE feature's wavelength to the nearest integer (Resonance RoPE) eliminates this gap at zero online cost, complementing existing post-critical scaling methods like YaRN.

3.1 Reader Orientation (Approachable Technical Breakdown)

The paper builds a drop-in modification to Rotary Position Embedding (RoPE) that improves how transformer models generalize to unseen sequence lengths. The system is simply a revised set of angular frequencies $\tilde{\Theta}$ that replace the original $\Theta$ in the RoPE computation, computed once offline by rounding each wavelength to an integer. The problem it solves is that when a model trained on short sequences (say, length 64) encounters longer sequences (say, length 128), the position encoding features for those new positions land at unseen intermediate values within the already-familiar value range—a subtle interpolation challenge that prior scaling methods ignored because they focused exclusively on keeping values within the training range rather than on where within that range the values fall.

3.2 Big-Picture Architecture (Diagram in Words)

The Resonance RoPE system has only two components:

  1. Original RoPE frequency set $\Theta = \{\theta_0, \ldots, \theta_{d/2-1}\}$ — the angular frequencies derived from the rotary base $b$ and head dimension $d$ according to the standard RoPE formula $\theta_j = b^{-2j/d}$. These define the rotation speed of each 2-dimensional feature subspace.

  2. Resonance RoPE frequency set $\tilde{\Theta} = \{\tilde{\theta}_0, \ldots, \tilde{\theta}_{d/2-1}\}$ — the modified angular frequencies computed by: (a) converting each $\theta_j$ to its wavelength $\lambda_j = 2\pi / \theta_j$, (b) rounding $\lambda_j$ to the nearest integer $\tilde{\lambda}_j = \text{round}(\lambda_j)$, and (c) converting back to frequency $\tilde{\theta}_j = 2\pi / \tilde{\lambda}_j$.

Information flows as follows: the pre-trained model's original $\Theta$ values are read → the rounding procedure in Algorithm 1 produces $\tilde{\Theta}$ → the standard RoPE computation (Equations 4–5) proceeds identically but using ${\bm{R}}^d_{\tilde{\Theta},m}$ instead of ${\bm{R}}^d_{\Theta,m}$ → queries and keys are computed as ${\bm{q}}_m = {\bm{R}}^d_{\tilde{\Theta},m}{\bm{W}}_q{\bm{x}}_m$ and ${\bm{k}}_n = {\bm{R}}^d_{\tilde{\Theta},n}{\bm{W}}_k{\bm{x}}_n$ → the rest of the transformer forward pass is unchanged. The only design choice is the rounding operation; there are no learned parameters, no runtime overhead, and no additional forward-pass computations.

3.3 Roadmap for the Deep Dive

  • First, the mathematical definition of Resonance RoPE as an optimization problem (minimizing feature gap) and as an algorithm (wavelength rounding), with the formal theorem that guarantees zero feature gap on pre-critical dimensions.
  • Second, the feature gap metric itself—what it measures, why it's the right objective, and how it differs from prior metrics like "embedded vector distance."
  • Third, the proof mechanics: why integer wavelengths eliminate the interpolation gap, and why this doesn't create positional ambiguity despite making individual features periodic.
  • Fourth, the compatibility argument: how Resonance RoPE integrates with YaRN and other post-critical scaling methods, and why the combination is synergistic rather than redundant.
  • Fifth, the connection to the PosGen benchmark design, which provides the evaluation framework for verifying that improvements are genuinely due to better position recognition.

3.4 Detailed, Sentence-Based Technical Breakdown

Formal Problem Statement: The Feature Gap Minimization Objective

Let $f({\bm{x}}, m) = {\bm{R}}^d_{\Theta, m}{\bm{W}}{\bm{x}}$ be the RoPE function that takes an input vector ${\bm{x}} \in \mathbb{R}^d$ and a position index $m$ and returns the position-encoded query or key vector. In a TSTL scenario, we test the model on positions $m \in \{L, L+1, \ldots, L'-1\}$ that were never seen during training on positions $\{0, 1, \ldots, L-1\}$. A scaled RoPE function $\tilde{f}$ (which could incorporate position interpolation, NTK-aware scaling, YaRN, or Resonance RoPE) produces better length generalization to the extent that it makes the feature vectors at OOD positions "familiar"—meaning close to some feature vector the model actually encountered during training.

The paper formalizes this intuition with the feature gap metric, defined per dimension $i$ in Equation 8 of Section 4:

hi(f~)=maxxXminm{0,,L1}n{L,,L1}f~(x,m)if~(x,n)ih_i(\tilde{f}) = \max_{{\bm{x}} \in \mathbb{X}} \min_{\substack{m \in \{0,\cdots,L-1\} \\ n \in \{L,\cdots,L'-1\}}} |\tilde{f}({\bm{x}}, m)_i - \tilde{f}({\bm{x}}, n)_i|

where $\mathbb{X} \subset \mathbb{R}^d$ is the set of all possible input vectors to which position encoding is applied, $m$ ranges over training positions, $n$ ranges over OOD test positions, $\tilde{f}({\bm{x}}, m)_i$ is the $i$-th scalar component of the position-encoded vector at position $m$, and $|\cdot|$ denotes absolute value.

What it computes: For each feature dimension $i$, the metric does the following: (1) for a fixed OOD test position $n$ and a fixed input vector ${\bm{x}}$, find the training position $m$ whose feature value $\tilde{f}({\bm{x}}, m)_i$ is closest to the OOD feature value $\tilde{f}({\bm{x}}, n)_i$; (2) take that minimal distance as the "gap" for that $({\bm{x}}, n)$ pair; (3) maximize over all possible inputs ${\bm{x}} \in \mathbb{X}$ to get the worst-case gap that any input could produce at that test position; (4) then, implicitly, the full vector gap is the maximum over all test positions $n$ as well (the $\max_{{\bm{x}}}$ over the $\min_{m,n}$ structure handles this since $n$ is part of the inner minimization). The output $h_i(\tilde{f})$ is a non-negative real number. A value of $0$ means that for every OOD position and every possible input vector, there exists some training position that produces an identical feature value on dimension $i$—the model never sees a genuinely novel scalar value on that dimension. A positive value means there exist OOD positions where the feature value differs from every training position's feature value by at least that amount, for some worst-case input.

Why this form: The design choices in this metric are intentional. The $\min_{m}$ inside the expression captures the idea that the model doesn't need to match every training position—it only needs one familiar feature value to avoid novelty. This is realistic because transformers process each position independently through the same learned weight matrices; if a feature value matches any training example's feature value, the downstream computation (the ${\bm{W}}_q$ and ${\bm{W}}_k$ projections, the attention dot product) receives an input from its training distribution. The $\max_{{\bm{x}}}$ makes the metric worst-case over inputs rather than average-case, which matters because even rare inputs that produce large gaps could cause systematic failures on those inputs in deployment. The $\max$ over $n$ (implicit in the definition's structure) ensures all OOD positions are covered. The metric is deliberately not about how well the full position encoding distinguishes different positions—that's a separate concern handled by the least common multiple argument—but only about whether OOD feature values are novel relative to training.

The paper contrasts this with the "embedded vector distance" metric from Xiong et al. (2023), which compares the original RoPE to the scaled RoPE at the same positions (measuring how much the scaling changed the encoding). The feature gap metric instead compares scaled RoPE across different positions (training vs. testing), which is the relevant quantity when the model is fine-tuned or used with the scaled embedding—the model has adapted to the scaled embedding's values on training positions, and the question is whether test positions produce values outside that adapted-to set.

The Resonance RoPE Algorithm: Wavelength Rounding

The core algorithmic contribution is remarkably simple and is specified in Algorithm 1 of the paper (Section 4). Given the original RoPE frequency set $\Theta = \{\theta_0, \theta_1, \ldots, \theta_{d/2-1}\}$ where $\theta_j = b^{-2j/d}$, Resonance RoPE produces a modified set $\tilde{\Theta}$ as follows:

For each dimension index $j \in \{0, 1, \ldots, d/2 - 1\}$:

  1. Compute the original wavelength:

    λj=2πθj=2πb2j/d\lambda_j = \frac{2\pi}{\theta_j} = 2\pi b^{2j/d}

    where $\lambda_j$ is the number of tokens after which the rotary angle $m\theta_j$ completes one full rotation of $2\pi$ radians. For a concrete example from LLaMA2-7B with $b = 10,000$, $d = 128$, and $j = 6$: $\lambda_6 = 2\pi \cdot 10000^{12/128} \approx 2\pi \cdot 2.371 \approx 14.91$ tokens.

  2. Round the wavelength to the nearest integer:

    λ~j=round(λj)\tilde{\lambda}_j = \text{round}(\lambda_j)

    where $\text{round}(\cdot)$ is standard half-up rounding to the nearest integer. Continuing the example: $\tilde{\lambda}_6 = \text{round}(14.91) = 15$ tokens.

  3. Convert back to angular frequency:

    θ~j=2πλ~j\tilde{\theta}_j = \frac{2\pi}{\tilde{\lambda}_j}

    For the example: $\tilde{\theta}_6 = 2\pi / 15 \approx 0.4189$ radians per token, compared to the original $\theta_6 = 10000^{-12/128} \approx 0.4214$ radians per token—a change of approximately 0.6% in the rotation speed.

After computing $\tilde{\Theta} = \{\tilde{\theta}_0, \ldots, \tilde{\theta}_{d/2-1}\}$, the modified RoPE rotation matrix ${\bm{R}}^d_{\tilde{\Theta}, m}$ is constructed using exactly Equation 2 from the original RoPE formulation, with $\tilde{\theta}_j$ replacing $\theta_j$ in each $2 \times 2$ rotation block:

Rθ~j,m=(cos(mθ~j)sin(mθ~j)sin(mθ~j)cos(mθ~j)){\bm{R}}_{\tilde{\theta}_j, m} = \begin{pmatrix} \cos(m\tilde{\theta}_j) & -\sin(m\tilde{\theta}_j) \\ \sin(m\tilde{\theta}_j) & \cos(m\tilde{\theta}_j) \end{pmatrix}

The queries and keys are then computed identically to standard RoPE:

qm=RΘ~,mdWqxm{\bm{q}}_m = {\bm{R}}^d_{\tilde{\Theta}, m} {\bm{W}}_q {\bm{x}}_m kn=RΘ~,ndWkxn{\bm{k}}_n = {\bm{R}}^d_{\tilde{\Theta}, n} {\bm{W}}_k {\bm{x}}_n

What this algorithm accomplishes: The rounding operation ensures that each 2-dimensional RoPE subspace has an integer temporal wavelength $\tilde{\lambda}_j$. This means that the rotary angle $m\tilde{\theta}_j = m \cdot 2\pi / \tilde{\lambda}_j$ cycles through exactly the same set of $\tilde{\lambda}_j$ distinct values (modulo $2\pi$) as position $m$ increments, with no phase shift between cycles. When $m$ increases by exactly $\tilde{\lambda}_j$, the angle increases by exactly $\tilde{\lambda}_j \cdot 2\pi / \tilde{\lambda}_j = 2\pi$—a full rotation that brings the sine and cosine values back to exactly where they started. There is no accumulation of fractional phase error.

Why rounding instead of some other integer approximation: The paper uses nearest-integer rounding (not floor, not ceiling) because it minimizes the change to each wavelength individually—the modified $\tilde{\lambda}_j$ is at most 0.5 tokens away from the original $\lambda_j$. This matters because the wavelength determines the "preferred interaction distance" for that feature dimension in the attention computation. A feature with $\lambda_j \approx 15$ means that tokens approximately 15 positions apart have aligned rotary angles and thus maximize their dot product contribution for that dimension. Changing this by a small fraction preserves the learned attention patterns; a larger change (e.g., forcing all wavelengths to be powers of 2) would disrupt the pre-trained positional biases. The paper doesn't perform an ablation on alternative rounding strategies (an acknowledged limitation), but the principle is clear from the design motivation: minimal perturbation to the existing wavelength structure.

How this integrates with existing scaling methods: Resonance RoPE is applied after any wavelength scaling from methods like NTK-Aware or YaRN. The sequence is: (1) apply the base scaling method to produce modified wavelengths $\hat{\lambda}_j$ (e.g., via YaRN's $\hat{\lambda}_j = (1-\gamma_j)s\lambda_j + \gamma_j\lambda_j$ formula); (2) round those modified wavelengths to integers: $\tilde{\lambda}_j = \text{round}(\hat{\lambda}_j)$; (3) compute $\tilde{\theta}_j = 2\pi/\tilde{\lambda}_j$. This is what the paper calls "Resonance YaRN" in experiments. The order matters: if we rounded first and then applied YaRN scaling, the scaling factor $s$ would break the integer property. The rounding must be the final step in the frequency computation pipeline.

Theorem 1: Zero Feature Gap on Pre-Critical Dimensions

The paper provides a formal guarantee (Theorem 1, Section 4) that Resonance RoPE reduces the feature gap to zero on all pre-critical dimensions. The theorem statement is:

For a RoPE-equipped model with context window $L$, Resonance RoPE $\tilde{f}$ reduces the feature gap on pre-critical dimensions to $0$. Specifically, $\forall {\bm{x}} \in \mathbb{X}$, $\forall n \in \mathbb{N} \setminus \{0, \cdots, L-1\}$, we have:

minm{0,,L1}f~(x,m)if~(x,n)i=0\min_{m \in \{0,\cdots,L-1\}} |\tilde{f}({\bm{x}}, m)_i - \tilde{f}({\bm{x}}, n)_i| = 0

for all $i = 0, \dots, 2c-1$.

where $c$ is the critical dimension index (the boundary where $\lambda_{c-1} < L \leq \lambda_c$), and $2c-1$ is the last pre-critical feature dimension (since dimensions come in pairs $[2j:2j+1]$).

The proof, provided in Appendix A and sketched in the main text, proceeds in three steps:

Step 1: Reduce to a trigonometric equality. For a given OOD position $n$ and dimension $i$ corresponding to frequency $\tilde{\theta}_j$ (where $i \in \{2j, 2j+1\}$), the condition $\tilde{f}({\bm{x}}, m)_i = \tilde{f}({\bm{x}}, n)_i$ reduces to:

acos(mθ~j)+bsin(mθ~j)=acos(nθ~j)+bsin(nθ~j)a\cos(m\tilde{\theta}_j) + b\sin(m\tilde{\theta}_j) = a\cos(n\tilde{\theta}_j) + b\sin(n\tilde{\theta}_j)

where $a, b \in \mathbb{R}$ are determined by the input ${\bm{x}}$ and the weight matrix ${\bm{W}}$. This equality holds if $m\tilde{\theta}_j$ and $n\tilde{\theta}_j$ differ by an integer multiple of $2\pi$, because sine and cosine are $2\pi$-periodic.

Step 2: Exploit integer wavelengths. The condition $m\tilde{\theta}_j - n\tilde{\theta}_j = 2\pi k$ for some integer $k$ is equivalent to:

(mn)2πλ~j=2πk    mn=kλ~j(m - n)\frac{2\pi}{\tilde{\lambda}_j} = 2\pi k \iff m - n = k\tilde{\lambda}_j

Since $\tilde{\lambda}_j$ is an integer by construction, we can set $k$ to be the integer quotient of $n$ divided by $\tilde{\lambda}_j$, i.e., $k = \lfloor n / \tilde{\lambda}_j \rfloor$ (or more precisely, $k = \text{round}(n / \tilde{\lambda}_j)$ to minimize $|m|$). Then:

m=nkλ~jm = n - k\tilde{\lambda}_j

which is the remainder of $n$ modulo $\tilde{\lambda}_j$.

Step 3: Verify that $m$ falls within the training range. This is the crucial step that uses the pre-critical property. By definition of the critical dimension, for all pre-critical dimensions $j < c$, we have $\lambda_j < L$. After rounding, $\tilde{\lambda}_j$ is within 0.5 of $\lambda_j$, so $\tilde{\lambda}_j < L$ as well (since $\lambda_j < L$ and $\tilde{\lambda}_j = \text{round}(\lambda_j) \leq \lfloor \lambda_j + 0.5 \rfloor$; as long as $\lambda_j$ is not exactly $L - 0.5$, which it won't be because $\lambda_j$ is a transcendental-like value). The remainder $m = n \bmod \tilde{\lambda}_j$ therefore satisfies $0 \leq m < \tilde{\lambda}_j < L$, meaning $m \in \{0, \ldots, L-1\}$—a valid training position.

What the proof establishes in operational terms: For every OOD test position $n$ and every pre-critical RoPE dimension, there exists a training position $m$ that produces exactly the same $\cos(m\tilde{\theta}_j)$ and $\sin(m\tilde{\theta}_j)$ values. This training position is essentially $n$ wrapped around modulo the integer wavelength. The model has seen the exact feature value before—not an approximation, not a nearby value requiring interpolation, but the identical numerical value. The model needs only to generalize its learned processing of that feature value to a new sequential context (different surrounding tokens, different absolute position), which is a much easier problem than generalizing to a novel feature value in a non-linear (trigonometric) space.

Why the proof only covers pre-critical dimensions: If $\lambda_j \geq L$ (post-critical), then even after rounding, $\tilde{\lambda}_j \geq L$, and the remainder $n \bmod \tilde{\lambda}_j$ for an OOD $n > L$ might be larger than $L-1$, falling outside the training range. This is exactly the extrapolation problem that YaRN and other methods address—and why Resonance RoPE must be combined with a post-critical scaling method rather than used alone.

The Periodicity Non-Issue: Least Common Multiple Argument

A natural concern is that making individual RoPE features exactly periodic with small integer wavelengths could create positional ambiguity—if $\tilde{\lambda}_j = 15$, then position $m$ and position $m+15$ produce identical values for that feature dimension. Could the model confuse these positions?

The paper addresses this with a combinatorial argument (Section 4, after Theorem 1). While each individual feature ${\bm{R}}_{\tilde{\theta}_j, m}$ repeats with period $\tilde{\lambda}_j$, the full set of $d/2$ features only repeats when all features simultaneously return to their starting values. This happens at the least common multiple (LCM) of all pre-critical wavelengths:

LCM(λ~0,λ~1,,λ~c1)\text{LCM}(\tilde{\lambda}_0, \tilde{\lambda}_1, \ldots, \tilde{\lambda}_{c-1})

The paper reports that for LLaMA2-7B, this LCM is greater than $7 \times 10^{51}$ tokens. At typical inference speeds (e.g., 50 tokens per second), this corresponds to approximately $4.4 \times 10^{42}$ years before a full position encoding repeat occurs. The position encoding is therefore effectively unique for any practical sequence length—the individual periodicities combine to form a system with astronomically long combined period. This is a standard consequence of the Chinese Remainder Theorem-like structure: if the wavelengths are pairwise coprime or have few common factors, the LCM grows exponentially in the number of dimensions.

The paper doesn't provide the exact LCM computation, but the magnitude is plausible: the pre-critical wavelengths for LLaMA2 range from approximately 7 tokens (for $j=0$, $\tilde{\lambda}_0 = \text{round}(2\pi) = 6$) to approximately 4,095 tokens (for the largest pre-critical $j$), and the intermediate values include many prime factors, leading to a massive combined LCM.

Why Pre-Critical Interpolation Matters: The Non-Linearity Argument

The paper's core argument for why eliminating the pre-critical feature gap improves performance rests on the non-linear nature of the RoPE feature transformation. On each pre-critical dimension $[2j:2j+1]$, the RoPE feature computation applies a rotation by angle $m\theta_j$ to a 2D vector $(a, b) = ({\bm{W}}{\bm{x}})_{[2j:2j+1]}$:

(ab)=(acos(mθj)bsin(mθj)asin(mθj)+bcos(mθj))\begin{pmatrix} a' \\ b' \end{pmatrix} = \begin{pmatrix} a\cos(m\theta_j) - b\sin(m\theta_j) \\ a\sin(m\theta_j) + b\cos(m\theta_j) \end{pmatrix}

The mapping from position $m$ to feature value $(a', b')$ involves the sine and cosine of $m\theta_j$. Sine and cosine are highly non-linear functions, especially when $\theta_j$ is not a rational multiple of $2\pi$. For a feature with wavelength ~14.91 tokens, the model sees approximately $4096 / 14.91 \approx 275$ distinct training values of $(a', b')$ for each $(a, b)$ pair. These 275 values are not uniformly distributed on the circle—the non-integer wavelength creates a phase shift that means the angular spacing between consecutive training positions varies slightly from cycle to cycle.

When the model encounters an OOD position $n > 4096$, its angle $n\theta_j$ will fall between two training angles with a spacing that depends on the accumulated phase error. The model must interpolate between two nearby training values on a non-linear manifold (the circle). While transformers have some capacity for this interpolation—they are universal function approximators—it requires additional representational capacity and is prone to error, especially when the interpolation involves novel local geometric relationships.

Resonance RoPE eliminates this interpolation burden entirely on pre-critical dimensions by making the relationship perfectly periodic: the OOD angle $n\tilde{\theta}_j$ exactly equals some training angle $m\tilde{\theta}_j$ (after accounting for full rotations). The model doesn't need to interpolate; it can directly apply the learned processing for that exact angle value. This is why the paper reports both better accuracy (the model makes fewer errors on OOD positions) and reduced variance across random seeds (the model's generalization is more robust, less dependent on whether the random training set happened to include "helpful" angular coverage).

The implicit design premise is that the exact wavelength value—whether 14.91 or 15—is less important for the model's learned positional biases than the elimination of the interpolation gap. The model was trained with wavelength 14.91 and learned attention patterns based on that specific rhythmic structure; changing it to 15 represents a small distribution shift in the positional relationship, but the benefit of making that relationship exactly periodic and eliminating the interpolation task outweighs the cost of the shift. The experimental results support this premise: Resonance YaRN consistently outperforms vanilla YaRN despite the wavelength perturbation.

Compatibility with YaRN and Other Post-Critical Scaling Methods

The paper explicitly positions Resonance RoPE as a compatible add-on, not a replacement, for existing RoPE scaling methods. The reasoning is direct: (1) Resonance RoPE addresses pre-critical dimensions (wavelength $\lambda_j < L$) by eliminating their interpolation gap; (2) post-critical scaling methods like YaRN, NTK-Aware, and Position Interpolation address post-critical dimensions (wavelength $\lambda_j \geq L$) by preventing their value extrapolation; (3) the two problems are orthogonal—solving one does not solve the other—and the two solutions are non-interfering—applying Resonance RoPE after post-critical scaling does not undo the scaling benefits.

The integration procedure for Resonance YaRN (used in all LLM-scale experiments) is:

  1. Apply YaRN's NTK-by-parts scaling to the original wavelengths $\lambda_j$ to get $\hat{\lambda}_j$:

    λ^j=(1γj)sλj+γjλj\hat{\lambda}_j = (1 - \gamma_j)s\lambda_j + \gamma_j\lambda_j

    where $\gamma_j = 1$ for $\lambda_j < L/\beta$ (no scaling), $\gamma_j = 0$ for $\lambda_j > L/\alpha$ (full NTK-aware scaling), and linearly interpolated for intermediate wavelengths, with $\alpha = 1$ and $\beta = 32$ as recommended by Peng et al. (2024).

  2. Convert to frequencies: $\hat{\theta}_j = 2\pi / \hat{\lambda}_j$.

  3. Round wavelengths to integers: $\tilde{\lambda}_j = \text{round}(\hat{\lambda}_j)$.

  4. Convert back to frequencies: $\tilde{\theta}_j = 2\pi / \tilde{\lambda}_j$.

Steps 3–4 are exactly the Resonance RoPE procedure applied to the already-scaled wavelengths. The result is that post-critical dimensions have their extrapolation prevented by YaRN's scaling, while all dimensions receive integer wavelengths that eliminate any residual interpolation gap (though for post-critical dimensions, the gap reduction argument of Theorem 1 does not apply because the wavelength exceeds $L$; the benefit there is more subtle and likely involves reducing the effective dimensionality of the generalization problem).

The paper also notes compatibility with other RoPE-based extensions, including the attention score scaling component of YaRN (which adjusts softmax temperature for longer sequences) and any fine-tuning procedure. Resonance RoPE only modifies the $\Theta$ parameter set; all other aspects of the model architecture, training objective, and inference procedure remain unchanged.

The PosGen Benchmark: Design Rationale for Isolating Position Recognition

The paper's synthetic evaluation framework, PosGen (Section 5), is designed to solve the confounding problem identified in Section 2: that standard long-context evaluations cannot distinguish between failures due to (a) the increasing algorithmic difficulty of generating later tokens versus (b) the model's inability to recognize OOD positions. PosGen achieves this isolation through a specific design strategy: the token generation rule at every position is controlled to have identical difficulty.

PosGen defines three subtasks, each based on a fixed function $h: \mathbb{V}^{j+k} \to \mathbb{V}$ where $\mathbb{V}$ is the model's vocabulary and $j, k$ are predefined constants. The three subtasks differ in which preceding tokens serve as inputs to $h$, thereby simulating different dependency patterns found in real reasoning tasks, but crucially, the computational complexity of applying $h$ is the same at every position—it always takes exactly $j+k$ input tokens and produces one output token.

Recursive subtask: $x_l = h(x_{l-(j+k)}, \ldots, x_{l-1})$ for $l \geq j+k$. The new token depends on the $j+k$ most recent tokens—a sliding window. This simulates Fibonacci-style or autoregressive generation where the dependency pattern is local and stationary (the distance to the farthest dependency is constant at $j+k$).

Chain-of-Thought (CoT) subtask: $x_l = h(x_0, \ldots, x_{j-1}, x_{l-k}, \ldots, x_{l-1})$ for $l \geq j+k$. The new token depends on $k$ recent tokens (simulating the previous reasoning step) and the first $j$ tokens (simulating the original question). This simulates chain-of-thought reasoning where later steps refer back to the fixed problem statement plus the most recent intermediate conclusion. Note that the dependency distances increase with $l$ (the first $j$ tokens become farther away), but the number of dependencies ($j+k$) remains constant.

Semi-recursive subtask: $x_l = h(x_{\lfloor l-(j+k)/2\rfloor - j}, \ldots, x_{\lfloor l-(j+k)/2\rfloor - 1}, x_{l-k}, \ldots, x_{l-1})$ for $l \geq j+k$. The new token depends on $k$ recent tokens and on $j$ tokens from a delayed position that slides forward at half the rate of sequence progression. This simulates the last-letter concatenation task (Zhou et al., 2023), where the model processes a sequence of words and the output depends on the final letters of words that appear at varying offsets.

In all three subtasks, given the first $j+k$ seed tokens, a sequence of unlimited length can be deterministically generated as ground truth. The training set contains sequences of length $L$, and the test set contains longer sequences of length $L'$. The key evaluation metric is OOD Accuracy—the model's token-level accuracy on positions $m \in \{L, L+1, \ldots, L'-1\}$ only.

Because the function $h$ is identical at all positions and always takes exactly $j+k$ inputs, any performance degradation on OOD positions cannot be attributed to the model encountering a harder generation rule. If the model learned $h$ correctly during training on short sequences, and the position representation perfectly generalizes, the model should maintain the same accuracy on OOD positions as on in-distribution positions. Observed degradation therefore isolates the position recognition failure mode—exactly the phenomenon that position embedding improvements target.

The paper's PosGen experiments (Section 6.1) use a modular addition task with $j=1, k=3$ and $h(x_0, x_1, x_2, x_3) = \sum_{i=0}^3 x_i \bmod 17$, with vocabulary $\mathbb{V} = \{0, \ldots, 16\}$. The choice of modular addition is motivated by Nanda et al. (2023)'s proof that this task is learnable by a one-layer transformer. The specific parameters $j=1, k=3$ mean that each token generation depends on exactly 4 preceding tokens, regardless of position—a lightweight computation that ensures the model's representational capacity is not the bottleneck. Training sequences have length $L=64$, test sequences have length $L'=256$, corresponding to a scaling factor $s=4$. The two-layer transformer uses T5-Small architecture (64-dimensional attention heads, so $d=64$, yielding $d/2 = 32$ RoPE features of which 17 are pre-critical since their wavelengths are below 64). The model is trained for 150 epochs with AdamW ($\text{lr} = 2\times 10^{-4}$, weight decay $1\times 10^{-2}$, batch size 128) on 10,000 training sequences, with 1,000 validation and 1,000 test sequences, and results are averaged over 5 random seeds.

4. Key Insights and Innovations

Innovation 1: Identifying Pre-Critical Interpolation as a Distinct, Unaddressed Failure Mode in RoPE Length Generalization

The paper's most fundamental intellectual contribution is not a method but a diagnosis: it identifies a previously unrecognized failure mode in RoPE-based length extrapolation that is orthogonal to the one the entire field had been working on. Prior to this work, the conceptual framework for understanding TSTL degradation in RoPE models was exclusively about value extrapolation on post-critical dimensions—the idea that OOD positions produce rotary angles $m\theta_j$ whose magnitudes exceed the training range, forcing the model to process novel numerical inputs. This framework motivated all existing solutions: Position Interpolation compresses the range, NTK-Aware scaling stretches the base to slow down rotation, and YaRN applies per-dimension scheduling to selectively prevent extrapolation. The underlying assumption was: if we keep all rotary angle values within the training range, the generalization problem is solved.

Resonance RoPE exposes this assumption as incomplete. By analyzing the pre-critical dimensions—those with wavelengths shorter than the training length—the paper shows that even when rotary angles remain within the training value range, the fact that most wavelengths are non-integers means that OOD positions land on unseen intermediate angle values between the discrete training points. This is an interpolation problem, not an extrapolation one: the model has seen the general vicinity of these values (the angular range is familiar) but has never seen these exact values, and must generalize in a non-linear trigonometric space. The paper formalizes this through the feature gap metric $h_i(\tilde{f})$ (Equation 8), which quantifies—per dimension—the maximum distance between an OOD position's feature value and the closest training position's feature value. On pre-critical dimensions with standard RoPE ($b=10,000$), this gap is systematically non-zero for over half of all RoPE features.

What makes this diagnosis intellectually distinctive is the conceptual boundary it draws. The field had implicitly treated "value in training range" as equivalent to "generalization-safe," collapsing extrapolation and interpolation into a single concern. The paper shows they are separate problems requiring separate solutions—and that existing methods, by focusing exclusively on the post-critical extrapolation problem, leave a massive set of dimensions (all pre-critical features) with an unaddressed generalization gap. This reframing changes how one thinks about RoPE scaling from "prevent novel value ranges" to "minimize feature novelty in both range and density."

The evidence for this diagnosis is both theoretical (Theorem 1 proves that integer wavelengths reduce the pre-critical feature gap to exactly zero, establishing that the gap is caused by non-integer wavelengths and is eliminable) and experimental (Resonance YaRN consistently outperforms vanilla YaRN on PosGen, where the task difficulty is controlled to isolate position recognition; see Table 1, where Resonance YaRN achieves 98.30% vs. 95.93% OOD accuracy on the Recursive subtask, and 48.46% vs. 33.70% on the Semi-Recursive subtask). The magnitude of the semi-recursive improvement (+14.76 percentage points) is particularly telling because that subtask's dependency pattern forces the model to attend across varying distances, making position recognition errors especially costly.

Innovation 2: Resonance RoPE as a Zero-Cost, Universally Compatible Patch for the Pre-Critical Interpolation Gap

The second innovation is the solution strategy itself: rather than designing a new scaling schedule, training procedure, or architectural modification, the paper shows that a trivial offline rounding operation—converting each RoPE wavelength to the nearest integer—eliminates the pre-critical interpolation gap entirely, with zero online computation cost and full compatibility with all existing post-critical scaling methods.

This is distinctive as an engineering contribution because of what it is not. It is not a new scaling law, not a learned correction, not a fine-tuning recipe, and not an architectural change. It is a one-time replacement of the $\Theta$ parameter set with a rounded version $\tilde{\Theta}$, after which the model's forward pass is bit-identical to standard RoPE except for the numerical values of the rotation angles. The conceptual move is recognizing that the interpolation problem has a structural solution—integer wavelengths force exact periodicity, which guarantees that every OOD position's feature value on pre-critical dimensions matches some training position's value exactly (Theorem 1)—rather than requiring a learned or optimized solution.

The significance of this strategy extends beyond the specific performance gains. It establishes a design principle: for position encoding features that complete multiple cycles during training, exact periodicity is preferable to non-integer quasi-periodicity because it eliminates interpolation burden without creating positional ambiguity (the least common multiple of all pre-critical wavelengths is astronomically large—greater than $7 \times 10^{51}$ for LLaMA2—so the full encoding never repeats in practice). This principle is transferable: any position encoding scheme with multi-cycle features and non-integer periods could potentially benefit from a similar integer-rounding approach.

The compatibility claim is central to the contribution's practical significance. Resonance RoPE does not compete with YaRN, NTK-Aware scaling, or Position Interpolation—it improves them by handling the dimensions they ignore. The paper demonstrates this by applying Resonance RoPE on top of YaRN (Resonance YaRN) rather than proposing it as a standalone method, and the results in Table 2 and Figure 4 show consistent improvements over vanilla YaRN across model sizes (7B and 13B), fine-tuning strategies (short-sequence-more-epochs and long-sequence-fewer-epochs), and evaluation types (perplexity and downstream tasks). The average L-Eval improvement of ~1 percentage point (Table 2, e.g., 37.58% vs. 36.61% for 7B at 4K FT) is modest but consistent, and the fact that it comes with literally zero additional cost makes it a strictly dominant improvement for any YaRN-based deployment.

Innovation 3: PosGen as a Benchmark That Disentangles Position Recognition from Task Difficulty in TSTL Evaluation

The third innovation is methodological: PosGen is the first TSTL benchmark that isolates position recognition failures from the confounding effect of increasing token-generation difficulty at longer sequence lengths. This is a measurement innovation, not a modeling one, but it is essential for the paper's central claims and for future research on position embeddings.

The problem PosGen solves is subtle but pervasive. In standard long-context evaluations—whether perplexity on PG19/GovReport or synthetic tasks like copying and induction heads—the difficulty of generating the correct next token inherently increases with sequence length, because later tokens depend on more context or more complex dependency patterns. When a model performs worse at position 2,000 than at position 200, it is impossible to determine how much of the degradation is due to the harder generation rule versus the novel position encoding. This confound has made it difficult to precisely evaluate position embedding methods: a method that improves position encoding could appear ineffective if task difficulty dominates, or a method that does nothing for position encoding could appear helpful if it incidentally improves task learning.

PosGen eliminates this confound by design. In all three subtasks, the generation rule $h$ takes exactly $j+k$ inputs at every position—no more, no less, regardless of sequence length. If the model has correctly learned $h$ during training on short sequences, and if the position encoding generalizes perfectly, then the model's accuracy on OOD positions should equal its accuracy on in-distribution positions. Any degradation must be due to position recognition failures. This transforms TSTL evaluation from a contaminated measurement into a clean diagnostic: the OOD accuracy metric directly quantifies position encoding quality.

The three-subtask structure (Recursive, CoT, Semi-Recursive) adds further diagnostic power by testing position recognition under different dependency patterns. The Recursive subtask requires only local attention (sliding window), the CoT subtask requires attending to both local context and a fixed distant prefix, and the Semi-Recursive subtask requires attending to tokens at dynamically varying distances. A position embedding method that improves on all three is robust across dependency patterns; one that improves on only some reveals pattern-specific weaknesses. This is evident in Table 1: vanilla RoPE achieves 65.29% OOD accuracy on Recursive but only 17.96% on Semi-Recursive, confirming that the Semi-Recursive pattern is hardest for position recognition (likely because the varying-distance dependencies make position errors compound). Resonance RoPE improves all three, but the largest gain is on Semi-Recursive (+11.82 points), suggesting that eliminating pre-critical interpolation is particularly valuable when the task requires precise position discrimination at multiple distance scales.

The benchmark's significance goes beyond this paper. By providing a clean, low-compute (two-layer transformer, 10K training sequences, 5 seeds) testbed for position embedding research, PosGen enables future work to systematically compare position encoding schemes without the confounding effects that plague LLM-scale evaluations. It fills a genuine gap in the evaluation ecosystem: before PosGen, there was no way to answer the question "does this new position encoding actually help with position recognition, or is the improvement coming from somewhere else?" without resorting to expensive and noisy LLM fine-tuning experiments. The paper's release of PosGen (referenced in the GitHub repository) is thus a contribution to research infrastructure as much as to the specific analysis of Resonance RoPE.

Innovation 4: The Feature Gap Metric as a Principled Optimization Objective for Position Encoding Design

The fourth contribution is the feature gap metric itself (Equation 8), which formalizes an intuitive notion—"how novel are the position encoding values at OOD positions?"—into a precise, computable quantity that can guide position encoding design. While the paper uses this metric primarily to motivate and analyze Resonance RoPE, the metric has broader significance as a design objective for future position encoding research.

What makes this metric distinctive compared to prior formalisms is its focus. Xiong et al. (2023) introduced "embedded vector distance," which measures how much the position encoding changed under scaling by comparing the original and scaled encodings at corresponding positions. That metric answers: "how much did we perturb the encoding?" The feature gap metric answers a different question: "after scaling and fine-tuning, do OOD positions produce feature values that the model has seen during training?" The first question is about modification magnitude; the second is about generalization readiness. The distinction matters because a large modification that achieves zero feature gap (all OOD values match some training value) could generalize better than a small modification that leaves a non-zero gap (some OOD values are novel)—the feature gap metric captures this tradeoff, while the embedded vector distance metric does not.

The metric's design also reflects a specific hypothesis about how transformers handle position encoding features: that the model learns to process specific $(a', b')$ value pairs (the output of the rotation applied to $(a, b)$ input pairs), and that encountering numerically identical $(a', b')$ values—even at different positions—enables zero-shot generalization, whereas encountering similar but not identical values requires interpolation capacity that may be unreliable. This hypothesis is plausible given what is known about how neural networks memorize and generalize in high-dimensional spaces (interpolation between training points is easier on linear manifolds than on curved ones like the circle), but it is not proven. The feature gap metric operationalizes this hypothesis into a measurable quantity, enabling empirical testing.

The paper's Theorem 1 demonstrates the metric's utility as an optimization target: by proving that Resonance RoPE achieves $h_i(\tilde{f}) = 0$ for all pre-critical dimensions, it establishes that zero feature gap is achievable through a simple modification, and the experiments then validate that achieving this theoretical optimum corresponds to empirical improvements. This creates a template for future work: propose a position encoding modification, compute its feature gap analytically or numerically on pre-critical and post-critical dimensions, and use the gap as a predictor of empirical TSTL performance. The metric could also guide hyperparameter selection—for instance, choosing the YaRN parameters $\alpha, \beta$ to minimize the feature gap rather than through grid search over downstream tasks.

5. Experimental Analysis

Evaluation Methodology

  • Dataset. The paper uses three distinct evaluation settings. For synthetic experiments: the newly proposed PosGen benchmark (Section 5), consisting of three subtasks (Recursive, Chain-of-Thought, Semi-Recursive) generated from a modular addition function $h(x_0, x_1, x_2, x_3) = \sum_{i=0}^3 x_i \bmod 17$ with vocabulary $\mathbb{V} = \{0, \ldots, 16\}$. Training uses 10,000 sequences of length 64; validation and test each use 1,000 sequences of length 256. Each subtask employs a distinct token dependency pattern but identical per-position computational complexity, ensuring that any degradation on OOD positions isolates position recognition failures. For perplexity evaluation: GovReport (Huang et al., 2021) and Proofpile (Azerbayev, 2022), with 50 randomly selected samples from each, reporting perplexity on progressively longer text fragments. For downstream evaluation: L-Eval (An et al., 2023), specifically its closed-ended task suite comprising Coursera, GSM, QuALITY, TOEFL, CodeU, and SFiction. The choice of L-Eval over alternatives like LongBench is not explained but provides coverage across lectures, math, QA, code, and fiction domains.

  • Base model(s). Synthetic experiments use a two-layer Transformer with T5-Small architecture (Raffel et al., 2020): 64-dimensional attention heads, $d=64$, yielding 32 RoPE features per head. Rotary base is set to 10,000 (standard RoPE default). LLM experiments use LLaMA2-Chat 7B and 13B (Touvron et al., 2023b), fine-tuned after replacing the original RoPE embeddings with scaled variants. The Chat variants rather than base LLaMA2 are used for the downstream evaluation since L-Eval requires instruction-following capability; for perplexity evaluation, the fine-tuned Chat models are also used, which introduces a slight confound (chat fine-tuning may affect language modeling perplexity independently of position encoding quality).

  • Metrics. For PosGen: OOD Accuracy — token-level next-token prediction accuracy measured exclusively on positions $m \in \{L, L+1, \ldots, L'-1\}$ where $L=64$ and $L'=256$. This isolates generalization to unseen positions. Results are reported as mean ± standard deviation across 5 random seeds. For perplexity: standard perplexity (exponentiated cross-entropy loss) evaluated on text fragments of gradually increasing length, plotted as curves showing perplexity vs. context length. For L-Eval: task-specific accuracy (percentage of correct answers) on each closed-ended subtask, plus an unweighted average across all six subtasks. The paper reports averages without confidence intervals, which makes it difficult to assess whether the observed 1–2 point differences are statistically significant.

  • Baselines. The paper compares against: (1) Vanilla RoPE (Su et al., 2024) — the standard RoPE with $b=10,000$, serving as the unmodified baseline for synthetic experiments. (2) NTK-Aware scaling (bloc97, 2023; Xiong et al., 2023; Liu et al., 2024) — scales the rotary base from $b$ to $s \cdot b$, evaluated without fine-tuning following the original bloc97 recipe. (3) Dynamic NTK-Aware scaling (Peng et al., 2024; Rozière et al., 2023) — dynamically computes $s = L_c / L$ based on current sequence length, evaluated without fine-tuning. (4) YaRN (Peng et al., 2024) — the current state-of-the-art RoPE scaling method combining NTK-by-parts wavelength scaling with attention score scaling, evaluated with fine-tuning. Resonance RoPE is compared both as a standalone modification to vanilla RoPE ("Resonance RoPE") and as a combination with YaRN ("Resonance YaRN"). There is no baseline that combines Resonance RoPE with NTK-Aware or Position Interpolation — the compatibility claim is only demonstrated for YaRN.

  • Generation budget / compute accounting. For PosGen: all methods use identical training data (10,000 sequences, length 64) and identical architecture (2-layer T5-Small), trained for exactly 150 epochs with the same optimizer settings. Compute is measured implicitly through the fixed training budget — all methods get exactly the same training compute, and the comparison is at equal training cost. Resonance RoPE adds zero inference computation since the $\tilde{\Theta}$ values are pre-computed offline. For LLM experiments: all fine-tuned methods are trained for approximately 100M tokens on PG19 (Rae et al., 2020), with two fine-tuning strategies compared: (a) "FT@32K/16K, fewer epochs" — training directly on the target extended length (32K for 7B, 16K for 13B) for 50 or 100 epochs respectively; (b) "FT@4K, more epochs" — training on the original pre-training length of 4,096 tokens for 400 epochs. The total training token count is approximately matched at 100M across all configurations, making the comparison fair in terms of fine-tuning compute. However, there is no accounting for the pre-training compute difference between 7B and 13B models, and the downstream comparisons across model sizes are not FLOPs-matched.

  • Cross-validation / statistical protocol. For PosGen: results are averaged over 5 random seeds with different initializations, and both mean and standard deviation are reported in Table 1. The training, validation, and test sets are generated with non-overlapping seed tokens (the first $j+k=4$ tokens of each sequence are unique across splits), ensuring that the model must learn the generation rule rather than memorize specific sequences. For LLM experiments: no cross-validation or statistical testing is reported. Each configuration is trained once and evaluated once on the fixed L-Eval test set. The lack of error bars or significance tests for the LLM results (Table 2, Figure 4) is a notable limitation — it is unclear whether the 1–2 point average improvements on L-Eval would replicate across different random seeds or data orders.

Main Quantitative Results

PosGen Synthetic Evaluation: Resonance RoPE Improves OOD Position Recognition, with Resonance YaRN Achieving the Highest Overall Performance

Table 1 reports the OOD accuracy (positions 65–256, since training length is 64) for four position encoding configurations across the three PosGen subtasks, each averaged over 5 seeds:

SettingRecursiveCoTSemi-Recursive
RoPE65.29 ± 0.4369.56 ± 0.3317.96 ± 0.03
Resonance RoPE (Ours)62.64 ± 0.1575.25 ± 0.1029.78 ± 0.07
YaRN95.93 ± 0.0498.71 ± 0.0033.70 ± 0.04
Resonance YaRN (Ours)98.30 ± 0.0099.58 ± 0.0048.46 ± 0.03

Several patterns emerge from these numbers:

Standalone Resonance RoPE helps on two of three subtasks but hurts on Recursive. Applying Resonance RoPE directly to vanilla RoPE (without any post-critical scaling) improves OOD accuracy substantially on CoT (+5.69 points, from 69.56% to 75.25%) and Semi-Recursive (+11.82 points, from 17.96% to 29.78%), but decreases performance on Recursive (−2.65 points, from 65.29% to 62.64%). The paper attributes the Recursive degradation to "the dominance of extrapolated post-critical dimensions in OOD positions" (Section 6.1.2) — since Resonance RoPE only addresses pre-critical interpolation and does nothing for post-critical extrapolation, the post-critical dimensions remain problematic on Recursive, and the pre-critical rounding may even slightly disrupt helpful pre-critical behaviors that partially compensated for post-critical failures. This negative result on Recursive is important because it validates the paper's claim that Resonance RoPE must be combined with a post-critical scaling method — it is not a standalone solution.

Resonance YaRN achieves the best results across all subtasks and dramatically reduces variance. The combination of YaRN (which handles post-critical extrapolation) and Resonance RoPE (which eliminates pre-critical interpolation) achieves the highest OOD accuracy on all three subtasks: 98.30% on Recursive (vs. 95.93% for vanilla YaRN, +2.37 points), 99.58% on CoT (vs. 98.71%, +0.87 points), and 48.46% on Semi-Recursive (vs. 33.70%, +14.76 points). The Semi-Recursive improvement is particularly striking — an almost 44% relative improvement — and suggests that the Semi-Recursive dependency pattern, which requires attending to tokens at dynamically varying distances, is especially sensitive to the pre-critical interpolation gap. The variance reduction for Resonance YaRN is also notable: on Recursive, the standard deviation drops from ±0.04 to effectively zero (±0.00 reported), and on CoT from ±0.00 to ±0.00 (both methods achieve near-perfect accuracy with negligible variance). The combination of higher accuracy and lower variance supports the paper's core claim that eliminating pre-critical interpolation makes position recognition more robust, not just more accurate on average.

The Semi-Recursive subtask is the hardest and shows the largest relative improvements. Across all methods, Semi-Recursive OOD accuracy is dramatically lower than Recursive or CoT. Even the best configuration (Resonance YaRN) achieves only 48.46%, compared to 98–99% on the other subtasks. This confirms that the Semi-Recursive dependency pattern — attending to tokens at $\lfloor l-(j+k)/2\rfloor$ offset, which changes non-monotonically with position — is fundamentally harder for position recognition. The paper hypothesizes that this is because the varying-distance attention pattern makes position encoding errors more consequential: if the model misidentifies position $\lfloor l-(j+k)/2\rfloor$, it attends to the wrong tokens entirely, whereas in Recursive (fixed window) or CoT (fixed prefix plus local window), position errors might still land within the correct dependency region by chance. The large gap between Resonance YaRN and vanilla YaRN on this subtask (48.46% vs. 33.70%) is the strongest evidence in the paper that pre-critical interpolation matters in practice, not just in theory.

Validation loss curves (Figure 3) show consistently lower loss for Resonance-enhanced methods throughout training. Figure 3 plots validation loss against training epochs for all four configurations on all three subtasks. Resonance RoPE and Resonance YaRN achieve lower validation loss than their non-Resonance counterparts at nearly all epochs. On the Semi-Recursive subtask, Resonance RoPE (without YaRN) achieves even lower validation loss than vanilla YaRN — a counterintuitive result given that YaRN handles post-critical extrapolation while Resonance RoPE does not. This suggests that on this specific subtask, the pre-critical interpolation problem dominates over the post-critical extrapolation problem. On Recursive and CoT, the ordering is as expected: Resonance YaRN < YaRN < Resonance RoPE ≈ RoPE, except that Resonance RoPE and RoPE cross on Recursive (Resonance RoPE starts better but ends worse, consistent with the OOD accuracy degradation).

LLM Perplexity Evaluation: Resonance YaRN Achieves Consistently Lower Perplexity Across All Context Lengths

Figure 4 plots perplexity vs. context length curves for LLaMA2-Chat 7B fine-tuned with different position encodings on GovReport (left panel) and Proofpile (right panel). The curves show perplexity evaluated on text fragments of progressively increasing length, from the model's original 4K training context up to the target 32K context.

Resonance YaRN achieves the lowest perplexity at all context lengths on both datasets. The Resonance YaRN curve sits below all other curves across the full context range. The improvement over vanilla YaRN (with the same hyperparameters optimized for YaRN) is visible from short contexts (~2K tokens) through the longest contexts (~32K tokens). The gap appears to widen slightly at longer contexts: at ~32K on GovReport, the vertical separation between Resonance YaRN and YaRN is visibly larger than at 4K, though the paper does not report exact perplexity values at specific lengths, making precise quantification impossible from Figure 4 alone.

The ordering of methods is consistent: Resonance YaRN < YaRN < NTK-Aware < Dynamic NTK-Aware. Dynamic NTK-Aware scaling (which adjusts $s$ dynamically based on current sequence length) performs worst, particularly on GovReport where its perplexity increases steeply after ~16K. Static NTK-Aware scaling performs better but is still worse than YaRN, which in turn is worse than Resonance YaRN. This ordering validates the cumulative improvement: NTK-Aware scaling improves over vanilla RoPE (not shown), YaRN improves over NTK-Aware by applying per-dimension scheduling, and Resonance YaRN improves over YaRN by eliminating pre-critical interpolation.

The improvement is not due to hyperparameter re-tuning for Resonance RoPE. An important methodological point: the Resonance YaRN configuration uses exactly the same YaRN hyperparameters ($\alpha=1$, $\beta=32$, scaling factor $s=8$, training recipe) as the vanilla YaRN configuration. The only difference is the application of the wavelength rounding step. This means the perplexity improvement is attributable specifically to the Resonance modification, not to better hyperparameter selection. The paper explicitly notes: "Resonance YaRN achieves a lower perplexity compared to YaRN with the same set of hyperparameters optimized for YaRN" (Section 6.2.2).

The Proofpile curves show a different shape than GovReport. On GovReport, perplexity increases roughly monotonically with context length for all methods, with the rate of increase slowing at longer contexts. On Proofpile, the curves are flatter and some methods (NTK-Aware, Dynamic NTK-Aware) show a slight decrease in perplexity at intermediate lengths before increasing again. This dataset-specific behavior likely reflects different distributional properties of government reports vs. mathematical proofs — proofs may have more predictable local structure that benefits from additional context up to a point — but the paper does not analyze this difference. The consistent ordering of methods across both datasets suggests the Resonance improvement is not dataset-specific.

LLM Downstream Task Evaluation: Resonance YaRN Shows Modest but Consistent Improvements on L-Eval Closed-Ended Tasks

Table 2 reports the accuracy on six L-Eval closed-ended subtasks (Coursera, GSM, QuALITY, TOEFL, CodeU, SFiction) and their unweighted average, for LLaMA2-Chat 7B (target context 32K) and 13B (target context 16K), with multiple fine-tuning strategies.

For LLaMA2-Chat 7B: Four pairs of YaRN vs. Resonance YaRN comparisons are presented, covering two fine-tuning strategies (FT@32K for 50 epochs, FT@4K for 400 epochs) and additionally two no-fine-tuning baselines (Dynamic NTK-Aware and static NTK-Aware).

  • FT@32K, 50 epochs: Resonance YaRN achieves 34.24% average vs. YaRN's 33.24% (+1.00 points). The improvement comes primarily from GSM (22.00% vs. 19.00%, +3.00) and QuALITY (34.16% vs. 33.17%, +0.99), partially offset by declines on TOEFL (55.76% vs. 50.56%, −5.20? No — Resonance YaRN improves TOEFL from 50.56 to 55.76, +5.20) and CodeU (0.00% vs. 4.44%, −4.44). Wait — this needs careful reading. Comparing Resonance YaRN to YaRN for FT@32K, 50 epochs: Coursera 36.48 vs. 36.05 (+0.43), GSM 22.00 vs. 19.00 (+3.00), QuALITY 34.16 vs. 33.17 (+0.99), TOEFL 55.76 vs. 50.56 (+5.20), CodeU 0.00 vs. 4.44 (−4.44), SFiction 57.03 vs. 56.25 (+0.78). The CodeU drop is significant (−4.44 points to zero) and concerning — it suggests Resonance RoPE may hurt on some specific task types even as it helps on average. The paper does not discuss this anomaly.

  • FT@4K, 400 epochs: Resonance YaRN achieves 37.58% average vs. YaRN's 36.61% (+0.97 points). GSM shows the largest gain (27.00% vs. 24.00%, +3.00), QuALITY improves substantially (40.59% vs. 37.62%, +2.97), but CodeU drops again (3.33% vs. 4.44%, −1.11) and TOEFL declines slightly (56.51% vs. 57.62%, −1.11). SFiction improves (61.72% vs. 60.94%, +0.78).

  • No-fine-tuning baselines: Dynamic NTK-Aware achieves 32.59% average, static NTK-Aware achieves only 25.43% average — substantially worse than fine-tuned methods. This confirms that fine-tuning is important for downstream task performance even when the position encoding scaling method works without fine-tuning for perplexity.

  • FT@4K strategy consistently outperforms FT@32K for both YaRN and Resonance YaRN. For vanilla YaRN: 36.61% (FT@4K) vs. 33.24% (FT@32K), +3.37 points. For Resonance YaRN: 37.58% (FT@4K) vs. 34.24% (FT@32K), +3.34 points. This suggests that training on shorter sequences for more epochs (400 epochs at 4K) is more effective than training on longer sequences for fewer epochs (50 epochs at 32K) at these specific training token budgets (~100M total tokens). The paper does not explore whether this finding holds at larger fine-tuning budgets.

For LLaMA2-Chat 13B: The target context is 16K with scaling factor $s=4$. The same fine-tuning strategies are compared (FT@16K for 100 epochs, FT@4K for 400 epochs).

  • FT@16K, 100 epochs: Resonance YaRN achieves 41.65% average vs. YaRN's 41.48% (+0.17 points) — a negligible improvement. Individual task differences are small and mixed: Coursera +0.58, GSM 0.00, QuALITY +0.49, TOEFL −0.37, CodeU +1.11, SFiction −0.78.

  • FT@4K, 400 epochs: Resonance YaRN achieves 39.87% average vs. YaRN's 39.06% (+0.81 points). The improvement is driven by GSM (35.00% vs. 34.00%, +1.00), CodeU (5.56% vs. 2.22%, +3.34), and QuALITY (42.57% vs. 41.09%, +1.48), partially offset by a decline in TOEFL (65.80% vs. 66.91%, −1.11).

  • The 13B model underperforms the 7B model on average under FT@4K. This is counterintuitive — a larger model fine-tuned on the same data should perform at least as well. For vanilla YaRN FT@4K: 39.06% (13B) vs. 36.61% (7B) — the 13B does outperform 7B by +2.45 points, consistent with expectations. For Resonance YaRN FT@4K: 39.87% (13B) vs. 37.58% (7B) — again +2.29 points in favor of 13B. The apparent anomaly is that 13B FT@4K underperforms 13B FT@16K (39.87% vs. 41.65%), while 7B FT@4K outperforms 7B FT@32K (37.58% vs. 34.24%). This interaction between model scale and optimal fine-tuning sequence length is not analyzed.

Key takeaway from Table 2: Resonance YaRN improves the average L-Eval score by approximately 0.8–1.0 percentage points for 7B across both fine-tuning strategies, and by 0.2–0.8 points for 13B. The improvements are consistent in direction (Resonance YaRN never underperforms YaRN on average) but modest in magnitude. Individual subtask results are noisy — CodeU in particular shows erratic behavior (0.00% for 7B Resonance YaRN FT@32K is the worst score on any subtask). The paper's claim that Resonance RoPE "improves LLM's length extrapolation ability, as evidenced by ... enhanced outcomes in downstream tasks involving lengthy contexts" (Abstract) is supported directionally but the effect size is small and the lack of confidence intervals makes statistical significance unclear.

Ablation Studies and Robustness Checks

Fine-tuning sequence length strategy (FT@long vs. FT@short): Table 2 compares two fine-tuning strategies at approximately equal total training tokens (~100M): training on the target extended length (32K/16K) for fewer epochs versus training on the original pre-training length (4K) for more epochs. For 7B, FT@4K consistently outperforms FT@32K for both YaRN (+3.37 points average) and Resonance YaRN (+3.34 points average). For 13B, the pattern reverses: FT@16K outperforms FT@4K for both YaRN (+2.42 points) and Resonance YaRN (+1.78 points). This interaction effect (model scale × optimal fine-tuning length) is not discussed or explained in the paper but is methodologically significant — it suggests that the optimal fine-tuning strategy for position encoding scaling may depend on model scale, and that the common practice of fine-tuning on the target extended length (as done in YaRN's original paper) may not be optimal for smaller models at fixed token budgets.

No-fine-tuning vs. fine-tuning comparison: Table 2 includes two no-fine-tuning baselines (Dynamic NTK-Aware and static NTK-Aware) alongside the fine-tuned YaRN variants. For 7B, fine-tuned YaRN (36.61% FT@4K) substantially outperforms Dynamic NTK-Aware without fine-tuning (32.59%) by +4.02 points, and massively outperforms static NTK-Aware without fine-tuning (25.43%) by +11.18 points. This confirms that fine-tuning is essential for downstream task performance even when the scaled position embedding works reasonably for perplexity without fine-tuning. The paper does not include a no-fine-tuning Resonance YaRN baseline — we cannot determine whether Resonance YaRN's improvement partly reflects better fine-tuning dynamics rather than better OOD position recognition per se.

Resonance RoPE as a standalone modification to vanilla RoPE (without post-critical scaling): Table 1 evaluates Resonance RoPE applied directly to vanilla RoPE (not combined with YaRN). The result is mixed: improvements on CoT (+5.69 points) and Semi-Recursive (+11.82 points), but a degradation on Recursive (−2.65 points). This ablation is important because it demonstrates that Resonance RoPE alone is not a universal improvement — it helps on pre-critical dimensions but the unaddressed post-critical extrapolation can still dominate on some tasks (Recursive). This supports the paper's claim that Resonance RoPE "must be combined with a post-critical scaling method" and explains why all LLM experiments use Resonance YaRN rather than standalone Resonance RoPE.

RoPE vs. YaRN baseline comparison on PosGen: Table 1 also allows comparison of vanilla RoPE to vanilla YaRN, which isolates the effect of post-critical scaling without any pre-critical modification. YaRN dramatically outperforms RoPE on all subtasks: Recursive 95.93% vs. 65.29% (+30.64 points), CoT 98.71% vs. 69.56% (+29.15 points), Semi-Recursive 33.70% vs. 17.96% (+15.74 points). This confirms that post-critical extrapolation is the dominant failure mode — fixing it yields ~30-point gains on the easier subtasks — but also that pre-critical interpolation matters additionally, since Resonance YaRN further improves over YaRN by 2–15 points depending on subtask.

Validation loss dynamics (Figure 3) as an implicit ablation of training stability: The validation loss curves in Figure 3 show that Resonance RoPE and Resonance YaRN not only achieve lower final loss but also exhibit smoother, more stable training trajectories than their non-Resonance counterparts. On the Recursive subtask, vanilla RoPE shows a loss spike around epoch 20 that Resonance RoPE avoids. On Semi-Recursive, vanilla RoPE's loss plateaus around 0.9 while Resonance RoPE continues to improve to ~0.7. These training dynamics suggest that eliminating the pre-critical interpolation gap may also benefit optimization during training, not just generalization at test time — the model spends less capacity struggling to fit non-periodic features and can allocate more representational power to learning the actual task.

Effect of model scale on Resonance improvement: Comparing 7B and 13B results in Table 2, the average improvement from Resonance YaRN over vanilla YaRN is larger for 7B (0.97–1.00 points depending on FT strategy) than for 13B (0.17–0.81 points). This could indicate that larger models are naturally better at interpolating pre-critical features (more capacity to learn the non-periodic mapping), making the Resonance modification less impactful. However, the 13B model's overall performance is higher (e.g., 41.65% vs. 34.24% for FT@target-length), so ceiling effects may also play a role — there is less room for improvement. The paper does not explore scaling trends systematically (e.g., 1B, 3B, 7B, 13B, 70B), which would be needed to characterize how the benefit of Resonance RoPE scales with model size.

Critical Assessment

Does Resonance RoPE improve position recognition in a way that is separable from task difficulty?

Yes, strongly demonstrated by PosGen. The PosGen results (Table 1) provide clean evidence because the benchmark controls per-position generation difficulty. The OOD accuracy metric isolates position recognition: on Positions 65–256 (never seen during training), the model must apply the learned function $h$ — which takes exactly 4 inputs regardless of position — and any failure is due to misidentification of which tokens are the correct inputs. The fact that Resonance YaRN improves OOD accuracy from 33.70% to 48.46% on Semi-Recursive (+14.76 points) while all methods use identical architecture and training data is strong evidence that the improvement comes specifically from better position encoding, not from better task learning. The variance reduction (standard deviations shrinking to near zero for Resonance YaRN on Recursive and CoT) further supports that the improvement is in robustness of position recognition — the model's performance becomes less dependent on whether the random training initialization happened to learn a good interpolation of the non-periodic features.

However, there is a nuance: the PosGen experiments use a two-layer Transformer trained from scratch, not a pre-trained LLM. This means the results demonstrate that Resonance RoPE improves length generalization during training from scratch, but do not directly demonstrate the same mechanism in the fine-tuning regime of the LLM experiments. The paper implicitly assumes that the mechanism transfers — that pre-trained LLMs also suffer from pre-critical interpolation and benefit from its elimination — but this is an assumption, not a proven fact. A PosGen-style experiment using a pre-trained and fine-tuned small Transformer (rather than trained from scratch) would bridge this gap but is not performed.

Does Resonance RoPE improve LLM downstream performance on long-context tasks?

The evidence is positive in direction but modest in magnitude and lacks statistical rigor. Table 2 shows that Resonance YaRN improves the average L-Eval score over vanilla YaRN by approximately 0.2–1.0 points across configurations. These improvements are consistent (Resonance YaRN wins or ties on 3 of 4 head-to-head comparisons for 7B and 2 of 2 for 13B) but small relative to the variance across subtasks. The lack of error bars, confidence intervals, or multiple training runs makes it impossible to determine whether these differences are statistically significant or could be explained by random seed variation. A 1-point average improvement on a 6-task benchmark where individual task accuracies vary by 20–60 points could easily arise from noise.

Furthermore, the improvement is not uniform across subtasks. On CodeU, Resonance YaRN degrades performance for 7B under both fine-tuning strategies (0.00% vs. 4.44% for FT@32K; 3.33% vs. 4.44% for FT@4K) and is mixed for 13B. On TOEFL, Resonance YaRN helps 7B FT@32K (+5.20 points) but hurts 7B FT@4K (−1.11 points) and 13B FT@16K (−0.37 points). On SFiction, the effects are small and mixed. The average improvement is driven primarily by GSM and QuALITY. This pattern — improvements on some tasks, neutral or negative on others — could indicate that Resonance RoPE's benefit is task-dependent in ways the paper does not analyze. A task that primarily requires attending to very long-range dependencies (where post-critical extrapolation dominates) might benefit less than a task requiring precise mid-range position discrimination (where pre-critical interpolation matters). The paper does not characterize the L-Eval tasks by their dependency distance distributions, so this hypothesis cannot be evaluated from the reported data.

Does Resonance RoPE achieve its claimed property of zero online computation cost?

Yes, trivially. The method replaces $\Theta$ with $\tilde{\Theta}$ through an offline computation that involves a few arithmetic operations per RoPE feature (divide, round, divide). During inference, the forward pass computes ${\bm{R}}^d_{\tilde{\Theta}, m}$ using the pre-computed $\tilde{\Theta}$ values exactly as standard RoPE computes ${\bm{R}}^d_{\Theta, m}$. There is no additional computation, no extra parameters, and no change to the attention mechanism. The claim of zero online cost is both true and verifiable from the algorithm description (Algorithm 1).

Is Resonance RoPE truly compatible with all RoPE-based scaling methods, or only demonstrated with YaRN?

Only demonstrated with YaRN. The paper claims compatibility with "RoPE and all RoPE-based scaling methods" (Section 4, multiple locations) but only evaluates the combination with YaRN. The PosGen experiments compare standalone Resonance RoPE and Resonance YaRN, and the LLM experiments exclusively use Resonance YaRN. There is no evaluation of "Resonance NTK-Aware" or "Resonance Position Interpolation." While the theoretical compatibility argument is sound (wavelength rounding is the final step regardless of how wavelengths were derived), the empirical claim that it improves all methods is untested. Position Interpolation compresses all wavelengths by a factor $s$, which could interact with the rounding step in unexpected ways — for example, if compression makes many pre-critical wavelengths very small (near 6), rounding them all to the same integer could create degeneracies that hurt performance. Testing Resonance RoPE with at least one other scaling method would strengthen this claim considerably.

Missing experiments and analyses

Several experiments would have strengthened the paper's claims or clarified open questions:

  1. Multiple fine-tuning runs with error bars for LLM experiments. The LLM results (Table 2, Figure 4) are based on single training runs per configuration. Given the 1-point average improvements on L-Eval, running 3–5 seeds per configuration and reporting confidence intervals would establish whether the improvements are reliable or within noise. This is especially important because LLM fine-tuning is known to be sensitive to data order and random seed.

  2. Resonance RoPE combined with scaling methods other than YaRN. Testing Resonance NTK-Aware and Resonance Position Interpolation would validate the universal compatibility claim and potentially reveal interactions between the rounding operation and different scaling strategies.

  3. Ablation on the rounding strategy. The paper uses standard round-to-nearest-integer. Alternative choices include rounding up (ceil), rounding down (floor), or rounding to the nearest integer that is coprime with other wavelengths to maximize the LCM. An ablation comparing these choices would clarify whether "closest integer" is optimal or whether other criteria (e.g., maximizing positional distinguishability through coprime wavelengths) could yield further improvements.

  4. Scaling behavior with model size and training compute. The paper tests only one synthetic model scale (2-layer T5-Small) and two LLM scales (7B, 13B). Does the benefit of Resonance RoPE diminish as model capacity increases (because larger models can learn to interpolate the non-periodic features)? Does it increase with longer target contexts (where more pre-critical dimensions are involved)? A scaling study across model sizes (e.g., 1B, 3B, 7B, 13B, 70B) and across target context lengths (e.g., 8K, 16K, 32K, 64K) would characterize the regime where Resonance RoPE is most impactful.

  5. Direct measurement of the feature gap in LLMs before and after Resonance RoPE. The paper proves Theorem 1 analytically for pre-critical dimensions but does not compute the actual feature gap values $h_i(\tilde{f})$ for LLaMA2 with and without YaRN, with and without Resonance RoPE. Computing these values numerically would: (a) verify that the theoretical gap reduction translates to the actual learned weight matrices; (b) quantify how much of the gap reduction occurs on pre-critical vs. post-critical dimensions; (c) correlate per-dimension gap reduction with per-task performance improvements to identify which dimensions matter most.

  6. Attention pattern analysis. If Resonance RoPE makes position recognition more robust, this should be visible in attention maps — the model should attend to the correct dependency positions more reliably on OOD positions. Visualizing attention patterns on PosGen's Semi-Recursive subtask with and without Resonance YaRN would provide mechanistic evidence for the claimed improvement and potentially reveal failure modes when Resonance RoPE does not help or hurts.

  7. Evaluation on a broader set of downstream tasks. L-Eval covers six closed-ended tasks, but other long-context benchmarks exist (LongBench, Bai et al., 2023; ZeroSCROLLS, Shaham et al., 2023; ∞-Bench). Testing on multiple benchmarks would establish whether the improvements generalize across task types and evaluation protocols, or are specific to L-Eval's task selection and prompting format.

  8. Analysis of the CodeU degradation. For LLaMA2-Chat 7B with Resonance YaRN FT@32K, CodeU accuracy drops to 0.00% from 4.44% for vanilla YaRN — a complete failure on that subtask. Understanding why would be informative: is CodeU particularly sensitive to the wavelength perturbation? Does it require precise position discrimination at a scale disrupted by rounding? The paper's silence on this anomaly is a gap.

Do the experiments support the paper's central claims?

Claim: "Resonance RoPE narrows the generalization gap in TSTL scenarios by refining the interpolation of RoPE features for OOD positions." Supported by the PosGen results, which show that Resonance YaRN improves OOD accuracy across all subtasks (Table 1) and that validation loss is consistently lower throughout training (Figure 3). The mechanism is analytically demonstrated through Theorem 1 and the feature gap metric. The evidence is cleanest for the synthetic setting; the LLM evidence (perplexity and downstream tasks) is consistent with the claim but does not isolate the mechanism — the LLM improvements could potentially arise from other effects of the wavelength perturbation (e.g., slightly altered attention patterns that happen to benefit language modeling) rather than specifically from reduced pre-critical interpolation.

Claim: "Resonance RoPE significantly improves model performance without additional online computational costs." The "without additional online computational costs" is trivially true. "Significantly improves" is supported for PosGen (up to +14.76 points on Semi-Recursive) but the claim is weaker for LLM downstream tasks where improvements are 0.2–1.0 points on average. The word "significantly" is ambiguous between statistical significance and practical significance; the paper provides evidence for practical significance on PosGen but not for statistical significance on LLM tasks.

Claim: "Resonance RoPE is compatible with RoPE and any RoPE-based scaling techniques." Compatible with YaRN is demonstrated. Compatible with "any" method is an overstatement relative to the experiments performed. The theoretical argument for compatibility is sound, but the empirical verification is limited to one scaling method, one model family, and one class of tasks.

6. Limitations and Trade-offs

The Method Does Not Address Post-Critical Extrapolation — It Must Be Combined with Another Scaling Method to Work

The assumption or constraint. Resonance RoPE operates exclusively on pre-critical RoPE dimensions—those with wavelengths shorter than the pre-training sequence length L. It rounds these wavelengths to integers, which Theorem 1 proves eliminates the feature gap for those dimensions. However, it does nothing for post-critical dimensions (wavelength ≥ L), where the dominant failure mode is value extrapolation: OOD positions produce rotary angles entirely outside the training range. The paper states this explicitly in the Limitations section:

"Our proposed Resonance RoPE focus on reducing the interpolation of only RoPE's pre-critical dimensions on OOD positions. However, this method does not solve the extrapolation issue on RoPE's post-critical dimensions, which has been shown to be also detrimental to LLM's length extrapolation performance. Thus, the technique of Resonance RoPE needs to be combined with another RoPE scaling method that can reduce extrapolation on RoPE's post-critical dimensions, e.g., YaRN, to achieve the full potential of LLM in TSTL scenarios."

The consequence. Resonance RoPE is not a standalone solution for TSTL. Using it without a post-critical scaling method produces mixed or negative results. This is directly observable in Table 1: standalone Resonance RoPE applied to vanilla RoPE degrades OOD accuracy on the Recursive subtask from 65.29% to 62.64% (−2.65 points), even while improving CoT and Semi-Recursive. The paper attributes this to "the dominance of extrapolated post-critical dimensions in OOD positions" on Recursive (Section 6.1.2). A practitioner who applies Resonance RoPE alone to extend a model's context window—without also applying YaRN, NTK-Aware scaling, or Position Interpolation—will likely see worse performance than the unmodified model on at least some tasks. This means Resonance RoPE is inherently a complementary technique, not a self-contained solution, and its deployment requires selecting and tuning a separate post-critical method. The paper only evaluates the combination with YaRN, so the interaction with other scaling methods (NTK-Aware, Position Interpolation) is empirically uncharacterized.

What evidence exists in the paper. Table 1 (Resonance RoPE vs. vanilla RoPE on PosGen) provides the direct evidence: −2.65 points on Recursive. The paper's Limitations section acknowledges this constraint in general terms. The LLM experiments only evaluate Resonance YaRN, implicitly acknowledging that standalone Resonance RoPE is insufficient for LLM-scale deployment.

Mitigation status. The paper does not attempt to solve the post-critical extrapolation problem—it explicitly delegates this to existing scaling methods. The recommended deployment path is Resonance YaRN (as demonstrated) or, by extension, Resonance NTK-Aware or Resonance Position Interpolation (claimed compatible but untested). This is a reasonable engineering choice—division of labor between methods—but it means Resonance RoPE inherits all limitations of whichever post-critical method it is paired with, including YaRN's sensitivity to the α, β hyperparameters and its requirement for fine-tuning.


The LLM Downstream Improvements Are Small in Magnitude and Lack Statistical Rigor

The assumption or constraint. The paper claims that Resonance YaRN "improves LLM's length extrapolation ability, as evidenced by ... enhanced outcomes in downstream tasks involving lengthy contexts" (Abstract). However, the LLM experiments (Table 2) report results from single training runs per configuration with no error bars, confidence intervals, or multiple-seed averaging. The improvements over YaRN are modest: for LLaMA2-Chat 7B, +0.97 to +1.00 percentage points on the L-Eval average; for LLaMA2-Chat 13B, +0.17 to +0.81 points. Individual subtask results are noisy, with Resonance YaRN sometimes performing substantially worse (e.g., CodeU: 0.00% vs. 4.44% for 7B FT@32K).

The consequence. A practitioner deciding whether to adopt Resonance RoPE for production LLM deployment faces uncertainty about whether the observed improvements are real or noise. The 1-point average gain on a 6-task benchmark where individual task scores range from 0% to 62% could easily arise from random seed variation, data order effects, or subtle differences in fine-tuning dynamics unrelated to position encoding quality. Without statistical quantification, the LLM-scale evidence reduces to "directionally consistent but not reliably measured." The anomalous CodeU result—complete failure (0.00%) on one subtask for the 7B model with Resonance YaRN under FT@32K—is particularly concerning: it suggests that Resonance RoPE could catastrophically degrade performance on certain task types, and the paper provides no analysis of why or how to predict such failures.

Additionally, the improvements are small in absolute terms. A 1-point average gain on a benchmark where the best configuration achieves ~37% accuracy means the relative improvement is ~2.7%. For a production system processing millions of tokens, this might translate to a meaningful number of additional correct answers; for a research benchmark where other interventions (better data, longer fine-tuning, different architecture) often yield 5–10 point gains, it is modest. The paper does not contextualize the effect size relative to other methods for improving long-context performance (e.g., simply fine-tuning for more tokens, or using a different RoPE scaling method).

What evidence exists in the paper. Table 2 reports all LLM downstream results. The lack of error bars or multiple-seed statistics is evident from the table structure. The paper's PosGen experiments (Table 1) do include standard deviations across 5 seeds, demonstrating that the authors are aware of statistical best practices—which makes their absence from the LLM experiments a conspicuous gap rather than an oversight.

Mitigation status. Not addressed. The paper does not discuss the need for or difficulty of multiple-seed LLM evaluation, nor does it acknowledge the lack of statistical rigor as a limitation. The computational cost of running multiple fine-tuning seeds for 7B and 13B models is substantial but not prohibitive given modern hardware (each fine-tuning run in the paper used 4× A100 40G GPUs for ~100M tokens). Running even 3 seeds would roughly triple the compute cost but would transform the reliability of the conclusions.


The Method Is Only Empirically Validated with YaRN on LLaMA2-Chat — Compatibility with Other Scaling Methods, Model Families, and RoPE Variants Is Unverified

The assumption or constraint. The paper repeatedly claims that Resonance RoPE is "compatible with RoPE and any RoPE-based scaling techniques" (Section 7, also Section 4) and positions it as "a universal improvement for RoPE and RoPE-based scaling methods" (Section 4). However, all LLM-scale experiments exclusively test Resonance YaRN on LLaMA2-Chat. Resonance RoPE is never evaluated in combination with NTK-Aware scaling, Position Interpolation, or any other post-critical method. It is never tested on non-LLaMA RoPE-based models (e.g., Mistral, Mixtral, Qwen, Code LLaMA, Gemma). It is never tested with non-standard rotary bases (e.g., the larger bases used in some recent models for improved length generalization). The synthetic PosGen experiments test Resonance RoPE with vanilla RoPE and with YaRN, using a standard base of 10,000—a narrow slice of the RoPE design space.

The consequence. A practitioner using a model other than LLaMA2-Chat—or using a RoPE scaling method other than YaRN—has no empirical evidence that Resonance RoPE will help rather than hurt. The theoretical argument for compatibility (wavelength rounding is the final step regardless of how wavelengths were derived) is sound, but interactions could exist. For example, Position Interpolation compresses all wavelengths by a factor s, potentially making many pre-critical wavelengths very small; rounding several different small wavelengths to the same integer could create degenerate feature dimensions that hurt rather than help. NTK-Aware scaling changes the rotary base rather than individual wavelengths; the interaction with the subsequent rounding step on the resulting wavelength distribution is not characterized. Different model families use different head dimensions, numbers of layers, and pre-training data distributions, all of which could affect how sensitive the model is to the wavelength perturbation that Resonance RoPE introduces.

The paper is transparent that the evaluation scope is limited—the model family and scaling method are clearly stated—but the gap between "demonstrated with YaRN on LLaMA2" and "universal improvement for any RoPE-based method" is wide.

What evidence exists in the paper. All LLM experiments (Section 6.2, Table 2, Figure 4) use LLaMA2-Chat 7B and 13B with YaRN scaling. The synthetic experiments (Section 6.1, Table 1, Figure 3) use a custom 2-layer Transformer with T5-Small architecture, RoPE base 10,000, and YaRN as the only tested scaling method. There are no experiments with Mistral, Code LLaMA, Mixtral, or any other RoPE-based architecture. There are no experiments combining Resonance RoPE with NTK-Aware scaling or Position Interpolation.

Mitigation status. The paper does not address this scope limitation as a limitation. The abstract and introduction language ("a novel approach designed to narrow the generalization gap in TSTL scenarios") does not qualify the scope to specific model families or scaling methods. The Limitations section discusses the need for other models only as future work: "Future work includes exploring Resonance RoPE's performance on other foundational models" (Section 7). This is an appropriate future direction but the current claims of universality are stronger than the empirical evidence supports.


The assumption or constraint. The paper's central mechanistic claim is that Resonance RoPE improves TSTL performance by eliminating the pre-critical feature interpolation gap, as formalized through the feature gap metric and Theorem 1. The PosGen experiments (Table 1) cleanly demonstrate this mechanism: by controlling token-generation difficulty, PosGen isolates position recognition, and Resonance YaRN substantially improves OOD accuracy. However, the LLM experiments (Table 2, Figure 4) do not provide equivalent isolation. The LLM improvements could arise from the posited mechanism (better OOD position recognition), or from other consequences of the wavelength perturbation that are unrelated to feature gap reduction—for instance, the slight change in each feature's rotation speed (e.g., from wavelength ~14.91 to 15 for feature j=6 in LLaMA2, a ~0.6% change in θ) could alter the learned attention patterns in ways that happen to benefit language modeling on the evaluation datasets, independently of whether the interpolation gap was the cause of prior failures.

The consequence. The paper has strong evidence for the mechanism at the two-layer Transformer scale on synthetic data, and correlational evidence for improved performance at the LLM scale on natural language data, but no direct evidence linking the two. A skeptical interpretation of the LLM results would be: "Resonance RoPE slightly perturbs the RoPE frequencies, and this perturbation happens to improve perplexity on GovReport/Proofpile and accuracy on some L-Eval subtasks by a small amount, but the mechanism might be unrelated to pre-critical interpolation." The paper's narrative—that the PosGen mechanism explains the LLM gains—is plausible and parsimonious, but it is an inference, not a demonstrated causal chain.

Establishing this link would require LLM-scale measurements of the feature gap, or intervention experiments showing that the improvement magnitude correlates with the number of pre-critical dimensions affected, or attention pattern analyses comparing OOD position recognition with and without Resonance RoPE. None of these are performed.

What evidence exists in the paper. PosGen results (Table 1, Figure 3) establish the mechanism at a small scale. LLM results (Table 2, Figure 4) establish the performance improvement at a large scale. The paper connects them through the shared method (Resonance RoPE) and the consistent direction of improvement, but does not provide any LLM-scale measurement of the feature gap, per-dimension analysis, or attention-level verification that OOD position recognition specifically improves in the LLM experiments.

Mitigation status. The paper does not acknowledge this as a limitation. The PosGen and LLM experiments are presented as complementary evidence for the same claim, but the inferential gap between them—from synthetic mechanism to natural language performance—is not discussed.


The Difficulty Estimation for Real-World Deployment Is Implicitly Assumed Away — Resonance RoPE Helps All TSTL Scenarios Equally

The assumption or constraint. The paper does not analyze whether the benefit of Resonance RoPE depends on characteristics of the specific TSTL scenario: the scaling factor s, the ratio of pre-critical to post-critical dimensions, the training sequence length L, or the nature of the downstream task. Resonance RoPE is applied uniformly to all RoPE features whose wavelength rounds to an integer below L, regardless of how much interpolation gap those features originally had, how close their original wavelength was to an integer, or how important those specific dimensions are for the downstream task.

The consequence. The method may be applying a perturbation (wavelength shift) to dimensions where the original interpolation gap was small and the perturbation cost (altering learned positional biases) outweighs the benefit. Conversely, it applies the same uniform treatment to all pre-critical dimensions, when some may have much larger original interpolation gaps than others (features with wavelengths nearly halfway between integers, where the phase shift per cycle is maximal). A more selective approach—only rounding dimensions where the gap reduction benefit exceeds some threshold, or where the original wavelength is within ε of an integer—might achieve most of the benefit with less perturbation to the learned representation. The uniform rounding strategy is simple and works on average, but it likely leaves performance on the table for scenarios where the pre-critical interpolation problem is either negligible or concentrated in a subset of dimensions.

Additionally, the paper provides no guidance on when Resonance RoPE is most valuable versus when it provides negligible benefit. In the PosGen experiments, the Semi-Recursive subtask shows a +14.76 point improvement from Resonance YaRN, while CoT shows only +0.87 points. This suggests task dependence, but the paper does not analyze what task properties (dependency distance distribution? number of long-range vs. short-range dependencies?) predict Resonance RoPE's effectiveness. A practitioner cannot determine from the paper whether their specific application—say, long-document summarization versus multi-turn dialogue—will benefit substantially or negligibly.

What evidence exists in the paper. The PosGen results (Table 1) show varying improvement magnitudes across subtasks: +2.37 points on Recursive, +0.87 on CoT, +14.76 on Semi-Recursive. The LLM results (Table 2) show varying improvements across L-Eval subtasks, with some showing degradation (CodeU). This heterogeneity is present in the data but not analyzed. The paper does not include an ablation on selective rounding or on the correlation between original interpolation gap magnitude and per-dimension or per-task improvement.

Mitigation status. Not addressed. The paper presents Resonance RoPE as a uniform, always-apply modification and does not discuss when it might be unnecessary or when a more targeted version might be preferable. The choice to round all pre-critical wavelengths (rather than selecting a subset) is a design choice that is presented without alternatives or analysis of its optimality.


The LCM Positivity Argument Masks a Subtle Representational Cost: Individual Features Becoming Exactly Periodic Changes the Position Encoding Geometry

The assumption or constraint. The paper defends against the concern that integer wavelengths create positional ambiguity by arguing that the least common multiple (LCM) of all pre-critical wavelengths is astronomically large (greater than 7×10⁵¹ for LLaMA2, Section 4, after Theorem 1), so the full position encoding never repeats in practice. This argument is mathematically correct for the joint encoding across all dimensions. However, it does not address a different concern: individual attention heads may rely primarily on a subset of RoPE dimensions for their positional computations. If a particular attention head has learned to use primarily dimensions j=6 and j=7 for position discrimination (perhaps because those wavelengths correspond to useful distance scales for that head's function), and both of those wavelengths become exact integers after Resonance RoPE, then the effective period of that head's position encoding becomes the LCM of just those two wavelengths—potentially much smaller than 7×10⁵¹.

The consequence. In the worst case, if an attention head specializes in a small subset of RoPE dimensions that happen to have small integer wavelengths with a low LCM, Resonance RoPE could introduce genuine positional ambiguity at the head level—the head could confuse positions separated by the head-specific LCM. The paper does not measure or analyze per-head wavelength usage, so it is unknown whether this worst case occurs in practice. The fact that Resonance YaRN improves performance empirically suggests it does not occur in problematic ways for the tested models and tasks, but the theoretical possibility exists and could manifest in models or tasks where heads strongly specialize in particular frequency bands.

More subtly, even when no outright ambiguity occurs, making individual dimensions exactly periodic changes the distance metric implicit in the attention dot product. With non-integer wavelengths, the RoPE features for position m and position m+k differ not only in the absolute rotation applied but also in the accumulated phase shift—the feature values at m+k are not simply a rotation of the values at m by kθⱼ, but include a small additional displacement from the non-integer cycle completion. This phase shift provides additional positional information that distinguishes, say, positions 15 and 30 even when the wavelength is ~14.91 (they have different accumulated phase errors). By making wavelengths exact integers, Resonance RoPE removes this phase-shift-based distinguishability, which could theoretically reduce the model's ability to resolve absolute position at distances that are multiples of the integer wavelength.

What evidence exists in the paper. None directly. The empirical results show net improvement from Resonance RoPE, suggesting that the cost of removing phase-shift information is outweighed by the benefit of eliminating the interpolation gap, at least on average. But there is no head-level analysis, no measurement of how individual dimensions are used by different attention heads, and no characterization of when the periodicity cost might dominate the interpolation benefit.

Mitigation status. The paper addresses only the joint-encoding LCM argument, not the per-head subset argument. This is acknowledged implicitly in the limitation scope—the paper is about empirical performance gains, not about a complete theoretical characterization of the representational tradeoffs. However, for a method whose entire justification is geometric (eliminating a specific feature-level interpolation gap), a deeper analysis of the geometric tradeoffs is a notable absence.

7. Implications and Future Directions

How This Work Changes the Landscape

This paper does not introduce a new paradigm for position encoding, nor does it propose a replacement for the dominant RoPE scaling methods. Instead, it makes a more surgical but potentially more broadly impactful contribution: it identifies and names a previously invisible failure mode—pre-critical feature interpolation—that afflicts all RoPE-based models and all existing RoPE scaling methods equally, and it provides a zero-cost fix that layers cleanly on top of whatever post-critical scaling strategy one already uses.

The conceptual shift is from a one-dimensional view of RoPE generalization ("keep all feature values within the training range") to a two-dimensional view ("keep values within the training range and make them land on values the model has actually seen, not between them"). Prior to this paper, the field treated "value in training range" as a sufficient condition for generalization safety. Resonance RoPE demonstrates that it is necessary but not sufficient—the density of feature value coverage within that range matters independently. This reframes RoPE scaling from a problem of extrapolation prevention (avoiding novel value ranges on post-critical dimensions) to a joint problem of extrapolation prevention + interpolation elimination (avoiding novel value ranges on post-critical dimensions and avoiding novel intermediate values on pre-critical dimensions).

The magnitude of this contribution is a refined diagnostic with a lightweight fix, not a paradigm shift. It does not overturn YaRN, NTK-Aware scaling, or Position Interpolation—it improves them by handling the dimensions they leave untouched. The PosGen benchmark formalizes something the field had implicitly noticed but could not measure: that TSTL degradation is not a single phenomenon but a composite of task-difficulty confounds and genuine position recognition failures. By providing the first clean measurement apparatus for the position recognition component, PosGen enables future work to optimize position encodings with far less noise than was possible when using perplexity on natural text or existing synthetic tasks as proxies.

The paper also resolves a latent tension in the existing literature, though it does so implicitly. Prior work on RoPE scaling methods (Chen et al., 2023; bloc97, 2023; Peng et al., 2024; Liu et al., 2024) showed that post-critical extrapolation is the dominant source of degradation—fixing it yields 15–30 point accuracy gains on PosGen (Table 1: YaRN vs. vanilla RoPE). But those same methods left a residual gap: even the best scaling method (YaRN) achieved only 33.70% OOD accuracy on the Semi-Recursive subtask, far below the near-perfect 98.71% on CoT. Why would a method that prevents extrapolation leave such a large task-dependent residual? The answer, as this paper shows, is that Semi-Recursive's varying-distance dependency pattern makes it especially sensitive to the interpolation gap on pre-critical dimensions—the exact problem Resonance RoPE addresses. The fact that Resonance YaRN pushes Semi-Recursive from 33.70% to 48.46% (+14.76 points) while only marginally improving CoT (+0.87 points) provides a coherent explanation for a previously puzzling pattern in the literature: why some tasks benefit more from position encoding improvements than others. It is not that the scaling method is inadequate; it is that different tasks stress different dimensions of the position encoding, and pre-critical interpolation is an orthogonal axis of generalization quality that prior methods ignored.

Practically, this work makes several research directions more attractive:

  • Integer-wavelength design principles for position encodings are undervalued. The paper shows that the seemingly trivial choice of whether wavelengths are integers or reals has measurable effects on length generalization. This opens an avenue for principled wavelength design—rather than accepting whatever wavelengths emerge from the standard $\theta_j = b^{-2j/d}$ formula, one could design wavelength schedules that explicitly balance interpolation elimination (via integer wavelengths), extrapolation prevention (via YaRN-like scheduling), and positional distinguishability (via coprime wavelength selection).

  • Fine-grained diagnostic benchmarks for position encodings are now feasible and necessary. PosGen demonstrates that one can build a controlled testbed that isolates position recognition from task difficulty. The research community should adopt this methodology—or extensions of it—as a standard evaluation for any new position encoding proposal, replacing or supplementing the noisy signal from perplexity curves and downstream task averages. A method that claims to improve position encoding but does not improve OOD accuracy on PosGen is likely benefiting from some other mechanism, and the field should know this.

  • The YaRN pipeline becomes the default integration target for pre-critical improvements. Since Resonance RoPE is validated specifically as a YaRN add-on, and YaRN is the current state-of-the-art for post-critical scaling, the combination "YaRN + pre-critical fix" becomes the natural baseline that any future position encoding proposal must beat. A new method that outperforms YaRN but underperforms Resonance YaRN is only a partial solution to the TSTL problem.

Conversely, this work makes some research directions less attractive:

  • Developing ever-more-complex post-critical scaling schedules without also addressing pre-critical interpolation is a diminishing-returns strategy. The paper shows that switching from NTK-Aware scaling (uniform base scaling) to YaRN (per-dimension scheduling) yields large gains (+30 points on PosGen Recursive). But further refinements to the post-critical schedule alone cannot address the pre-critical residual, which dominates on tasks like Semi-Recursive. Future scaling methods should treat pre-critical and post-critical handling as equally important design considerations rather than focusing exclusively on the extrapolation problem.

  • Position encoding methods that increase positional distinguishability at the cost of larger feature gaps may be counterproductive. Some approaches, like randomized position encodings (Ruoss et al., 2023), introduce noise to help the model generalize across position ranges. The feature gap framework suggests a tradeoff: randomization may improve robustness to extrapolation but could worsen the interpolation gap by smearing feature values across the range. The paper does not test this directly, but the metric provides a tool for quantifying the tradeoff that was not previously available.

  • Using perplexity alone to evaluate position encodings on natural text is insufficient. The paper's PosGen results demonstrate that position recognition can be precisely measured when task difficulty is controlled. In natural text perplexity evaluation, the signal from position encoding quality is contaminated by the inherent difficulty variation of the language modeling task across positions. Future position encoding papers that rely exclusively on perplexity curves as evidence should be viewed with appropriate skepticism—the curves conflate two distinct sources of degradation.

Follow-Up Research This Work Enables

1. Selective or thresholded Resonance RoPE with per-dimension cost-benefit analysis. The paper applies wavelength rounding uniformly to all pre-critical dimensions. But the original interpolation gap varies per dimension: a dimension with wavelength 14.91 (gap ~0.09 tokens from integer) experiences a different magnitude of phase shift per cycle than one with wavelength 14.51 (gap ~0.49 tokens). Rounding the former requires a 0.6% change in $\theta_j$; rounding the latter requires a 3.3% change. A follow-up study should compute the original feature gap $h_i(\tilde{f})$ numerically for each pre-critical dimension in LLaMA2, measure how the gap correlates with the magnitude of the wavelength perturbation under Resonance RoPE, and test whether only rounding dimensions above some gap threshold—or only those whose original wavelength is within $\epsilon$ of an integer—achieves most of the PosGen improvement with less perturbation to the learned attention patterns. The experiment would train multiple 2-layer Transformers on PosGen with Resonance RoPE applied to varying subsets of pre-critical dimensions, measuring OOD accuracy against both the fraction of dimensions rounded and the total $\ell_1$ perturbation to $\Theta$.

2. Head-level analysis of RoPE frequency usage to predict task-specific Resonance RoPE sensitivity. The paper demonstrates that Resonance YaRN's benefit varies substantially across PosGen subtasks (+0.87 to +14.76 points) and across L-Eval subtasks (e.g., GSM consistently shows larger gains than TOEFL). A mechanistic follow-up would analyze which attention heads in the trained model rely on which RoPE frequency bands, and whether Resonance RoPE's benefit is concentrated in heads that primarily use pre-critical dimensions. For a model trained on PosGen's Semi-Recursive subtask, one could compute the Fourier transform of each head's attention patterns to determine its preferred spatial frequencies, then correlate per-head frequency preference with the change in that head's attention accuracy under Resonance RoPE. The hypothesis is that heads relying on frequencies near integer wavelengths (where the original interpolation gap was small) benefit less than heads relying on frequencies midway between integers (where the gap was maximal). If confirmed, this would enable head-specific application of Resonance RoPE—rounding only the dimensions used by heads that are bottlenecked by interpolation—which could preserve more of the original learned positional biases while still achieving most of the performance gain.

3. Resonance RoPE applied to other RoPE scaling methods (NTK-Aware, Position Interpolation) and other model families (Mistral, Code LLaMA, Gemma). The paper claims universal compatibility but only tests with YaRN on LLaMA2-Chat. A direct replication study should apply Resonance RoPE on top of: (a) NTK-Aware scaling with scaling factors $s \in \{2, 4, 8, 16\}$, measuring perplexity on GovReport/Proofpile and OOD accuracy on PosGen with and without the Resonance modification; (b) Position Interpolation with varying compression factors, checking whether the wavelength compression interacts negatively with rounding (e.g., if compression makes many wavelengths small and near each other, rounding could create degenerate identical wavelengths that reduce effective positional resolution). Additionally, testing on Mistral-7B and Code LLaMA-7B (which use different rotary base values and head dimensions) would characterize whether the benefit depends on the specific wavelength distribution or is universal across RoPE variants. A negative result—Resonance RoPE helping on LLaMA2 but hurting on Mistral—would be equally informative, revealing model-family-specific sensitivity to wavelength perturbation.

4. Alternative integer-wavelength construction strategies beyond nearest-integer rounding. The paper uses $\text{round}(\lambda_j)$ to produce integer wavelengths. But this is only one of many ways to map non-integer wavelengths to integers while preserving some notion of proximity to the original value. Alternative strategies include: (a) rounding to the nearest integer that is coprime with all previously rounded wavelengths at lower indices, to maximize the LCM of any subset of dimensions (addressing the per-head periodicity concern discussed in the Limitations); (b) rounding to the nearest integer in a pre-computed set of "good" wavelengths that have been optimized via grid search to maximize PosGen performance; (c) using a learned rounding function where a small neural network predicts the optimal integer wavelength for each dimension given the original wavelength and the model's downstream task performance as a training signal. A comparison of these strategies on PosGen's three subtasks, measuring both OOD accuracy and training stability (validation loss variance across seeds), would reveal whether the simple rounding heuristic is near-optimal or whether there are substantial gains to be had from more careful wavelength selection.

5. Feature gap measurement in pre-trained LLMs to validate the mechanistic transfer from PosGen to natural language. The paper proves Theorem 1 analytically and demonstrates the mechanism empirically on PosGen, but never measures the feature gap in actual LLaMA2 models. A measurement study would: (a) extract the RoPE $\Theta$ values from a pre-trained LLaMA2-7B checkpoint; (b) for a sample of input vectors ${\bm{x}}$ (e.g., random Gaussian or actual token embeddings), compute the feature gap $h_i(\tilde{f})$ for each dimension $i$ under vanilla RoPE, YaRN, and Resonance YaRN, for test lengths up to 32K; (c) verify that the gap on pre-critical dimensions is non-zero for vanilla RoPE and YaRN, and drops to (near) zero for Resonance YaRN; (d) correlate the per-dimension gap reduction with per-dimension changes in attention weight patterns on long-context inputs. This would provide the missing causal link: if dimensions with the largest gap reduction show the largest changes toward correct attention patterns, the mechanistic story is confirmed at LLM scale. If the gap reduction is uncorrelated with attention improvements, then Resonance RoPE's LLM benefits likely arise from some other effect, and the PosGen mechanism does not cleanly transfer.

6. Resonance RoPE combined with Position Interpolation for extremely long contexts (100K+ tokens). YaRN achieves 64K context for LLaMA2, and the paper tests up to 32K. For very long contexts, Position Interpolation is often preferred because it provides the strongest extrapolation prevention (all dimensions are compressed into the training range), albeit at the cost of reduced local resolution. An interesting combination would be Resonance + Position Interpolation: compress all wavelengths by factor $s$, then round to integers. This would eliminate interpolation gaps on all dimensions simultaneously (since all wavelengths become pre-critical after compression, they are all subject to Resonance RoPE's zero-gap guarantee), potentially giving Position Interpolation the local-resolution benefits that Resonance RoPE provides while maintaining its global extrapolation prevention. A head-to-head comparison of Resonance YaRN vs. Resonance Position Interpolation on GovReport perplexity at 64K and 128K context lengths, with controlled fine-tuning budgets, would establish which combination dominates for ultra-long contexts.

Practical Applications and Downstream Use Cases

1. Extending context windows of deployed LLaMA-family models with no additional inference cost. For any production system running LLaMA2, LLaMA3, Mistral, or Mixtral with YaRN-based context extension (currently the most common approach for open-weight models), switching from vanilla YaRN to Resonance YaRN requires: (a) replacing $\Theta$ with $\tilde{\Theta}$ in the model configuration (a one-line code change, since the computation is Algorithm 1 applied offline), and (b) optionally re-running fine-tuning if the model was already fine-tuned with vanilla YaRN (though the paper shows that applying Resonance YaRN without re-tuning is not tested). The benefit is the L-Eval average improvement of ~1 percentage point (Table 2), plus lower perplexity across all context lengths (Figure 4), with zero additional latency, zero additional memory, and zero additional FLOPs at inference time. For a production system serving millions of requests daily on long-context tasks (document QA, summarization, code completion), a 1-point accuracy improvement with no cost is a strictly dominant upgrade. The CodeU degradation (0.00% for 7B FT@32K) is a deployment concern that warrants testing on the specific downstream task before rollout—practitioners should benchmark on their own task distribution rather than assuming uniform improvement.

2. Fine-grained position encoding evaluation during model development. The PosGen benchmark provides a lightweight (2-layer Transformer, 10K training samples, 5 seeds, runs on a single V100 GPU) diagnostic for position encoding quality that is not confounded by task difficulty. A team developing a new position encoding method—whether a RoPE variant, a learned encoding, or an architecture change—can now include PosGen in their evaluation pipeline alongside standard perplexity and downstream benchmarks. A method that improves perplexity but degrades PosGen OOD accuracy is likely benefiting from something other than better position recognition, which is valuable diagnostic information for guiding iteration. The three-subtask structure (Recursive, CoT, Semi-Recursive) further reveals whether the improvement is robust across dependency patterns or specific to local-attention tasks. The paper's release of PosGen code (referenced in the abstract footnote) makes this immediately adoptable.

3. Improving long-context fine-tuning data efficiency. The paper's finding that FT@4K for 400 epochs outperforms FT@32K for 50 epochs on LLaMA2-7B (37.58% vs. 34.24% for Resonance YaRN, Table 2) has practical implications for fine-tuning budget allocation. Given a fixed fine-tuning compute budget (~100M tokens in this study), training on shorter sequences for more iterations yields better downstream performance than training on the target extended length for fewer iterations. This is valuable guidance for practitioners who assumed that fine-tuning on the target length was necessary for good length generalization—it may be more effective to spend the budget on more optimization steps at the original pre-training length, letting the scaled position encoding (YaRN + Resonance) handle the generalization to longer contexts. The interaction with model scale (this pattern reverses for 13B, where FT@16K outperforms FT@4K) suggests that the optimal strategy is scale-dependent and should be tuned per deployment, but the principle that short-sequence fine-tuning is competitive or better for smaller models is actionable for 7B-scale deployments.

4. A zero-cost improvement for any future RoPE-based model release. The Resonance RoPE modification requires no architecture changes, no retraining from scratch, and no inference-time overhead. A model developer training a new RoPE-based LLM (whether LLaMA-derived or a novel architecture) can apply Resonance RoPE to the pre-training position encoding from the start—simply replace $\Theta$ with $\tilde{\Theta}$ in the model definition before training begins. The model would be trained from scratch with integer-wavelength RoPE features on pre-critical dimensions, avoiding the interpolation gap entirely during pre-training rather than patching it at fine-tuning time. The paper's PosGen results (trained from scratch with Resonance RoPE, showing +5.69 points on CoT and +11.82 points on Semi-Recursive over vanilla RoPE, Table 1) suggest this would improve length generalization from the outset. Even if the benefit is modest at the scale of a full pre-training run (which the paper does not test), the zero cost makes it a rational default choice—there is no downside to building the model with $\tilde{\Theta}$ rather than $\Theta$, and there may be an upside for length generalization that becomes apparent during context extension fine-tuning.