Learning Efficient Positional Encodings with Graph Neural Networks

Charilaos Kanatsoulis, Evelyn Choi, Stefanie Jegelka, Jure Leskovec, Alejandro Ribeiro

Abstract

Positional encodings (PEs) are essential for Graph Neural Networks (GNNs) and Graph Transformers to capture structural information. However, traditional methods based on Laplacian eigenvectors suffer from high computational costs ($O(N^3)$) and numerical instability. This paper introduces PEARL (Positional Encoding Networks), a framework that utilizes message-passing GNNs to generate expressive, stable, and scalable PEs. By leveraging random or basis vector initializations, PEARL achieves performance parity with full eigenvector methods while reducing complexity to linear or quadratic scales.

1. Introduction

In graph representation learning, the lack of a canonical node ordering presents a significant challenge. Unlike sequences or grids, graphs require absolute Positional Encodings (PEs) to allow models like Graph Transformers to distinguish between structurally similar but distinct nodes. The current standard for PEs involves the eigenvectors of the graph Laplacian. While effective, this approach is computationally prohibitive for large-scale graphs, requiring $O(N^3)$ operations. Furthermore, computing only a subset of eigenvectors (top-$K$) introduces inductive biases and instability due to the "eigengap" problem, where small perturbations in graph structure lead to large changes in eigenvectors.

This research introduces PEARL, a novel approach that bypasses explicit eigendecomposition by using GNNs themselves to learn positional representations. PEARL aims to satisfy four critical criteria: expressive power, scalability, stability, and genericness.

2. The PEARL Framework

The core innovation of PEARL is the use of message-passing GNNs to generate PEs. To maintain permutation equivariance while providing unique node identifiers, PEARL employs two distinct strategies:

2.1 R-PEARL (Random PEARL)

R-PEARL initializes each node with $M$ independent random samples. Each sample is processed by a GNN, and the results are aggregated using a statistical pooling function (e.g., empirical mean). This approach restores permutation equivariance through expectation. R-PEARL scales linearly ($O(MN)$), making it suitable for massive datasets. Crucially, the number of samples $M$ required for accuracy does not scale with the graph size $N$.

2.2 B-PEARL (Basis PEARL)

B-PEARL uses standard basis vectors ($M=N$) for initialization. This deterministic variant provides high expressive power and is particularly effective for smaller, complex graphs such as molecules. It operates with quadratic complexity ($O(N^2)$), which is a significant improvement over the cubic complexity of traditional spectral methods.

3. Theoretical Foundations

The authors provide a theoretical bridge between spectral methods and message-passing. They prove that standard GNNs function as nonlinear mappings of Graph Shift Operator (GSO) eigenvectors. This justifies the use of GNNs as a proxy for explicit eigendecomposition.

Furthermore, PEARL is shown to be strictly more powerful than the 1-Weisfeiler-Leman (1-WL) test. It can implicitly identify complex substructures, such as cycles of varying lengths, without explicit feature engineering. Because PEARL relies on the inherent stability of GNN message-passing, it avoids the sensitivity to perturbations that plagues traditional eigenvector-based PEs.

4. Experimental Evaluation

PEARL was evaluated across diverse benchmarks, demonstrating its versatility and efficiency:

  • Scalability on Large Graphs: On the RelBench dataset (38 million nodes), R-PEARL achieved an 11% performance improvement over PE-less baselines while maintaining high computational efficiency.
  • Molecular Modeling: On the ZINC dataset, B-PEARL achieved a state-of-the-art Test Mean Absolute Error (MAE) of 0.0644, outperforming more complex methods like SPE.
  • Out-of-Distribution (OOD) Robustness: Using the DrugOOD benchmark, B-PEARL showed superior generalization across different molecule sizes and scaffolds, improving AUC by up to 9.5% over BasisNet.
  • Structural Awareness: In the Circular Skip Link (CSL) isomorphism test, PEARL achieved 100% accuracy using random weights (no training), highlighting its innate ability to capture graph topology.

5. Conclusion

PEARL represents a significant step forward in graph representation learning by decoupling positional encoding from expensive spectral computations. By reframing PE generation as a GNN-based learning task, the framework provides a scalable, stable, and highly expressive alternative to traditional methods. While B-PEARL remains quadratic in complexity, the linear-time R-PEARL offers a viable path for applying sophisticated positional information to massive, real-world networks. Future work may explore non-i.i.d. sampling distributions to further enhance the expressive power of these learned encodings.

Summary updated

BibTeX
@inproceedings{kanatsoulis2025learning,
  author = {Charilaos Kanatsoulis and Evelyn Choi and Stefanie Jegelka and Jure Leskovec and Alejandro Ribeiro},
  title = {{Learning Efficient Positional Encodings with Graph Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=AWg2tkbydO},
}
Figure