Message passing neural network

Also known as: MPNN

On this page 7

A message passing neural network (MPNN) is a neural network for graph-structured data in which each node repeatedly sends messages to its neighbors, aggregates the messages it receives and updates its own hidden state. After several rounds, each node representation summarizes its local neighborhood, and an optional readout function turns all node states into a single graph-level output. The MPNN is the general framework behind most graph neural networks in graph learning.

The framework was formalized in 2017 for predicting quantum chemical properties of molecules, where it unified earlier graph models under one notation. Today architectures such as the graph convolutional network, GraphSAGE, the graph attention network and the graph isomorphism network are usually described as special cases of message passing in artificial intelligence research and practice.

How message passing works in an MPNN

An MPNN runs for a fixed number of message passing steps T, often called layers. In each step, every node computes messages from its neighbors with a message function, combines them with a permutation-invariant aggregation such as sum, mean or max, and passes the result together with its previous state to an update function. Edge features, such as bond types in a molecule, can enter the message function directly.

The aggregation must be invariant to neighbor order, because a graph has no natural ordering of nodes. This property makes the whole network permutation equivariant at the node level: relabeling the nodes relabels the outputs in the same way without changing their values.

The table below lists the three learnable functions that define any MPNN.

FunctionInputsTypical implementationRole
Message functionSender state, receiver state, edge featuresLinear layer or small MLPDecide what information flows
Update functionPrevious node state, aggregated messageGRU cell or MLPIntegrate neighborhood information
Readout functionAll final node statesSum, mean, attention or Set2SetProduce graph-level output
Aggregation operatorSet of incoming messagesSum, mean, max or attentionCombine messages without order
Core functions of the message passing framework

After k steps, a node’s representation depends on its k-hop neighborhood, which is the receptive field of the network. Most practical models use two to six layers, because deeper stacks tend to degrade rather than improve, as described later.

Common MPNN variants

Popular graph neural network architectures differ mainly in how they weight and aggregate messages. Writing them as MPNNs makes their assumptions explicit and easier to compare.

ArchitectureMessage weightingAggregationNotable property
Graph convolutional networkFixed by normalized node degreesWeighted sumSimple, strong baseline
GraphSAGEUniform over sampled neighborsMean, max or LSTMScales with neighbor sampling
Graph attention networkLearned attention coefficientsAttention-weighted sumAdapts to neighbor relevance
Graph isomorphism networkUniform with learnable self-weightSum followed by MLPMaximally expressive among MPNNs
Relational graph convolutional networkSeparate weights per edge typeSum per relationHandles knowledge graphs
Well-known architectures expressed as message passing

The choice of aggregator affects what the network can distinguish. Sum aggregation preserves multiset size, so it can count neighbors, whereas mean and max lose that information. This difference underlies the theoretical result discussed in the next section.

Expressive power and the Weisfeiler-Lehman limit

Standard MPNNs are at most as powerful as the 1-dimensional Weisfeiler-Lehman test at telling non-isomorphic graphs apart. The Weisfeiler-Lehman test iteratively recolors each node from the multiset of its neighbors’ colors, which is structurally the same operation as message passing. Graph isomorphism networks reach this upper bound by using injective sum aggregation with multilayer perceptrons.

The limit has practical consequences. A plain MPNN cannot distinguish two disjoint triangles from one six-node ring when all nodes have identical features, and it cannot reliably count cycles or detect certain substructures. Chemistry tasks that depend on ring structure can therefore suffer.

ExtensionMechanismCost
Positional encodingsLaplacian eigenvectors or random-walk featuresPreprocessing per graph
Higher-order networksMessages between node tuplesMemory grows quickly
Subgraph methodsRun an MPNN on many node-marked subgraphsSeveral times slower
Graph transformersGlobal attention over all node pairsQuadratic in node count
Methods that extend beyond the standard MPNN limit

Practical use and configuration

MPNNs support node classification, link prediction and graph classification with the same backbone, changing only the output head. Node tasks use final node states directly, link tasks score pairs of node states, and graph tasks apply the readout function and graph pooling before a classifier.

TaskOutput headTypical depthKey consideration
Node classificationPer-node classifier2 to 3 layersHomophily of the graph
Link predictionDot product or MLP on node pairs2 to 4 layersNegative sampling strategy
Graph classificationReadout plus classifier3 to 6 layersPooling and readout choice
Molecular property regressionReadout plus regressor3 to 6 layersRich edge features
Configuration choices by task

For large graphs with millions of nodes, full-batch training exceeds GPU memory. Neighbor sampling and partitioning methods such as Cluster-GCN restrict each mini-batch to a subgraph, trading some accuracy for predictable memory use.

Limitations of message passing

  • Over-smoothing: with many layers, node states converge and become indistinguishable.
  • Over-squashing: information from an exponentially growing neighborhood is compressed into a fixed-size vector, so distant signals are lost.
  • Heterophily: when connected nodes tend to have different labels, averaging neighbors can hurt accuracy.
  • Limited expressiveness: the Weisfeiler-Lehman bound prevents certain structures from being recognized.

Typical remedies include residual connections, normalization layers, a virtual node connected to all nodes, and graph rewiring that adds shortcut edges to relieve bottlenecks in information flow.

The simple explanation

Picture a group of people standing in a network, each talking only to direct friends. In every round, each person hears from their friends and updates what they know. After a few rounds, everyone knows a summary of their wider neighborhood.

A message passing neural network does the same with data points connected in a graph. The network learns what to say and how to listen. The result can describe one point, a link between two points, or the whole graph.

How it is used in practice

A pharmaceutical research group wants to screen 500,000 candidate molecules for water solubility before running laboratory tests. Each molecule becomes a graph: atoms are nodes with element and charge features, and bonds are edges labeled single, double, triple or aromatic.

The team trains an MPNN with four message passing steps, a GRU update function and a sum readout on roughly 10,000 molecules with measured solubility. Validation uses a scaffold split, so test molecules have core structures unseen during training, which gives a more honest estimate than a random split.

The model ranks the full library in under an hour on a single GPU. Chemists send only the top few hundred candidates to the laboratory, which cuts experimental cost substantially while keeping most of the promising compounds in the shortlist.