Analytic-Walk Rotary Positional Encodings for Graphs
Organizations: Shanghai Innovation Institute · Fudan University
Abstract
Rotary position encodings make attention sensitive to relative position, but extending them to graphs requires choosing how graph structure enters the rotation. Previous works assign each node a rotation from spectral coordinates, so the rotary factor between two nodes depends only on their endpoints and cannot distinguish the routes connecting them. We introduce Analytic-Walk Rotary Positional Encodings (AW-RoPE), which place the rotations on edges and sum the transported features over all walks, so contributions along different routes can reinforce or cancel. An exact variant evaluates the complete sum by a differentiable linear solve, and a sparse variant truncates it at a finite depth. We prove forward and parameter-derivative truncation bounds at fixed inputs and parameters. Both variants act on projected queries and keys, and the sparse recurrence also augments message-passing networks. Across five synthetic tasks both variants reduce nRMSE by -- relative to the strongest baseline, and on real superpixel, peptide and OGB benchmarks the sparse recurrence attains the best mean on every dataset with Performer kernels and on twelve of thirteen datasets with GIN. Analysis shows that AW-RoPE can distinguish routes whose only cue is how two endpoints are connected, while node-wise rotary encodings cannot.
Figures & tables
| Dataset | NoPE | WIRE | Exact | Sparse |
| Monochromatic-0 | ||||
| Monochromatic-5 | ||||
| Monochromatic-10 | ||||
| Monochromatic-15 | ||||
| Watts–Strogatz SPD |
| Method | Endpoint | Attention |
| Mixing (Zero) | ||
| WIRE | ||
| WIRE + mixing | ||
| Dynamic local gradient | ||
| Sparse AW, phases zeroed | ||
| Exact AW, phases zeroed |
Appendix figures & tables23 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
| number of nodes and directed edges | |
| row-normalized nonnegative transition | |
| antisymmetric directed-edge displacement | |
| rotary frequency of one complex channel | |
| lifted by | |
| geometric walk-decay factor in |
| Identity | Maximum error |
| Gradient operator factorization | |
| Gradient resolvent factorization | |
| Gauge covariance, operator | |
| Gauge covariance, resolvent | |
| Gauge-invariant magnitude | |
| Permutation equivariance |
| Exact AW-RoPE | Sparse AW-RoPE | ||||
| Dataset | Seed | Test nRMSE | Epoch | Test nRMSE | Epoch |
| Monochromatic-0 | 0 | 0.040 | 224 | 0.040 | 224 |
| Monochromatic-0 | 1 | 0.040 | 219 | 0.039 | 219 |
| Monochromatic-0 | 2 | 0.051 | 212 | 0.055 | 215 |
| Monochromatic-5 | 0 | 0.035 | 195 | 0.035 | 230 |
| Monochromatic-5 | 1 | 0.034 | 214 | 0.035 | 208 |
| Training epoch (s) | Peak allocated (MiB) | ||||
| Dataset | Exact | Sparse | Exact | Sparse | |
| Monochromatic-0 | 8 | ||||
| Monochromatic-5 | 16 | ||||
| Monochromatic-10 | 16 | ||||
| Monochromatic-15 | 8 | ||||
| Watts–Strogatz SPD | 8 | ||||
| Task | Checkpoint origin | ||||
| M0 | Exact-trained | ||||
| M0 | Sparse-trained | ||||
| M5 | Exact-trained | ||||
| M5 | Sparse-trained | ||||
| M10 | Exact-trained | ||||
| M10 | Sparse-trained |
| Nodes/graph | Method | Forward ms | Backward ms | Total ms | Peak MiB | |
| 64 | NoPE | – | ||||
| 64 | WIRE | – | ||||
| 64 | Exact AW-RoPE | – | ||||
| 64 | Sparse AW-RoPE | 16 | ||||
| 128 | NoPE | – | ||||
| 128 | WIRE | – |
| Nodes | Method | Forward ms | Backward ms | Total ms | Peak MiB | |
| 64 | NoPE | – | ||||
| 64 | WIRE | – | ||||
| 64 | Exact AW-RoPE | – | ||||
| 64 | Sparse AW-RoPE | 16 | ||||
| 128 | NoPE | – | ||||
| 128 | WIRE | – |
| Hyperparameter | Value |
| Backbone layers | 4 |
| Hidden width | 32 |
| Attention heads | 1 |
| Dropout | 0.2 |
| Batch size | 16 |
| Attention | full |
| Dataset | Method | LR | Validation | ||
| Mono-0 | NoPE | – | – | 0.046553 | |
| Mono-0 | AW | 16 | 0.6 | 0.031604 | |
| Mono-0 | AW-NB | 16 | 0.8 | 0.029987 | |
| Mono-0 | AW-NB-MS | 8 | 0.8 | 0.032441 | |
| Mono-5 | NoPE | – | – | 0.044055 | |
| Mono-5 | AW | 16 | 0.8 | 0.026159 |
| Dataset | GIN-NoPE | GIN-AW-RoPE | GIN-AW-NB | GIN-AW-NB-MS | Winner |
| Monochromatic-0 | AW-NB | ||||
| Monochromatic-5 | AW | ||||
| Monochromatic-10 | AW | ||||
| Monochromatic-15 | AW | ||||
| Watts–Strogatz SPD | AW |
| Injection | Validation | Test | |
| NoPE | – | ||
| AW-RoPE ReZero | |||
| AW-RoPE ReZero + norm. | |||
| AW-RoPE Single + norm. |
| Dataset | Method | Train s/epoch | Peak GiB | Loader s |
| Monochromatic-0 | NoPE | |||
| Monochromatic-0 | WIRE | |||
| Monochromatic-0 | AW-RoPE, | |||
| Monochromatic-0 | AW-RoPE, | |||
| Monochromatic-0 | AW-RoPE, | |||
| Peptides-struct | NoPE |
| Field class | Ingredients | Route | Feature-cond. |
| Mixing (Zero) | transport only | (proof) | |
| WIRE | endpoint phases | ||
| Static field (random, learned) | circulation | – | (proof) |
| Dynamic local gradient | adaptivity, local | (proof) | |
| Dynamic nonlocal Flat | adaptivity, nonlocal | – | ✓ (unstable) |
| Sparse AW (ours) | circulation + adaptivity | ✓ | ✓ |
| Task | Collision or empirical failure | Successful construction |
| Route interference, endpoint | Mixing (Zero), WIRE and pointwise gradient transport | AW route-phase interference |
| Feature-conditioned cycle, full block | Static shell transport and pointwise gradients; WIRE and random fixed fields fail empirically | Local edge AW or dynamically projected nonlocal Flat |
| Arm | Evaluation | 20 | 21 | 22 | 23 | 24 |
| Sparse AW | Test | 100.00 | 100.00 | 100.00 | 93.45 | 99.91 |
| Sparse AW | 48/64 nodes | 92.97 | 81.64 | 100.00 | 50.00 | 71.88 |
| Dynamic nonlocal Flat | Test | 99.91 | 100.00 | 99.96 | 74.26 | 100.00 |
| Dynamic nonlocal Flat | 48/64 nodes | 50.78 | 82.81 | 100.00 | 50.00 | 97.27 |
| Dataset | Metric | WIRE | Mixing | WIRE + mixing | Sparse AW-RoPE |
| Monochromatic-0 | nRMSE | ||||
| Peptides-struct | MAE |
| Dataset | Arm | Allocated | Positional | Unused encoder |
| Monochromatic-0 | WIRE | 39644 | 320 | 0 |
| Monochromatic-0 | Mixing | 39324 | 0 | 85 |
| Monochromatic-0 | WIRE + mixing | 39644 | 320 | 0 |
| Monochromatic-0 | Sparse AW-RoPE | 39656 | 332 | 85 |
| Peptides-struct | WIRE | 506729 | 1920 | 0 |
| Peptides-struct | Mixing | 504809 | 0 | 270 |