01 / 12
AI for Materials Science  ·  Lecture 10 (Complete Beginner-to-Research Edition)

Graph Neural Networks & Machine Learning Interatomic Potentials:
Molecular GNNs, Chemprop D-MPNN, Crystal CGCNN & Equivariant MLIPs

Zesheng Liu
Laboratory of Organic Electronics, Linköping University
Modules 10a–10c  |  50-Line PyTorch GNN, Full-Course AqSolDB Leaderboard, CGCNN & Energy-Conserving MD
Linköping University Laboratory of Organic Electronics

Lecture 10 roadmap: from molecular graphs to universal potentials

Unifying the entire semester's themes—inductive bias, symmetry, extrapolation, and physical conservation (10a–10c)
PART 1 · MODULE 10a

50-Line Molecular GNN

Representing molecules as (x, edge_index) graphs, message passing with index_add_, permutation invariance, Sum vs. Mean readout, and acene extrapolation.

PART 2 · MODULE 10b

Chemprop & Course Finale

Directed bond message passing (D-MPNN) avoiding tottering echoes, one-line CLI training on the exact same AqSolDB split, and our full-course model leaderboard.

PART 3 · MODULE 10c

Crystal CGCNN & MLIPs

Periodic crystal multi-graphs & Gaussian radial basis (GBF), gated CGCNN invariance, autograd conservative forces (F = −∇E) in NVE MD, and MACE equivariant potentials.

Graphs are the native data structure of matter—encoding atoms, bonds, and physical symmetries directly into neural network message passing.
Linköping University Laboratory of Organic Electronics

Message passing: a GNN is a learnable Morgan fingerprint

Each GNN layer expands an atom's receptive field by one bond hop—turning local neighborhoods into end-to-end learned embeddings
Message passing: a GNN is a learnable Morgan fingerprint
Just like Morgan fingerprint radius r = 2 hashes 2-hop neighborhoods, an L-layer GNN aggregates L-hop chemical environments—with learnable PyTorch weights!
Linköping University Laboratory of Organic Electronics

Zero magic: a complete PyTorch GNN layer in 8 lines

No PyG black boxes required—index_add_ gives exact, permutation-invariant neighborhood aggregation
1
msg = self.W_msg(torch.cat([h[src], h[dst], e_attr], -1))
Compute one message vector per directed bond from neighbor atom + bond features.
2
agg.index_add_(0, src, msg)
Sum all incoming bond messages per atom—guaranteed permutation invariant!
3
h_mol = global_sum_pool(h, batch_idx)
Batching multiple molecules = one big disconnected graph + batch_idx vector.
SYMMETRY BUILT IN

Why Graphs Beat SMILES Strings

  • No arbitrary atom numbering: Shuffling atom indices produces the exact same output (diff = 0).
  • No syntax errors: Bonds and ring closures are explicit edges, never fragile parentheses.
  • Determinism note: Enable torch.use_deterministic_algorithms(True) for reproducible index_add_!
A GNN is simply repeated 'gather neighbor messages -> permutation-invariant sum -> MLP update', followed by graph readout.
Linköping University Laboratory of Organic Electronics

Closing Lecture 02's acene cliffhanger: Sum Readout extrapolates!

Random Forests flatline on unseen pentacene; a Sum-Readout GNN naturally continues the physical hydrophobicity trend
Closing Lecture 02's acene cliffhanger: Sum Readout extrapolates!
Readout physics matters: Sum Readout preserves extensive molecular size (enabling size extrapolation), whereas Mean Readout throws away atom count!
Linköping University Laboratory of Organic Electronics

Chemprop D-MPNN: directed bond messages eliminate tottering

Standard atom-based MPNNs bounce messages back and forth across the same bond; D-MPNN updates directed bond states instead
Chemprop D-MPNN: directed bond messages eliminate tottering
Chemprop (Yang et al., JCIM 2019) is the industry-standard molecular property GNN—requiring just one CLI command (chemprop train) with scaffold splits.
Linköping University Laboratory of Organic Electronics

Full-course AqSolDB leaderboard (identical 1,896-molecule test set)

Every model from Lectures 02, 07, and 10 evaluated head-to-head on the exact same test split
Full-course AqSolDB leaderboard (identical 1,896-molecule test set)
End-to-end graph learning (RMSE 1.04–1.05) decisively beats both 17-descriptor MLPs (1.17) and descriptor+fingerprint Random Forests (1.11)!
Linköping University Laboratory of Organic Electronics

GNN oversmoothing & the Cell 2020 Halicin discovery funnel

Why 3–5 message-passing layers hit the sweet spot—and how Chemprop united our entire course toolkit to discover a novel antibiotic
GNN oversmoothing & the Cell 2020 Halicin discovery funnel
Deep vanilla GNNs blur all atoms together (oversmoothing); pairing a 3–5 layer D-MPNN with RDKit descriptors, BO & Tanimoto < 0.4 filtering unlocked Halicin!
Linköping University Laboratory of Organic Electronics

From molecules to periodic crystals: Multi-Graphs & GBF distances

Inorganic crystals have no discrete covalent bonds—edges connect periodic neighbor images weighted by Gaussian radial basis functions
From molecules to periodic crystals: Multi-Graphs &amp; GBF distances
Expanding interatomic distances d_ij into K smooth Gaussian basis functions gives CGCNN sub-0.05 Å sensitivity while preserving exact E(3) translation & rotation invariance.
Linköping University Laboratory of Organic Electronics

Machine Learning Potentials (MLIPs): autograd forces conserve energy!

Predict scalar total energy E(R) with smooth activations (SiLU), then compute Fi = −∂E/∂Ri via torch.autograd.grad
Machine Learning Potentials (MLIPs): autograd forces conserve energy!
Never predict MD forces directly—differentiating a smooth scalar energy network guarantees a curl-free conservative force field and stable NVE trajectories!
Linköping University Laboratory of Organic Electronics

The MLIP frontier: E(3)-equivariant universal potentials (MACE / CHGNet)

Retaining directional tensor features (spherical harmonics Ylm) delivers near-DFT accuracy at 10,000× speed across the periodic table
The MLIP frontier: E(3)-equivariant universal potentials (MACE / CHGNet)
Pre-trained universal MLIPs (MACE-MP-0, MatterSim, SevenNet) plug directly into ASE—turning hours of DFT crystal relaxation into milliseconds on a laptop.
Linköping University Laboratory of Organic Electronics

Summary (Take home notes)

  • Graphs match the physics of matter: Molecular GNNs learn end-to-end representations directly from atoms & bonds, with built-in permutation invariance.
  • Readout & directed edges matter: Sum Readout unlocks size extrapolation (acenes), and Chemprop's D-MPNN removes tottering—achieving our best AqSolDB RMSE (1.04–1.05).
  • Periodic crystals need multi-graphs + GBF: CGCNN encodes periodic boundary images and continuous distances, preserving translation, rotation, and supercell invariance.
  • Conservative MLIPs via autograd: Differentiating a smooth scalar energy network (F = −∇E) with Force Matching ensures strict NVE MD energy conservation.
  • Universal equivariant MLIPs are here: MACE and CHGNet bring near-DFT accuracy at O(N) speed across the entire periodic table.
Linköping University Laboratory of Organic Electronics

Thanks for your listening

Zesheng Liu  ·  zesheng.liu@liu.se
AI for Materials Science  ·  Lecture 10  |  Final Practice: 10d_exercises.ipynb  ·  Wishing you great discoveries in Materials AI!
Linköping University Laboratory of Organic Electronics