Sheaf-MPNN: Sheaf Neural Networks as Local Message Passing

7 minute read

Published:

TL;DR: the action of a sheaf Laplacian can be evaluated edge by edge. Transport both endpoint states into a shared edge space, compute their disagreement, pull the result back, and sum at each node. Sheaf-MPNN uses this local view to put multiple sheaf architectures into a common PyTorch Geometric framework.
Paper: Sheaf-MPNN: A Library for Sheaf Neural Networks as Message Passing
Authors: Alessio Borgi, Mario Severino, Luke Braithwaite, Steve Azzolin, Rémi Bourgerie, Olga Zaghen, Emanuele Mule, Riccardo Ali, Leo Minh Kustermann, Edoardo Coppola, Antonio Purificato, Stefano Fiorini, Christopher Irwin, Filippo Spiga, Ling Guo, Fabrizio Silvestri, Michael Bronstein, and Pietro Liò
Version: arXiv preprint, v2, November 11, 2026
📄 Paper · PDF · 💻 Code · 📚 Documentation

What the paper contributes

Sheaf-MPNN provides a shared message-passing formulation and library for 15 sheaf-network families, with homogeneous and heterogeneous variants, directed settings, multiple restriction-map parameterizations, and benchmark tooling. Its equivalence results require matching the original normalization, state, and update rule. A common interface therefore preserves architecture-specific dynamics rather than making every model the same diffusion layer. Paper, Sections 2–3 and Appendix B.

The useful starting point is a familiar distinction from numerical linear algebra: storing a matrix and evaluating its action are different operations. An iterative solver often needs only a function that computes \(x\mapsto Ax\). A sheaf propagation layer can use that same idea.

Deriving the local computation

Consider an undirected graph. For edge \(e=\{u,v\}\), let

\[R_{ue}:\mathbb{R}^{d_u}\to\mathbb{R}^{d_e},\qquad R_{ve}:\mathbb{R}^{d_v}\to\mathbb{R}^{d_e}\]

be restriction maps. The two node states need not initially share coordinates. Their images \(R_{ue}x_u\) and \(R_{ve}x_v\) do share the edge space, so they can be compared.

Choose one orientation for each edge and define the discrepancy

\[r_e=R_{ue}x_u-R_{ve}x_v.\]

The quadratic consistency energy is

\[E(x)=\frac12\sum_{e=\{u,v\}}\|r_e\|^2.\]

Differentiating with respect to the two endpoint states gives

\[\nabla_{x_u}E_e=R_{ue}^{\top}r_e,\qquad \nabla_{x_v}E_e=-R_{ve}^{\top}r_e.\]

After adding the contributions incident to \(u\),

\[(L_{\mathcal F}x)_u= \sum_{e=\{u,v\}} R_{ue}^{\top}\big(R_{ue}x_u-R_{ve}x_v\big).\]

This derivation uses fixed maps and Euclidean inner products. With another inner product, the appropriate adjoint replaces the plain transpose. If maps are themselves predicted from \(x\), differentiating the entire learned energy would additionally differentiate through those maps. The expression above is the action of the operator for the supplied maps.

One edge's contribution to the sheaf LaplacianStates at u and v are mapped to a shared edge space, where their difference r is computed. The edge contributes R u transpose r to u and minus R v transpose r to v. Each node sums the contributions of its incident edges. Node u State xᵤ Node v State xᵥ Rᵤₑ Rᵥₑ Shared edge space r = Rᵤₑxᵤ − Rᵥₑxᵥ Compare transported states Contribution at u: Rᵤₑᵀr Contribution at v: −Rᵥₑᵀr Sum edge contributions, then apply the chosen node update.
Original explanatory diagram for an unnormalized, fixed sheaf. Each undirected edge is processed once here, with contributions sent to both endpoints.

Expanding the products recovers the familiar diagonal block \(\sum_eR_{ue}^{\top}R_{ue}\) and off-diagonal block \(-R_{ue}^{\top}R_{ve}\). The local calculation and the block-matrix multiplication therefore describe the same linear map.

The transpose is important: it is the adjoint that returns an edge-space signal to the node space. It is not generally an inverse. A restriction map can be rectangular or singular, so an inverse might not even exist.

A two-node example with numbers

Take scalar stalks with \(R_{ue}=2\), \(R_{ve}=-1\), and \(x=(1,3)\). The edge sees values \(2\) and \(-3\), so its discrepancy is \(r_e=5\). Its contributions are

\[R_{ue}^{\top}r_e=10,\qquad -R_{ve}^{\top}r_e=5.\]

The corresponding matrix is

\[L_{\mathcal F}=\begin{bmatrix}4&2\\2&1\end{bmatrix},\qquad L_{\mathcal F}\begin{bmatrix}1\\3\end{bmatrix}=\begin{bmatrix}10\\5\end{bmatrix}.\]

A diffusion step with \(\eta=0.1\) produces \(x'=x-\eta L_{\mathcal F}x=(0,2.5)\). The discrepancy halves to 2.5, and the energy falls from 12.5 to 3.125.

Consistency does not require equal raw node states: \(x=(1,-2)\) has zero discrepancy because both transported values equal 2. This is the basic reason that averaging in edge space can preserve a distinction that raw averaging would erase.

import numpy as np

x = np.array([1.0, 3.0])
ru, rv = 2.0, -1.0

# One oriented edge; send a contribution to each endpoint.
r = ru * x[0] - rv * x[1]
local_action = np.array([ru * r, -rv * r])

# Assemble only to check the tiny example.
B = np.array([[ru, -rv]])
L = B.T @ B
np.testing.assert_allclose(local_action, L @ x)

updated = x - 0.1 * local_action
np.testing.assert_allclose(updated, [0.0, 2.5])

This snippet demonstrates the algebra. It is not a reproduction benchmark or the library’s neural layer.

Normalization is part of the operator

Let \(D_u=\sum_{e\ni u}R_{ue}^{\top}R_{ue}\). If the desired operator is \(\Delta=NL_{\mathcal F}N\) for block-diagonal \(N\), its action at \(u\) is

\[(\Delta x)_u=\sum_{e=\{u,v\}} N_uR_{ue}^{\top}\left(R_{ue}N_ux_u-R_{ve}N_vx_v\right),\]

assuming symmetric \(N_u\). Both endpoints must use their own normalization. Normalizing only after aggregation implements a different operator.

Singular blocks require a convention: pseudoinverses and regularization define different maps. Adding \(I\) to the degree block is not equivalent to adding arbitrary graph self-loops. State the convention before comparing implementations.

For the normalized NSD implementation discussed in the paper, \(N_u=(D_u+I)^{-1/2}\). The appendix also describes numerical safeguards that can alter exact equality, including jitter and entrywise clipping. These details belong in a numerical parity comparison. Appendix C.3.

One message-passing interface, several dynamics

An edge-space interaction can be more general than subtraction:

\[m_{v\to u}=R_{ue}^{\top}\psi(R_{ve}z_v,R_{ue}z_u,e_{uv}),\qquad x'_u=\phi\left(x_u,\sum_{v}m_{v\to u}\right).\]

Here \(z\) is a transformed node state. Choosing \(\psi(a,b)=b-a\) recovers the Laplacian contribution; choosing a different interaction changes the propagation. The node update still determines whether the result is used as diffusion, a residual signal, or part of a recurrence.

The repository’s model table makes the connection to other chapters concrete:

FamilyWhat must be preserved when implementing it locally
NSDRestrictions, normalization, residual and nonlinear update
PolyNSDThe polynomial recurrence and spectral rescaling
NSPPrevious state needed by the wave recurrence
DNSDAdjacency-style propagation and its depth-related layer design
HetSheafType-aware construction of the relevant maps

For example, a generic second-order recurrence \(x_{k+1}=2x_k-x_{k-1}-\eta^2Lx_k\) can become a first-order update by carrying the augmented state \((x_k,x_{k-1})\). Dropping the second component changes the dynamics even if each Laplacian application is correct. Similarly, evaluating a polynomial via a recurrence avoids assembling its full matrix, but still requires the recurrence’s intermediate states.

Direction and storage conventions

For one undirected edge, the two cross blocks are transposes:

\[R_{ue}^{\top}R_{ve}=\left(R_{ve}^{\top}R_{ue}\right)^{\top}.\]

That relationship does not provide two independently chosen directions. A genuinely directed architecture needs a stated arc convention and an appropriate aggregation rule.

In a source-to-target edge list, reverse arcs may be necessary to represent an undirected graph. But the numerical example above already sends both contributions from one stored edge. Feeding it a doubled edge list would count every edge twice. Representation choices must agree with the implementation’s scatter logic.

Using the library

The repository documents installation of the experiment tools and a short training run:

pip install "sheaf_mpnn[experiments] @ git+https://github.com/alessioborgi/sheaf-mpnn"
sheaf run --preset cora --optim.epochs 3 --cv.folds 2

This downloads dataset assets on first use. It is a smoke run, not a performance result. Consult the installation instructions and documentation for the current environment and APIs.

The README notes that its citation and several heterophily datasets use directed DSNN releases. Matching a familiar dataset name is consequently insufficient for reproducing a published score: check the actual edge list, preprocessing, labels, and splits. Dataset access and variants.

What removing assembly does and does not buy

A dense-map multiplication with \(d\) stalk coordinates and \(f\) channels costs roughly \(d^2f\) multiply-add work per incidence. Summing over edges suggests $$O(Ed^2f)$$ transport work. Diagonal maps reduce the multiplication to elementwise scaling. These counts omit map prediction, channel mixing, and normalization.

Avoiding a global sparse matrix removes its assembly and storage requirements; it does not eliminate the maps, edge intermediates, or backward-pass activations. Batching, scatter operations, and memory layout can determine the actual speed. A sparse global implementation is also not a dense \(nd\times nd\) baseline.

The paper supplies equivalence arguments and benchmarking infrastructure, but explicitly does not report numerical parity with reference implementations. The right evidence for a speed or memory claim is a measured comparison with matched settings. Appendix C.6.

A useful validation proceeds from fixed-map outputs to gradients, then to complete layers with identical weights and normalization. Only after that should runtime and predictive accuracy be compared. This distinguishes an implementation improvement from an accidental model change.

Takeaway

Sheaf-MPNN makes the local structure of sheaf propagation explicit. The geometry still lives in the restriction maps; the architecture still lives in its update rules. What changes is the computational interface: the operator can be applied through local transport and aggregation, making implementations easier to compose and compare.

Return to the Sheaf Neural Networks overview for the reading path, or compare the standard MPNN formulation with the edge-space construction above.