Sum-Product Loop Programming: From Probabilistic Circuits to Loop Programming

Viktor Pfanschilling, Hikaru Shindo, Devendra Singh Dhami, Kristian Kersting

Abstract

Sum-Product Loop Programming (SPLL) introduces a novel probabilistic programming language that bridges the gap between the expressive flexibility of standard programming and the computational efficiency of Probabilistic Circuits (PCs). By integrating loops and recursion while enforcing tractability through a specialized type system, SPLL enables exact inference and fast training on complex, variable-length data structures.

Introduction: The Expressivity-Tractability Trade-off

In probabilistic modeling, researchers often face a choice between expressiveness and tractability. Deep Probabilistic Programming Languages (DPPLs) like Pyro offer immense flexibility but typically rely on slow, approximate inference. Conversely, Probabilistic Circuits (PCs), such as Sum-Product Networks (SPNs), guarantee linear-time marginal probability calculations but are often "stiff," requiring fixed input dimensions and struggling with control flow like loops.

The primary challenge lies in the "completeness" constraint of SPNs, which requires different branches of a model to cover identical sets of variables. SPLL addresses this by allowing loops and recursion while automatically ensuring the resulting model remains as efficient as a standard SPN.

The SPLL Framework

SPLL is a functional language that provides two simultaneous interpretations of the same source code: a generative script for sampling and a probabilistic function for calculating exact densities.

The SPLL workflow, from source code to probabilistic inference.

Key Innovations

  • Tractability via Typing: A "tractability checker" acts as a type system, verifying before execution if operations are mathematically solvable in reasonable time. If a program is too complex to solve exactly, the compiler raises an error.
  • Continuous Relaxations: To handle discrete if-then-else decisions during training, SPLL employs a "sigmoid trick" to smooth gradients, allowing the model to learn logic parameters via standard gradient descent.
  • Recursive SPNs: The framework proves that consistent SPLL programs are equivalent to sets of finite SPNs, inheriting their speed while handling variable-length data.

Bridging Code and Circuits

A core insight of SPLL is that recursive loops can be viewed as "infinite" SPNs that are pruned to a finite size based on specific data samples. This allows the model structure to adapt dynamically to the input.

Mapping between generative code and its corresponding probabilistic circuit representation.

By using recursion to construct lists, SPLL ties recursion depth to the number of data elements, naturally satisfying the requirements for valid probability distributions that static SPNs cannot meet. This dual nature makes SPLL a potent tool for neuro-symbolic AI, where logical structures meet deep learning optimization.

Evaluation and Results

The authors validated SPLL using benchmarks designed to expose the limitations of traditional SPNs:

  • Multivariate Mixture of Gaussians: Demonstrated that SPLL replicates state-of-the-art SPN performance on standard tasks.
  • Variable-length Gaussian Sequences: Showed that SPLL can learn distributions where the number of variables changes per sample—a task fundamentally impossible for a single, static SPN.
  • Gradient Flow: Confirmed that continuous relaxation successfully enables the simultaneous learning of logic and distribution parameters.

Limitations and Future Directions

While SPLL marks a significant step forward, several challenges remain. Certain arithmetic operations, like adding independent random variables (which requires convolution), are currently restricted to maintain tractability. Additionally, while optimized for likelihood computation and sampling, future iterations aim to support a wider variety of queries and more robust variable binding. Integration of "Neural Function Calls" is also planned, which would allow embedding deep neural networks directly within SPLL logic.

Summary updated

BibTeX
@inproceedings{pfanschilling2022sum,
  author = {Viktor Pfanschilling and Hikaru Shindo and Devendra Singh Dhami and Kristian Kersting},
  title = {{Sum-Product Loop Programming: From Probabilistic Circuits to Loop Programming}},
  booktitle = {KR},
  year = {2022},
}
Figure