GraphSPNs: Sum-Product Networks Benefit From Canonical Orderings

Milan Papez, Martin Rektoris, Václav Smídl, Tomás Pevný · DOI

Introduction

Deep generative models such as Variational Autoencoders (VAEs) and Generative Adversarial Networks (GANs) have demonstrated significant success in generating realistic graphs, particularly in molecular design. However, these models are typically "intractable," meaning they do not support efficient, exact probabilistic inference. Tasks such as calculating the exact likelihood of a subgraph or performing conditional completion (e.g., "Given this fragment, what is the most likely full molecule?") remain computationally prohibitive.

Sum-Product Networks (SPNs) offer a solution as a class of deep generative models designed for tractable inference. However, SPNs require data in a fixed-size, ordered format, which conflicts with the variable size and permutation-invariant nature of graphs. This paper introduces GraphSPNs, a framework that bridges this gap by combining virtual node-padding with canonical node ordering.

Methodology

GraphSPNs represent a graph through its node features and adjacency matrix as a joint probability distribution. To adapt graphs for SPNs, the authors employ two primary techniques:

Virtual Node-Padding

To handle graphs of varying sizes, all graphs are padded with "virtual nodes" up to a predefined maximum size $m$. This transformation converts variable-sized graph structures into fixed-size tensors suitable for SPN processing.

Permutation Invariance Strategies

A central challenge in graph modeling is permutation invariance—the identity of a graph is independent of node indexing. The authors evaluate four strategies to address this:

  1. None: No specific handling of node order.
  2. Random Sampling: Averaging model outputs over multiple random node permutations.
  3. k-ary Sub-graphs: Decomposing the graph into smaller, fixed-size components.
  4. Sorting (Canonical Ordering): Applying a deterministic rule (e.g., RDKit canonicalization) to ensure atoms are consistently ordered.
Overview of strategies for achieving permutation invariance in GraphSPNs.

The model is implemented using tensorized SPNs (EinSum networks), which efficiently compute the sums and products required for exact inference.

Experimental Evaluation

The models were evaluated on the QM9 dataset, a standard benchmark containing approximately 134,000 small organic molecules with up to 9 atoms (C, O, N, F). The primary goal was to assess the model's ability to learn chemical rules and generate valid, novel structures.

Key Results

The experimental results demonstrate that canonical ordering is the most effective strategy for training GraphSPNs. By enforcing a specific order, the model only needs to capture a single permutation of a molecule rather than $n!$ variations, significantly simplifying the learning task.

Performance comparison of GraphSPN variants and baseline models on the QM9 dataset.

As shown in the results table, the Sorting variant achieved a "Validity without check" score of 81.62%, vastly outperforming the Random Sampling variant, which scored only 15.38%. This indicates that canonical ordering is essential for the model to internalize structural chemical constraints. Furthermore, GraphSPNs remained competitive with intractable state-of-the-art models like MoFlow and GraphAF in terms of uniqueness and novelty.

Discussion and Conclusion

The success of GraphSPNs highlights the power of tractability in graph generation. Unlike black-box models, GraphSPNs can perform exact marginalization, allowing them to handle missing data and complex queries naturally.

However, several limitations remain. The virtual node-padding approach may not scale efficiently to very large graphs, such as proteins, due to the fixed input size requirements of SPNs. Additionally, the performance of the sorting method depends on the availability of robust canonicalization algorithms, which is a non-trivial problem for general graphs. Future work may explore more scalable architectures or improved smoothing techniques for $k$-ary models to enhance expressivity while maintaining tractability.

Summary updated

BibTeX
@inproceedings{papez2024graphspns,
  author = {Milan Papez and Martin Rektoris and Václav Smídl and Tomás Pevný},
  title = {{GraphSPNs: Sum-Product Networks Benefit From Canonical Orderings}},
  booktitle = {TPM @ UAI},
  year = {2024},
  url = {https://openreview.net/forum?id=NKdl7FHlFK},
}
Figure