Back to paper library
Paper notesarXiv 2017ICML 2017

MPNN

So They Were All Passing Messages

Original paper

Neural Message Passing for Quantum Chemistry

Paper authors

Justin Gilmer · Samuel S. Schoenholz · Patrick F. Riley · Oriol Vinyals · George E. Dahl

Publication
ICML 2017Conference
First submitted to arXiv
arXiv:1704.01212
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{graphlearningmpnn2017,
  title = {{Neural Message Passing for Quantum Chemistry}},
  author = {Justin Gilmer and Samuel S. Schoenholz and Patrick F. Riley and Oriol Vinyals and George E. Dahl},
  year = {2017},
  eprint = {1704.01212},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1704.01212}
}
On this page

To find a molecule's dipole moment, energy gap or zero-point vibrational energy, chemists usually run a density functional theory (DFT) calculation. A small molecule takes roughly a thousand seconds.

When drug or materials screening involves millions of candidate molecules, that speed becomes a bottleneck.

Justin Gilmer, Samuel Schoenholz, Patrick Riley, Oriol Vinyals and George Dahl, from Google Brain, Google and DeepMind, want neural networks to predict these properties directly from molecular graphs, taking around a hundredth of a second per molecule.

Plenty of neural networks could already consume molecular graphs, each with its own name. The paper's first move is to put them all into one framework.

Figure 1 of the paper: an organic molecule has two routes to property prediction. The upper route uses DFT, taking around 10 to the power of 3 seconds; the lower route uses a message passing neural network, with atoms exchanging messages step by step, taking around 10 to the power of -2 seconds. Both predict targets such as energies and vibrational frequencies.
Figure 1 from Gilmer et al., taken from PDF page 1. The original caption is omitted.

Defining the Problem

The authors note that most machine-learning applications in chemistry still depend on feature engineering. Researchers manually design molecular representations—Coulomb matrices, Bag of Bonds, molecular fingerprints—then attach an off-the-shelf regressor.

Neural networks have been tried but are not yet widely adopted. The authors compare this with image modeling before convolutional networks became widespread: evidence is needed that neural networks with suitable inductive biases really work in this domain.

Molecules have natural symmetries. Renumber the atoms and the molecule stays the same; a suitable model should be invariant to graph isomorphism. The authors pursue two goals: identify a common form for existing graph neural networks, then push it to its limits on a practical benchmark.

That benchmark is QM9: roughly 130,000 small molecules, each with 13 properties computed by DFT. Evaluation uses an intuitive standard, “chemical accuracy,” established in chemistry; errors below that threshold meet the accuracy chemists consider acceptable.

Solving the Problem

The Message Passing Framework

MPNNs (Message Passing Neural Networks) divide the forward pass into two phases.

The message passing phase runs for TT steps. At each step, node vv receives a message from each neighbor ww, sums them, and updates its state:

mvt+1=∑w∈N(v)Mt(hvt,hwt,evw)m_v^{t+1}=\sum_{w\in N(v)}M_t\left(h_v^t,h_w^t,e_{vw}\right) hvt+1=Ut(hvt,mvt+1)h_v^{t+1}=U_t\left(h_v^t,m_v^{t+1}\right)

MtM_t is the message function, which sees both sender and receiver states and edge features evwe_{vw}; UtU_t is the update function.

The readout phase combines the final states of all nodes into a graph representation:

y^=R({hvT∣v∈G})\hat y=R\left(\left\{h_v^T\mid v\in G\right\}\right)

RR must be invariant to node permutations. All three functions are learnable.

The authors then show, one by one, how at least eight existing models fit this form: Duvenaud et al.'s molecular-fingerprint convolutions, gated graph neural networks (GG-NNs), Interaction Networks, molecular graph convolutions, deep tensor networks, and three Laplacian-based spectral methods (Bruna et al., ChebNet and GCN).

For GCN, the message function multiplies the neighboring state by weights and scales it by the two endpoint degrees; the update is ReLU. On a five-node graph, compute it through message and update functions, then compare with GCN's matrix formulation:

Python
import numpy as np
rng = np.random.default_rng(0)

n = 5
edges = [(0, 1), (0, 2), (1, 2), (2, 3), (3, 4)]
nbrs = {v: [v] for v in range(n)}            # Start with self: a self-loop is an edge too
for i, j in edges:
    nbrs[i].append(j)
    nbrs[j].append(i)
deg = {v: len(nbrs[v]) for v in range(n)}    # Degrees after adding self-loops
h = rng.normal(size=(n, 3))
W = rng.normal(size=(3, 3))

def message(h_v, h_w, v, w):                 # M_t(h_v, h_w, e_vw)
    return h_w @ W / np.sqrt(deg[v] * deg[w])

def update(h_v, m_v):                        # U_t(h_v, m_v)
    return np.maximum(m_v, 0)

def mpnn_step(h):
    return np.array([update(h[v], sum(message(h[v], h[w], v, w) for w in nbrs[v]))
                     for v in range(n)])

# Compare with GCN matrix form ReLU(Â H W)
A = np.eye(n)
for i, j in edges:
    A[i, j] = A[j, i] = 1
d = A.sum(1)
A_hat = A / np.sqrt(np.outer(d, d))
print("Matches the GCN matrix form:", np.allclose(mpnn_step(h), np.maximum(A_hat @ h @ W, 0)))
Text
Matches the GCN matrix form: True

Both compute the same thing: one describes a single node's perspective, while the other writes the whole graph as a matrix. The framework's benefit is that replacing message or update gives another model.

Which Variations Did the Authors Try?

With a common form in hand, the authors try several choices for each component:

  • Message function: GG-NN selects a matrix by edge type and multiplies the neighbor's state. The proposed edge network maps continuous edge features through a neural network into a d×dd\times d matrix, allowing quantities such as interatomic distance. Another option, pair message, sees both sender and receiver states, but is less stable to train and is not explored further.
  • Virtual graph elements: one option adds special “virtual edges” between otherwise unconnected node pairs; another adds a master node connected to every node, acting as global scratch space that everyone can read and write at each step. Both let information travel farther during message passing.
  • Readout function: beyond GG-NN's sum-based readout, the authors try set2set, designed for sets and expected to be more expressive.
  • Towers: split a dd-dimensional node state into kk parts, run message passing separately, then mix them through a shared network. This allows larger hidden states for the same computation.

For inputs, explicitly representing hydrogen atoms as nodes and including full edge features—bond types and interatomic distances—matter for many targets.

Discussion

Main Results on QM9

The metric is the error ratio: mean absolute error divided by the target's chemical-accuracy threshold. A value below 1 achieves chemical accuracy. The authors compare five handcrafted molecular representations, each with an off-the-shelf regressor, two existing MPNN baselines, and their best variant: edge-network messages, set2set readout and explicit hydrogens.

MethodMean error ratio over 13 targets
Molecular fingerprint ECFP453.97
Coulomb matrix3.37
Bag of Bonds (BoB)2.08
HDAD1.35
Molecular graph convolution (GC)2.59
GG-NN1.36
enn-s2s (this paper)0.68
enn-s2s, ensemble of 5 models0.52

The single model sets the best result of the time on all 13 targets, achieving chemical accuracy on 11. Training a separate model for each target also works better than training all 13 together, sometimes by as much as 40%.

Without Spatial Information

QM9 provides 3D molecular conformations, but real applications often have only connectivity. In a topology-only setting, the authors find that every change allowing distant nodes to exchange information helps:

ModelMean error ratio
GG-NN3.47
GG-NN + virtual edges2.90
GG-NN + master node2.62
GG-NN + set2set readout2.57

All three changes improve every one of the 13 targets; set2set achieves chemical accuracy on 5. These experiments add a partial-charge node feature, itself a DFT output unavailable in practical use. The main results above do not use this feature.

Towers bring an unexpected benefit. Intended simply to speed training, they beat the baseline on 12 of 13 targets under both training settings and generalize better.

Virtual Edges and the Master Node

These changes occupy only a short passage in the paper, but are interesting in hindsight. More than three years later, Alon and Yahav call GNNs' difficulty transmitting distant information over-squashing; their repair also connects all nodes in the last layer. Later Graph Transformers add a route for all nodes to see one another at every layer.

Conclusion

This paper organizes graph neural networks, each previously named separately, into three functions: message, update and readout. The name becomes so widely used that many papers call this whole family message passing.

On QM9, edge networks, set2set and explicit hydrogens produce the best results of the time on all 13 targets, reaching chemical accuracy on 11.

The authors urge researchers to push this family to its limits on applications that really matter, finding the implementation details that count, rather than constantly inventing new variants. After reading the paper, those details are often the most useful: whether hydrogens should be nodes, whether to train targets separately, and which readout to use.