Gain-Rigid Sparse Attention
Implementation & benchmark of arXiv:2607.05023 — Rigidity on compact surfaces through hyperbolic symmetries
Source paper: Rigidity on compact surfaces through hyperbolic symmetries arXiv:2607.05023 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Construct a sparse attention or message-passing graph as a gain graph, where every directed edge carries a relative frame label and reverse edges carry the inverse label. Grow the graph using the paper's 2-extension operation: replace two old edges by a new vertex connected to their four endpoints, while preserving the relative gain products. The resulting mask is intended to preserve global information flow under controlled sparsity and to avoid isolated components and brittle bridges commonly produced by magnitude pruning.
Formulas
Mathematical statement
A gain graph is a directed graph with an edge-label map \(\psi:E\to\Gamma\), where \(\Gamma\) is a group; an edge is written \(u\xrightarrow{g}v\), and reversing it gives \(v\xrightarrow{g^{-1}}u\). The paper's 2-extension removes \(f_1=v_1\to v_2\) and \(f_2=v_3\to v_4\), adds a new vertex \(v\), and inserts \(e_i=v\to v_i\) satisfying \(\psi'(e_1)^{-1}\psi'(e_2)=\psi(f_1)\) and \(\psi'(e_3)^{-1}\psi'(e_4)=\psi(f_2)\); the inverse operation is a 2-reduction. Here \(\Gamma\) is a finite or continuous group of feature-frame transforms, \(g_{uv}\) is the relative frame from source token \(v\) to target token \(u\), and \(W_g\) is a gain-conditioned message operator. The transferred property is inductive topology growth with preserved relative labels, not a claim that the hyperbolic rigidity theorem directly proves transformer accuracy.
Implementation notes
Integrate this at the attention-mask and message-value path of a small graph transformer or language-model block. (1) Represent each token or graph node as a vertex, maintain a directed sparse edge list, and attach a group label \(g_{uv}\); start from a seed graph and generate additional vertices or connectivity using 2-extensions. For two old edges \(v_1\to v_2\) and \(v_3\to v_4\), delete them, create \(v\), choose labels \(a,b,c,d\) with \(a^{-1}b=\psi(f_1)\) and \(c^{-1}d=\psi(f_2)\), and add \(v\to v_1,v\to v_2,v\to v_3,v\to v_4\). (2) In each attention layer compute transformed keys and values using a small representation \(R_g\) of the label group, then apply masked attention over the neighbors. For a cyclic group, use \(R_g\) as a 2D rotation; for a first test, use scalar sign labels or learned lookup matrices. (3) Implement the sparsity condition as a brute-force oracle over small induced subgraphs: reject a proposed extension if a subset violates the selected \((2,3,1,0)\) count rule; separately compare this exact version with a simpler degree/connectivity approximation. Compute connected components, shortest-path diameter, and the rank of the linearized message-propagation Jacobian. (4) Run a cheap experiment with a 6-layer graph transformer on Cora or OGB-Arxiv at 10%, 20%, and 30% edge budgets. Compare dense attention, random sparsity, magnitude-pruned attention, locality-based kNN masks, and gain-rigid masks. Measure validation accuracy, loss at equal FLOPs, component count, gradient variance, and peak activation memory. Success means equal-or-better accuracy at 2-5x lower attention FLOPs, no disconnected components, and a smoother loss curve than random sparse masks.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: Significant win ✓
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 8/10
Built a cyclic-group gain-graph MVP with inverse labels, rotation representations, and 2-extension construction. The algebraic checks passed exactly, including nonzero extension offsets and reverse-edge inverses. At 51 undirected edges on 32 nodes, the gain-rigid graph stayed connected with full 8-step reachability, while equal-budget random graphs were disconnected in 66% of trials; this is a clear topology-level signal, not evidence of transformer accuracy gains.
- Agent confidence
- 8/10
- Baseline
- 100 equal-budget random graphs: mean 2.06 components, 66% disconnected, mean 8-step reachability 0.955, mean active fraction 0.954375, connected-case mean diameter 6.324.
- Dense reference
- 496 edges, 1 component, diameter 1, 8-step reachability 1.0.
- Idea
- Gain-rigid graph: 51 undirected edges, 1 component, diameter 6, 8-step reachability 1.0, active fraction 1.0. Reverse/inverse and extension-equation checks passed; rotation orthogonality error was 0.0.
Limitations: This is a topology and linear message-propagation MVP, not a trained graph transformer or language model. It does not test accuracy, loss at equal FLOPs, magnitude pruning, kNN masks, gradient variance, activation memory, the exact (2,3,1,0) sparsity oracle, or larger datasets; gain labels are cyclic rotations and the random baseline is unoptimized.
How to run: python3 experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.05023)
Beats the tuned baseline by 28.7% (p=0.0081, wins 8 / 8 paired seeds; metric: lower is better).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.2059
- Idea mean
- 0.1469
- Effect (Δ)
- -0.059 (−28.7%; negative = idea better)
- Wins
- 8 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Helps
- Baseline tuning
- swept over 3 configs
Tested only the built-in sequence forecasting track, 8 seeds, 15 epochs, and a tiny 2-layer transformer. No CIFAR, graph benchmark, dense-vs-sparse FLOP profiling, magnitude-pruning baseline, activation-memory measurement, exact (2,3,1,0) oracle, or larger-scale language-model evaluation was performed.
How to run: python3 bench_gain_rigid.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Worked ✓
Agent confidence: 8/10
Implemented gain-rigid sparse attention on the structurally matched sequence forecasting track with the same transformer dimensions and training budget as the baseline. The 51-edge cyclic gain graph preserved inverse labels and connected information flow; trained-model gradient probes showed 100% active input influence for both systems. Across 8 paired seeds, test MSE decreased from 0.205856 to 0.146874, with paired delta -0.058982 and permutation p=0.0081, satisfying the benchmark's significant-win criterion.
- Baseline
- Best shared-grid lr=0.001; 8-seed mean test MSE 0.205856, std 0.022615.
- Comparison
- Idea wins 8/8 paired seeds; delta_mean=-0.058982; permutation p_value=0.0081; verdict=idea better (significant).
- Idea
- Best shared-grid lr=0.003; 8-seed mean test MSE 0.146874, std 0.018828; 51 undirected gain edges over 32 sequence positions.
Benchmark result
Beats the tuned baseline by 28.7% (p=0.0081, wins 8 / 8 paired seeds; metric: lower is better).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.2059
- Idea mean
- 0.1469
- Effect (Δ)
- -0.059 (−28.7%; negative = idea better)
- Wins
- 8 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Helps
- Baseline tuning
- swept over 3 configs
Tested only the built-in sequence forecasting track, 8 seeds, 15 epochs, and a tiny 2-layer transformer. No CIFAR, graph benchmark, dense-vs-sparse FLOP profiling, magnitude-pruning baseline, activation-memory measurement, exact (2,3,1,0) oracle, or larger-scale language-model evaluation was performed.
How to run: python3 bench_gain_rigid.py
Artifacts
- bench_gain_rigid.py 6.4 KB View Raw
- bench_report.json 3.7 KB View Raw
- experiment.py 6.0 KB View Raw
- report.md 1.6 KB View
- report_bench_2026-09-04T122316.md 4.4 KB View
- results.json 0.7 KB View Raw
- update_signature.py 1.8 KB View Raw