Graph Generative Models and Applications
M2 · P2 (announced) · Year 2 · Period 2
Contents
- Introduction and overview
- 0. Recap: generating graphs in M1
- 1. The problem, formalized
- 2. Autoregressive models: DeepGMG and GraphRNN in depth
- 3. VAEs: GraphVAE, NeVAE and valence constraints
- 4. Normalizing flows: change of variables and GraphAF
- 5. Discrete diffusion: DiGress in detail
- 6. Evaluating rigorously: MMD, validity, FCD
- 7. Conditional generation and text-to-graph
- 8. Applications: drugs, materials, synthetic networks
- 9. Research of the LLGA team
- 10. Open problems
- Exercises / Labs
- Projects and assessment
- References
Introduction and overview
| Module | Graph Generative Models and Applications |
| Code | M2 · P2 (announced) — official code not published (course description not published) |
| Team and workload | Instructor: master’s team (LLGA / DaSciM) · ~24 h · the M2 extension of the “graph generation” chapter of the M1 core course: autoregressive models, VAEs, flows and discrete diffusion taken all the way to the theorems, rigorous distributional evaluation, conditional generation and text-to-graph, molecule/material/synthetic-network applications — and the research of the LLGA team. |
| Status in the program | M2Graph × LLM route · M2 program being finalized |
Audience: an engineer working on graphs, chemistry or networks who wants to generate valid structures. Empirical first: we start from what fails in practice — a generated molecule with an impossible valence, a generator with a “good” MMD on degrees but the wrong motifs — and only then name the models that address it: GraphRNN, GraphVAE, flows, DiGress.
This module is the generative part of machine learning on relational data, and the sequel to the graph generation chapter of the M1 Graph ML course.
What you will be able to do
- Formalize graph generation as a distributional problem (a distribution over a combinatorial space);
- Explain the DeepGMG and GraphRNN autoregressive models in detail, from the stopping decision to the enumeration order;
- Derive the ELBO of graph VAEs and handle valence constraints (GraphVAE, NeVAE);
- Apply the change of variables of normalizing flows to mixed discrete/continuous variables (GraphAF);
- Unroll the discrete diffusion of DiGress: noising processes, masking orders, denoising network;
- Evaluate a generation rigorously: MMD on graph statistics, chemical validity, FCD;
- Condition the generation (target properties) and generate graphs from text;
- Situate the real applications — drugs, materials, networks — and read the recent research of the LLGA team.
Official objectives and syllabus
Official course description not published (S3/S4 catalog empty): as of the start of the 2026 academic year, the “LLGA 2 – Semestre 3” and “LLGA 2 – Semestre 4” tracks of the 2026-2027 SynapseS catalog still list no courses, and the master’s wiki indicates that the detailed M2 program is “under development” (period 2: “to be completed soon”).
The program below therefore reflects the master’s brochure (period 2), with an indicative volume of ~24 h; these course materials are calibrated to that volume (see the session plan below). The following table maps each brochure theme to the course sections; the materials’ own additions are marked “going beyond the syllabus”.
| Brochure theme | Course section covering it |
|---|---|
| The graph generation problem, formalized | ch. 1 (graph space, sampling, combinatorial complexity) |
| Autoregressive models | ch. 2 (DeepGMG, GraphRNN in depth) |
| Graph VAEs | ch. 3 (GraphVAE, NeVAE, valence constraints) |
| Normalizing flows | ch. 4 (change of variables, GraphAF) |
| Discrete diffusion | ch. 5 (DiGress in detail) |
| Rigorous distributional evaluation | ch. 6 (MMD, validity, FCD) |
| Conditional generation and text-to-graph | ch. 7 |
| Applications: molecules, materials, synthetic networks | ch. 8 |
| Research of the LLGA team | ch. 9 |
| Going beyond the syllabus — recap of the “generation” chapter of the M1 core course | ch. 0 |
| Going beyond the syllabus — open problems and internship topics | ch. 10 |
| Going beyond the syllabus — labs (toy GraphRNN, small graph VAE, MMD evaluation) | Exercises / Labs |
Where this course fits in the program
An M2 module announced for period 2 and preselected by the Graph × LLM route of the home page, with an explicitly research flavor: taught by the LLGA / DaSciM team, it prepares for internships and PhDs on the generation of discrete structures.
Prerequisites: chapter 9 of Graph Machine and Deep Learning for Generative AI (first encounter with graph generation, revisited in ch. 0); the GNN architectures of Advanced Graph Neural Networks, which serve as denoisers and encoders everywhere here; and the VAE, diffusion and guidance chapters of Multimodal Generative AI (ch. 1, 3–4, 7). Control in Generative AI (M2 P1, upstream) summarises NeVAE, GraphAF and DiGress; this page is the reference for their details.
Optional deepening: Computational Optimal Transport for ML and Fairness, which is not on the Graph × LLM route; its Gromov-Wasserstein chapter goes beyond the one-box summary of ch. 6.
Downstream: the module leads to the biological and industrial applications of generation (ch. 8) and to the open problems (ch. 10) — as many gateways to the research-oriented internship and, beyond, to the PhD; it also feeds the “LLMs × graphs” crossroads developed in Advanced Topics in Large Language Models (ch. 8).
Course outline
- Recap: generating graphs in M1 — what was already covered in M1: introductive versions of graph VAEs and GANs, and the vocabulary of the problem.
- The problem, formalized — graph space, sampling, combinatorial complexity: why generating graphs is hard.
- Autoregressive models: DeepGMG and GraphRNN in depth — building the graph sequentially, decision by decision.
- VAEs: GraphVAE, NeVAE and valence constraints — the graph encoder-decoder and the art of obtaining valid molecules.
- Normalizing flows: change of variables and GraphAF — one-step generation by dense invertible flows, on mixed variables.
- Discrete diffusion: DiGress in detail — noising then denoising edges and attributes: the state of the art explained step by step.
- Evaluating rigorously: MMD, validity, FCD — why visual quality is not enough, and which distributional metrics to use.
- Conditional generation and text-to-graph — targeting a property, and generating from a natural-language description.
- Applications: drugs, materials, synthetic networks — three industrial and scientific territories examined seriously.
- Research of the LLGA team — the lab’s recent contributions, presented by their authors (self-study).
- Open problems — what the community does not yet know how to do, and the internship topics hiding there (self-study).
- Exercises / Labs — implement a toy GraphRNN, train a small graph VAE, evaluate by MMD.
- Projects and assessment — solo and group project subjects, a written-exam proposal and a grading rubric.
- References — the reference papers of each family, to be read in the original.
Session plan
24 h in class (announced) = 8 sessions of 3 h. The volume is the indicative ~24 h given by the master’s brochure for this module (the SynapseS 2026–2027 sheet is not yet published); no session-by-session programme is published, so the split below is our proposal for covering these notes in that time. Level 1 = foundations (reviews, definitions, first worked examples), 2 = core methods, 3 = advanced theory; the level never goes down from one session to the next.
| Session | Hours | Level | Content | Practice |
|---|---|---|---|---|
| 1 | 3 h | 1 | ch. 0 Recap of M1 graph generation; ch. 1 The problem formalized: graph space, exchangeability, Aldous-Hoover, homomorphism densities | Ex. 7 |
| 2 | 3 h | 2 | ch. 2 Autoregressive models: DeepGMG, GraphRNN and its complexity, fragment-based variants | Ex. 9 (lab: toy GraphRNN on graphs of fewer than 20 nodes) |
| 3 | 3 h | 2 | ch. 3 VAEs: GraphVAE and matching, NeVAE and the valence mask | Ex. 2, 10 (lab: small graph VAE) |
| 4 | 3 h | 2 | ch. 4 Normalizing flows: change of variables, triangular Jacobians, GraphAF and its RL fine-tuning | Ex. 6 |
| 5 | 3 h | 2 | ch. 5 Discrete diffusion: transition matrices, closed-form posterior, DiGress | Ex. 5 |
| 6 | 3 h | 2 | ch. 6 Evaluation: MMD, orbits, FCD and the pitfalls | Ex. 1, 4 |
| 7 | 3 h | 2 | ch. 7 Conditional generation: three mechanisms, text-to-graph routes, SMILES and SELFIES | Ex. 3 |
| 8 | 3 h | 2 | ch. 8 Applications: inverse design and Pareto fronts, drugs, materials, synthetic networks | Ex. 8 |
Self-study, outside the 24 h (about 5.5 h in total): ch. 9 Research of the LLGA team — PathNN, GOAT, NGG, pseudo-code prompting (≈ 3 h) · ch. 10 Open problems (≈ 2.5 h).
How to study this module
- Read the indicated papers after the corresponding chapter: they are written for specialists, the chapter gives you the keys to read them.
- Implement GraphRNN in a toy version (graphs with fewer than 20 nodes, exercise 9) before moving to frameworks: the sequential logic is easier to see there.
- Always check the chemical validity of the molecules generated in the labs: it is the permanent reminder that combinatorics is not an image.
- For each model family, fill in a small “sampling speed / quality / failure mode” table: it is the reading grid of the field.
- Take notes on ch. 9 (the team’s research): it is the best preparation for research internship interviews.
The LLGA perspective “Large Language Models, Graphs and Applications”: this module is the heart of the graph side of that motto. Graph generation is the place where molecules, materials and networks meet foundation models — the text-to-graph of ch. 7 being the exact junction point between LLMs and discrete structures. For students aiming at research (the master’s research internship, a PhD) as for those aiming at the life-science and materials industries, this is where the LLGA master is furthest ahead of neighboring programs.
Independent note As everywhere in the two-year path, the method here is to meet the concrete failure modes first, and only then the names and theorems that explain them.
0. Recap: generating graphs in M1
This chapter recalls what the M1 Graph ML course established about graph generation, so that the rest of the module can prove and extend it.
Recap of the Graph ML module (M1 P2, ch. 9) — what is assumed known
- The problem: sample G \sim p_\theta(G) where p is learned on a family of graphs (active molecules, networks…), with three specific difficulties: variable size, discrete outputs, a space quotiented by isomorphism;
- The limiting model: graphons W : [0,1]^2 \to [0,1]. Two distinct results: the Aldous-Hoover theorem (every infinite exchangeable random graph is a mixture of graphon models) and the Lovász-Szegedy theorem (every convergent sequence of dense graphs has a graphon limit in the cut metric); estimation by step functions;
- Classical random models: Erdős-Rényi G(n,p) (iid edges, degrees \sim \mathrm{Bin}(n-1,p), connectivity thresholds) and the SBM: P(A_{ij}=1 \mid z_i=a, z_j=b) = B_{ab}, likelihood, EM/MCMC inference, the Kesten-Stigum threshold;
- An overview of the deep families: GraphVAE (one-shot decoder), NeVAE (sequential decoding constrained by valence), GraphRNN (sequentialization by adjacency rows, BFS orders), DiGress (categorical noising q(X_t \mid X_{t-1}) = \mathrm{Cat}(X_t;\ X_{t-1} Q_t) on one-hot rows, closed-form Bayesian denoising);
- First metrics: validity/uniqueness/novelty, MMD on histograms, FCD — the analogue of the image FID (cf. Multimodal GenAI module ch. 7);
- The GNN foundation: message passing, MPNN, GIN and the 1-WL bound (cf. Advanced GNN module ch. 2) — the encoder of all the models in this module.
The module’s approach The M1 told the story of graph generation: each family was presented there with its idea and one equation. The M2 proves it: exact sampling conditions, changes of variables, closed-form posteriors, evaluation biases — then goes beyond the M1 on three axes:
- flows (ch. 4, absent from the M1);
- distributional evaluation pushed to its paradoxes (ch. 6);
- conditional generation and text-to-graph with LLMs (ch. 7), the 2026 frontier.
The control of generators (hard constraints, guidance, RL fine-tuning) is the subject of Control in Generative AI (M2 P1, ch. 8). That module comes before this one and summarises these models; this page is the reference for their details.
1. The problem, formalized
Before comparing models, we must say precisely what a “law on graphs” is and what a correct generator must respect. A concrete scene shows why: a generator can produce graphs whose statistics are close to the data and which are nevertheless chemically invalid. This chapter fixes the space of graphs, the invariance that any generator must respect, and the statistics that characterize a law on large graphs.
What breaks Three classic mistakes: ignoring permutation invariance; evaluating without motif or orbit statistics; and enforcing valence too late, after generation instead of during it.
Definition 1.1 — The labeled graph space and its measure A labeled graph is a triple G = (X, E, n): n nodes, node types X \in \mathcal{X}^n (atoms, tags, features), edge types E \in \mathcal{E}^{n \times n} (single/double/triple bonds…).
For fixed n, the space \mathcal{G}_n = \mathcal{X}^n \times \mathcal{E}^{n\times n} is finite (cardinality \sim |\mathcal{E}|^{n^2}) but gigantic: with |\mathcal{E}| = 4 and n = 30 atoms, 4^{900} \approx 10^{542} adjacencies — hence the need for a strong structural prior.
The total space is the disjoint union \mathcal{G} = \bigsqcup_{n \geq 1} \mathcal{G}_n; a law p on \mathcal{G} mixes a law on size p(n) and conditional laws p(G \mid n).
Generating = being able to sample from p_\theta \approx p_\star, the empirical law of a dataset \mathcal{D} = \{G_1, \dots, G_N\}.
Definition 1.2 — Exchangeability (in-depth recap) A law p on \mathcal{G} is exchangeable if for every permutation \pi of \{1..n\}: p\big((X_{\pi(1)},\dots,X_{\pi(n)}),\ (\pi E \pi^\top),\ n\big) = p(X, E, n).
The graphon model with graphon W draws iid latents and independent edges given them: x_i \sim \mathcal{U}([0,1]), \qquad A_{ij} \mid x \sim \mathrm{Bern}\big(W(x_i,x_j)\big); it is exchangeable for every n.
The Aldous-Hoover theorem — Aldous (1981) and Hoover (1979), see Lovász (2012) — gives a converse for infinite graphs only: the laws of infinite jointly exchangeable random graphs are exactly the mixtures of graphon models (Proposition 1.3).
Practical consequence: a correct generator must be permutation-invariant, either by construction (one-shot VAEs, diffusion: exchangeable GNN architectures), or on average (autoregressive models: randomize the construction order, cf. ch. 2).
The converse fails at finite n The uniform law on the three graphs with 3 nodes and exactly one edge is exchangeable, but it is not a mixture of graphon models. Such a mixture extends to an exchangeable law on 5 nodes. In that extension every triple of nodes has the law of the first three, so each of the 10 triples carries exactly one edge; each edge lies in 3 triples, so the graph would have 10/3 edges: impossible.
Proposition 1.3 — Aldous-Hoover, forward direction (guided sketch) Let (A_{ij})_{i,j \geq 1} be an infinite symmetric random array that is jointly exchangeable: its law is invariant under every permutation of finitely many indices. Equivalently, take a projective family of exchangeable laws p_n on n-node graphs, each the marginal of the next.
Then there is a random graphon W such that, conditionally on W, the array follows the graphon model of W: the law is a mixture of graphon models. The mixture reduces to a single fixed W exactly when the array is dissociated (subgraphs induced on disjoint node sets are independent).
Proof. Exchangeability \Rightarrow the law of the adjacencies is invariant under every finite permutation of the nodes. The De Finetti representation for exchangeable arrays (extension of the De Finetti theorem from exchangeable sequences to symmetric matrices) then gives iid uniform latent variables (x_i), an independent random variable \alpha and a measurable function W_\alpha.
Conditionally on \alpha and the latents, the edges are independent with laws \mathrm{Bern}(W_\alpha(x_i, x_j)).
The idea of De Finetti’s proof (sequence case): the empirical frequency \hat F_k = \frac{1}{k}\sum_{i \leq k} \mathbf{1}[S_i] of an event converges a.s. to a random variable F (a bounded reverse martingale; martingales and their convergence are recalled in Reinforcement Learning, 0.2). Exchangeability forces conditional independence given F, and F plays the role of the latent parameter. Since F is random, the result is a mixture of iid laws: this is where the mixture over W comes from.
The symmetric-array case adds the product structure [0,1]^2. ∎
Theorem 1.4 — Counting to generate: subgraph counting determines the graphon Two graphons W, W' are equal in cut metric \delta_\square iff they have the same homomorphism densities t(F, W) for all graphs F: t(F, W) = \int_{[0,1]^{|F|}} \prod_{(i,j) \in E(F)} W(x_i, x_j)\, dx_1 \dots dx_{|F|}. (|F| is the number of nodes of F.)
Now t(F, W) is estimated on a large graph by the subgraph density: for a W-random graph G_n, t(F, G_n) \to t(F, W) a.s. (the sampling lemma: t(F, G_n) concentrates around its mean). The counting lemma is the complementary continuity bound |t(F, W) - t(F, W')| \leq e(F)\, \delta_\square(W, W'), with e(F) the number of edges of F. This is the theoretical foundation of ch. 6: comparing generators by their motif statistics (triangles, paths, stars) amounts to comparing their limiting graphons — orbit-MMD evaluation is a finite, empirical version of this theorem.
The four families, one reading grid Each family answers the three questions differently: (i) exchangeability? (ii) exact likelihood or bound? (iii) hard constraints possible?
| Family | Exchangeability | p_\theta in closed form? | Hard constraints |
|---|---|---|---|
| Autoregressive (ch. 2) | via the order (BFS, random) | p_\theta(G, \pi) for one order: yes; p_\theta(G) = \sum_\pi p_\theta(G, \pi): no, only lower-bounded | natural (step masks) |
| VAE (ch. 3) | by architecture | no (ELBO only) | post-processing or dedicated heads |
| Flows (ch. 4) | autoregressive (GraphAF) or by architecture | exact for continuous data; for GraphAF, per order and dequantized | flow masks |
| Discrete diffusion (ch. 5) | by architecture | no (variational ELBO) | inpainting of a fixed subgraph; otherwise soft guidance only |
This grid is the through-line of the module; it closes in ch. 10 (open problems).
2. Autoregressive models: DeepGMG and GraphRNN in depth
The founding idea (You et al., 2018; Li et al., 2018): sequentialize the construction — a graph becomes a trajectory of local decisions (add a node, add an edge, choose a type), and all the machinery of sequential models (RNNs, then transformers) applies. Two competing formalizations: by nodes (GraphRNN) and by neighborhood expansion (DeepGMG).
Theorem 2.1 — DeepGMG (Li et al., ICML 2018): factorization by graph states Let G_t denote the partial graph after t decisions. The construction chain, which adds the nodes in an order \pi, defines the factorization p_\theta(G, \pi) = \prod_{t=1}^{T} p_\theta(a_t \mid G_{t-1}), where a_t \in \{\textsf{ADDNODE}(x),\ \textsf{ADDEDGE}(e),\ \textsf{STOP}\}, each decision being a categorical parameterized by a graph network: h_{G_{t-1}} = \mathrm{GN}\big(\{h_v\}, \{h_{uv}\}, u\big) \quad\text{(node, edge, and global states)}, and the heads p(a_t \mid h_{G_{t-1}}, h_v) read these states — e.g. p(\textsf{ADDEDGE}(u,v)) = \mathrm{softmax}\big(f_e(h_u \oplus h_v)\big). Three technical points:
- training follows a canonical order of the data (a fixed arbitrary order, e.g. that of the file);
- the likelihood of one construction sequence is exact: the product is p_\theta(G, \pi) for the node order \pi used. The likelihood of the graph sums over all the orders that build it, p_\theta(G) = \sum_{\pi} p_\theta(G, \pi) \;\geq\; p_\theta(G, \pi), a sum over up to n! terms, which is intractable: the training objective \log p_\theta(G, \pi) is only a lower bound on \log p_\theta(G) (cf. problem 10.5);
- the model is exchangeable only on average: if one trains on several random orders (\mathbb{E}_{\pi}[p(G \mid \pi)]), the marginal law is exchangeable.
Proposition 2.2 — GraphRNN (You et al., ICML 2018): two nested RNNs, proven complexity With the BFS order of the nodes, the graph is the sequence of adjacency rows S^i = (A_{i,1}, \dots, A_{i,i-1}) \in \{0,1\}^{i-1}: h_i = \mathrm{RNN}_{node}(h_{i-1}, s_i), \qquad P(S^i \mid h_i) = \prod_{j < i} \mathrm{Bern}\big(\mathrm{RNN}_{edge}(h_i, s^i_{<j})\big).
Proof. Complexity. The edge level emits i-1 bits for node i, each in one RNN step: \sum_{i \leq n} (i-1) = \Theta(n^2) steps in total, each in \mathcal{O}(1) with respect to n (the state h_i has fixed size); the node level adds \Theta(n) steps.
Training cost per graph: \Theta(n^2) RNN steps versus \Theta(n^3) for a decoder that would recompute the whole history; memory \mathcal{O}(n) states.
Why BFS? an arbitrary order makes the prefix S^1..S^k depend on the numbering; the BFS order depends only on the explored neighborhood: two BFS numberings of the same graph differ only by intra-level permutations, and the prefixes remain identical in law — exchangeability is approximate, not exact; aromatic rings “closed at the end of the order” remain the textbook failure case. ∎
Modern variants: when the “token” becomes a node Autoregressive graph generation has been absorbed by the LLM wave:
- textual representation — generate SMILES (a linearized molecule) with an LLM: this is today’s industrial production (ch. 7);
- graph tokenization — define a vocabulary of fragments (scaffolds, synthesis motifs) and generate the graph fragment by fragment, the generalization of junction trees (Jin et al., 2018: decompose the molecule into a tree of chemically valid fragments, generate the tree — structural validity guaranteed by construction);
- action-by-action — the chemical agent ChemCrow (Bran et al., 2023) orchestrates tools (synthesis NMR, docking) rather than atoms: the “local decision” becomes a tool call — cf. LLMs module (M2) ch. 8 for the agent layer.
The loop is closed: GraphRNN sequentialized the graph for an RNN; LLMs industrialize the same sequentialization.
- Strengths of autoregressive models: exact likelihood of each ordered sequence, sequential sampling with natural stopping, local constraints injectable at every step (ch. 8 of the Control in Generative AI module);
- Limits: \Theta(n^2) cost in steps, exposure to the order, errors that propagate (a wrong node-type choice contaminates everything after it); diffusion (ch. 5) answers exactly these last two limits.
3. VAEs: GraphVAE, NeVAE and valence constraints
A variational autoencoder generates a whole graph at once from a latent vector, instead of decision by decision. This chapter derives the graph VAE and its matching problem, then shows how NeVAE builds chemical validity into the decoder itself.
3.1. The graph VAE: ELBO and one-shot decoder
Theorem 3.1 — GraphVAE (Simonovsky & Komodakis, 2018) and the matching problem GNN encoder q_\phi(z \mid G) = \mathcal{N}(\mu_\phi(G), \mathrm{diag}(\sigma^2_\phi(G))), one-shot decoder: p_\theta(G \mid z) = p(n \mid z) \cdot p_\theta(\hat A, \hat X \mid z) with continuous adjacency \hat A \in [0,1]^{n\times n} (independent sigmoids) and features \hat X.
The likelihood is written against the data via a correspondence matrix (Hungarian matching, an \mathcal{O}(n^3) algorithm): the decoder does not emit in a canonical order, its nodes must be matched to those of G — the price of one-shot decoding. The ELBO: \log p_\theta(G) \geq \mathbb{E}_{q_\phi(z \mid G)}[\log p_\theta(G \mid z)] - \mathrm{KL}\big(q_\phi(z\mid G)\,\|\,\mathcal{N}(0, I)\big), proven in M1 Deep Learning (P1, theorem 9.2 or P2, proposition 7.8, whichever you took) and recalled in Multimodal GenAI ch. 0–1; here the reconstruction term is not a simple sum of Bernoullis because of the matching — it is lower-bounded by the optimal matching (sum of the log-probabilities over the retained pairs), which preserves the validity of the ELBO.
3.2. NeVAE in detail: valence as the architect
Theorem 3.2 — NeVAE (Samanta et al., AAAI 2019): granular VAE with constrained decoding Four ingredients, to be known precisely:
- Sparse encoder: one embedding per atom z_i \in \mathbb{R}^d, MPNN messages between neighboring atoms only — \mathcal{O}(n + m) memory instead of \mathcal{O}(n^2): the molecular graph is sparse, exploiting this divides memory by \Theta(n); the posterior law is a product of local Gaussians q(z_i \mid G) = \mathcal{N}(\mu_i, \sigma_i^2);
- Remaining valence as state: let r_v^{(t)} \in \{0, \dots, 4\} denote the available valence of atom v at step t (4 for C, 2 for O, 1 for H…). Each decoding head is conditioned on this state: p\big(\text{bond }(u, v, b)\big) = \mathrm{softmax}\big(f\,[\,z_u, z_v, r_u, r_v\,]\big), where the mask forbids any b with b > r_u or b > r_v — a saturated carbon (r = 0) can no longer receive a bond, by construction;
- Aromaticity: aromatic rings are not alternating single/double bonds but a dedicated type; specific heads sample ring membership — otherwise the model massively underestimates benzene cores;
- Noise correction: during training, if a sampled bond violates valence, it is resampled among the legal ones before the loss is computed — the penalty on forbidden bonds is softened and the gradient does not break; measured result: chemical validity > 90% without RDKit sanitization, versus a few percent for unconstrained GraphVAE.
Proposition 3.3 — The valence mask guarantees validity, not exact conditioning At one decision with context x (the partial molecule), masking the forbidden outputs replaces p_\theta by its renormalization on the legal subset \mathcal{L}(x):
Key result — the mask renormalizes on the legal subset, step by step \tilde p_\theta(y \mid x) = \frac{p_\theta(y \mid x)\,\mathbf{1}[y \in \mathcal{L}(x)]} {Z(x)}, \qquad Z(x) = \sum_{y' \in \mathcal{L}(x)} p_\theta(y' \mid x).
Over a whole construction sequence y = (y_1, \dots, y_T), the masked law is the product of these local renormalizations: \tilde p_\theta(y) = \prod_t \frac{p_\theta(y_t \mid y_{<t})}{Z(y_{<t})}. Three consequences:
- Validity: every sampled molecule respects the valences, by construction;
- No exact conditioning: in general \tilde p_\theta \neq p_\theta(\cdot \mid \text{valid}), because the normalizers Z(y_{<t}) depend on the prefix;
- Bound: if the mask never removes more than a mass \varepsilon (Z \geq 1 - \varepsilon) and sequences have at most T steps, then for every valid y (1-\varepsilon)^{T} \leq \frac{\tilde p_\theta(y)}{p_\theta(y \mid \text{valid})} \leq (1-\varepsilon)^{-T}.
This is the graph instance of Control in Generative AI, Proposition 2.2, stated there for token masks over a grammar.
Proof.
- Validity: the support of \tilde p is included in the valid molecules, which no post-processing guarantees (post-processing repairs; it does not guarantee that the repaired law is close to the target law).
- Bias, on a counterexample: two decisions over \{a, b\}, with p(a) = p(b) = \tfrac12, \quad p(a \mid a) = 0.1, \quad p(b \mid a) = 0.9, \quad p(\cdot \mid b) \text{ uniform}, and ab forbidden. The mask forces a after a, so \tilde p(aa) = 0.5, whereas p(aa \mid \text{valid}) = 0.05 / 0.55 \approx 0.09. Exact conditioning would weight each legal choice by the probability of finishing validly from there; the mask ignores that lookahead.
- Bound: for valid y, \frac{\tilde p_\theta(y)}{p_\theta(y \mid \text{valid})} = \frac{P_\theta(\text{valid})}{\prod_t Z(y_{<t})} . The denominator lies in [(1-\varepsilon)^T, 1]. So does the numerator, because a p_\theta-path is valid exactly when each step stays legal: P_\theta(\text{valid}) = \mathbb{E}_{\tilde p}\Big[\prod_t Z(y_{<t})\Big].
In practice molecular datasets lie (almost) entirely in the valid set, so a well-trained model puts little mass on forbidden bonds: \varepsilon is small, the mask is cheap in bias and decisive in validity. ∎
From GraphVAE to NeVAE: the general lesson Injecting domain knowledge into the architecture (valence, aromaticity) beats post-processing; this lesson will repeat: the valency and cycle input features of DiGress (ch. 5), chemically valid fragments of junction trees (ch. 2), valence constraints of the Control module (ch. 8). Trade-off: the model becomes specific to one domain (organic chemistry) — for general graphs (social networks), the “hard constraint” analogue does not exist, and that is precisely one of the open problems of ch. 10.
Example 3.4 — NeVAE decoder step by step (by hand) Prefix: C1—C2—O3, with remaining valences r = (3, 2, 1). Bond orders are 1, 2 or 3; the mask allows a bond b between u and v only if b \leq \min(r_u, r_v). The atom head gives p(\text{atom}) = (\text{C}: 0.6,\ \text{O}: 0.3,\ \text{N}: 0.1).
| Step | Draw | Mask applied | Remaining valences after the step |
|---|---|---|---|
| 1 | new atom C4 (r = 4), attached to O3 | b \leq \min(1, 4): single only | O3: 0 (closed for good), C4: 3 |
| 2 | new atom N5 (r = 3), attached to C4, double bond drawn | b \leq \min(3, 3): all three orders | C4: 1, N5: 1 |
| 3 | ring-closing bond N5—C1 | b \leq \min(1, 3): single only | N5: 0, C1: 2 |
| 4 | STOP | O3 and N5 can no longer receive any bond | C1: 2, C2: 2, C4: 1 |
The result is the five-membered ring C1—C2—O3—C4=N5—C1. Implicit hydrogens fill the free valences (CH₂, CH₂, CH), which gives 2-oxazoline, C₃H₅NO.
At no step could a valence be exceeded: the mask did the chemistry. Exercise 2 implements this decoder.
4. Normalizing flows: change of variables and GraphAF
A VAE only gives a lower bound on the likelihood. A normalizing flow gives it exactly, by transforming simple noise with an invertible map; this chapter proves the change-of-variables formula, shows why triangular Jacobians make it cheap, and applies it to graphs with GraphAF.
The formula and the affine coupling layer were met in Multimodal Generative AI, 4.3 (Proposition 4.3, Definition 4.4) and in the flow box of Deep Learning, 9.4; 4.1 recalls them with the proof, and 4.2 specializes them to graphs.
4.1. The change of variables, proven
Theorem 4.1 — Additive/affine flows: exact likelihood Let f_\theta : \mathbb{R}^d \to \mathbb{R}^d be a diffeomorphism (a differentiable bijection with differentiable inverse) and z \sim p_Z (e.g. \mathcal{N}(0, I)). Then y = f_\theta(z) has density
Key result — change of variables p_Y(y) = p_Z\big(f_\theta^{-1}(y)\big)\,\Big|\det \frac{\partial f_\theta^{-1}}{\partial y}(y)\Big| = p_Z(z)\,\Big|\det \frac{\partial f_\theta}{\partial z}(z)\Big|^{-1}.
Proof. First point: for a diffeomorphism f and a measurable set B, \mathbb{P}(Y \in B) = \mathbb{P}(z \in f^{-1}(B)) = \int_{f^{-1}(B)} p_Z(z)\,dz = \int_B p_Z\big(f^{-1}(y)\big)\Big|\det J_{f^{-1}}(y)\Big|\,dy by the change of variables of multivariate integration (the volume element is multiplied by the Jacobian in absolute value — cf. Refresher Statistics module, Jacobians chapter); identify the integrand with p_Y(y).
Second point: J_{f^{-1}}(y) = \big[J_f(z)\big]^{-1} (derivative of an inverse), and \det(M^{-1}) = 1/\det(M). ∎
Proposition 4.2 — Composition and triangular Jacobians
- \det(f \circ g)' = \det(f') \cdot \det(g') (product rule for determinants, \det(AB) = \det A \det B): a flow is a composition f = f_L \circ \dots \circ f_1 and the log-Jacobian adds up.
- If each f_\ell alters only one block of coordinates conditionally on the others (coupling: y_a = x_a, y_b = s(x_a) \odot x_b + t(x_a)), its Jacobian is triangular — the determinant is the product of the diagonal elements \prod_i s_i(x_a), computable in \mathcal{O}(d) instead of \mathcal{O}(d^3).
Proof. The Jacobian of a coupling has blocks \begin{pmatrix} I & 0 \\ \ast & \mathrm{diag}(s) \end{pmatrix}, which is block-triangular, with determinant \prod_i s_i.
Limiting case: autoregressive masks (MADE): y_i = \tau(x_i\,;h_i(x_{<i})) give a lower triangular Jacobian (not strictly lower: its diagonal \partial y_i/\partial x_i is non-zero, otherwise the determinant would vanish) — this is exactly the building block of GraphAF below. ∎
4.2. GraphAF: the autoregressive flow for graphs
Theorem 4.3 — GraphAF (Shi et al., ICLR 2020): exact likelihood + RL fine-tuning GraphAF combines the sequential factorization of ch. 2 with the flow of ch. 4.1: each decision (new atom, new bond) starts from a source z_t \sim \mathcal{N}(0,1) transformed by a conditional flow: x_t = f_\theta\big(z_t\,;\ s_t\big), \qquad s_t = \mathrm{GNN}\big(G_{t-1}, \text{candidates}\big), where s_t is the state of the partial graph (MPNN embeddings of the candidate nodes), and the density of the decision is read exactly via Theorem 4.1: \log p_\theta(G) = \sum_t \Big[\log p_Z(z_t) - \log\big|\det J_{f_\theta}(z_t\,;\ s_t)\big|\Big]. Key results:
- exact likelihood of the dequantized decision sequence in the BFS order (no ELBO, unlike VAEs) — like any autoregressive model, this is p_\theta(G, \pi) for one order (ch. 2);
- 68% of valid molecules without chemical rules, 100% with a valence check at each bond (an invalid bond is resampled, the mask of ch. 3) — the mask and the flow are orthogonal;
- sampling remains sequential (\Theta(n^2) steps). Property optimization is done by reinforcement learning: the pre-trained flow is the policy, the reward is the property Q(G) (penalized logP, QED) of the finished molecule plus small penalties for invalid steps, and the weights are fine-tuned with PPO.
Latent gradient ascent (z_t moved along a differentiable surrogate of \nabla_{z_t} Q, exercise 6) is also possible with a flow, as it is in VAE latent spaces (Gómez-Bombarelli et al., 2018; JT-VAE, Jin et al., 2018), but it is not what GraphAF does: Q is computed by a chemistry toolkit on a discrete graph.
Discrete flows: the cardinal difficulty Theorem 4.1 requires a continuous space (Jacobian!). Three answers:
- GraphAF dequantizes: it adds uniform noise to the one-hot decisions, runs a continuous flow, and keeps the argmax when generating;
- discrete flows (Tran et al., 2019) are bijections of a finite set of categories, such as the modular shift y = (\mu + \sigma x) \bmod K. A bijection of a finite set preserves probability mass, so p_Y(y) = p_X(f^{-1}(y)) with no Jacobian or correction term, and the log-likelihood stays exact; gradients pass through the argmax by a straight-through estimator. GraphDF (Luo et al., 2021) applies them to molecular graphs;
- argmax flows (Hoogeboom et al., 2021) take a third route: a continuous flow followed by an argmax, a surjection rather than a bijection, trained through a variational dequantization bound.
To be known to exist; the module’s lab implements only the (continuous) GraphAF route, simpler and sufficient for the properties.
# GraphAF skeleton (pedagogical): one conditional flow step
import torch, torch.nn as nn
class CouplingStep(nn.Module):
"""y_b = s(h) * x_b + t(h); diagonal Jacobian = prod(s)."""
def __init__(self, d):
super().__init__()
self.net = nn.Linear(64, 2 * d) # GNN state (64) -> (s, t)
def forward(self, x_b, h):
s, t = self.net(h).chunk(2, dim=-1)
s = torch.sigmoid(s + 2.0) # s > 0: positive det, stable
y = s * x_b + t
return y, s.log().sum(-1) # y and log|det J|
# generation of an atom/bond decision:
# h = GNN(G_t); z ~ N(0,1); x, ld = flow(z, h)
# atom = argmax or sample of softmax(x) (+ valence mask!)
# log p(x) = log N(z) - ld (change of variables theorem)- Flow balance sheet: exact likelihood, invertible latents (usable for latent optimization), RL fine-tuning of the policy for properties — at the price of a sequential cost equal to the autoregressive models and strong architectural constraints (triangular Jacobians);
- LLGA link: the internal GNN of GraphAF is an MPNN — replacing it by a PathNN (ch. 9) or a graph transformer (cf. Advanced GNN module ch. 5) is an open research question, at the boundary of the two M2 modules.
5. Discrete diffusion: DiGress in detail
Continuous diffusion (Multimodal GenAI module ch. 3) noises with Gaussians — pointless for categorical atom types. DiGress (Vignac et al., ICLR 2023) transposes the machinery to the categorical, via the D3PM framework (Austin et al., 2021): noising = Markov chains on the categories, denoising = closed-form Bayesian posterior. Goal of this chapter: master all the equations.
Definition 5.1 — Forward process by transition matrices A type x (atom among K) is represented as a one-hot row vector X \in \{0,1\}^{1 \times K}. The noising is a Markov chain independent per node and per edge: q(X_t \mid X_{t-1}) = \mathrm{Cat}\big(X_t;\ X_{t-1} Q_t\big), \qquad (Q_t)_{jk} = q(X_t = k \mid X_{t-1} = j), where Q_t \in [0,1]^{K \times K} is row-stochastic (rows summing to 1): row j is the law of the new type given the old one j, and X_{t-1} Q_t selects that row.
The usual cases:
- uniform Q_t = (1 - \beta_t) I + \beta_t \frac{1}{K}\mathbf{1}\mathbf{1}^\top (with probability \beta_t, forget and redraw uniformly);
- absorbing (toward a mask state
[MASK]— the analogue of BERT’s MLM, cf. LLMs module M2 ch. 3); - discretized Gaussian (transition toward neighboring types).
The composition is exact: q(X_t \mid X_0) = \mathrm{Cat}(X_t\,;\ X_0 \bar Q_t) \quad \text{with} \quad \bar Q_t = Q_1 Q_2 \cdots Q_t = \bar Q_{t-1} Q_t, and more generally, for s < t, q(X_t \mid X_s) = \mathrm{Cat}(X_t;\ X_s Q_{s+1} \cdots Q_t). This row convention is that of D3PM, DiGress and Graph ML 9.5.
Proposition 5.2 — Stationary marginal (proven in the uniform case) For the uniform kernel above, with the retention \bar\alpha_t = \prod_{s \leq t} (1 - \beta_s), the marginal is q(X_t \mid X_0) = \mathrm{Cat}\big(X_t;\ \bar\alpha_t X_0 + (1-\bar\alpha_t)\, \mathbf{u}\big), with \mathbf{u} = \tfrac1K \mathbf{1}^\top the uniform law: at large t = T, the law is (almost) uniform — independent of X_0, the condition for “total” noising.
Proof. By recursion: let p_t = q(X_t \mid X_0) (row vector); then p_t = p_{t-1} Q_t = p_{t-1}\big[(1-\beta_t) I + \frac{\beta_t}{K}\mathbf{1}\mathbf{1}^\top\big] = (1-\beta_t)\,p_{t-1} + \beta_t\, \mathbf{u} since p_{t-1} \mathbf{1} = 1 (mass law). Unrolling, p_t = \bar\alpha_t X_0 + (1 - \bar\alpha_t)\,\mathbf{u}. At t = T, the weight of X_0 is \bar\alpha_T \approx 0 (the schedule is chosen so that the retention vanishes).
The dataset marginal law is also accessible: one can make it converge toward the empirical marginal \mathbf{m} = \frac{1}{N}\sum_i X_0^{(i)} rather than the uniform, with Q_t = (1-\beta_t) I + \beta_t \mathbf{1}\mathbf{m} (every row equal to \mathbf{m} in the second term). DiGress uses this option (“no bond” edges dominate, reflecting them in the final law helps the denoising). ∎
Theorem 5.3 — Posterior q(X_{t-1} \mid X_t, X_0) in closed form (the heart of DiGress)
Key result — closed-form discrete posterior q(X_{t-1} = j \mid X_t = i,\ X_0 = k) = \frac{(Q_{t})_{j i}\,(\bar Q_{t-1})_{k j}} {(\bar Q_{t})_{k i}}.
All quantities are rows/columns of the transition matrices — direct computation, no network is involved; the network only serves to estimate \hat X_0.
Proof. Bayes on the chain: q(X_{t-1} \mid X_t, X_0) \propto q(X_t \mid X_{t-1})\, q(X_{t-1} \mid X_0) (Markov: X_t \perp X_0 \mid X_{t-1}). In one-hot, q(X_t = i \mid X_{t-1} = j) = (Q_t)_{j i} and q(X_{t-1} = j \mid X_0 = k) = (\bar Q_{t-1})_{k j}; the denominator is the marginal q(X_t = i \mid X_0 = k) = \sum_j (Q_t)_{j i} (\bar Q_{t-1})_{k j} = (\bar Q_t)_{k i} (matrix product \bar Q_t = \bar Q_{t-1} Q_t — this is exactly the composition of Definition 5.1). ∎
Theorem 5.4 — DiGress: architecture, loss, input features and guidance
- Denoising network: a graph transformer (cf. Advanced GNN module ch. 5) predicts \hat X_0, \hat E_0 = \mathrm{softmax}_K\big(\mathrm{GNN}(X_t, E_t)\big); training is a weighted cross-entropy on the clean types at the drawn steps t, with a weight \lambda > 0 that balances edges against nodes: \mathcal{L} = \mathbb{E}_{t, G_0}\;\mathbb{E}_{q(X_t, E_t \mid X_0, E_0)} \big[-\log p_\theta(\hat X_0 = X_0) - \lambda \log p_\theta(\hat E_0 = E_0)\big]\,;
- Structural and spectral input features: at every step the denoiser also receives features recomputed on the noisy graph — cycle counts (up to 5-cycles per node, 6-cycles per graph), Laplacian features (number of connected components, first eigenvalues and eigenvectors), and for molecules the current valency of each atom and the molecular weight. They are inputs, not losses: they compensate for the limited expressivity of message passing (same lesson as NeVAE ch. 3, transposed);
- Noised topology: “no bond” is one of the edge categories, so edges also appear and disappear along the chain, while the marginal kernel keeps the expected edge density at that of the data; exchangeability is exact: no node order exists in the process (unlike GraphRNN);
- Sampling: from (X_T, E_T) (marginal law), iterate \hat X_0 \to q(X_{t-1} \mid X_t, \hat X_0) (Theorem 5.3); cost: T GNN passes (the paper samples every step; it has no step-skipping sampler), each \mathcal{O}(n^2) — parallel over all nodes: the contrast with the \Theta(n^2) sequential steps of GraphRNN;
- Conditioning by regressor guidance: the denoiser stays unconditional; a separate regressor g_\eta is trained to predict the property y from noisy graphs. At each step, with G read as one-hot tensors and a guidance scale \lambda_g, p(G_{t-1} \mid G_t, y) \;\propto\; p_\theta(G_{t-1} \mid G_t)\, \exp\Big(-\lambda_g\, \big\langle \nabla_{G_t} \|y - g_\eta(G_t)\|^2,\ G_{t-1} \big\rangle\Big), a first-order expansion of p_\eta(y \mid G_{t-1}). The samples follow the target property (e.g. dipole moment, HOMO energy on QM9) at a cost in diversity (the trade-off of ch. 9 of the Control in Generative AI module). Classifier-free guidance (ch. 7) came with later graph diffusion models, such as Graph DiT (Liu et al., 2024);
- Inpainting (appendix of the paper): freeze a scaffold (known types and edges), generate the rest, and reset the frozen entries after every reverse step — conditional generation by partial graph without retraining.
Cousins and descendants EDP-GNN (Niu et al., 2020): continuous score matching on the permuted adjacency (with permutation annealing); GDSS (Jo et al., ICML 2022): a coupled node/edge SDE system, solved as a joint continuous diffusion; EDM/EDT (3D): equivariant positions in addition to types — the geometric entry point (cf. Geometric Deep Learning M2 module for equivariance); NGG (ch. 9): the recipe moved into a latent space of graph features.
The diffusion family dominates the 2023-2026 molecular state of the art on the quality/exchangeability trade-off — autoregressive models keep the exact likelihood of each ordered sequence, flows add invertible latents: ch. 6 shows how to compare them fairly.
6. Evaluating rigorously: MMD, validity, FCD
A graph generator is not scored image by image but distribution against distribution (M1 recap); at the M2 level, we require: the formulas, their biases, and their attacks. Why so much rigor? because evaluation drives research: a truncated metric produces truncated models (ch. 10).
Definition 6.1 — MMD (Maximum Mean Discrepancy) on graph features For a kernel k on \mathbb{R}^d (e.g. Gaussian k(u,v) = e^{-\|u-v\|^2/2\sigma^2}) and a feature \phi : \mathcal{G} \to \mathbb{R}^d (degree histogram, clustering coefficients, orbit counts…):
Key result — MMD between two samples of graphs \begin{aligned} \mathrm{MMD}^2\big(\{G_i\}_{i\leq n}, \{G'_j\}_{j\leq m}\big) &= \Big\|\frac{1}{n}\sum_i k(\phi(G_i), \cdot) - \frac{1}{m}\sum_j k(\phi(G'_j), \cdot)\Big\|^2_{\mathcal{H}} \\ &= \frac{1}{n^2}\sum_{i,i'} k_{ii'} + \frac{1}{m^2}\sum_{j,j'} k_{jj'} - \frac{2}{nm}\sum_{i,j} k_{ij}. \end{aligned}
This is computable in \mathcal{O}(n^2 + m^2); the estimator is unbiased if one removes the diagonals (\frac{1}{n(n-1)}). In practice: three canonical features (degrees, clustering, orbits) and a Gaussian kernel with median bandwidth.
Proposition 6.2 — Orbits: the right scale of motifs Orbit counts count the occurrences of each orbit of a small graph F (4-5 nodes: triangles, squares, paws…) modulo automorphisms: the graphlets with 2 to 4 nodes have 15 orbits in total, 11 of which belong to the 6 connected 4-node graphlets (the orbits, not the graphs, are counted); each node of G is classified into the orbit of its pattern neighborhood.
Raw subgraph counts (without quotient by \mathrm{Aut}) over-count: a complete triangle counts 3 times as “closed paths”; the quotient corrects this constant factor per pattern.
The theoretical link: these features are exactly empirical t(F, \cdot)’s of Theorem 1.4 — comparing orbit MMDs = comparing the graphons in the limiting sense (up to motif size).
Theorem 6.3 — FCD: the Fréchet ChemNet distance (Preuer et al., 2018) Let e : \text{molecule} \to \mathbb{R}^d be the embedding of an activity-predictor network (ChemNet, pre-trained) assumed approximately Gaussian on each family; \mathrm{FCD}(\mathcal{D}_{\mathrm{gen}}, \mathcal{D}_{\mathrm{ref}}) = \|\mu_1 - \mu_2\|^2 + \mathrm{tr}\big(\Sigma_1 + \Sigma_2 - 2(\Sigma_1 \Sigma_2)^{1/2}\big), with (\mu_k, \Sigma_k) the means/covariances of the embeddings of the two sets — exactly the d^2_{\mathcal{W}_2} metric of two Gaussians (the analogue of the FID; Multimodal GenAI module ch. 7); the matrix square root is computed via eigenvalues. Key property: the FCD penalizes invalid molecules (no embedding → infinite distance or fixed penalty): it integrates validity and distributional similarity of properties — why it became the reference metric of molecular benchmarks (GuacaMol, MOSES).
The pitfalls of evaluation (to be known by heart)
- Validity ≠ quality: 100% validity is obtained by memorizing the dataset (perfect validity, 0 novelty); always report validity and uniqueness and novelty and FCD;
- MMD sensitive to sample size: the biased (diagonal-included) estimator of \mathrm{MMD}^2 has a bias of order 1/n — it shrinks with n, but differs between sample sizes; comparing two models with different numbers of generated n is invalid — protocol: same n, same seeds, several trials; significance is tested by bootstrap;
- Chosen features = favored families: degrees + clustering ignore the motif-position correlation; a generator can pass the exam on marginal distributions and fail on the joints (molecules whose fragments are right but assembled absurdly); hence the addition of orbits, FCD, and transport distances (Gromov-Wasserstein, Optimal Transport module);
- Metric overfitting: optimizing against the FCD (e.g. by guidance) eventually inflates it — honest evaluation keeps one metric kept secret (the held-out principle, cf. healthy benchmarking: Dwivedi et al., JMLR 2023, recalled in the Advanced GNN module ch. 1).
| Metric | Granularity | Cost | Captures | Main limitation |
|---|---|---|---|---|
| Validity / uniqueness / novelty | per molecule | RDKit, \mathcal{O}(n) | syntactic legality, memorization | blind to the distribution |
| MMD degrees / clustering | marginal | \mathcal{O}(n^2) kernel | local structure | ignores joints |
| MMD orbits | motifs (4-5 nodes) | enum. costly | motifs modulo automorphisms | bounded size |
| FCD | chemical properties | 1 ChemNet pass | property distribution + validity | depends on the predictor |
| Gromov-Wasserstein | whole graphs | OT \mathcal{O}(n^3) | structure without correspondence | cost, choice of intra distance |
Gromov-Wasserstein in one box Two graphs are described by intra-graph cost matrices C and C' (adjacency or shortest-path distances), of sizes n \times n and m \times m, and by node weights p and q, uniform by default.
Let \Pi(p, q) be the couplings: nonnegative n \times m matrices with row sums p and column sums q. Then \mathrm{GW}^2(C, C') = \min_{T \in \Pi(p, q)} \sum_{i,k=1}^{n} \sum_{j,l=1}^{m} \big(C_{ik} - C'_{jl}\big)^2\, T_{ij}\, T_{kl}. No node correspondence is needed: the coupling T is a soft matching, and the value is invariant to relabelling either graph.
The problem is a non-convex quadratic program. The usual solver adds an entropy term and alternates two steps: linearize the cost at the current T, then project with Sinkhorn (Peyré, Cuturi & Solomon, 2016). For the square loss, one linearization costs \mathcal{O}(n^2 m + n m^2), that is \mathcal{O}(n^3) per pair of graphs of size n (POT: ot.gromov.entropic_gromov_wasserstein). Optimal Transport, ch. 5 develops it, as an optional deepening.
7. Conditional generation and text-to-graph
In practice one rarely wants any plausible graph: one wants a molecule with a given property, or a graph matching a description. This chapter compares the three ways of conditioning a generator and the routes by which LLMs now generate graphs from text.
7.1. Three conditioning mechanisms
Definition 7.1 — Conditioning a graph generator One goes from p_\theta(G) to p_\theta(G \mid c) where c is the conditioning. The three mechanisms are those of Graph ML 9.7 — input conditioning, guidance by a property predictor, latent search — here with their model-level instances:
- at the input (concat/fusion): the GNN receives c (property vector, text embedding) — trained on pairs (G, c), possibly with dropout of c to enable classifier-free guidance; NGG (ch. 9) conditions this way; simple, soft control;
- by guidance: a predictor of c from the noisy object steers the sampling — the regressor guidance of DiGress (ch. 5), or classifier-free guidance in later diffusion models; strong control, zero or light retraining, price: diversity;
- by search: generate massively then filter/optimize (Bayesian optimization or gradient ascent in a latent space — the classic QSAR pipeline); exact control a posteriori, high sampling cost.
A fourth route changes the weights of the generator itself: reinforcement-learning fine-tuning on the property, as GraphAF (ch. 4) and REINVENT (ch. 8) do.
The control-fidelity / diversity trade-off is quantified in ch. 9 of the Control in Generative AI module; here we retain: for graphs, “hard” conditioning (scaffold, valences) and “soft” (properties, text) combine — inpainting + regressor guidance in DiGress.
Classifier-free guidance, recalled. It is proved in Multimodal Generative AI, Theorem 4.1, with the site’s weight convention: w = 1 is the conditional model, w > 1 over-guides. A categorical denoiser outputs logits \ell rather than a noise estimate, and the same rule acts on them, per node and per edge: \tilde\ell_w = \ell(\varnothing) + w\big(\ell(c) - \ell(\varnothing)\big), \qquad \tilde p_w \propto p(\cdot \mid \varnothing)^{1-w}\, p(\cdot \mid c)^{w}. This logit-space version is the one Example 7.3 computes by hand.
7.2. Text-to-graph: the LLM × graphs encounter
Theorem 7.2 — Four text-to-graph routes (2022-2026)
- Molecule ↔︎ text translation: MolT5 (Edwards et al., EMNLP 2022) pre-trains a T5 on text + SMILES and treats description → molecule as a translation; the text is the conditioning, the SMILES the target; graph generation is delegated to the SMILES grammar (valence ≈ free);
- The LLM writes the generator: instead of generating the graph directly, the LLM writes code (NetworkX) that generates the graph; “Demystifying the Power of LLMs in Graph Generation” (Wang et al., Findings NAACL 2025) shows that network-science prompting (clustering, motifs) suffices to match generators trained on classic families; the agent produces target properties, the code implements them — control moves up one level of abstraction;
- Simulator agents: generate dynamic networks by making LLM agents interact (relations, citations, conversations): “Dynamic and Textual Graph Generation via Large-Scale LLM-based Agent Simulation” (Ji et al., 2024) reaches 105 nodes — the structure emerges from the interaction, the text animates the nodes;
- LLM + GNN hybrid: the LLM proposes, the GNN evaluates, the loop optimizes (Chen et al., 2023; ChemCrow, Bran et al., 2023: 18 tools including property predictors and docking) — the “proposal/evaluation” loop of ch. 9 of the M1 Graph ML, industrialized by agent tools (cf. LLMs module M2 ch. 8).
Why SMILES won (for now) Generating graphs by direct LLM (edge lists) fails at small scale: local (valence) and global (connectivity) coherence constraints drowned in the long sequence; SMILES encodes valence in the grammar (parentheses, aromaticity): the next token has little illegal freedom — the same lesson as NeVAE (ch. 3): move the constraints from post-processing into the syntax. The counterpart: SMILES is not canonical (one molecule, several encodings; cf. GOAT, ch. 9, on the cost of orders); SELFIES (Krenn et al., 2020) makes the grammar totally valid: every sequence decodes — the practical reference for the 2026 labs.
Example 7.3 — Toy molecular CFG (pen and paper) For the target c = “high logP”, the logits of step t of the denoiser are:
- without conditioning: (C: 2.0,\ O: 1.5,\ N: 0.5);
- with conditioning: (C: 3.0,\ O: 0.5,\ N: 0.5).
With guidance w = 3, the guided logits are uncond + w(cond − uncond): (C: 5.0,\ O: -1.5,\ N: 0.5), and the probabilities are \approx (0.987,\ 0.0015,\ 0.011). Carbon dominates: high logP = carbon chains — chemically coherent. Increasing w → collapse onto carbon (diversity drops): the fidelity/diversity curve of the Control module, readable on a single step.
The Year 2 end-of-year project Y2.2, a text-to-3D-molecule copilot assembles the pieces of this chapter: a text-conditioned generator, guidance toward properties, and the evaluation of ch. 6.
8. Applications: drugs, materials, synthetic networks
Generating graphs is not an end in itself: it is the operational arm of inverse design — specify what one wants (a property, a structure, a statistic) and let the model explore the space \mathcal{G} on our behalf. This chapter visits the module’s three application territories, each time with the same three questions: which hard constraints? which objectives? which evaluation?
Definition 8.1 — Inverse design, Pareto, scalarization We have predictors Q_1, \dots, Q_m : \mathcal{G} \to \mathbb{R} (solubility, synthesizability, predicted activity…). Inverse design seeks to maximize a vector objective Q = (Q_1, \dots, Q_m): in general no G optimizes all the Q_i at once (solubility against permeability, activity against toxicity).
One defines Pareto dominance: G \succ G' if Q_i(G) \geq Q_i(G') for all i, with at least one strict inequality; the non-dominated ones form the Pareto frontier.
Two usual scalarizations bring the problem back to a scalar objective: J(G) = \sum_{i} w_i\, Q_i(G) \quad\text{(weighted)}, \qquad J_{\times}(G) = \prod_{i} \pi_i\big(Q_i(G)\big)^{w_i} \quad\text{(geometric)}, where \pi_i : \mathbb{R} \to [0,1] maps each property into [0,1] (sigmoids, normalization); the geometric form (that of GuacaMol’s MPO tasks) penalizes heavily any collapsed objective: a product does not forgive a zero.
The role of the generator: proposing candidates where direct combinatorial optimization (10^{542} adjacencies, ch. 1) is hopeless — guidance during sampling (the regressor guidance of ch. 5), search in a latent space (ch. 7) and reinforcement-learning fine-tuning (GraphAF, ch. 4; REINVENT, Theorem 8.2) are the three interfaces between p_\theta and J.
Theorem 8.2 — Drug discovery: where does the generator plug in? The industrial pipeline, simplified but faithful:
- Target and hypothesis: a protein involved in a disease;
- Proposal: the generator samples G \sim p_\theta(\cdot \mid c) (c = target descriptor, properties) or optimizes J in the latent space — GraphAF RL fine-tuning (ch. 4), DiGress regressor guidance (ch. 5), RL policies on SMILES (industrial pipelines of the REINVENT type);
- Filtering: validity (valence, ch. 3), QED — the “drug-likeness” score on [0,1] (Bickerton et al., 2012) —, synthesizability SA, logP, diversity (ch. 6);
- Costly evaluation: docking (predicted interaction energy), ADMET models (absorption, toxicity) — each step costs orders of magnitude more than the previous one;
- Synthesis and trials: the real bottleneck — hence the operational metric: the quality of the top-k (the k candidates actually synthesized), not the batch average.
An often-ignored consequence: optimizing the mean of J over 104 molecules can be worse than optimizing the maximum — the useful generator is the one that explores the corners of the Pareto frontier; this is exactly the fidelity/diversity curve of the Control in Generative AI module (ch. 9), reread from the application side.
Molecular benchmarks: ZINC, MOSES, GuacaMol
- ZINC (Sterling & Irwin, 2015): the database of purchasable compounds — the reservoir; the subset ZINC-250k (≈ 250,000 lead-like molecules, popularized by grammar VAEs) is the standard training set of chapters 3-5 (NeVAE, GraphAF train and evaluate on it);
- MOSES (Polykovskiy et al., 2020): ~1.9M ZINC molecules with scaffold split (the test scaffolds are unknown at training time) and standardized metrics: validity, uniqueness, novelty, FCD, scaffold similarity — the “distribution-learning” protocol of ch. 6;
- GuacaMol (Brown et al., 2019): two families of tasks — distribution-learning (reproduce a library: FCD, KL divergences on physico-chemical properties, validity/novelty) and goal-directed (rediscover a given molecule, similarity, isomers, and the MPO tasks: maximize the geometric product of properties — Definition 8.1 in action).
The common trap: metric learning (ch. 6, point 4); on goal-directed tasks, a model can memorize the targets — hence the evaluation on targets kept secret. These benchmarks are to molecular generation what CIFAR/ImageNet are to vision (cf. Deep Learning module): convenient stops, not the destination.
Theorem 8.3 — Materials: the periodic constraint (CDVAE, MatterGen) A crystal is not a molecule: it is a triple (A, X, L), in the notation of CDVAE — atom types A of the n atoms of the unit cell (here A is not an adjacency), their coordinates X \in \mathbb{R}^{n \times 3} in the cell (Cartesian in CDVAE; MatterGen works with fractional coordinates), and the lattice L \in \mathbb{R}^{3 \times 3} (three cell vectors), the invariance being the group of integer translations: every quantity (distances, energies, densities) is computed modulo the periodic images. Two models bound the domain:
CDVAE (Xie et al., ICLR 2022): a VAE whose decoder denoises by diffusion; the initialization places the atoms far from any equilibrium and the diffusion makes them “fall” toward realistic bonds — the physical inductive bias (stability is a local energy minimum) is inscribed in the dynamics: the exact analogue of the valence mask of ch. 3, moved into the space of positions;
MatterGen (Zeni et al., Nature 2025): joint diffusion on atom types, coordinates and lattice — with conditioning by adapter. Small added modules inject the target property (composition, symmetry, magnetism…) into each layer of the base model (learned on the whole periodic table); each ends in a zero-initialized layer, so training starts exactly from the unconditional model. The base score network is then fine-tuned together with these modules on a labelled dataset: the paper’s Supplementary Information states that all weights are updated, not just the added layers. The base is a starting point, not a frozen backbone.
With a null label, the fine-tuned network still returns the unconditional score, so one network supplies both terms of the classifier-free guidance recalled in ch. 7 (the paper uses w = 2 in that convention). One pretrained base thus yields many fine-tuned models, one per property combination, each cheaper to obtain than training from scratch when labels are scarce.
Evaluation specific to materials: stable fraction (predicted energy close to the convex hull of known phases), novelty against crystallographic databases (the analogue of the novelty of ch. 6), symmetry validity (space groups). The module’s lesson repeats: periodicity is a hard constraint — it is architectural (equivariance to translations, cf. Geometric Deep Learning M2 module), never a post-processing.
Proposition 8.4 — Synthetic networks: generating to protect Sharing a real graph (contacts, transactions, calls) means exposing individuals: the structure itself re-identifies — knowing the neighbors of a node suffices to find it again in most real networks, and anonymizations by masking are systematically broken.
Generating a synthetic network that reproduces the useful statistics (degrees, clustering, motifs — the features of ch. 6) without copying the individuals is the alternative. NetGAN (Bojchevski et al., ICML 2018) opened the way: learn the distribution of the graph’s biased random walks (a GAN on node sequences), then reconstruct the adjacency from the co-occurrences of the walks — the graph is never copied, only its “walk signature” is.
Proof. The fidelity/confidentiality trade-off, quantified. Fidelity is measured by MMD on degrees/clustering/orbits (ch. 6); confidentiality by node-level membership inference tests (the graph counterpart of the attacks of the Security and Robustness M2 module): a generator that memorizes (overfitting on a single graph) spits out exact subgraphs — detectable, real damage.
Mastering the trade-off goes through:
- the regularization of p_\theta (limiting memorization as one limits overfitting — cf. Machine Learning module ch. 8);
- noise at the node/edge level (the analogue of the Gaussian mechanism of DP — cf. Emerging ML ch. 5 and Privacy and Uncertainty M2 modules);
- evaluation on both sides: publishing a synthetic network without an attack test is a rerun of the “100% validity” of ch. 6 — half a proof. ∎
Example 8.5 — Pareto by hand (pen and paper) Four candidates, two normalized objectives (Q_1 = predicted activity, Q_2 = synthesizability): A = (0.9;\ 0.2), \quad B = (0.7;\ 0.7), \quad C = (0.6;\ 0.9), \quad D = (0.2;\ 0.95).
Dominance. Does B dominate D? 0.7 > 0.2 but 0.7 < 0.95 — no; step by step, all four are on the frontier.
Weighted scalarization J = w Q_1 + (1-w) Q_2:
- at w = 0.3, C wins (J = 0.81) ahead of D (0.725) and B (0.70);
- at w = 0.6, C prevails again (0.72) against B (0.70) and A (0.62);
- A overtakes C only for w \geq 0.7.
The ranking pivots with the weights: report the frontier, never an isolated argmax.
Geometric version J_\times = Q_1 Q_2: C (0.54) and B (0.49) dominate, A (0.18) and D (0.19) are eliminated — unbalanced profiles are crushed: the signature of MPO.
| Domain | Object | Hard constraint | Typical objectives | Evaluation |
|---|---|---|---|---|
| Molecules | 2D graph (types, bonds) or SMILES | valence, aromaticity (ch. 3) | QED, SA, logP, docking, MPO | validity/uniqueness/novelty, FCD (ch. 6), GuacaMol, MOSES |
| Materials | crystal (A, X, L): types, coordinates, lattice | periodicity, equivariance (Geometric DL) | stability, band gap, magnetism | stable fraction, novelty vs crystallographic databases |
| Networks | simple graph, sometimes labeled | size, target degrees | target statistics (spectrum, degrees, clustering) | MMD (ch. 6), membership tests (privacy) |
9. Research of the LLGA team
The LLGA master is driven by the DaSciM laboratory (Data Science and Mining, LIX, CNRS — École Polytechnique: M. Vazirgiannis, J. Lutzeyer, G. Nikolentzos and their PhD students), the host laboratory of the internships and PhDs.
This chapter presents four of its works, chosen because they touch directly on the objects of this module: the encoder of the generators (PathNN), the order question (GOAT), a latent-diffusion generator conditioned by features (NGG) and the LLM × graphs frontier (pseudo-code prompting). The other axes of the laboratory are covered by the Graph ML (ch. 11) and Advanced GNN (ch. 9) modules; here, each paper reads as the extension of a chapter.
Work 9.1 — PathNN: aggregating paths, not neighbors (Michel, Nikolentzos, Lutzeyer & Vazirgiannis, ICML 2023) Standard message passing (ch. 0) aggregates immediate neighbors; PathNN aggregates paths starting from the node: h_v^{(\ell)} = \mathrm{AGG}\Big(\big\{\, \mathrm{LSTM}\big(h_v^{(0)}, h_{u_1}^{(0)}, \dots, h_{u_\ell}^{(0)}\big)\ :\ (v, u_1, \dots, u_\ell) \in \mathcal{P}_v^{(\ell)} \,\big\}\Big), where \mathcal{P}_v^{(\ell)} is a set of paths of length \ell — three variants: shortest paths (to all destinations), random walks, sampled simple paths.
Two reasons to be interested here:
- expressivity: paths of length \ell capture multi-hop dependencies that \ell layers of MPNN irretrievably mix — strictly above 1-WL on chosen pairs (cf. Advanced GNN module ch. 2); since the number of simple paths grows exponentially, sampling \mathcal{P}_v bounds the cost: an expressivity/cost trade-off tuned in the encoder;
- role in this module: PathNN is an encoder — the natural candidate for the q_\phi(z \mid G) of the VAEs (ch. 3) and the backbone of the NGG below; replacing the MPNN with a more expressive encoder is the simplest improvement lever for latent-based generators.
Work 9.2 — GOAT: rehabilitating the order of neighbors (Chatzianastasis, Lutzeyer, Dasoulas & Vazirgiannis, AAAI 2023) The whole module has run into order: autoregressive models impose a canonical order on it (BFS, ch. 2), the one-shot decoder must match its nodes (Hungarian matching, ch. 3).
GOAT attacks the root: the usual aggregators (sum, mean, max, attention) are invariant — they throw away all order information between neighbors, while this order carries signal (synergies, redundancies between neighbors).
The GOAT layer is a permutation-sensitive attention: each node learns a local order of its neighborhood (position scores) and encodes the neighbors in that learned order — global invariance is preserved (the order is a function of the graph, not of a numbering), local sensitivity is restored. Results: prediction of centrality metrics (betweenness…) where invariant GNNs struggle.
The “generation” reading: an encoding that distinguishes neighborhoods that 1-WL confounds gives the latent more to say — the flip side of the matching problem of ch. 3: better encoding the order means better recovering it at decoding.
Work 9.3 — NGG: latent diffusion conditioned by graph features (Evdaimon, Nikolentzos, Xypolopoulos, Kammoun, …, Vazirgiannis, 2024) The Neural Graph Generator applies the latent diffusion recipe to graphs (recap: Multimodal GenAI module ch. 3-4):
- Encoder: a GNN compresses G \mapsto h_G (latent);
- Conditioned latent diffusion: a denoiser learns to denoise h_G given a vector of target features c — spectrum of the Laplacian (the first eigenvalues), degree statistics, clustering coefficient… descriptors that are global, interpretable, measurable;
- Decoder: from the denoised latent to the adjacency. Sampling: choose c — the statistical “specification sheet” — then generate.
Position with respect to the chapters: DiGress (ch. 5) denoises the complete object (types, edges); NGG denoises a representation — the exchangeability is that of the encoder, the per-step cost much lower, and the conditioning is “macro” (global features) where the molecular CFG of ch. 7 is “micro” (a property of one molecule). The evaluation is that of ch. 6: MMD on degrees/clustering/orbits between generated graphs and target families (SBM, citation networks…). It is also the “synthetic networks” building block of ch. 8: specify a spectrum and a degree distribution, obtain whole graphs.
Work 9.4 — Pseudo-code prompting: reasoning about graphs with programs (Skianis, Nikolentzos & Vazirgiannis, 2024) A series of graph problems (connectivity, shortest path, existence of cycles, maximum flow, spanning tree…) is submitted to LLMs: the same instruction formulated in pseudo-code (algorithmic specification: loops, conditions, invariants) systematically beats its natural-language formulation — on both axes: understanding (executing the described algorithm) and producing (writing the algorithm for the posed problem).
The reading for this module:
- it is the experimental confirmation of route 2 of ch. 7 (“the LLM writes the generator”): the program is the most reliable graph representation for an LLM — unambiguous, verifiable, executable;
- the natural bridge with tool-using agents (ch. 7, ChemCrow): describe the task in pseudo-code then have it verified by a solver (NetworkX) — the proposal/verification loop of the Control module (ch. 2), instantiated on graphs.
| Work | Question | Central idea | Related chapters |
|---|---|---|---|
| PathNN (ICML 2023) | what to read on a graph? | aggregate paths (LSTM) instead of neighborhoods | ch. 3-5 (encoders) |
| GOAT (AAAI 2023) | the local order of neighbors | permutation-sensitive attention, learned order | ch. 2-3 (orders, matching) |
| NGG (2024) | generate with given features | latent diffusion conditioned by spectrum/degrees | ch. 5-6, ch. 8 (synthetic networks) |
| Pseudo-code prompting (2024) | have graph algorithms executed | pseudo-code beats natural language | ch. 7 (text-to-graph) |
Pedagogical instructions for use Recommended reading order: NGG first (closest to the heart of the module — exercise 8 extends it); GOAT next (after redoing the matching of ch. 3); PathNN (with the Advanced GNN module ch. 2 alongside); pseudo-code prompting last (after ch. 7). Each paper lends itself to a presentation session: problem, idea, one equation, one critical experiment, one limitation — the format of the module’s defenses.
10. Open problems
The grid of ch. 1 (exchangeability, likelihood, constraints) closes here: four work sites where it still has no satisfactory answer — and a fifth, theoretical one. For each: the 2026 state, the promising direction, and the master’s modules that contribute to it.
Problem 10.1 — Evaluation: a metric without a theory of the measure Chapter 6 showed the biases; the heart of the problem is that there is no canonical distance on \mathcal{G}: the edit distance is NP-hard to compute, Gromov-Wasserstein costs \mathcal{O}(n^3) per pair (cf. Optimal Transport module), and MMD depends on an arbitrary choice of features and kernel — a generator can satisfy degrees + clustering + orbits and fail on every untested statistic.
The FCD itself depends on a frozen bioactivity predictor (ChemNet, 2015): the metric ages with it.
Promising directions:
- task-based evaluation (do the generated graphs improve a downstream predictor, as augmentation data?);
- learned “critics” (a generated/real classifier trained to discriminate — if it succeeds, the distribution is betrayed);
- cheap surrogates of GW.
Methodological reference: the lesson of healthy benchmarking (Dwivedi et al., JMLR 2023 — Advanced GNN module ch. 1).
Problem 10.2 — Global hard constraints The valence mask (ch. 3) is local: each decision only looks at the remaining valences — hence its tractability. The useful constraints are often global: connectivity, cycle sizes, total number of edges, quotas per type, stability.
The automaton that would enforce them at decoding is exponential (the technical point of the Control module ch. 3, on text, carries over as is); the cycle, spectral and valency input features of DiGress (ch. 5) inform the denoiser about them without guaranteeing them, and guidance only tilts the law; post-processing repairs them at the price of the bias of ch. 3.
Direction: constrained generation with guarantee — projection at each diffusion step onto the admissible set (the discrete posterior of thm. 5.3 is no longer in closed form as soon as it is constrained: the whole challenge), solvers in the loop, learned rejection methods. This is the shared work site with the Control in Generative AI module (ch. 8).
Problem 10.3 — Scaling up All the complexities of the module are at best \mathcal{O}(n^2) per object: square adjacency, \Theta(n^2) sequential steps for GraphRNN, T GNN passes for DiGress — and \mathcal{O}(n^2) tokens to describe a graph to an LLM (ch. 7). Real networks reach 108-109 nodes.
Leads: generation by fragments (junction trees, ch. 2 — the fragment as the decision unit divides the number of steps); latent generation (NGG, ch. 9: one denoises a fixed-size representation); training on subgraphs (mini-batch — at the price of a sampling bias); sparsification.
Underlying open question: sample complexity — how many graphs are needed to learn a law at large n? (the generational counterpart of the generalization theory of Machine Learning, ch. 8).
Problem 10.4 — The integration of LLMs Chapter 7 showed four routes; their blind spots:
- tokenization — no canonical serialization of graphs is satisfactory (SMILES is not canonical, the edge list is \mathcal{O}(n^2) tokens, cf. GOAT ch. 9 on the cost of orders);
- guarantee — the LLM hallucinates invalid adjacencies; the remedy is grammatical (SELFIES) or agentic (the tool verifies);
- memorization — an LLM can spit out training graphs (the privacy problem of ch. 8, displaced);
- evaluation — text-to-graph does not yet have its GuacaMol.
Directions: graph foundation models (multi-family pre-training, adaptation by prompt — cf. Boosting and Foundation Models M2 module), LLM + GNN hybrids (propose/verify), and standardized evaluation (the “code” protocol of ch. 7 as a provisional standard).
Problem 10.5 — Theory: beyond exchangeability and likelihood Two frontiers.
- Limits: the Aldous-Hoover theorem (ch. 1) describes infinite exchangeable random graphs, as mixtures of graphon models, which are dense — now real networks are sparse, grow (preferential attachment), evolve (temporal), and their limits require non-exchangeable extensions (graphexes): what is the theory of neural generators on these objects?
- Likelihood against quality: the ELBO of VAEs and diffusions (ch. 3, 5) is an uncontrolled bound — the gap between ELBO and log-likelihood can be enormous without the samples suffering, or the opposite; and for autoregressive models (ch. 2), the exact likelihood depends on an arbitrary order — what invariant quantity do they really optimize?
These two questions condition any theory of learning for graph generators — the natural extension of the generalization theory of Machine Learning, ch. 8 (deepened in the Statistical Learning Theory notes, kept for reference) and of the Advanced Deep Learning module.
| Problem | 2026 state | Direction | Related modules |
|---|---|---|---|
| Evaluation (10.1) | conventional MMD/FCD, known biases | learned critics, task-based evaluation, affordable GW | OT, Multimodal GenAI ch. 7 |
| Global constraints (10.2) | input features, guidance, repair | guaranteed projection in diffusion, solvers | Control in GenAI ch. 3, 8 |
| Scale (10.3) | generalized \mathcal{O}(n^2) | fragments, latent, subgraphs | Machine Learning ch. 8 |
| LLMs (10.4) | SMILES + efficient agents, weak guarantees | graph foundations, verified hybrids | LLMs M2, Boosting/Foundation M2 |
| Theory (10.5) | infinite exchangeable (dense) complete, sparse and non-exchangeable open | graphexes, likelihood invariants | Machine Learning ch. 8, Adv. Deep Learning |
The grid of ch. 1, closed Reread the table of ch. 1 (exchangeability / likelihood / constraints): each filled cell calls for the next empty one — VAEs trade exact likelihood for architectural exchangeability; flows buy likelihood at the price of sequential cost; diffusion buys exchangeability and parallelism at the price of hard constraints. Problem 10.2 is precisely the empty cell of the last column. Typical exam question: “place NGG, DiGress and GraphAF in the grid, and say which cell each leaves open” — if you can answer that, the module is acquired.
Exercises / Labs
★ Guided lab: a complete “home-grown” evaluation (the module’s lab, ch. 6).
Build three reference families: 500 Erdős-Rényi graphs G(n, p{=}0.15), 500 two-block SBMs (p_{in} = 0.3, p_{out} = 0.05), 500 Barabási-Albert (m = 2), with n \sim \mathcal{U}\{20, \dots, 40\};
implement three features per graph (mean degree, mean clustering coefficient, triangles per node) and the Gaussian-kernel MMD of def. 6.1, with both the unbiased estimator (diagonals removed) and the biased one; extensions: full degree and clustering histograms, orbit counts;
compute the 3×3 MMDs families against families, feature by feature, each family against a fresh sample of itself on the diagonal;
redo (c) with n = 20, 50 and 200 graphs drawn per family, and plot the biased and unbiased estimates of the same-family MMD² against n;
bootstrap: 95% intervals on each MMD (200 resamplings);
write the table of ch. 6 and conclude: which pair of families does each feature separate, which does it confuse?
# lab skeleton (networkx + numpy) import networkx as nx, numpy as np def features(gs): # gs: list of graphs return np.array([[np.mean([d for _, d in g.degree()]), # a mean degree nx.average_clustering(g), # b clustering sum(nx.triangles(g).values()) / (3 * g.number_of_nodes())] # c triangles per node for g in gs]) def mmd2(X, Y, sigma=None, unbiased=True): # squared MMD, Gaussian kernel, median bandwidth Z = np.vstack([X, Y]); n, m = len(X), len(Y) D2 = ((Z[:, None] - Z[None]) ** 2).sum(-1) sigma = sigma or np.sqrt(np.median(D2[D2 > 0])) K = np.exp(-D2 / (2 * sigma ** 2)) Kxx, Kyy, Kxy = K[:n, :n], K[n:, n:], K[:n, n:] if unbiased: # diagonals removed: can be slightly negative, no sqrt return ((Kxx.sum() - np.trace(Kxx)) / (n * (n - 1)) + (Kyy.sum() - np.trace(Kyy)) / (m * (m - 1)) - 2 * Kxy.mean()) return Kxx.mean() + Kyy.mean() - 2 * Kxy.mean() # biased (V-statistic)Proof. Guidance (expected results, from a run of this skeleton with 500 graphs per family):
- mean degree separates BA from the other two: for BA it is almost fixed at 2m(n-m)/n \approx 3.7, while ER and SBM average about 4.35 (0.15 \times 29) and 5 with a spread of about 1, so ER and SBM are close;
- clustering separates ER (about 0.14, close to p) from SBM and BA (about 0.23 and 0.26), which it confuses;
- triangles per node separate SBM (about 0.94) from BA (about 0.41).
Each feature confuses a different pair: always report several features.
On two samples of the same family, the biased MMD² exceeds the unbiased one by about \tfrac{2}{n}\big(1 - \mathbb{E}\,k(x, x')\big), here roughly 0.9/n (ch. 6, trap 2), and its square root shrinks like 1/\sqrt n. The lab measures why models must be compared at equal n.
The bootstrap gives the last lesson: with 20 graphs per family, the 95% interval of ER against SBM on mean degree contains 0 in most runs; with 500, it no longer does. An MMD without an interval is not a conclusion. ∎
★ Valence mask (ch. 3). Alphabet \{C, O, N\} with valences \{4, 2, 3\}, single bonds only. (a) Write the masked sequential decoder (state = remaining valences r_v, Proposition 3.3); (b) sample 1,000 molecules without the mask (unconstrained heads, logits \mathcal{N}(0,1)) then with the mask, up to 12 atoms; (c) measure the validity (no atom exceeds its valence; free valences are filled by implicit hydrogens, as RDKit does) and compare it with the reasoning of Proposition 3.3.
Proof. Solution: without the mask, each sampled bond violates a valence with increasing probability as generation proceeds (the r_v are no longer respected); the observed validity is typically a few percent at 12 atoms — and 1-(1-\varepsilon)^T \to 1 explains the collapse (prop. 3.3).
With the mask: 100% validity by construction under this definition (the support is restricted to legal outputs), at the price of a bias bounded by Proposition 3.3 — the renormalization redistributes the forbidden mass onto the legal ones. Requiring instead that every atom be saturated without hydrogens would not be guaranteed: the mask prevents overflow, it does not force the generation to use every free valence before stopping.
The code: maintain r_v, forbid bonds b with b > r_u or b > r_v, resample among the legal ones — eight lines, the most profitable investment of the module. ∎
★ The CFG sweep (ch. 7). Take up example 7.3 (unconditioned logits (2.0;\ 1.5;\ 0.5), conditioned (3.0;\ 0.5;\ 0.5)) and plot w \mapsto (probability of carbon, entropy) for w \in \{0, 1, 2, 3, 8\}. Where is the “elbow”?
Proof. Solution: guided logits u + w(c - u) = (2 + w;\ 1.5 - w;\ 0.5).
- w = 0: probs (0.55;\ 0.33;\ 0.12), H \approx 0.95 nats;
- w = 1: (0.86;\ 0.07;\ 0.07), H \approx 0.50;
- w = 2: (0.96;\ 0.01;\ 0.03), H \approx 0.19;
- w = 3: (0.987;\ 0.002;\ 0.011), H \approx 0.07;
- w = 8: carbon at 99.99%, H \approx 0.
Fidelity (probability of carbon) is already nearly maximal at w = 2 while entropy has been divided by five: the elbow is at w \approx 2 — beyond, one pays diversity without gaining the target. The exact curve of Theorem 9.2 of the Control module, on a single step. ∎
★ FCD in dimension 2 (ch. 6). Two Gaussian embedding families of diagonal \mathbb{R}^2: \mu_1 = (0, 0), \Sigma_1 = \mathrm{diag}(1, 4); \mu_2 = (1, 0), \Sigma_2 = \mathrm{diag}(4, 9). Compute the Fréchet distance; what does it become if the two families have the same mean?
Proof. Solution: for diagonal covariances, (\Sigma_1 \Sigma_2)^{1/2} is diagonal with square roots of the products: \sqrt{1 \times 4} = 2, \sqrt{4 \times 9} = 6. Hence \|\mu_1 - \mu_2\|^2 = 1 and \mathrm{tr}(\Sigma_1 + \Sigma_2 - 2(\Sigma_1\Sigma_2)^{1/2}) = (1 + 4 + 4 + 9) - 2(2 + 6) = 2 , so FCD = 3.
With equal means, only the trace remains (here 2): the FCD separates means and covariances — why it detects at once a shift in mean properties (logP…) and an impoverishment of diversity (reduced variances), the two typical failures of generators. ∎
★★ The absorbing posterior, in closed form (ch. 5). For the absorbing kernel (stay in state k with probability \alpha_t = 1 - \beta_t, be masked otherwise: sink state [\textsf{MASK}]), prove: q(X_{t-1} = X_0 \mid X_t = \textsf{MASK},\ X_0) = \frac{\bar\alpha_{t-1}\,\beta_t}{1 - \bar\alpha_t}, \qquad \bar\alpha_t = \prod_{s \leq t} \alpha_s, and check that the remaining mass is on X_{t-1} = \textsf{MASK}.
Proof. Solution: X_t = \textsf{MASK} occurs with probability 1 - \bar\alpha_t (complement of “never masked up to t”); jointly X_{t-1} = X_0, X_t = \textsf{MASK} requires “never masked up to t-1 then masked exactly at t”: probability \bar\alpha_{t-1}\beta_t.
The quotient gives the formula; the remaining mass equals (1 - \bar\alpha_{t-1})/(1 - \bar\alpha_t) — the two sum to 1 since 1 - \bar\alpha_t = (1 - \bar\alpha_{t-1}) + \bar\alpha_{t-1}\beta_t . This is the D3PM-absorbing posterior: when X_t is masked, X_{t-1} is never revealed — the network must guess it (\hat X_0) then sample it with these probabilities: the inpainting machine of ch. 5. ∎
★★ Flow and latent gradient ascent (ch. 4). (a) For the
CouplingStepof ch. 4, show that the log-determinant of the Jacobian equals \sum_i \log s_i and is computed in \mathcal{O}(d); (b) derive a latent gradient step, an alternative to the RL fine-tuning that GraphAF actually uses (Theorem 4.3): to maximize Q(G_t), show that \nabla_{z_t} Q\big(G_t\big) = J_{f_\theta}(z_t)^\top\, \nabla_{x_t}\, Q\big(\mathrm{disc}(x_t)\big), where \mathrm{disc} is the discretization (argmax/sampling); discuss going through the discretization (straight-through gradient / Gumbel-softmax).Proof. Hints: (a) the Jacobian is block-triangular \begin{pmatrix} I & 0 \\ \ast & \mathrm{diag}(s) \end{pmatrix} (prop. 4.2): the determinant is the product of the diagonals; for (b), apply the chain rule on z_t \mapsto x_t = f_\theta(z_t) \mapsto G_t.
Since the discretization is not differentiable, one replaces it with a relaxation (temperature softmax) or propagates back the gradient of the continuous predictor: the guidance step moves z_t without changing the weights — but each displacement pulls the trajectory away from the learned law: too large, it fabricates out-of-distribution graphs that the predictor scores well but that chemistry rejects (the fidelity/diversity trade-off of the Control module ch. 9). ∎
★★ Step-function graphon and triangle density (ch. 1 and 6). Let W be constant by blocks on [0,1]^2 with two blocks: density p in the block 1 (x, y \leq \tfrac{1}{2}), q in block 2, r between blocks.
Show t(K_3, W) = \tfrac{1}{8}\big(p^3 + q^3 + 3 p r^2 + 3 q r^2\big) (integral over the 8 block combinations);
verify numerically with p = 0.9, q = 0.6, r = 0.05 and by sampling a graph with n = 100 nodes (50/50) — why do the two coincide to within \mathcal{O}(1/\sqrt{n})?
Proof. Solution: each triplet (a, b, c) of blocks contributes \tfrac{1}{8} W_{ab} W_{bc} W_{ac}:
- (1,1,1) gives p^3, (2,2,2) gives q^3;
- the three permutations of (1,1,2) give p r^2 each, those of (2,2,1) give q r^2.
Numerically t = (0.729 + 0.216 + 0.0068 + 0.0045)/8 \approx 0.1195 . The sampling realizes Bernoulli variables with parameters W(x_i, x_j), independent conditionally on the latents: the empirical triangle density is an average of bounded terms in which each edge has a small influence — concentration (McDiarmid’s bounded-differences inequality) around t(K_3, W) at rate \mathcal{O}(1/\sqrt{n}): this is the sampling lemma of Theorem 1.4, verified hands in the mud. ∎
★★★ Open: text-to-graph and target features (ch. 7, 9).
Ask an LLM to produce NetworkX code generating 500 graphs with a statistical specification (mean degree 4, clustering 0.3, n between 20 and 40) — the “Demystifying” route of ch. 7;
evaluate with the MMD of lab 1 against an SBM family calibrated to the same features;
critique: did the LLM optimize the features (by reading them in the prompt) or generate a law (unrequested distributional properties)? Compare with the NGG approach (conditioning by features, ch. 9): what additional guarantees does the trained model give? (Synthesis question — defense.)
Proof. Hints: also measure unrequested features (spectrum, diameter, motifs): the LLM/SBM difference there is proof that the LLM satisfies the letter of the specification without capturing its distributional spirit (or the opposite); NGG, for its part, learns the law conditional on the features from real data — the unspecified correlations come from the data, not from the prompt. This is the exact frontier of open problem 10.4. ∎
★★★ Lab: a toy GraphRNN, and the order question (ch. 2, 6).
Read the code: each node contributes its BFS row S^i (Proposition 2.2), truncated to its M predecessors; check that an all-zero row can serve as STOP, because in BFS order every new node is linked to an earlier one;
train on 300 connected two-block SBMs with 12 to 18 nodes, then sample 100 graphs;
evaluate with the harness of exercise 1 (
features,mmd2) against the held-out graphs (the 54 connected SBMs beyond the first 300), and against an Erdős-Rényi baseline with the same sizes and densities;open: replace the random-root BFS by a fixed root, then by a uniformly random order with M = n. How do the loss, the samples and the training time change? Which graphs does each order make hard (rings, long paths)?
# toy GraphRNN (torch); nx, np, features and mmd2 come from the skeleton of exercise 1 import torch, torch.nn as nn torch.manual_seed(0); rng = np.random.default_rng(0) M = 12 # bandwidth: node i links only to its M predecessors def bfs_rows(g): # (n-1, M): row i-1, column k = edge to node i-1-k root = int(rng.integers(g.number_of_nodes())) order = [root] + [v for _, v in nx.bfs_edges(g, root)] A, S = nx.to_numpy_array(g, nodelist=order), np.zeros((len(order) - 1, M)) for i in range(1, len(order)): prev = A[i, max(0, i - M):i][::-1] S[i - 1, :len(prev)] = prev return S class GraphRNN(nn.Module): def __init__(self, h=64): super().__init__() self.node, self.edge = nn.GRU(M, h, batch_first=True), nn.GRU(1, h, batch_first=True) self.init, self.out = nn.Linear(h, h), nn.Linear(h, 1) def forward(self, S): # S: (B, L, M); an all-zero row means STOP B, L, _ = S.shape h, _ = self.node(torch.cat([torch.ones(B, 1, M), S[:, :-1]], 1)) # teacher forcing bits = S.reshape(B * L, M, 1) o, _ = self.edge(torch.cat([torch.ones(B * L, 1, 1), bits[:, :-1]], 1), self.init(h).reshape(1, B * L, -1)) return self.out(o).reshape(B, L, M) # one logit per bit @torch.no_grad() def sample(model, n_max=40): x, hn, g = torch.ones(1, 1, M), None, nx.empty_graph(1) for i in range(1, n_max): h, hn = model.node(x, hn) he, b, row = model.init(h), torch.ones(1, 1, 1), [] for k in range(M): o, he = model.edge(b, he) b = torch.bernoulli(torch.sigmoid(model.out(o))) row.append(int(b)) if sum(row) == 0: break # STOP: in BFS order every new node has a parent g.add_edges_from((i, i - 1 - k) for k in range(M) if row[k] and i - 1 - k >= 0) x = torch.tensor(row, dtype=torch.float).reshape(1, 1, M) return g data = [g for s, k in enumerate(rng.integers(6, 10, 400)) # connected 2-block SBMs, 12-18 nodes if nx.is_connected(g := nx.stochastic_block_model([k, k], [[0.6, 0.05], [0.05, 0.6]], seed=s))] train, test = data[:300], data[300:] model = GraphRNN(); opt = torch.optim.Adam(model.parameters(), lr=3e-3) for step in range(1500): # about a minute on a laptop CPU rows = [bfs_rows(train[i]) for i in rng.integers(len(train), size=32)] L = max(len(r) for r in rows) + 1 # + one STOP row S, mask = torch.zeros(len(rows), L, M), torch.zeros(len(rows), L) for b, r in enumerate(rows): S[b, :len(r)], mask[b, :len(r) + 1] = torch.tensor(r), 1 nll = nn.functional.binary_cross_entropy_with_logits(model(S), S, reduction="none").sum(-1) loss = (nll * mask).sum() / mask.sum() opt.zero_grad(); loss.backward(); opt.step() gen = [sample(model) for _ in range(100)]Proof. Expected results (one run of this code, about a minute on a laptop CPU): every sample is connected — the BFS construction guarantees it — and the sizes match (about 15 nodes). The clustering MMD² is about 0.03, against 0.35 for the density-matched ER baseline; on degrees and triangles both are close to the data.
Hints for (d): a random order breaks the bandwidth bound of BFS, so M must grow to n and the rows lose their local structure; and the training losses of two orders are bounds on different quantities, \log p_\theta(G, \pi) for different laws of \pi (Theorem 2.1, point 2) — compare samples, not losses. ∎
★★★ Lab: a small graph VAE, and the matching problem (ch. 3).
Read the code: a GCN-style encoder with mean pooling gives q_\phi(z \mid G); the decoder emits the N(N-1)/2 edge logits and N node-existence logits in one shot (Theorem 3.1). A canonical BFS order from a node of maximal degree replaces the Hungarian matching;
train on the graphs of exercise 9, with a KL weight that rises from 0 to 1 over the first 2,000 steps (why is the final loss still minus the ELBO?), sample 100 graphs and evaluate them as in exercise 9;
encode one test graph in its canonical order, then after a random permutation of its nodes: compare the latent means and the reconstruction losses;
open: replace the fixed order by a matching — at each training step, match decoded nodes to true nodes with
scipy.optimize.linear_sum_assignmenton a node-similarity matrix — and compare the samples with those of (b). Which global properties does a one-shot decoder with independent edges lose?
# small one-shot graph VAE; data, train, test as in exercise 9 N, H, Z = 18, 64, 8 # max nodes, hidden width, latent size iu = torch.triu_indices(N, N, 1) # the N(N-1)/2 upper-triangle slots def canon(g): # padded adjacency, BFS order from a max-degree node root = max(g.degree, key=lambda t: t[1])[0] order = [root] + [v for _, v in nx.bfs_edges(g, root)] A = np.zeros((N, N)); A[:len(order), :len(order)] = nx.to_numpy_array(g, nodelist=order) return torch.tensor(A, dtype=torch.float), torch.arange(N) < len(order) class GraphVAE(nn.Module): def __init__(self): super().__init__() self.l1, self.l2 = nn.Linear(2, H), nn.Linear(H, H) self.mu, self.lv = nn.Linear(H, Z), nn.Linear(H, Z) self.dec = nn.Sequential(nn.Linear(Z, 256), nn.ReLU(), nn.Linear(256, len(iu[0]) + N)) def encode(self, A, node): # dense GCN + mean pooling: permutation-invariant P = A + torch.diag_embed(node.float()); P = P / P.sum(-1, keepdim=True).clamp(min=1) x = torch.relu(self.l1(torch.stack([node.float(), A.sum(-1) / 4], -1))) # inputs: 1, degree x = torch.relu(self.l2(P @ x)) + x hg = (x * node.unsqueeze(-1)).sum(1) / node.sum(1, keepdim=True) return self.mu(hg), self.lv(hg) def forward(self, A, node): mu, lv = self.encode(A, node) out = self.dec(mu + torch.randn_like(mu) * (0.5 * lv).exp()) # reparameterization return out[:, :-N], out[:, -N:], mu, lv # edge, node logits T = [canon(g) for g in train] A_all, n_all = torch.stack([a for a, _ in T]), torch.stack([m for _, m in T]) vae = GraphVAE(); opt = torch.optim.Adam(vae.parameters(), lr=1e-3) bce = nn.functional.binary_cross_entropy_with_logits for step in range(3000): # about 20 s on a laptop CPU i = torch.as_tensor(rng.integers(len(train), size=64)); A, node = A_all[i], n_all[i] e_log, n_log, mu, lv = vae(A, node) rec = bce(e_log, A[:, iu[0], iu[1]], reduction="sum") + bce(n_log, node.float(), reduction="sum") kl = -0.5 * (1 + lv - mu ** 2 - lv.exp()).sum() loss = (rec + min(1.0, step / 2000) * kl) / len(i) # KL warm-up, then loss = -ELBO opt.zero_grad(); loss.backward(); opt.step() @torch.no_grad() def sample_vae(k): gs = [] for out in vae.dec(torch.randn(k, Z)): keep = torch.bernoulli(torch.sigmoid(out[-N:])).bool() A = torch.zeros(N, N); A[iu[0], iu[1]] = torch.bernoulli(torch.sigmoid(out[:-N])) gs.append(nx.from_numpy_array(((A + A.T)[keep][:, keep]).numpy())) return gsProof. Expected results (one run, about 20 s): the KL stays near 2 nats per graph (in our run without the warm-up and the degree input, it fell to almost 0: posterior collapse, the decoder then outputs an average graph). Only about two samples in three are connected, against all of them for GraphRNN, because the edges are independent given z; the clustering MMD² (about 0.09) lies between GraphRNN’s and the ER baseline’s.
In (c) the latent means coincide — the encoder is invariant — but the reconstruction loss jumps (from about 58 to 140–190 nats, depending on the permutation): the decoder only knows the canonical order. This is the matching problem of Theorem 3.1, and the reason why GOAT (Work 9.2) studies orders. ∎
Projects and assessment
No official sheet is published yet for this module: the “LLGA 2 – Semestre 3” and “LLGA 2 – Semestre 4” lists of the 2026–2027 SynapseS catalog are empty, so its assessment is not displayed. The subjects, the exam and the rubric below are therefore proposals of these notes, for instance half project and half written exam. They exercise objectives O2 (generative modelling theory), O4 (graph-structured data) and O5 (Graph × LLM), with O7 (hands-on practice) throughout and O8 (trustworthy AI) in solo project 2.
Group project 1 is the generator work package of the Year 2 end-of-year project Y2.2, a text-to-3D-molecule copilot.
Solo projects
- [Solo · ≈ 20 h] Paper study: graph-generation evaluation done right (O’Bray et al., ICLR 2022). Can the ranking of two graph generators flip with the kernel, its bandwidth or the sample size, and how should an MMD be reported?
- Implement: extend lab 1 (exercise 1) into a small tested library — unbiased MMD² on degree, clustering and orbit histograms (orbits counted with ORCA, Hočevar & Demšar, 2014), bootstrap intervals, and the Gromov-Wasserstein distance of the ch. 6 box on 50 pairs of graphs.
- Paper: L. O’Bray, M. Horn, B. Rieck, K. Borgwardt, Evaluation Metrics for Graph Generative Models: Problems, Pitfalls, and Practical Solutions, ICLR 2022.
- Data: the ER, SBM and BA families of exercise 1; samples of the GraphRNN of exercise 9 and of the VAE of exercise 10; if a free GPU is available, a DiGress trained with the public code on the SPECTRE SBM set (Martinkus et al., 2022).
- Deliverables: the library, a 5-page report, a 10-minute talk. Chapters: ch. 1, 6.
- Success: one ranking flip reproduced (or an explanation of why it does not occur); the 1/n bias of the biased estimator measured within 20%; every MMD reported with a 95% interval.
- [Solo · ≈ 25 h] Synthetic networks: fidelity against leakage. Can a generator trained on one real network reproduce its statistics without leaking its edges?
- Implement: train CELL (Rendsburg, Heidrich & von Luxburg, ICML 2020), the low-rank simplification of NetGAN (Bojchevski et al., 2018), on 85% of the edges of a real network. Measure fidelity by MMD on degrees, clustering and orbits (ch. 6), and leakage by an edge-level membership-inference attack: the AUC of “edge present in the synthetic graph” for training edges against the 15% held-out edges.
- Privacy knob: randomized response on the training adjacency, each bit kept with probability p, so \varepsilon = \ln(p/(1-p)), for 5 values of \varepsilon.
- Data: the SNAP email-Eu-core network (1,005 nodes). Deliverables: code, a 5-page report with the fidelity–leakage curve, a 10-minute talk.
- Chapters: ch. 6, 8 (Proposition 8.4); it connects this course to Privacy and Uncertainty.
- Success: a fidelity–leakage curve over the 5 budgets with error bars over 3 seeds, and a membership AUC near 0.5 at the smallest \varepsilon — or a diagnosis of why not.
Group projects
- [Group of 3 · ≈ 30 h each] Mask against diffusion: scaffold-constrained molecule generation. On small molecules, which gives the better validity–diversity–property trade-off, with and without an imposed scaffold: a valence-masked autoregressive decoder or discrete diffusion?
- Implement: (a) a masked autoregressive graph decoder (exercise 2 scaled up, Example 3.4); (b) a small DiGress trained with the public code, with scaffold inpainting (Theorem 5.4); (c) regressor guidance toward QED, swept over the guidance scale.
- Paper and data: C. Vignac et al., DiGress: Discrete Denoising Diffusion for Graph Generation, ICLR 2023; QM9 (Ramakrishnan et al., 2014: about 134k molecules with at most 9 heavy atoms); RDKit for validity and QED, the
fcdpackage for the FCD. - Split: member A the masked decoder; member B DiGress and inpainting; member C the evaluation harness (validity, uniqueness, novelty, FCD; ch. 6) and the guidance sweep.
- Deliverables: a repository, a 6-page report, a 15-minute talk. Chapters: ch. 2, 3, 5, 6, 7; it uses the fidelity–diversity analysis of Control in Generative AI, ch. 9.
- Success: DiGress validity and uniqueness within a few points of the paper’s QM9 table; 100% valence validity for the masked decoder (Proposition 3.3); a curve of mean QED against internal diversity over at least 5 guidance scales and 3 seeds.
- [Group of 3 · ≈ 30 h each] Text-to-graph: LLM-written generators against feature-conditioned latent diffusion. Given a natural-language statistical specification, which approach matches the requested statistics, and which also gets the unrequested ones right? This scales up exercise 8.
- Implement: (a) an LLM pipeline that turns 20 specifications (size, mean degree, clustering, number of communities) into NetworkX code, run in a sandbox, with natural-language and pseudo-code prompts (Work 9.4); (b) a small NGG-style latent diffusion conditioned on the same features (Work 9.3); (c) the harness of exercise 1, extended to the Laplacian spectrum, the diameter and motif counts.
- Papers: I. Evdaimon et al., Neural Graph Generator: Feature-Conditioned Graph Generation using Latent Diffusion Models, 2024; Y. Wang et al., Demystifying the Power of Large Language Models in Graph Generation, Findings of NAACL 2025. Model: an open instruction model such as Qwen2.5-7B-Instruct, on a free GPU tier.
- Split: member A the LLM pipeline and the sandbox; member B the latent diffusion; member C the specifications, the evaluation and the statistics.
- Deliverables: a repository, a 6-page report, a 15-minute talk. Chapters: ch. 6, 7, 9 and problem 10.4; it connects this course to Large Language Models, ch. 8 and Advanced Topics in LLMs.
- Success: for both methods, the mean absolute error on the requested features and the MMD on the unrequested ones, with intervals, over the 20 specifications; a paragraph that explains the gap with the “letter against spirit” argument of exercise 8.
- [Group of 2 · ≈ 25 h each] Multi-objective inverse design with honest Pareto reporting. When properties conflict, does reinforcement-learning fine-tuning of a generator or a genetic baseline give the better Pareto front, and does the scalarization matter?
- Implement: a SELFIES language model pre-trained on a ZINC-250k subset (ch. 7), fine-tuned by REINVENT-style policy gradient on a weighted and on a geometric scalarization (Definition 8.1); a graph genetic algorithm as baseline (Graph GA, Jensen, 2019).
- Benchmark: three GuacaMol MPO tasks, for example Osimertinib, Fexofenadine and Ranolazine MPO (Brown et al., 2019).
- Split: member A the language model and its fine-tuning; member B the baseline, the scalarizations and the Pareto analysis.
- Deliverables: code, a 5-page report, a 10-minute talk. Chapters: ch. 6, 7, 8; it reuses the policy gradient of Reinforcement Learning.
- Success: MPO scores over 3 seeds; Pareto fronts and top-10 quality reported rather than batch means (Theorem 8.2); the internal diversity of the top 100.
Written exam (proposal)
Format: 2 hours, one handwritten A4 sheet allowed, no electronic device; four questions, 20 points.
Question (5 points). Place GraphRNN, GraphAF and DiGress in the reading grid of ch. 1: how is each one exchangeable, what does its likelihood objective compute, and which hard constraints can it enforce? Say also how each original paper optimizes or conditions on a molecular property.
Expected:
- GraphRNN: exchangeable only on average over BFS orders; it trains \log p_\theta(G, \pi), a lower bound on \log p_\theta(G); step masks are possible; the paper does no property optimization (1.5 points).
- GraphAF: an autoregressive flow, with the exact likelihood of the dequantized ordered sequence; a valence check at each bond gives 100% validity; properties are optimized by RL fine-tuning with PPO (1.5 points).
- DiGress: exactly exchangeable (equivariant denoiser, noise independent per node and per edge); a variational bound only; hard constraints only by inpainting a fixed subgraph; property conditioning by regressor guidance on noisy graphs (2 points).
Question (6 points). Uniform discrete diffusion on K = 3 types, with \beta_1 = 0.1 and \beta_2 = 0.2, in the row convention of Definition 5.1.
- Write Q_1 and Q_2, and compute q(X_2 \mid X_0 = e_1). (b) Compute the posterior q(X_1 \mid X_2 = e_2, X_0 = e_1) with Theorem 5.3. (c) Interpret the result.
Expected:
- (a) The uniform kernel Q_t = (1-\beta_t) I + \tfrac{\beta_t}{3}\mathbf{1}\mathbf{1}^\top gives diagonal entries 14/15 and off-diagonal entries 1/30 for Q_1, and 13/15 and 1/15 for Q_2. With \bar\alpha_2 = 0.72, Proposition 5.2 gives q(X_2 \mid X_0 = e_1) = 0.72\, e_1 + 0.28\, \mathbf{u} \approx (0.813,\ 0.093,\ 0.093) \quad \text{(2 points)}.
- (b) The unnormalized weights (Q_2)_{j2}(Q_1)_{1j} are 14/225, 13/450 and 1/450 for j = 1, 2, 3. They sum to 7/75 = (\bar Q_2)_{12}, so the posterior is q(X_1 \mid X_2 = e_2, X_0 = e_1) = \big(\tfrac23,\ \tfrac{13}{42},\ \tfrac{1}{42}\big) \approx (0.667,\ 0.310,\ 0.024) \quad \text{(3 points)}.
- (c) The jump to type 2 most likely happened at step 2, the noisier step: X_1 is still the original type with probability 2/3 (1 point).
Question (5 points). A valence mask renormalizes each decision on its legal subset. (a) Prove that every sample is valid. (b) Build a two-step example where the masked law differs from the law conditioned on validity. (c) If the mask never removes more than a mass \varepsilon and sequences have at most T steps, prove that for every valid y (1-\varepsilon)^{T} \leq \frac{\tilde p_\theta(y)}{p_\theta(y \mid \text{valid})} \leq (1-\varepsilon)^{-T}.
Expected: (a) the support argument of Proposition 3.3 (1 point); (b) its counterexample, where the mask gives 0.5 to aa and conditioning gives 0.05/0.55 \approx 0.09 (2 points); (c) write the ratio as P_\theta(\text{valid}) / \prod_t Z(y_{<t}) and show that both terms lie in [(1-\varepsilon)^T, 1] (2 points).
Question (4 points). Let X and Y be two independent samples of size n from the same law, and k a Gaussian kernel, so k(x, x) = 1. (a) Show that the biased estimate of \mathrm{MMD}^2 (diagonals included) has mean \frac{2}{n}\big(1 - \mathbb{E}\,k(x, x')\big), \qquad x, x' \text{ independent draws}.
- Deduce why two generators must be compared with the same number of samples.
Expected: (a) for each sample, \mathbb{E}\Big[\frac{1}{n^2}\sum_{i,i'} k(x_i, x_{i'})\Big] = \frac{1}{n} + \Big(1 - \frac{1}{n}\Big)\,\mathbb{E}\,k(x, x'), and the cross term has mean \mathbb{E}\,k(x, x'); subtracting twice the cross term gives the result (3 points). (b) The bias is positive and depends on n: with fewer samples a generator looks worse for no reason (1 point).
Grading rubric (proposal)
| Criterion | Weight | What earns the marks |
|---|---|---|
| Correctness and validity checks | 25 % | tested code; chemical validity and graph statistics checked; numbers agree with the results of the chapters used |
| Evaluation protocol | 25 % | equal sample sizes and seeds, unbiased MMD with bootstrap intervals, validity, uniqueness, novelty and FCD reported together, one metric held out (ch. 6) |
| Analysis | 20 % | each result explained by a proposition or theorem of the course; failures diagnosed, not hidden |
| Report and figures | 15 % | 4–6 pages; fronts and curves with axes and error bars; stated limitations |
| Talk and questions | 15 % | 10–15 minutes; every member can explain every part of the work |
References
- Theory: graphons and limits: L. Lovász, Large Networks and Graph Limits, AMS Colloquium Publications 60, 2012 — the reference for the theorems of ch. 1 (Aldous 1981 and Hoover 1979 are presented there in detail).
- Autoregressive models (ch. 2): J. You, R. Ying, X. Ren, W. Hamilton, J. Leskovec, GraphRNN: Generating Realistic Graphs with an Auto-Regressive Model, ICML 2018; Y. Li, O. Vinyals, C. Dyer, R. Pascanu, P. Battaglia, Learning Deep Generative Models of Graphs (DeepGMG), ICML 2018; W. Jin, R. Barzilay, T. Jaakkola, Junction Tree Variational Autoencoder for Molecular Graph Generation, ICML 2018 (generation by fragments).
- VAE (ch. 3): M. Simonovsky, N. Komodakis, GraphVAE: Towards Generation of Small Graphs Using Variational Autoencoders, 2018; B. Samanta, A. De, G. Jana, P. K. Chattaraj, N. Ganguly, M. Gomez-Rodriguez, NeVAE: A Deep Generative Model for Molecular Graphs, AAAI 2019; R. Gómez-Bombarelli et al., Automatic Chemical Design Using a Data-Driven Continuous Representation of Molecules, ACS Central Science 2018 (latent optimization).
- Flows (ch. 4): C. Shi, M. Xu, Z. Zhu, W. Zhang, M. Zhang, J. Tang, GraphAF: A Flow-based Autoregressive Model for Molecular Graph Generation, ICLR 2020; Y. Luo, K. Yan, S. Ji, GraphDF: A Discrete Flow Model for Molecular Graph Generation, ICML 2021; D. Tran, K. Vafa, K. K. Agrawal, L. Dinh, B. Poole, Discrete Flows: Invertible Generative Models of Discrete Data, NeurIPS 2019; E. Hoogeboom, D. Nielsen, P. Jaini, P. Forré, M. Welling, Argmax Flows and Multinomial Diffusion: Learning Categorical Distributions, NeurIPS 2021 (argmax surjections).
- Diffusion (ch. 5): J. Austin, D. Johnson, J. Ho, D. Tarlow, R. van den Berg, Structured Denoising Diffusion Models in Discrete State Spaces (D3PM), NeurIPS 2021; C. Vignac, I. Krawczuk, A. Siraudin, B. Wang, V. Cevher, P. Frossard, DiGress: Discrete Denoising Diffusion for Graph Generation, ICLR 2023 (code); C. Niu, Y. Song, J. Song, S. Ermon, Permutation Invariant Graph Generation via Score-Based Generative Modeling (EDP-GNN), AISTATS 2020; J. Jo, S. Lee, S. J. Hwang, Score-based Generative Modeling of Graphs via the System of Stochastic Differential Equations (GDSS), ICML 2022; G. Liu, J. Xu, T. Luo, M. Jiang, Graph Diffusion Transformers for Multi-Conditional Molecular Generation (Graph DiT, classifier-free guidance), NeurIPS 2024.
- Evaluation (ch. 6): K. Preuer, P. Renz, T. Unterthiner, S. Hochreiter, G. Klambauer, Fréchet ChemNet Distance, J. Chem. Inf. Model. 2018 (code); V. P. Dwivedi, C. K. Joshi, A. T. Luu, T. Laurent, Y. Bengio, X. Bresson, Benchmarking Graph Neural Networks, JMLR 2023; L. O’Bray, M. Horn, B. Rieck, K. Borgwardt, Evaluation Metrics for Graph Generative Models: Problems, Pitfalls, and Practical Solutions, ICLR 2022; G. Peyré, M. Cuturi, J. Solomon, Gromov-Wasserstein Averaging of Kernel and Distance Matrices, ICML 2016.
- Molecular benchmarks (ch. 8): T. Sterling, J. Irwin, ZINC 15 — Ligand Discovery for Everyone, J. Chem. Inf. Model. 2015; N. Brown, M. Fiscato, M. H. S. Segler, A. C. Vaucher, GuacaMol: Benchmarking Models for De Novo Molecular Design, J. Chem. Inf. Model. 2019; D. Polykovskiy et al., Molecular Sets (MOSES): A Benchmarking Platform for Molecular Generation Models, Front. Pharmacol. 2020; G. R. Bickerton, G. V. Paolini, J. Besnard, S. Muresan, A. L. Hopkins, Quantifying the Chemical Beauty of Drugs (QED), Nature Chemistry 2012; M. Olivecrona, T. Blaschke, O. Engkvist, H. Chen, Molecular De-novo Design through Deep Reinforcement Learning (REINVENT), J. Cheminformatics 9:48, 2017.
- Materials and networks (ch. 8): T. Xie, X. Fu, O.-E. Ganea, R. Barzilay, T. Jaakkola, Crystal Diffusion Variational Autoencoder for Periodic Material Generation (CDVAE), ICLR 2022; C. Zeni et al., A Generative Model for Inorganic Materials Design (MatterGen), Nature 638, 2025 (models); A. Bojchevski, O. Shchur, D. Zügner, S. Günnemann, NetGAN: Generating Graphs via Random Walks, ICML 2018.
- LLMs × graphs (ch. 7): C. Edwards, T. Lai, K. Ros, G. Honke, K. Cho, H. Ji, Translation between Molecules and Natural Language (MolT5), EMNLP 2022; M. Krenn et al., SELFIES: A Robust Representation for Semantically Valid Graphs, 2020; A. Bran et al., Augmenting Large Language Models with Chemistry Tools (ChemCrow), Nature Machine Intelligence 2024; Y. Wang, R. A. Rossi, N. Park, N. K. Ahmed, D. Koutra, F. Dernoncourt, T. Derr, Demystifying the Power of Large Language Models in Graph Generation, Findings of NAACL 2025; J. Ji et al., Dynamic and Textual Graph Generation via Large-Scale LLM-based Agent Simulation, 2024; Y. Yao et al., Exploring the Potential of Large Language Models in Graph Generation, 2024.
- Research of the DaSciM team (ch. 9): G. Michel, G. Nikolentzos, J. F. Lutzeyer, M. Vazirgiannis, Path Neural Networks: Expressive and Accurate Graph Neural Networks, ICML 2023 (code); M. Chatzianastasis, J. F. Lutzeyer, G. Dasoulas, M. Vazirgiannis, Graph Ordering Attention Networks (GOAT), AAAI 2023; I. Evdaimon, G. Nikolentzos, C. Xypolopoulos, A. Kammoun, et al., Neural Graph Generator: Feature-Conditioned Graph Generation using Latent Diffusion Models, 2024 (code); K. Skianis, G. Nikolentzos, M. Vazirgiannis, Graph Reasoning with Large Language Models via Pseudo-code Prompting, 2024 (code); laboratory page: DaSciM (LIX, École Polytechnique).
- Related modules: M1 foundation and overview: Graph Machine and Deep Learning (ch. 9); expressive encoders: Advanced GNN (M2); control and constraints: Control in Generative AI (M2); continuous diffusion and FID: Multimodal GenAI ch. 3-4, 7; agents and LLMs: Large Language Models (M2) ch. 8; privacy of synthetic networks: Privacy and Uncertainty (M2).