RiRoPE co-designs positions with sparse attention — 6.14 RULER points over YaRN at 64K, ~90% retention at 8× training length
Reindexing each query's selected keys during training and inference bounds relative positions to the attention budget — with a kernel fix that keeps tensor-core matmuls intact.

A Tencent Hunyuan-led team (with CUHK, HKUST, and Nvidia co-authors) proposes RiRoPE (ReIndexing RoPE): renumber each query's selected keys consecutively during training and inference, so relative positions are bounded by the attention budget instead of the sequence length. On a matched OLMo-3-7B continued-pretraining setup, they report a 6.14-point RULER gain over a sparse RoPE+YaRN baseline at 64K, ~90% score retention at 512K (8× the training length) with no positional retuning, and a 21.24-point advantage over switching to reindexing only at inference. Sparse attention has always inherited positional encodings designed for dense attention, even though sparsity changes each query's context.
What shipped
In sparse attention, each query attends to a bounded set of keys. RiRoPE assigns those selected keys consecutive indices in their original order, skipping the gaps left by unselected tokens. With at most B selected tokens, every relative distance stays within [0, B−1] regardless of sequence length. When nothing is skipped — short sequences attended in full — it reduces to ordinary indexing. Instantiated with RoPE, it becomes RiRoPE, chosen for RoPE's ubiquity and compatibility with OLMo-3's pretrained weights.
Sparse attention bounds the number of keys in the softmax, but with ordinary RoPE a faraway selected key still carries a large positional distance that was poorly covered or unseen in training. Reindexing makes long-range interactions share positional representations with short-range ones.
The paper's engineering contribution is making this trainable at all. In standard RoPE, a key's rotation depends only on its own absolute position, so one rotated key serves every query — that's what makes sparse-attention kernels fast. Under reindexing, the rotation angle depends on the query's selection, so a naive implementation would rotate each key separately for every query that selects it, materializing per-pair rotated keys and destroying the efficiency gain.
The fix, which the authors call structure-aware rotation reuse, separates a token's within-block offset from the number of selected blocks between key and query: keys keep reusable within-block rotations, while queries accumulate the rotations associated with selected blocks. That yields fused SM90 kernels that preserve tensor-core matrix multiplication without materializing per-pair rotated keys. The code is released on GitHub, including training recipes, the fused kernels, and an eval harness.
The headline numbers come from a matched continued-pretraining setup on OLMo-3-7B: 50B tokens at 64K context, evaluated in-range (4K–64K) and beyond (128K–512K) with no further training or positional retuning. The authors report:
| Attention | Position | RULER 64K | RULER 128K | RULER 256K | RULER 512K | HELMET 64K |
|---|---|---|---|---|---|---|
| Sparse | RoPE+YaRN | 74.10 | 42.23 | 23.30 | 15.21 | 42.97 |
| Sparse | NoPE | 78.86 | 75.18 | 72.44 | 70.63 | 49.20 |
| Sparse | RiRoPE | 80.24 | 77.53 | 75.19 | 72.17 | 47.37 |
That's 6.14 RULER points over the RoPE+YaRN baseline at 64K (74.10→80.24) and 4.40 HELMET points (42.97→47.37). At 512K — eight times the 64K training length — RiRoPE retains 72.17/80.24 ≈ 90% of its 64K score. The architecture is 24 sliding-window layers (4,096-token window) plus 8 sparse global layers with block size 128, top-16 historical blocks plus the current block, giving an attention budget of roughly 2,176 tokens per query in the sparse layers.
Why it matters
The most interesting result is the controlled ablation that positional geometry is learned, not tolerated. StreamingLLM and similar approaches reindex surviving cache tokens consecutively at inference — a post-hoc adaptation of a model trained without those positions. RiRoPE's claim is that the model must encounter query-dependent positions during training to learn to use them. The clean comparison: native training beats inference-only switching by 21.24 RULER points at 256K on identical weights and recipe. That's a direct demonstration that "just reindex at inference" leaves real performance on the table.
The second consequence: extrapolation becomes a non-issue by construction. Because relative distances are bounded by the attention budget, the model keeps ~90% of its 64K RULER score at 512K with no positional scaling — no YaRN-style tuning, no length extrapolation tricks. For anyone building long-context sparse models, that removes a whole class of failure modes.
The third is the kernel work itself. Query-dependent rotation is a known blocker for sparse-attention efficiency, and the within-block/block-level rotation split is a concrete, code-released pattern engineers can inspect and adapt. The paper reports the incremental forward-kernel overhead at 256K as 8.62% relative to core attention (6.42% relative to indexer + preparation + core attention together) on an H20 GPU.
Caveats
This is a single-paper result, marked "Work in progress" on arXiv, with no independent replication or critique yet. All benchmark numbers are author-reported.
The authors' own table shows a live competitor: NoPE (no positional encoding) nearly matches RiRoPE on RULER 64K (78.86 vs 80.24) and beats it on HELMET 64K (49.20 vs 47.37). RiRoPE leads all variants at 128K+, but a skeptic would ask how much of the gain is reindexing versus simply not using a length-scaled encoding.
Several things are unvalidated. Only block-sparse MHA on one 7B model was tested end-to-end; the shared-KV (MQA/MLA) and GQA strategies are described but not validated for quality or efficiency. The method does not explicitly encode the sizes of skipped gaps — that information is discarded by design. The paper frames the result as concerning positional geometry rather than which tokens the selector picks, so the interaction between reindexing and indexer quality is unexplored. And the efficiency evidence is thin: it's forward-kernel overhead on one GPU, not end-to-end training time or throughput versus baselines.