An Efficient Framework for Length Extension via Dynamically Growing Positional Embedding and Correlation-Aware Routing Attention

wang ning, Zekun Li, Tongxin Bai, Man Yao, Zhen Qin, Guoqi LiOpenReview 2026 · Submission to ICLR 2026 · Rejected

TL;DR

This paper introduces a highly efficient framework for extending the context window of Large Language Models (LLMs) by up to 128× their original training length. By combining a novel data-augmentation-based positional encoding (CRG NTK) with a sparse, correlation-based "Merge and Select" (MS) attention mechanism, the authors achieve state-of-the-art extrapolation while using 16× fewer GPU resources than previous leading methods like LongRoPE.

What Problem Does This Paper Address?

Modern LLMs are typically pre-trained on fixed, relatively short sequence lengths (e.g., 4K tokens). When we try to use them for long-document analysis or complex coding tasks, they face two major hurdles:

  1. Positional Overfitting: Models overfit to the specific positional encodings seen during training, causing performance to collapse when they encounter "unseen" positions in longer sequences.
  2. Computational Bottlenecks: Standard attention is quadratic; doubling the sequence length quadruples the memory and compute requirements. Fine-tuning on extremely long sequences is often prohibitively expensive.

Existing solutions like Positional Interpolation (PI) or NTK-aware scaling help, but they often rely on hand-crafted heuristics that don't fully exploit the model's latent capacity for extrapolation. Furthermore, as sequences get longer, the "noise" from irrelevant tokens begins to drown out the useful signal, a problem standard Softmax attention struggles to solve.

Methods

The authors propose a two-pronged strategy:

1. CRG NTK Positional Embedding

This is a data-augmentation technique for Rotary Positional Embeddings (RoPE). It consists of three components:

  • Cyclic & Randomly Truncated: During fine-tuning, the model is exposed to random offsets and modular mappings of position indices. This forces the model to become robust to local phase shifts rather than just memorizing absolute positions.
  • Dynamically Growing: Instead of picking one scaling factor, the authors use a power-law growth schedule to "scan" the positional solution space. This allows the model to incrementally learn how to handle increasingly larger scales.

2. Merge and Select (MS) Attention

To handle the computational load and noise of long sequences, the authors introduce a routing-based sparse attention mechanism:

  • Selection: The Q, K, and V tensors are segmented into regions. The model uses "semantic tokens" (compressed representations of these regions) to calculate a coarse relevance map, selecting only the most important Key-Value regions for each Query region.
  • Merging: Selected regions are merged to balance computational efficiency with contextual breadth. This explicitly filters out irrelevant "noise" tokens, which the authors argue is crucial for maintaining performance at extreme lengths.

3. Reduced Fine-Tuning

Building on the LongLoRA framework, they show that fine-tuning only the $W_q$ and $W_k$ weights (the ones that interact with positional encodings) is sufficient to achieve these gains, significantly reducing memory overhead.

Datasets

  • Fine-tuning: The RedPajama dataset was used for training.
  • Evaluation:
    • PG19 and Proofpile for measuring language modeling perplexity.
  • Passkey Retrieval: A needle-in-a-haystack task to test long-range memory.
  • LongBench: A comprehensive benchmark for long-context understanding.
  • Standard Benchmarks: ARC-c, HellaSwag, MMLU, and TruthfulQA to ensure the model doesn't lose its general reasoning abilities (catastrophic forgetting).

Key Insights and Ideas

  • The Depth Limit Hypothesis: One of the most intriguing theoretical claims in the paper is that a model's extrapolation limit is approximately bounded by its depth (number of layers). For a 32-layer Llama2-7B model, they hypothesized and empirically approached a 32× extrapolation limit for stable perplexity.
  • Position as a Search Space: Rather than treating positional scaling as a fixed math problem to be solved, the authors treat it as a space to be explored via data augmentation. By "scanning" different scales during training, the model learns a more generalized representation of relative distance.
  • Noise is the Real Enemy: The authors argue that simply increasing sequence length isn't enough; you must actively filter noise. Their routing mechanism acts as a hard filter, which they found performed better than the "soft" filtering of standard Softmax when sequences reached hundreds of thousands of tokens.

Key Results

  • Massive Extrapolation: Llama2-7B and Mistral-7B, fine-tuned at only 16K context length, achieved 128× extrapolation (up to 2 million tokens) on simple retrieval tasks.
  • Stable Perplexity: The models maintained stable perplexity over 32× sequence length extensions (e.g., testing at 512K after training at 16K).
  • Efficiency Gains: The framework requires at least 16× less GPU training time compared to LongRoPE to achieve comparable performance. For example, they reached a 1M context window using a single A100 GPU in about 29 hours, whereas previous methods required clusters of 8 GPUs for multiple days.
  • Performance Preservation: The models maintained their performance on short-context benchmarks (like MMLU), proving that the length extension didn't come at the cost of general intelligence.

Limitations and Future Work

  • Hardware Optimization: While the algorithm is theoretically efficient, the authors note that future work should incorporate Triton operators to further optimize the spatial complexity of the routing step.
  • Relative Shifts: The current method focuses on scaling; the authors suggest that future versions could incorporate relative shifts between Query and Key tokens to help the model "sense" deviations in position more accurately.
  • Hyperparameter Tuning: The selection of segment sizes and merge factors currently requires some manual tuning; the authors aim to develop a loss-function-based approach to automate these choices.

Summary updated

BibTeX
@misc{ning2026efficient,
  author = {wang ning and Zekun Li and Tongxin Bai and Man Yao and Zhen Qin and Guoqi Li},
  title = {{An Efficient Framework for Length Extension via Dynamically Growing Positional Embedding and Correlation-Aware Routing Attention}},
  year = {2026},
  url = {https://openreview.net/forum?id=dPhxStH5N5},
  howpublished = {OpenReview},
  note = {Submitted to ICLR 2026},
}
Figure