explainx.ai350K+ learn from us
TrendingAI News TodayExplainx for Business
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

follow on google

Add explainx.ai as a preferred source

corporate training

support@explainx.ai

get started

Find your pathTake Free Evaluation

community

Join the community

learn

mind: share how you thinkpathways — start freeworkshopsbootcampscoursescompare Explainxcertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcpestacktoolsmdx readeragentsllmsdesignsdictionarypeopleagi trackerfelony benchranks

company

aboutvisionmissionteaminstructorsteach on explainxpartnershipscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource libraryfor LLMsexplainx.ai kids

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportcontactprivacytermsdata rightshow we create contentsubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

explainx.ai

On this page

  • TL;DR
  • Why sparse attention breaks vanilla RoPE
  • What native position reindexing does
  • Reported results on OLMo-3-7B
  • Engineering: kernels and the GitHub repo
  • What developers ask about sparse attention and positions
  • Training recipe snapshot (from the open repository)
  • How to try RiRoPE responsibly
  • What this means next to other 2026 long-context work
  • Related reading on explainx.ai
← Back to blog

explainx / blog

Tencent RiRoPE: Sparse Attention With Native Position Reindexing

Sparse Attention, Tencent, Long Context, Research, Open Source

Part of AI Research

Tencent Hunyuan published RiRoPE on arXiv Nov 27, 2026: native position reindexing for sparse attention with open OLMo-3 recipes on GitHub. Benchmarks, SM90 kernels, and how to try it.

Dec 1, 2026·9 min read·Yash Thakker
add explainx.ai
go deep
Tencent RiRoPE: Sparse Attention With Native Position Reindexing

Tencent Hunyuan released RiRoPE on arXiv 2611.37952 and open-sourced training code at Tencent-Hunyuan/RiRoPE: sparse attention that reassigns consecutive position indices to each query''s selected keys during training and inference, so rotary embeddings see distances bounded by the sparse budget—not the full document length. The team claims roughly +6.14 RULER points at 64K versus sparse RoPE plus YaRN on matched OLMo-3-7B continued pretraining, and ~90% of the 64K RULER score at 512K without extra positional retuning.

Daily briefFrom Yash · 350K+ students taught

Catch up on AI

One AI story explained in plain English, plus one thing to try. Every day, free. Unsubscribe anytime.

TL;DR

table · 2 cols
QuestionAnswer
What problem does RiRoPE fix?Dense RoPE distances on sparsely selected keys can reflect huge gaps in the original sequence, hurting long-context quality
What changes?Selected keys for each query are renumbered 0…B−1 in document order; RoPE uses those indices
Why train natively?The paper shows large gains over inference-only reindexing (21.24 RULER at 256K in their ablation)
What shipped?Full Pixi-based OLMo-3 recipes, SM90 fused kernels, and OLMES eval wiring on GitHub
Can I run it on a laptop GPU?Not for sparse inference: README requires SM90 and batch size 1
Where does this sit vs NVIDIA''s sparse guide?NVIDIA''s sparse co-design post optimizes indexer kernels; RiRoPE co-designs positional math inside the same sparse pattern

Why sparse attention breaks vanilla RoPE

Most open models still apply rotary positional embeddings as if every query attended across the entire prior sequence. Sparse attention changes that assumption: each query only sees a subset of keys chosen by an indexer or block router, yet the keys keep original absolute positions in the sequence.

The RiRoPE authors argue that mismatch matters. Two tokens might be neighbors in the sparse set but thousands of positions apart in RoPE space if many intermediate tokens were skipped. Relative embeddings then encode distances the model never experienced during training, which shows up as weak RULER-style retrieval and citation tasks at long lengths.

This is related to, but not identical with, context eviction tricks used in streaming setups. Eviction can re-pack positions at inference; RiRoPE makes that packing part of the training objective so weights learn attention patterns under reindexed geometry.

RiRoPE ties sparse key selection to consecutive position indices for long-context modelingRiRoPE ties sparse key selection to consecutive position indices for long-context modeling

What native position reindexing does

The paper defines a selection map for each query: a set of active key indices. Position reindexing assigns the k-th active key (in document order) the ordinal index k − 1, ignoring unselected tokens.

Consequences the authors emphasize:

  1. Relative distance between any two attended keys is at most the attention budget minus one, not the full context length.
  2. Long-range pairs inside the sparse set can share short positional encodings, similar to local pairs, which they say improves extrapolation beyond the training length.
  3. Query-dependent rotations follow from different queries selecting different keys—RiRoPE is not a single global position table.

Applying the rule to RoPE yields ReIndexing RoPE (RiRoPE). The team still uses RoPE on sliding-window layers in their OLMo-3 stack; global sparse layers switch to RiRoPE on attended keys while indexers follow the variant recipe in the GitHub README.

Reported results on OLMo-3-7B

The arXiv paper and README reproduce a stage-3 table: 64K continued pretraining on 50B tokens, then evaluation out to 512K without further training.

Headline numbers from the repository table (RULER / HELMET at listed lengths):

table · 5 cols
AttentionPosition schemeRULER 64KRULER 512KHELMET 64K
SparseRoPE + YaRN74.1015.2142.97
SparseNoPE78.8670.6349.20
SparseRiRoPE80.2472.1747.37

Those are Tencent''s measurements on their OLMo-3 variant stack (24 sliding layers with 4,096-token windows, eight sparse global layers with block size 128 and top-16 historical blocks). Treat them as one checkpoint family, not a universal gain for every sparse model you download.

The paper stresses length extrapolation: at 512K—eight times the 64K training length—RiRoPE retains about 90% of its 64K RULER score in their setup, while sparse RoPE plus YaRN collapses to 15.21 on the same row. That is the practical hook for teams shipping million-token context claims on sparse backbones: positional co-design may matter as much as FLOP savings.

Long-context sparse attention quality depends on how positions are reassignedLong-context sparse attention quality depends on how positions are reassigned

Engineering: kernels and the GitHub repo

Sparse attention only wins if kernels stay fast. RiRoPE''s twist—query-dependent rotations—can break key reuse optimizations that dense FlashAttention-style paths rely on. The paper describes structure-aware rotation reuse and fused kernels that avoid materializing per-pair rotated keys while keeping tensor-core matmul shapes.

The open repo backs that with:

  • focus/ fused SM90 sparse-attention kernels
  • Pixi lockfile pinning PyTorch 2.9.1, CUDA 12.9, Transformers 5.2.0, FlashAttention 2.8.3, and evaluation via frozen OLMES under third_party/olmes/
  • --variant rirope training stages with shared sparse topology across ablations (rope, hope, nope, index_nope, etc.)

Requirements are strict. scripts/setup.sh checks for SM90; sparse Hugging Face inference demands batch size 1 and unpadded inputs. That is a research and datacenter path today, not a plug-in for consumer GPUs—similar to how NVIDIA''s sparse attention guidance targets tensor-core tile shapes first.

For builders comparing indexer-heavy sparse designs, also read Zyphra ZHA''s hierarchical indexer and TeleChat agent sparse stacks on Ascend. RiRoPE attacks the positional side; ZHA attacks indexer complexity.

What developers ask about sparse attention and positions

Search traffic around Tencent Hunyuan still skews toward video and 3D products, but the technical questions RiRoPE answers show up wherever teams ship long prompts on sparse backbones:

Does YaRN fix sparse attention at 1M tokens? YaRN stretches RoPE frequencies for dense attention patterns. When each query only sees a sparse subset, the model may still assign full-sequence distances between two keys that are adjacent in the attended set. YaRN does not renumber indices; RiRoPE does. The paper''s sparse RoPE plus YaRN row still falls to 15.21 RULER at 512K in their table.

Why not use NoPE instead? The same table shows sparse NoPE strong at extrapolation (70.63 RULER at 512K) but slightly behind RiRoPE at the 64K training length. RiRoPE keeps rotary structure on attended keys while reindexing; NoPE removes explicit positions and relies on causal masking. Picking between them is an empirical trade-off on your tokenizer, task mix, and kernel stack—not a universal rule.

Is inference-only reindexing enough? The README documents scripts/switch_to_rirope.py for ablations, but the paper''s controlled comparison reports 21.24 extra RULER points at 256K when RiRoPE is trained from stage two onward versus switching only at serve time. That matches how NVIDIA''s co-design essay treats Top-k fusion as a training-serving contract: shortcuts at inference often hide quality debt until you run ruler-style evals.

How does this connect to KV cache sizing? Sparse attention reduces how many keys enter attention, not necessarily how positions are encoded for the keys that remain. If your KV cache planner assumes dense RoPE when serializing blocks, RiRoPE-style per-query numbering may require custom cache layouts—another reason the team ships fused SM90 code instead of only a math note.

Training recipe snapshot (from the open repository)

Without repeating the entire README, the OLMo-3-7B path Tencent documents looks like this:

table · 5 cols
StageContextToken budgetSteps (default)Output
ConvertN/AN/AOne-shotmsa-mean-init sparse indexer init from dense stage-1
Stage 28,192~50.3B tokens24,000Sparse continued pretrain (rirope variant)
Stage 365,536~50.0B tokens11,921Long-context extension on longmino-50b parquet

Hyperparameters include FSDP2, BF16, z-loss 1e-5, SkipStep regularization, document-isolated packing with seed 42, and linear LR decay with 200 warmup steps. Multi-node training uses eight nodes of eight GPUs in the documented example—scale that to your cluster, but keep variant flags aligned across stages or you lose the positional geometry the paper measures.

Evaluation routes through OLMES tasks: RULER from 4K through 512K with offline dataset caches, HELMET up to 256K on five long-context categories, and a general suite of twelve benchmarks after stage 2. Long HELMET runs can require an external LLM judge and a local T5 NLI model for citation tasks—budget time and API cost before you promise weekly regression in production.

How to try RiRoPE responsibly

If you only need a headline number, read the arXiv abstract and stop. If you need to verify for a product or paper:

  1. Clone Tencent-Hunyuan/RiRoPE and run bash scripts/setup.sh on an SM90 node (or --skip-gpu-check then pixi run --locked check on GPU hardware).
  2. Prepare data paths exactly as README placeholders describe—training expects parquet shards; eval expects offline Hugging Face caches (HF_HUB_OFFLINE=1 by default).
  3. Convert dense OLMo-3 stage-1 weights with scripts/convert_checkpoint.py before stage-2 sparse continued pretraining.
  4. Smoke test with scripts/make_smoke_fixture.py and pixi run --locked test before committing cluster time.
  5. Compare variants using the documented index_nope path plus scripts/switch_to_rirope.py only if you are studying inference-only switching, not production quality.

For inference without training, the README''s Python snippet registers custom olmo3_msa_loggate modules and sets chunk_prefill_size / chunk_prefill_threshold for long prompts. You still need a trained RiRoPE checkpoint path; the repo documents layout but does not host multi-terabyte weights in-tree.

What this means next to other 2026 long-context work

RiRoPE does not replace sparse routing research from NVIDIA, DeepSeek-class models, or Meituan LongCat. It says: once you commit to top-k blocks per query, also commit to how positions are numbered inside that top-k.

Teams fine-tuning sparse open weights should ask:

  • Does our checkpoint use YaRN or NoPE on global sparse layers today?
  • If we add inference reindexing, are we repeating the 21-point RULER penalty the paper reports at 256K?
  • Do our serving kernels support query-dependent RoPE without exploding memory?

If the answer to the kernel question is no, RiRoPE remains a training recipe until your inference stack catches up—much like early speculative decoding wins appeared in papers before they landed in default vLLM builds.

For governance and compliance teams, note that RiRoPE does not change data handling—it is a positional encoding change inside an already-sparse OLMo-3 derivative. Your existing model-card disclosures for OLMo and Hugging Face gating still apply if you redistribute checkpoints you train with these scripts.

Related reading on explainx.ai

  • NVIDIA sparse attention co-design for long context
  • RoPE, partial RoPE, and NoPE in 2026 open models
  • What is KV cache in LLM inference?
  • Zyphra ZHA hierarchical sparse attention
  • Millie 2 phone-scale sparse attention context claims
  • Tencent AngelSpec sparse attention speedups

Sources: arXiv 2611.37952 · Tencent-Hunyuan/RiRoPE (README and results table, accessed December 1, 2026)

Architecture details and benchmark tables reflect Tencent''s November 27, 2026 paper and the GitHub repository as checked on December 1, 2026.

Spotted something out of date? Let us know.
Daily briefFrom Yash · 350K+ students taught

Catch up on AI

One AI story explained in plain English, plus one thing to try. Every day, free. Unsubscribe anytime.

  • ✓ Free
  • ✓ One email a day, no spam
  • ✓ Unsubscribe anytime
Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

View Yash Thakker in People in AI →

Related posts

Nov 24, 2026

MemOnce: Scalable LLM Memory With One KV Decode Per Query

Nanjing University researchers published MemOnce on arXiv 2611.27973 with code on GitHub. The architecture stores compact memory once, picks sparse indices once per turn, and rebuilds attention KV only when needed—targeting agent sessions that outgrow linear KV growth.

Nov 18, 2026

NVIDIA Sparse Attention Co-Design: Eight Rules for 128K+ Context on GPUs

On November 17, 2026 NVIDIA published a hardware-aware sparse attention primer for model developers. It explains why the indexer—not core attention—often dominates at 128K tokens, and lists eight design guidelines tuned with production FP8 kernels.

Nov 4, 2026

LoCo: Tencent Researchers Teach a 7B Reasoning Model When to Stop Thinking

A Tencent-affiliated team published LoCo, a way to make reasoning models stop deliberating once they have enough information. It reports 41.7 to 45.4 percent shorter completions on math and 23.4 to 36.3 percent on code, with accuracy kept or improved, and released a 7B model and MIT-licensed code.