Advanced techniques
Graph Neural Networks and Message Passing
Build the core mental model of graph neural networks, including node features, edges, aggregation, permutation invariance, and receptive fields.
By the end you can
- Represent a machine learning problem as nodes, edges, features, and targets
- Explain the message–aggregate–update pattern of a GNN layer
- Relate layer depth to graph receptive field and oversmoothing risk
- Distinguish node-, edge-, and graph-level predictions
Analogy
The neighborhood conversation analogy
Every household in a city updates its view of local conditions by talking to the households next door. In the first round, each household learns about immediate neighbors. In the second, information can arrive from neighbors of neighbors. The update combines local attributes with messages from the surrounding network. Each household has one index card for everything it heard. A graph layer must summarize many neighbor messages into a fixed-size representation, and the learned functions, edge structure, and aggregation rule determine which details survive.
The pattern got its name in 2017. Gilmer and four co-authors called it neural message passing, and they tested it on QM9, a benchmark of small molecules. Their model “predicts DFT to within chemical accuracy on 11 out of 13 targets”. Variants “operating on the topology of the molecule alone (with no spatial information as input)” reached that accuracy “on 5 out of 13 targets”. Chemical accuracy is not the model's own standard. The paper defines it as “a target error that has been established by the chemistry community”.
The thirteen targets have a paper of their own, and it is worth knowing what they are before treating 11 against 5 as a result. QM9 was published in Scientific Data in 2014, by Ramakrishnan and three co-authors. Its abstract states the provenance exactly: “These molecules correspond to the subset of all 133,885 species with up to nine heavy atoms (CONF) out of the GDB-17 chemical universe of 166 billion organic molecules.” Every structure is computed at the B3LYP/6-31G(2df,p) level of theory. Gilmer's group used those structures as regression targets per molecule — “QM9 consists of 130k molecules with 13 properties for each molecule”.
So the two counts, 11 and 5, come from one dataset, one set of thirteen targets, and one difference in what the network is allowed to read: geometry, or the molecule's topology alone. That is what a neighborhood conversation is worth when the neighborhood is defined well. It is also what it costs when the definition drops information the target depends on.
Message passing turns relational neighborhoods into learnable representations.
Figure
A graph is more than a table with an ID column
A graph contains nodes, edges, and optional features on both. Nodes might be accounts, molecules, papers, products, or road intersections. Edges might represent transactions, bonds, citations, co-purchases, or physical connections. The graph can be directed, weighted, typed, dynamic, or contain several relation families.
A message-passing layer computes messages along edges, aggregates incoming messages for each node, and updates the node representation. Aggregation should be insensitive to arbitrary neighbor order. Sums, means, maxima, attention-weighted combinations, and learned set functions are common choices. Stacking layers expands the receptive field: after two layers, a node can incorporate information from paths of roughly two hops.
More layers are not automatically better, and the reason has been characterised twice. A 2018 paper by Li and two co-authors found the mechanism. Graph convolution, they showed, “is actually a special form of Laplacian smoothing, which is the key reason why GCNs work, but it also brings potential concerns of over-smoothing with many convolutional layers”. The smoothing is not a defect bolted onto the method. It is the method, and depth is the dose.
The end state has a name and a rate as well, given by Oono and Suzuki in 2019. They open from the practitioner's side: “However, it is known that they do not improve (or sometimes worsen) their predictive performance as we pile up many layers and add non-lineality.” Their proof says where the representations go. When the GCN's weights satisfy conditions set by the spectra of the augmented normalised Laplacian, the output exponentially approaches a set of signals that carry only connected-component and node-degree information. That is the whole surviving content of a node after enough layers: which component it sits in, and how many neighbors it has. Everything the features contained has been averaged away.
The graph structure defines which observations are allowed to exchange information.
Visual
Inside one message-passing layer
The exact neural functions vary, but the computational pattern is broadly shared. A layer forms messages along edges from source-node, target-node, edge and relation features; aggregates the unordered set of incoming messages at each destination node; updates the node state by combining the old representation with that aggregate; optionally updates edge or global state as well; and then the next layer repeats the cycle for another hop.
What that loop can and cannot do is not a matter of taste. Two groups reached the same ceiling in 2019, working separately. One paper came from Xu and three co-authors, the other from Morris and six. Both showed that a standard neighbourhood-aggregation GNN is at most as powerful as the 1-dimensional Weisfeiler-Leman graph isomorphism test at telling non-isomorphic graphs apart. Morris and colleagues state it flatly: “We show that GNNs have the same expressiveness as the 1-WL in terms of distinguishing non-isomorphic (sub-)graphs. Hence, both algorithms also have the same shortcomings.” GCN and GraphSAGE therefore provably cannot distinguish certain simple graph structures. No amount of data or training removes the limit. It belongs to the aggregation, not to the fit.
The second limit concerns information that has to travel far through a fixed topology, and it has a measured price. Alon and Yahav, in 2021, took GNNs that Brockschmidt had already tuned over 500 configurations. They changed one thing. The last of the eight layers became a fully-adjacent layer — no additional tuning, no extra learnable weights. On QM9: “The main results are that breaking the bottleneck by modifying a single layer to be an FA layer significantly reduces the error rate, by 42% on average, across six GNN types.” The same single change cut error by 12% on ENZYMES and by 4.8% on NCI1. Di Giovanni and five co-authors later proved the mechanism behind that gain: depth cannot mitigate over-squashing, and graph topology dominates it. One layer's connectivity bought 42%. More layers would not have.
- 1
Form edge messages
Combine source-node, target-node, edge, and relation features.
- 2
Aggregate by destination
Reduce the unordered set of incoming messages.
- 3
Update node state
Combine the old node representation with the aggregate.
- 4
Optionally update edges or graph state
Propagate richer relational or global information.
- 5
Repeat for another hop
Stack layers to expand the receptive field.
The pattern has a provable ceiling at 1-WL, and its bottleneck is topology rather than depth.
Comparison
Where the target lives
The supervision level changes pooling, negative sampling, and evaluation. Node prediction assigns a label or value to each node using neighborhood context — a fraud account, a paper topic. It carries the risk of split leakage through edges, and it may be transductive or inductive. Edge or link prediction asks whether, how, or when two nodes are related. It therefore requires a negative-edge strategy, usually respects temporal ordering, and is scored with ranking metrics, as in recommendation and knowledge graphs. Graph prediction pools node and edge representations into a single output per graph — a molecule property, a program's behavior. There, pooling must preserve the relevant structure, graph size can confound the prediction, and splits may need scaffold or entity controls.
GraphCast shows what a node-level target looks like when the graph is the planet. It is a message-passing GNN operating on a multi-scale mesh over the globe. It produces 10-day forecasts of hundreds of weather variables at 0.25° resolution in under a minute. Lam and colleagues reported the result in Science in 2023: “We show that GraphCast significantly outperforms the most accurate operational deterministic systems on 90% of 1380 verification targets, and its forecasts support better severe event prediction, including tropical cyclones, atmospheric rivers, and extreme temperatures.” The denominator is the part worth copying. The claim is not a headline average over an unnamed evaluation. It is a stated count of 1,380 verification targets, with the fraction won given against it.
The architecture then followed the result into public operations. ECMWF's own account of building its Artificial Intelligence Forecasting System records that “the design choice of graph neural networks was made for the first implementation”. AIFS Single became operational in February 2025.
Node prediction
Predict a label or value for each node.
- Examples: fraud account, paper topic
- Uses neighborhood context
- Split leakage through edges is a risk
- Can be transductive or inductive
Edge or link prediction
Predict whether, how, or when two nodes are related.
- Requires negative-edge strategy
- Examples: recommendation and knowledge graphs
- Temporal ordering often matters
- Ranking metrics are common
Graph prediction
Pool node and edge representations into one graph output.
- Examples: molecule property, program behavior
- Pooling must preserve relevant structure
- Graph size can confound predictions
- Splits may need scaffold or entity controls
Example
Questions that define the graph before the model
Most graph failures begin with an unjustified representation choice, so it helps to read a system that had to make one and then run on it. Google Maps' production ETA model is a graph neural network over the road network. Road segments are the nodes. Edges join segments that are consecutive or share an intersection. The unit the model works over is a “Supersegment” of adjacent segments sharing significant traffic volume. Derrow-Pinion and sixteen co-authors report what the deployed system did: “Our GNN proved powerful when deployed, significantly reducing negative ETA outcomes in several regions compared to the previous production baseline (40+% in cities like Sydney).” DeepMind's release of the system, on 3 September 2020, reported real-time ETA accuracy improvements of up to 50% in cities including Berlin, Jakarta, São Paulo, Sydney, Tokyo and Washington D.C.
None of those figures are architectural. They rest on the answers given before any layer was written: what a node is, what makes an edge, and what unit the prediction is attached to. Ask the same questions of your own graph before choosing an aggregation rule.
- What creates an edge, and could that rule leak future or target information? Google's answer was fixed by the physical network — segments that are consecutive or share an intersection — not by a correlation found in the data.
- Are edges directed, weighted, typed, timestamped, or uncertain? A road network is directed and timestamped; a citation graph is directed and permanent; treating them alike hides the difference.
- Which node and edge attributes are available at prediction time? Anything reconstructed after the fact is not a feature, whatever the training table says.
- Can new nodes or entirely new graphs appear after deployment? A road opens; a molecule outside the 133,885 species of QM9 arrives; the model must have a defined behaviour for both.
- How should isolated nodes and missing relations be handled? A node with no neighbors receives no messages, so message passing has nothing to add over its own features.
- Does the graph change fast enough that stale neighborhoods become misleading? Traffic changes by the minute, which is why the deployed unit is a “Supersegment” of adjacent segments sharing significant traffic volume rather than a fixed static region.
Key idea
Graph splits can leak through connectivity even when row IDs differ
Randomly splitting nodes can leave train and test nodes directly connected. That may be valid in a transductive benchmark where the full graph is known, and invalid in a production claim about unseen entities or future edges. Message passing can also carry target-derived features across the boundary.
The size of the resulting optimism has been measured on a public benchmark, not merely warned about. The Open Graph Benchmark team compared splits in 2020, on the same datasets and the same models. On ogbg-moltox21 the best GIN scored 86.03±1.37% ROC-AUC under a random split, against 77.57±0.62% under the realistic scaffold split. That is a gap of 8.46 percentage points, produced by the split alone. On ogbg-molhiv the random split ran 5.66 percentage points higher than the scaffold split. Their conclusion on the ogbg-mol* datasets is one sentence: “We find the random split to be much easier than scaffold split.” Nothing about the architecture changed between those two numbers.
So define whether deployment is transductive, inductive over new nodes, inductive over new graphs, or temporal. Construct splits and neighborhoods accordingly. Remove edges or features that would not exist at prediction time. A model reported under the easier split is not a better model. It is the same model, scored against a question it will not be asked in production.
On ogbg-moltox21 the split alone was worth 8.46 percentage points of ROC-AUC.
Steps
A graph-modeling baseline ladder
Graph structure should demonstrate incremental value over simpler features, and the published cost of skipping the ladder is that the ranking stops carrying information. Shchur and three co-authors re-ran four prominent GNN models in 2018, under one common, fairly tuned protocol: “We perform a thorough empirical evaluation of four prominent GNN models and show that considering different splits of the data leads to dramatically different rankings of models.” Once hyperparameters and the training procedure were tuned equally for every model, the simpler architectures outperformed the more sophisticated ones. The OGB authors report the same fragility from the other direction. GNN scores on the small citation datasets — Cora, CiteSeer and PubMed, 2,700 to 20,000 nodes — are “often unstable and nearly statistically identical to each other”.
The ladder exists so that a reported gain survives that test. Build a non-graph baseline first, using node attributes and carefully engineered aggregate features. Add one-hop aggregation and see whether immediate neighborhoods add signal at all. Compare simple GNN variants — GCN-, GraphSAGE-, or attention-style layers — at matched capacity, tuned equally, since unequal tuning is precisely what reversed the ordering. Vary depth and measure both the gain and the oversmoothing that Oono and Suzuki bounded. Audit hubs and isolated nodes by inspecting performance by degree and component. Then stress the split, evaluating new nodes, new graphs, or future windows as deployment requires — the difference the OGB team measured at 8.46 percentage points on ogbg-moltox21.
1. Build a non-graph baseline
Use node attributes and carefully engineered aggregate features.
2. Add one-hop aggregation
Test whether immediate neighborhoods add signal.
3. Compare simple GNN variants
Use GCN-, GraphSAGE-, or attention-style layers with matched capacity.
4. Vary depth
Measure gains and oversmoothing as receptive field expands.
5. Audit hubs and isolated nodes
Inspect performance by degree and component.
6. Stress the split
Evaluate new nodes, new graphs, or future windows as deployment requires.
Steps
Review the graph before reviewing the network
A sophisticated GNN cannot rescue an invalid edge definition or a contaminated split. The two largest effects in this lesson were not architectural: 8.46 percentage points on ogbg-moltox21 came from changing the split, and 42% of the QM9 error came from changing the connectivity of a single layer. Review the graph accordingly.
Define nodes and edges, explaining what each relation means and when it becomes observable. Road segments joined where they are consecutive or share an intersection is a definition a reader can check; a similarity edge computed from the target is not. Timestamp the topology, so that future relationships cannot appear in historical training neighborhoods. Build relational baselines from degree, counts, and neighborhood aggregates before any message passing runs. Test edge ablations, removing or shuffling relation types to measure which parts of the topology actually contribute signal — the gap between 11 out of 13 QM9 targets with geometry and 5 out of 13 from topology alone is what a well-run ablation looks like. Inspect degree and component slices, evaluating hubs, isolated nodes, cold-start nodes and disconnected regions separately, because a node with no neighbors receives nothing from the mechanism the model is being credited for. Finally, specify inductive behavior: state how new nodes, new edges and new graph versions are handled. And remember the ceiling. A standard neighbourhood-aggregation GNN cannot distinguish structures beyond the 1-dimensional Weisfeiler-Leman test, so a task that requires that distinction requires a different model rather than more layers.
1. Define nodes and edges
Explain what each relation means and when it becomes observable.
2. Timestamp the topology
Prevent future relationships from appearing in historical training neighborhoods.
3. Build relational baselines
Compare degree, counts, and neighborhood aggregates before message passing.
4. Test edge ablations
Remove or shuffle relation types to measure which topology contributes signal.
5. Inspect degree and component slices
Evaluate hubs, isolated nodes, cold-start nodes, and disconnected regions.
6. Specify inductive behavior
Describe how the model handles new nodes, edges, and graph versions.
Key takeaways
- Graphs represent entities and relationships through nodes, edges, and associated features — QM9, a dataset of 133,885 molecular species with 13 targets per molecule, is one such representation.
- Message passing forms edge messages, aggregates neighbors, and updates node states; Gilmer and four co-authors named the pattern in 2017 and reached chemical accuracy on 11 of 13 QM9 targets with geometry, 5 of 13 without it.
- Aggregation should respect the unordered nature of ordinary graph neighborhoods, and it carries a proven ceiling: two groups showed independently in 2019 that such a GNN is at most as powerful as the 1-dimensional Weisfeiler-Leman test.
- Layer depth expands the receptive field but degrades representations — graph convolution is a special form of Laplacian smoothing, and Oono and Suzuki proved the output exponentially approaches signals carrying only connected-component and node-degree information.
- Node, edge, and graph targets require different pooling, negatives, and evaluation designs; GraphCast's node-level forecasts beat the most accurate operational deterministic systems on 90% of 1380 verification targets, a stated denominator rather than an average.
- A GNN should outperform strong non-graph baselines under a deployment-matched split: the random split flattered GIN by 8.46 percentage points on ogbg-moltox21, and unequal tuning reversed the ranking of four models when Shchur and three co-authors re-evaluated them.