Examples
The gallery holds 16 notebooks. They start with a one-gate circuit and work up to trained networks and directed factor graphs. Each page is a full run of its notebook, with the outputs it produced.
Foundations
The primitives, the core gates, and the circuit-to-simulator pipeline.
01 · Introduction to parametrised stochastic circuitsBuild and sample your first stochastic circuits: pbits, pdits, and pmodes, each driven by its core gate, from constructor to simulator.
02 · Random walks on graphsSimulate a continuous-time random walk on a graph with one PSWAP gate per edge, then refine the Trotter step until the flow matches the exact kernel.
03 · Bunny graph diffusionScale the graph-walk construction to a real 3D mesh: heat spreading across the Stanford bunny, one gate per mesh edge.
04 · The execution interface: sampling and readoutsTurn raw circuit samples into histograms, expectations, and error bars that shrink at the exact 1/sqrt(N) Monte Carlo rate.
Discrete models
Boltzmann machines, diffusion, and trained circuits on pbits.
05 · Chemical reaction networksRun real mass-action chemistry as a stochastic circuit: combustion and reversible binding, validated against the exact CTMC and Gillespie.
06 · Ising sampling and contrastive divergenceTrain a Boltzmann machine with persistent contrastive divergence and sample it by chromatic Gibbs, recovering every coupling on an 8-site ring.
07 · Discrete diffusion on MNISTDrive a diffusion model's reverse process on stochastic primitives: a trained UNet steers 784 PNOT flips to denoise binarized MNIST.
08 · Stochastic convolutional networksTrain a circuit by gradients taken through the sampler itself: parameter-shift updates teach a weight-tied stochastic kernel to classify images.
09 · Training a stochastic graph network for MaxCutLearn MaxCut with a stochastic graph network: REINFORCE trains one PISING update per edge, benchmarked against the brute-force optimum.
Continuous and hybrid
Gaussian gates, state-space models, and mixed discrete and continuous processes.
10 · Pmode Gaussian gatesCarry continuous state through circuits with affine Gaussian gates and exact moment propagation, plus mixture gates for non-Gaussian density.
11 · Building a Gaussian hierarchical state-space modelDecode event times from a BCI-style feature stream: a linear-Gaussian state-space model whose exact smoothed posterior is a stack of affine gates.
12 · Sampling Langevin dynamics on a graph Ising modelWrite your own gate: a custom overdamped-Langevin sampler (ULA and MALA) over a soft-spin Ising energy, validated against exact quadrature.
13 · Simulating a regime-switching diffusion processCompose discrete and continuous primitives into a regime-switching diffusion, checked against analytic mixture and occupancy laws.
14 · Gaussian-Bernoulli clustering as a Boltzmann machineCluster with a Boltzmann machine: a Gaussian mixture written as one joint energy, sampled by block Gibbs with analytic responsibilities.
Directed factor graphs
The layer beneath the circuits: custom factors wired into a directed graph and sampled, with a PSC as one shape it takes.
15 · Introduction to factors and directed factor graphsWire samplers into directed factor graphs: factors, ports, composite tiles, and the parametrised stochastic circuit as one shape they take.
16 · Gibbs sampling on a directed factor graphBuild a 4x4 Ising sampler from hand-written factors and check block Gibbs against exact enumeration, from temperature sweeps to pattern completion.