Graph Learning2017intermediate12 min read

Neural Message Passing for Quantum Chemistry

تمرير الرسائل العصبي للكيمياء الكمّية

Gilmer, J. · Schoenholz, S. S. · Riley, P. F. · Vinyals, O. · Dahl, G. E. — ICML

The problem

By 2017, predicting molecular properties with machine learning was far behind progress in vision and language. Multiple architectures had appeared — GG-NNs, Interaction Networks, molecular fingerprints, spectral methods — but each used different notation, different update rules, and different outputs. Researchers could not easily compare them, combine their strengths, or know which design choices actually mattered. Meanwhile, quantum chemistry simulations (DFT) remained the workhorse, but a single calculation on one small molecule took about an hour — far too slow for drug discovery at scale.

The contribution

The paper reformulates eight existing graph neural network models into a single unified framework called Neural Networks (MPNNs). Every MPNN is defined by just three functions: a message function M that computes what information each node sends to its neighbors, an update function U that refreshes each node's , and a R that aggregates all node states into a single graph-level prediction. Within this framework, the authors explore novel variants — edge neural networks for continuous edge features, readouts, , and multi-tower architectures — achieving state-of-the-art results on the QM9 molecular property benchmark, predicting DFT calculations to within chemical accuracy on 11 of 13 targets.

The impact

The MPNN framework became the canonical language for describing graph neural networks. Its message-update-readout abstraction was adopted by virtually every subsequent GNN paper and library — PyTorch Geometric, DGL, and DeepMind's graph_nets all speak MPNN. The framework directly influenced AlphaFold 2's structure module (which uses message passing on residue graphs) and GIN's theoretical analysis (which used MPNN to study expressiveness). MPNN proved that a simple, general abstraction could both unify a scattered field and push its empirical frontier.

Imagine a post office serving a small village. Every house is an atom, and the roads between houses are chemical bonds. Each morning every house writes a postcard describing itself — its element, its charge, its mood — and hands copies to its immediate neighbors. Each house reads all incoming postcards, combines them with what it already knows, and writes a new postcard for the next round.

After a few delivery rounds, even houses at opposite ends of the village know about each other — not because anyone ran across the whole map, but because information rippled outward through the local mail network.

The village clerk then reads everyone's final postcard and writes a single summary report: "This molecule's energy is X, its dipole moment is Y."

That is the entire MPNN: message → update → readout. Everything else is choosing how to write the postcards.

The problem: a zoo of graph models with no common language

Before MPNN, if you wanted to learn on molecular graphs you had at least eight architectures to choose from — each described with its own notation, trained on its own benchmarks, and impossible to compare fairly:

  • Convolutional Fingerprints (Duvenaud et al., 2015) — learned molecular fingerprints via , but the message function summed node states and edge states separately, missing correlations between them.
  • Gated Graph Neural Networks (Li et al., 2016) — used a update and matrix-multiply messages, but assumed discrete edge types.
  • Interaction Networks (Battaglia et al., 2016) — modeled physics simulations with a neural network message function over concatenated node and edge features.
  • Deep Tensor Neural Networks (Schütt et al., 2017) — used element-wise multiplication to combine node and edge information.
  • Spectral / Laplacian methods (Bruna et al., 2013; Kipf & Welling, 2016) — defined convolution via the eigenvectors, elegant but hard to scale beyond a single fixed graph.

The community needed a Rosetta Stone — a single framework that revealed what these models shared and where they truly differed.

Open in Lab
Eight architectures, one framework. Click any model to see how its message, update, and readout functions map into the MPNN abstraction.
The demo wakes as you arrive…

The framework: message → update → readout

An MPNN operates on an undirected graph GG with node features xvx_v and edge features evwe_{vw}. The has two phases:

Phase 1 — Message passing runs for TT time steps. At each step, every node vv collects messages from its neighbors N(v)N(v), aggregates them, and updates its own hidden state. Think of it as TT rounds of the postcard game: each round, every atom listens to its bonded neighbors and revises its internal description.

Phase 2 — Readout takes all the final node states and produces a single prediction for the entire graph. This is the village clerk writing the summary report. The readout must be permutation-invariant — shuffling the order of atoms cannot change the prediction, because molecules have no canonical ordering.

mvt+1=∑w∈N(v)Mt(hvt,  hwt,  evw)m_v^{t+1} = \sum_{w \in N(v)} M_t(h_v^t,\; h_w^t,\; e_{vw})
Step 1: message aggregation — Each node v gathers messages from its neighbors N(v). The message function M takes the sender's state, the receiver's state, and the edge features, and returns a message vector. All neighbor messages are summed.
hvt+1=Ut(hvt,  mvt+1)h_v^{t+1} = U_t(h_v^t,\; m_v^{t+1})
Step 2: node state update — Each node combines its current state with the aggregated message to produce a new state. In practice, U is often a GRU — the same gated recurrent unit from sequence models, repurposed here for graph iteration.
y^=R ⁣({hvT∣v∈G})\hat{y} = R\!\bigl(\{h_v^T \mid v \in G\}\bigr)
Step 3: readout — graph-level prediction — The readout function R operates on the set of final node states and must be invariant to permutation. Simple form: sum all states and pass through a neural network. Advanced form: use Set2Set, which attends over the set multiple times for richer aggregation.
Open in Lab
Watch messages flow through a water molecule (H₂O). Click "Next Step" to advance the message passing rounds and see how each atom's representation enriches over time.
The demo wakes as you arrive…

Unification: eight architectures in three functions

The power of the MPNN framework is that seemingly different architectures become interchangeable parts. Here is how three key models decompose:

GG-NN (Li et al., 2016): the message function is a matrix multiply M(hv,hw,evw)=AevwhwM(h_v, h_w, e_{vw}) = A_{e_{vw}} h_w, one learned matrix per edge type. The update is a GRU. The readout uses gating: R=∑vσ(i(hvT,hv0))⊙j(hvT)R = \sum_v \sigma(i(h_v^T, h_v^0)) \odot j(h_v^T).

Interaction Networks (Battaglia et al., 2016): the message function is a full neural network over concatenated inputs: M(hv,hw,evw)=NN([hv,hw,evw])M(h_v, h_w, e_{vw}) = \text{NN}([h_v, h_w, e_{vw}]). The update is also a neural network. The readout sums and passes through another network.

GCN (Kipf & Welling, 2016): the message function scales by normalized degree: M(hv,hw)=cvwhwM(h_v, h_w) = c_{vw} h_w where cvw=(deg(v)deg(w))−1/2Avwc_{vw} = (\text{deg}(v) \text{deg}(w))^{-1/2} A_{vw}. The update is U(hv,mv)=ReLU(Wmv)U(h_v, m_v) = \text{ReLU}(W m_v).

Once you see the pattern, every new GNN architecture becomes a sentence in the same language: "My message function is ___; my update is ___; my readout is ___."

Key innovations within the framework

Beyond unification, the paper introduced several novel MPNN variants that each addressed a specific limitation:

Edge Neural Network — Previous message functions either assumed discrete edge types (bond = single/double/triple) or ignored edge information entirely. The edge network replaces the fixed matrix multiply with a small neural network that maps continuous edge features (bond type + spatial distance) to a d×dd \times d matrix: M(hv,hw,evw)=A(evw) hwM(h_v, h_w, e_{vw}) = A(e_{vw})\, h_w. This lets the model reason about 3D spatial relationships — how far apart two atoms are — not just whether they are bonded.

Virtual Graph Elements — In a sparse molecular graph, two atoms on opposite ends are separated by many hops. Information must ripple step by step, which is slow and lossy. Two fixes:

  • Virtual edges: add a special edge type between every non-bonded pair, creating a fully connected graph. Now every atom can talk to every other atom in a single step.
  • Master node: add a single global node connected to all atoms with a special edge type. The master node acts as a shared bulletin board — every atom writes to it and reads from it each round, enabling global coordination without quadratic edge count.

Set2Set Readout — Simple readout functions just sum the final node states, which limits expressiveness. Set2Set (Vinyals et al., 2015) uses an mechanism that reads the node set multiple times, producing a richer graph-level representation. This alone improved average performance across all 13 targets.

Open in Lab
Compare a sparse molecular graph (left) with virtual edges (center) and a master node (right). Toggle to see how information flows change.
The demo wakes as you arrive…

Scaling up: the multi-tower trick

One bottleneck of message passing is cost: a single step on a dense graph with nn nodes and dd-dimensional embeddings costs O(n2d2)O(n^2 d^2) multiplications. As molecules get larger or embeddings get richer, this becomes expensive.

The multi-tower trick splits each dd-dimensional node into kk smaller pieces of size d/kd/k. Each piece runs message passing independently (like kk parallel "towers"), then a mixing network recombines them. The total cost drops to O(n2d2/k)O(n^2 d^2 / k) — an 8-tower model with d=200d=200 runs roughly 2× faster than a single-tower model.

Surprisingly, the tower structure also improved generalization on 12 of 13 targets, likely because it acts like an implicit ensemble — each tower learns slightly different features, and the mixing network combines their perspectives.

Open in Lab
Drag the tower count slider to see how splitting the embedding reduces computation while maintaining (or improving) expressiveness.
The demo wakes as you arrive…

QM9: predicting quantum properties of molecules

The paper evaluated MPNNs on QM9 — a dataset of ~134,000 small organic molecules (up to 9 heavy atoms: C, N, O, F plus hydrogens). For each molecule, density functional theory (DFT) computes 13 quantum properties: atomization energies at various conditions, orbital energies (HOMO, LUMO, gap), vibrational frequencies, dipole moments, and polarizability.

DFT is the gold standard, but painfully slow: a single molecule takes about an hour on a modern CPU. The MPNN runs ~300,000 times faster.

The key benchmark threshold is "chemical accuracy" — an error level that chemists consider small enough to be practically useful. The best MPNN variant (edge network + set2set + explicit hydrogens) achieved chemical accuracy on 11 of 13 targets, and the ensemble model on all 13 in some configurations.

Open in Lab
Error ratios on QM9 targets. Values below 1.0 (dashed line) mean the model achieved chemical accuracy. Compare MPNN against traditional baselines.
The demo wakes as you arrive…

What the model sees: atoms, bonds, and distances

Each atom is described by a feature vector encoding its element type (one-hot: H, C, N, O, F), atomic number, whether it accepts or donates electrons, whether it is aromatic, its hybridization state (sp, sp², sp³), and the number of attached hydrogens.

Edges carry bond information. Three representations were tested, each adding more spatial detail:

  • Chemical graph only: edges are discrete bond types (single, double, triple, aromatic). No 3D information.
  • Distance bins: bond distances are binned into 10 intervals (8 uniform bins over [2, 6] Å plus [0, 2] and [6, ∞]), combined with bond type. This lets the GG-NN style matrix multiply handle distance.
  • Raw distance + bond type: a 5-dimensional edge vector — one continuous distance value plus a 4-dimensional one-hot bond type. This requires the edge neural network to process.

The richest representation (raw distance + explicit hydrogen atoms as nodes) performed best, but made graphs ~3× larger (up to 29 nodes instead of 9), increasing time by ~10×.

The MPNN forward pass in code

Message Passing Neural Network — core forward passpython

Simplified to show the idea — not the real implementation.

import numpy as np

def message_pass(node_states, adj, edge_features, M_fn, U_fn, T=3):
    """Run T rounds of message passing on a molecular graph.

    node_states: (n, d) — one row per atom
    adj:         list of (i, j) pairs — edges
    edge_features: dict (i,j) -> feature vector
    M_fn:        message function M(h_v, h_w, e_vw) -> message vector
    U_fn:        update function U(h_v, aggregated_msg) -> new h_v
    """
    h = node_states.copy()
    for t in range(T):
        new_h = h.copy()
        for v in range(len(h)):
            # Gather messages from all neighbors
            neighbors = [w for (i, w) in adj if i == v]
            msgs = [M_fn(h[v], h[w], edge_features[(v, w)]) for w in neighbors]
            if msgs:
                agg = sum(msgs)           # sum aggregation
                new_h[v] = U_fn(h[v], agg)  # update node state
        h = new_h
    return h

def readout(final_states, R_fn):
    """Aggregate all node states into a single graph prediction.

    R must be permutation-invariant — simplest: sum then MLP.
    """
    graph_vec = sum(final_states)   # sum pooling
    return R_fn(graph_vec)           # predict property

# That's the whole framework. GG-NN, GCN, Interaction Nets,
# and every other MPNN differ only in their M, U, and R choices.

Why it mattered

  1. 2016

    GG-NN (Gated Graph Neural Network)

    Li et al. introduced gated recurrent updates on graph-structured data, one of the key precursors that MPNN unified.

  2. 2017

    MPNN — This Paper

    Gilmer et al. unify eight GNN architectures into the message-update-readout framework and achieve state of the art on QM9.

  3. 2017

    SchNet

    Continuous-filter convolutional networks for molecules that use the same MPNN language for spatial message passing.

  4. 2019

    GIN (Graph Isomorphism Network)

    Xu et al. prove that sum aggregation in MPNNs is as powerful as the Weisfeiler-Leman graph isomorphism test, establishing theoretical limits for the entire framework.

  5. 2020

    DimeNet — Directional Message Passing

    Gasteiger et al. extend MPNN with directional information (bond angles), pushing molecular property prediction further.

  6. 2021

    AlphaFold 2

    DeepMind's protein structure predictor uses message passing on residue graphs in its Evoformer and structure modules — a direct descendant of the MPNN abstraction applied to biology's hardest problem.

  7. 2022

    GNN Libraries Mature

    PyTorch Geometric, DGL, and JAX-based frameworks all implement the MPNN abstraction as their core API, making message passing the default paradigm for graph learning.

The MPNN paper's greatest legacy is not any single model variant — it is the language it gave the field. When a researcher today says "message function," "update function," and "readout function," they are speaking MPNN. That vocabulary made it possible to compare, compose, and improve graph neural networks systematically, and it is the foundation on which every modern GNN is built.

CitationGilmer, Schoenholz, Riley, Vinyals, Dahl. Neural Message Passing for Quantum Chemistry. ICML, 2017.

Terms in this paper