Tencent-Hunyuan/RiRoPE
HF Paper ↗Native RoPE reindexing for sparse attention beyond the training context
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
RiRoPE changes the coordinates used by sparse global attention, not the order of selected tokens. For each query, selected keys receive consecutive indices in their original order, with unselected gaps removed. Relative distances therefore stay in [0, B−1] for attention budget B rather than growing with the full sequence. Training and inference use the same rule. The OLMo-3-7B sparse backbone combines 24 sliding-window RoPE layers (4,096 tokens) with eight global layers that select the top 16 historical blocks plus the current block, at 128 tokens per block. These layers use block-count-corrected LogGate and softmax1; the RiRoPE indexer uses NoPE.
Fused SM90 sparse-attention kernels live in focus/. The model package registers two custom model types with Transformers, while configs/ carries stage and variant configurations and third_party/olmes/ freezes the evaluation harness. The locked Python 3.11 environment couples PyTorch 2.9.1 with CUDA 12.9 and Transformers 5.2.0; the stack also includes VeOmni, FlashAttention, Triton, NVIDIA CuTe DSL and Quack. Configured model variants and Transformers registration are the documented integration points.
Key Capabilities & Differentiators
The workflow spans dense Stage-1 checkpoint conversion, 8K and 64K continued pretraining, DCP-to-HF export, and standalone Hugging Face generation. Sparse initialization derives indexer weights through grouped FP32 head averaging. The two stages budget roughly 50B tokens each; moving to Stage 3 transfers model weights but starts a fresh optimizer and LR schedule. Resuming within a stage can restore optimizer, dataloader and SkipStep state. Six training variants cover dense RoPE, sparse positional baselines, RiRoPE, and an index_nope control that can switch to RiRoPE at inference without changing weights.
After matched 64K continued pretraining, RiRoPE scored 80.24 versus sparse RoPE+YaRN's 74.10 on 64K RULER, and 72.17 versus 15.21 at 512K without further training or retuning. On HELMET it scored 47.37 at 64K and 51.13 on the 256K extension; the latter averages five categories and is not a like-for-like comparison across lengths. The CLI also covers 12 general-capability benchmarks. Evaluation uses batch size 1 and 4,096-token prefill chunks above 32,768 tokens, with options for parallel workers or layer sharding across GPUs.
Trade-offs & Limitations
The strongest evidence is the comparison with sparse RoPE+YaRN on the same backbone, which isolates the positional choice more directly than the dense RoPE+YaRN baseline does. The improvement is not uniform across alternatives: sparse NoPE scores 49.20 versus RiRoPE's 47.37 on 64K HELMET, and 70.63 versus 72.17 on 512K RULER. Reindexing preserves order but discards the original distances across skipped tokens in global layers. It changes how selected keys are positioned; it cannot recover a historical block the indexer did not select.
Operationally, native training and paper-matched evaluation come at the cost of a specialized runtime. Sparse inference requires SM90, batch size 1 and unpadded inputs. The benchmark scores establish neither latency nor throughput, and the two 50B-token stages make full replication a different undertaking from checkpoint evaluation. Measure peak VRAM and prefill time on the target context before choosing a GPU layout. The repository license is unspecified, so verify rights before commercial deployment or redistribution.
Hardware & Deployment Guide
Plan for Linux x86_64, an NVIDIA SM90 GPU (tested on H20), CUDA 12.9 with nvcc, and a C++ compiler. scripts/setup.sh runs pixi install --locked and checks the stack; FlashAttention builds from source on first install. A build or login node can use --skip-gpu-check, then run pixi run --locked check on a compute node. The documented full recipes show eight GPUs and support multi-node FSDP2 with shared access to data and outputs. A generated fixture provides a two-GPU smoke path without external data.
Model and dataset access default to offline, so stage checkpoints, training Parquet shards and evaluation assets locally; the long-length RULER and HELMET extensions have separate data layouts. Full HELMET adds a judge for LongQA and summarization and local T5 NLI for citation, whereas the documented judge-free subset runs through 128K. This is a local CLI and Transformers workflow, not a turnkey serving deployment. The manifest version is 0.1.0, and there is no GitHub release milestone to anchor an upgrade plan.
Research teams with SM90 access that need controlled OLMo-3-7B comparisons of sparse positional encodings, long-context extrapolation tests, or a local checkpoint-to-evaluation workflow.
You need a production inference server with padded multi-request batching, verified support beyond SM90, a predictable VRAM and throughput budget without profiling, or clear commercial licensing out of the box.
Quick Start & Installation
curl -fsSL https://pixi.sh/install.sh | bash # skip if Pixi is already installed bash scripts/setup.sh
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/Tencent-Hunyuan/RiRoPE.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about RiRoPE
How do I load RiRoPE in Transformers, and can I switch an existing checkpoint?
model before using Transformers Auto classes so that olmo3_msa_loggate and olmo3_dual_rope are registered, then load a compatible HF checkpoint. The weight-preserving scripts/switch_to_rirope.py path is an ablation for index_nope Stage-2 or Stage-3 checkpoints, not a general converter for dense RoPE models.What GPU do I need, and how should I size VRAM?
Can we self-host it for commercial use?
THIRD_PARTY_NOTICES.md and the terms for the code, dependencies, checkpoints and datasets separately. If HELMET evaluation uses an external judge, review that provider's data-handling terms as well.Which alternatives should I benchmark before adopting RiRoPE?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy