Sheaf-Based Positional Encodings: Letting Node Features Into the Spectrum

12 minute read

Published:

TL;DR: Positional encodings from graph Laplacian eigenvectors are the standard way to break the locality limit of message passing and to give Graph Transformers back the structure they discard. But \(L = D - A\) is a function of adjacency alone, so the encoding is blind to node data — a problem on heterophilic graphs, where connected nodes are deliberately dissimilar. This paper builds PEs from the sheaf Laplacian instead, whose restriction maps are parameterised by node features, using either the precomputed connection Laplacian (ConnLap) or a learned one (SheafLap). ConnLap improves on graph-Laplacian PEs across all nine node-classification datasets; SheafLap is stronger where it works and unstable where it does not, and costs roughly a thousand times more per epoch.
Paper: Sheaf-based Positional Encodings for Graph Neural Networks
Authors: Yu He, Cristian Bodnar, Pietro Liò
Venue: NeurIPS 2023 Workshop on Symmetry and Geometry in Neural Representations · PMLR 228

What a positional encoding is for

Message passing is local. A node’s representation is a function of its immediate neighbourhood, so two nodes with isomorphic neighbourhoods get identical embeddings — which is the 1-WL ceiling, and the reason GNNs fail on regular graphs and miss simple substructures.

Positional encodings break this by telling each node where it sits globally. The standard recipe: eigendecompose the graph Laplacian, take the eigenvectors of the smallest \(k\) eigenvalues, concatenate them to the node features. Laplacian eigenmaps embed the graph into Euclidean space in a way that respects its topology, so nearby nodes get nearby coordinates.

Graph Transformers need this even more acutely. Attending over a fully connected graph throws away the input structure entirely — the expressive power of a Transformer without PEs is that of DeepSets, since no edge remains. PEs are what put the topology back.

The gap this paper targets. \(L = D - A\) is built from adjacency and nothing else. Two nodes in structurally equivalent positions get equivalent encodings even if their feature vectors are opposites. On a homophilic graph that is mostly harmless — position and feature-similarity correlate. On a heterophilic graph, where connected nodes are dissimilar by construction, the encoding is describing a geometry the data does not have.

The sheaf Laplacian does not have this problem, because the restriction maps are functions of the node features. Its spectrum therefore encodes structure and semantics together.

Two ways to get the sheaf

ConnLap — precomputed. Constrain the restriction maps to be orthogonal and the sheaf Laplacian becomes the connection Laplacian, a discrete vector bundle whose transports approximate parallel transport on a manifold. For an edge \((v,u)\) the transport collapses to a single step,

\[ \mathbf{P} = \mathbf{P}^{\gamma}_{v \to u} = \mathcal{F}^{\top}_{u \trianglelefteq e}\mathcal{F}_{v \trianglelefteq e}, \]

because an edge gives a canonical one-step path. The maps come straight from Conn-NSD: local PCA over each node’s 1-hop neighbourhood produces an orthonormal tangent basis, and the SVD of \(O_v^{\top}O_u\) produces the aligning rotation \(O_{vu} = UV^{\top}\). This happens once at preprocessing, exactly like the graph Laplacian it replaces.

SheafLap — learned. Follow NSD instead: \(\mathcal{F}_{v \trianglelefteq e:=(v,u)} = \Phi(x_v, x_u)\) with \(\Phi(x_v,x_u) = \sigma(W[x_v \Vert x_u] + b)\) reshaped to \(d \times d\), restricted to orthogonal matrices to balance efficiency against generality.

Either way the PE construction is the same. Eigendecompose the \(nd \times nd\) matrix, take the eigenvectors of the smallest \(k\) eigenvalues, reshape to \(n \times kd\), and concatenate with the \(n \times d_x\) features to get \(X' \in \mathbb{R}^{n \times (d_x + kd)}\).

The sign ambiguity does not go away. Laplacian eigenvectors are determined only up to sign, and up to rotation within any repeated eigenspace. That problem is inherited wholesale — the paper acknowledges it, points at SignNet as the fix, and leaves it for future work. This is the same obstruction the site covers for graph Laplacians in the sign-ambiguity chapter, and the one SheafPool confronts at the readout end. Moving from \(n \times n\) to \(nd \times nd\) makes it worse, not better: there are more eigenvectors, so more signs to get wrong.

Node-level results

GCN base model — chosen precisely because it is known to fail on heterophilic graphs — with \(k = 8\) eigenvectors and stalk dimension \(d = 3\), on the usual nine datasets.

Dataset\(h\)No PEGraphLapConnLapSheafLap
Texas0.1157.3058.2258.3861.08
Wisconsin0.2149.8055.4957.6554.51
Film0.2225.2025.1326.5323.80
Squirrel0.2246.6247.5647.9251.11
Chameleon0.2363.9764.2865.5765.20
Cornell0.3045.9551.3552.9748.38
Citeseer0.7472.3473.8373.8874.35
Pubmed0.8086.4386.4386.4985.84
Cora0.8184.7185.0585.1385.88

Three clean readings.

ConnLap beats GraphLap on all nine. Never by much — the largest margin is 2.16 on Wisconsin, and Pubmed moves by 0.06 — but the direction is unanimous. That is the paper’s central claim and the table supports it.

SheafLap is higher-variance in both directions. It takes the largest single gain in the study, +3.55 on Squirrel over Squirrel’s GraphLap, and wins Texas, Citeseer and Cora too. But on Film it scores 23.80, below the no-PE baseline of 25.20, and on Cornell it lands 3 points under GraphLap. Adding a learned positional encoding can make the model worse than adding none.

Every PE helps on heterophilic data, which is the real signal. Cornell moves from 45.95 to 52.97 and Wisconsin from 49.80 to 57.65. These are exactly the datasets where a GCN is worst, and where the positional information has the most to add.

The paper’s explanation for ConnLap’s greater stability is worth recording, because it is three concrete mechanisms rather than a hand-wave: the datasets have high feature dimension, so the manifold assumption ConnLap depends on is plausible; precomputation avoids the numerical trouble SheafLap occasionally hits in backpropagation; and the datasets are small enough that there may simply not be enough data to fit a sheaf.

Graph-level results, and the honest failure

On molecules the story changes, and the paper does not hide it.

 ZINC (MAE ↓)ZINC + LSPE (MAE ↓)MOLTOX21 (AUC ↑)
No PE0.251 ± 0.00977.2 ± 0.6
GraphLap0.202 ± 0.0060.196 ± 0.00877.4 ± 0.7
ConnLap0.249 ± 0.0050.193 ± 0.01477.9 ± 0.2

On ZINC, ConnLap barely improves on no encoding at all (0.249 against 0.251) while the plain graph Laplacian reaches 0.202. That is a substantial defeat, and the diagnosis is the interesting part: ZINC’s node features are one-hot atom types. Sparse one-hot vectors do not satisfy the manifold assumption in any meaningful way — there is no local geometry for PCA to find — so the construction has nothing to work with. MOLTOX21, whose nodes carry 9-dimensional feature vectors encoding atomic number, chirality and formal charge, behaves as expected and ConnLap wins.

The rescue is elegant. Letting the encoding evolve during training (LSPE) moves ConnLap from 0.249 to 0.193, overtaking GraphLap’s 0.196, while GraphLap barely improves (0.202 to 0.196). The sheaf structure is a good initialisation even where the manifold assumption fails; it just cannot be left frozen.

Across base models on MOLTOX21, both Laplacian PEs hurt PNA (75.5 with no PE, 75.2 and 75.3 with them), where a random-walk encoding reaches 76.1. The paper’s reading — that PNA’s multiple-aggregator scheme benefits from relative rather than global positional information — is a real limitation stated plainly, and it generalises beyond this paper.

Cost

This is the section most likely to decide whether you use the method. Seconds, from the appendix:

 Texas precomputeCiteseer precomputeSquirrel precomputeCiteseer / epochSquirrel / epoch
GraphLap49.671,886.589,654.074.4741.87
ConnLap608.328,562.4672,148.343.4833.98
SheafLap0003,139.4531,503.36

ConnLap’s preprocessing runs several times to an order of magnitude longer than the graph Laplacian’s, but it is a one-off per dataset and the per-epoch cost is comparable — so across a hyperparameter sweep it amortises to nearly nothing.

SheafLap has no preprocessing and pays for it every epoch, at roughly three orders of magnitude over the alternatives: 3,139 seconds per epoch on Citeseer against 4.47. Since training runs hundreds of epochs, the learned variant is not practical at any of these scales, whatever its accuracy. That is the paper’s own conclusion, and it explains why graph-level experiments use ConnLap only — batching complicates the learned route further, and “unbatching graphs during training” is left as future work.

Two smaller findings

Unnormalised beats normalised. Ablating the normalisation of the learned sheaf Laplacian, the unnormalised version wins in every case but one. Normalisation reduces the number of possible sign configurations, which should help with the ambiguity problem — but apparently not enough to pay for the expressiveness it costs.

More eigenvectors help, then stop helping. Accuracy rises with \(k\) up to a turning point and then declines: more eigenvectors mean more positional information but also more sign ambiguity. Cornell is the exception, showing no such curve, which the authors read as evidence that Laplacian PEs are simply a poor fit for that graph — and which retrospectively explains SheafLap’s poor Cornell showing in the main table.

The qualitative figure is the clearest argument in the paper. Decalin and bicyclopentyl are a well-known pair of non-isomorphic graphs that GNNs cannot distinguish. Given deliberately heterophilic alternating node features, GraphLap assigns a smoothly varying colour scheme across each ring — it is describing structure, and the structure is nearly the same. ConnLap assigns mixed colours within a ring, because the features differ there. That is precisely the difference the method exists to produce, shown rather than asserted.

✅ Key Takeaways

  • Graph Laplacian PEs encode adjacency only. Sheaf Laplacian PEs encode adjacency and node data, because the restriction maps are parameterised by features.
  • Two variants: ConnLap (precomputed via local PCA and tangent-space alignment) and SheafLap (learned via an MLP, orthogonal maps).
  • ConnLap improves on graph-Laplacian PEs on all nine node-classification datasets — consistently, though usually by under a point.
  • SheafLap has the highest single gain (+3.55 on Squirrel) and also drops below the no-PE baseline on Film. It is the less reliable of the two.
  • On ZINC, ConnLap fails (0.249 vs GraphLap 0.202) because one-hot atom features violate the manifold assumption — then wins (0.193) once the encoding is allowed to evolve during training.
  • ConnLap's preprocessing is a one-off costing several times the graph Laplacian's; SheafLap costs roughly 1000× more per epoch, which rules it out at these scales.
  • Eigenvector sign ambiguity is inherited and made worse by the larger spectrum. SignNet is named as the fix and not applied.

References