Open weights · Field guide

Reindexing positions changes how sparse attention sees a sequence

A sparse attention pattern can leave retained tokens far apart in their original sequence. Reindexing asks what position should mean within the context actually used.

In this article
Position reindexing — Of the 64K reference score: ~90%. RULER at 512K context in the reported experiment.

Suppose a query attends to a handful of tokens scattered across a very long sequence. The positions may remain far apart in the original coordinate system even though almost everything between them is absent from the computation. The reindexing study asks whether a model should represent distance differently for that sparse set. It changes how retained evidence is positioned after selection.

The initial obstacle was clear: even when sparse attention limits the number of keys considered per query, those keys retain their original positions in the full sequence. Under standard Rotary Position Encoding (RoPE), this means a distant key—say, one from far back in the input—can still appear with a large positional distance relative to its query, regardless of how few tokens are actually attended. This creates a mismatch between the model’s attention budget and the positional range it must handle. The model is thus forced to learn and manage rare or unseen relative distances during training, which undermines both generalization and efficiency.

To address this, the team introduced native position reindexing—making position assignment dependent on each query’s selected tokens during both training and inference. For every query, the selected keys are assigned consecutive integer positions in their original order, preserving sequence order while compressing long gaps left by skipped tokens. This ensures that relative distances within a query’s context are bounded not by the full sequence length but by the attention budget itself.

This design preserves the structure of the original input while enabling the model to generalize over context lengths without extending the positional range. Unlike prior methods that rely on interpolation or frequency rescaling, which depend on a fixed target length and may degrade performance within the original window, native reindexing adapts dynamically per query. It also avoids the inconsistencies seen in inference-time reindexing schemes like StreamingLLM or InfiniteHiP, where position assignments are determined by heuristic cache eviction policies that drift over time and are never optimized jointly with attention behavior.

The approach is built into the sparse attention architecture using a lightweight indexing mechanism inspired by MiniMax Sparse Attention. Query and key vectors are projected into index space via learned linear transformations; these indices are then used to compute scores within KV blocks through scaled dot products, followed by max-pooling across heads. The resulting score maps directly to which tokens are selected for attention. By aligning the positional coordinates with the actual selected context, the model learns to treat relative distances as bounded and meaningful—without relying on positions that may not exist in real input.

A key technical challenge was preserving efficiency in the face of query-dependent rotations. In RoPE, position is encoded via rotation matrices derived from fixed frequencies applied to token indices. When these indices are reindexed per query, the resulting rotations differ across queries, making it difficult for rotated keys to be reused efficiently. To mitigate this, the researchers introduced structure-aware rotation reuse and fused kernel operations that maintain tensor-core optimization while allowing shared computation across similar positional patterns. This preserves computational efficiency without sacrificing the flexibility of dynamic indexing.

The method was tested on a dense-to-sparse transition in an existing model (OLMo-3), converted to block-sparse attention via LogGate during continued pretraining. The training process used native reindexing consistently throughout, ensuring that each query’s selected tokens were assigned consecutive positions based on their original order. This allowed the model to learn position relationships within its attention budget without being exposed to long-range distances that were either absent or poorly represented in training.

The results show that the model maintains strong performance on standard benchmarks while demonstrating improved handling of long-context inputs—without requiring expansion of positional encoding ranges. The key insight is not just that positions are reindexed, but that this indexing becomes a learned, adaptive feature of attention rather than an external fix. This co-design allows sparse models to treat their context more naturally, reducing reliance on interpolation or post-hoc adjustments.

Instead, it rethinks how position is defined in sparse attention: as a function of selected tokens and their order, rather than a fixed enumeration of sequence indices. This shift enables better alignment between computation, context selection, and positional meaning—without introducing new complexity or sacrificing efficiency.

Retaining a fraction of a score at a longer context

At 512K context, the position-reindexing researchers report retaining about 90 percent of their 64K RULER score without additional training or positional retuning. That is a ratio between two scores for the tested approach. It is not a statement that the model answered 90 percent of the longer-context questions correctly. The absolute scores and the change in context length supply the rest of the interpretation. A separate comparison in the report evaluates the value of training with the new position rule rather than switching it on only at inference.

Native Position Reindexing in Sparse Attention Training

In sparse attention models, each query attends only to a subset of keys, typically selected based on relevance or proximity. During training, these queries are processed in parallel, and the positions of selected tokens are often assigned sequentially according to their original order within the sequence. However, traditional methods assign fixed global positions that do not reflect the actual context of each query—gaps left by unselected tokens remain large and poorly represented. The proposed method introduces native position reindexing: during both training and inference, each query’s selected keys are assigned consecutive indices in their original order. This reindexing compresses positional distances within the attention budget, ensuring that relative positions between attended tokens are bounded not by sequence length but by the number of keys actually considered. Unlike prior approaches that apply reindexing only at inference time—such as StreamingLLM or InfiniteHiP—the model learns these query-specific position assignments through training. This allows the internal representations to adapt to the structure of sparse attention, rather than merely tolerating it.

The method is implemented with rotary position embeddings (RoPE), resulting in ReIndexing RoPE (RiRoPE). In standard RoPE, each key is rotated using a fixed function based on its global position. When different queries select different sets of keys, those keys must be rotated independently, leading to high memory and computation costs. To address this, the method introduces structure-aware rotation reuse: within block-sparse multi-head attention (MHA), keys are grouped into blocks, and their rotations are reused across queries that select them. The within-block offset—how far a key is from the start of its block—is preserved and reused when the same key appears in different queries. This avoids redundant computation while maintaining accurate positional information. A fused kernel implementation ensures these rotations can be efficiently computed using tensor cores, preserving performance gains during forward passes.

Evaluation of Long-Context Performance Across Training Stages

The experiments are conducted on OLMo-3-7B, trained through three stages: Stage 2 (mid-training) with 50 billion tokens at an 8K context length, and Stage 3 (long-context extension) with another 50 billion tokens extended to 64K. The model is evaluated using synthetic benchmarks like RULER and HELMET, which test retrieval accuracy over varying sequence lengths, as well as general capabilities on math, code, and language tasks. After mid-training at 8K, RiRoPE maintains performance comparable to baseline models in general tasks, indicating that the reindexing does not degrade foundational knowledge. When extended to 64K context length, RiRoPE outperforms sparse RoPE with YaRN by 6.14 points on RULER and 4.40 points on HELMET. These gains are observed consistently across both synthetic and realistic tasks, suggesting that the reindexing improves the model’s ability to maintain positional coherence over long sequences.

The key observation is that these improvements persist beyond the training context—without further training or changes to position encoding settings. At 128K, 256K, and 512K sequence lengths, RiRoPE consistently outperforms all other evaluated variants, including sparse RoPE with YaRN and NoPE (a baseline without positional encoding). At 512K—eight times the original training length—the model achieves a score of 72.17, retaining approximately 90% of its performance at 64K. In contrast, sparse RoPE with YaRN scores only 15.21, and NoPE reaches 70.63, which is slightly lower than RiRoPE. This demonstrates that the model’s ability to generalize in long-context settings is not just a result of extended training but stems from its learned understanding of query-dependent positional structures.

How Native RiRoPE Training Boosts Extrapolation

The results show that native reindexing during training enables better extrapolation than inference-only reindexing. A controlled ablation reveals that switching to RiRoPE only at inference time leads to a significant drop in performance—specifically, a 21.24-point deficit on RULER at 256K compared to training with RiRoPE throughout. This difference indicates that the model does not merely “tolerate” reindexed positions during generation; it learns their geometric structure through training. The positional assignments are no longer arbitrary or heuristic-driven—they emerge from the joint optimization of attention and position encoding. As a result, when generating long sequences, the model can maintain consistent relative positioning between attended tokens, even as context grows beyond training length.

The gains are not due to changes in attention mechanisms, data distribution, or model architecture but rather to a more accurate alignment between position encoding and sparse selection dynamics.

The scope of these observations is limited to the OLMo-3-7B block-sparse MHA architecture with RoPE-based positional encodings. While the method is agnostic to specific positional encodings, its effectiveness is demonstrated in this setting due to the compatibility with existing training pipelines and architectures. The findings suggest that native reindexing—when integrated into training—can improve long-context modeling without requiring additional data or model modifications.

What Distinguishes Native Position Reindexing from Inference-Time Adaptation

The key distinction between native position reindexing and inference-time adaptation lies in whether the model learns to associate query-specific positional geometry during training or merely responds to it at inference. In native reindexing, each query’s selected tokens are assigned consecutive indices based on their original order, and this indexing is used throughout training—meaning the model’s internal representations evolve to reflect these dynamic positional relationships. This allows gradients to adjust attention weights in response to relative distances defined by the query’s own context, rather than relying on fixed, global token positions. A test that would distinguish these approaches is whether performance improves when reindexing is applied consistently across all training stages—especially in long-context extrapolation beyond the original sequence length. If RiRoPE outperforms sparse RoPE with inference-only adaptation at 128K, 256K, and 512K without further tuning, it indicates that learning the query-dependent positional structure during training is essential.

When Positional Geometry Becomes Context-Dependent

The current evidence supports native reindexing as a beneficial design for sparse attention, but its effectiveness is bounded by the assumption that positional relationships are defined by query-specific sequences rather than global sequence order. This boundary emerges from the observation that RiRoPE performs best when both training and inference use reindexed positions—yet the model’s success depends on sufficient head sharing or block structure to enable efficient computation. Without such structural support, rotation reuse breaks down, and the computational overhead increases, potentially undermining performance gains. Furthermore, the experiments fix the LogGate block-sparse architecture and attention budget, meaning results cannot be generalized to other sparse designs such as dynamic selection or token-level gating. A critical boundary is thus reached when the model’s ability to generalize beyond training length depends not just on reindexing but also on the consistency of key-value access patterns across heads and layers. If performance drops significantly in models with minimal head sharing—such as in a single-query, multi-head setting—it would suggest that the benefit of native reindexing is contingent on architectural features that enable amortized computation.

How Token Selection Affects Reindexed Distances

A central open question remains about how position reindexing interacts with the underlying token selection process. The current framework assumes that reindexing occurs regardless of whether tokens are selected in a contiguous, random, or structured manner—yet it does not test whether different selection strategies produce distinct positional learning outcomes. For example, if a query selects only nearby tokens, the reindexed positions may be small and redundant, offering little signal for long-range contextual modeling. Conversely, a query selecting distant tokens might generate large relative distances in the reindexed space, potentially enabling better geometric understanding of faraway context. This lack of control means we cannot determine whether reindexing is most effective when combined with structured, long-range selection—such as in a sliding window or global key access pattern—or if it performs equally well under more random or sparse sampling. Additionally, the model’s ability to learn from these dynamic positions may depend on how often a given query revisits similar token sets during training. Without such controlled experiments, it remains unclear whether native position reindexing serves as a general-purpose enhancement or one that works best under specific data distributions and query behaviors. This gap limits our understanding of when and why the method produces superior long-context performance, and what role token-level dynamics play in shaping its success.