Code
qcr:2604.15215.1

Generative modeling with Gaussian Boson Sampling: classically trainable Bosonic Born Machines

Quantum generative modeling has emerged as a promising application of quantum computers, aiming to model complex probability distributions beyond the reach of classical methods. In practice, however, training such models often requires costly gradient estimation performed directly on the quantum hardware. Crucially, for certain structured quantum circuits, expectation values of local observables can be efficiently evaluated on a classical computer, enabling classical training without calls to the quantum hardware in the optimization loop. In these models, sampling from the resulting circuits can still be classically hard, so inference must be performed on a quantum device, yielding a potential computational advantage. In this work, we introduce a photonic quantum generative model built on parametrized Gaussian Boson Sampling circuits. The training is based on the efficient classical evaluation of expectation values enabled by the Gaussian structure of the state, allowing scalable optimization of the model parameters through the maximum mean discrepancy loss function. We demonstrate the effectiveness of the approach through numerical experiments on photonic systems with up to 805 modes and over a million trainable parameters, highlighting its scalability and suitability for near-term photonic quantum devices.
QML
Qumode
Circuit-based
Photonics
Uploaded 2 months ago
79
Views
Citing this entry? Use this QCR ID

Overview

Budapest-Quantum-Computing-Group/gaussian_bosonic_born_machines
10
README.md

Gaussian Bosonic Born Machines (GBBMs)

This repository contains a lightweight research codebase for training a Gaussian Bosonic Born Machine (GBBM) on binary datasets, together with a few classical baseline models.

The main script trains a Gaussian generative model by matching sampled parity-string expectation values, which yields an approximation of the squared maximum mean discrepancy as the loss function. The repository also includes utilities for benchmarking against classical models located in bench_models/.

Repository layout

.
├── gbbm.py
├── utils.py
├── requirements.txt
├── LICENSE
└── bench_models/
    ├── train_rbm.py
    └── nonparametric_models.py
Files
  • gbbm.py Main training script for the Gaussian Bosonic Born Machine.

  • utils.py Helper functions for parity-string sampling, empirical expectation values, covariance estimation, and maximum mean discrepancy evaluation.

  • bench_models/train_rbm.py Trains an RBM baseline and evaluates it with the same sample-based metric.

  • bench_models/nonparametric_models.py Benchmarks simple nonparametric baselines, including Chow–Liu tree models.

  • requirements.txt Python dependencies.

Installation

Create a virtual environment, then install the dependencies:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

The code depends on:

  • jax
  • optax
  • numpy
  • matplotlib
  • tqdm
  • pgmpy
  • piquasso==7.0.0

Expected data format

The scripts expect NumPy arrays saved under a local data/ directory.

Standard training/evaluation setup
data/
├── training_set.npy
└── test_set.npy

Both arrays should have shape:

(num_samples, num_bits)

with binary entries.

Quick start

1. Train the Gaussian Bosonic Born Machine
python gbbm.py

This script:

  1. loads data/training_set.npy and data/test_set.npy,
  2. initializes a multilayer Gaussian model,
  3. optimizes the parameters with Adam,
  4. saves learned weights, losses, covariance statistics, and test-set evaluation results.
2. Train the RBM baseline
python3 -m bench_models.train_rbm

This script can optionally tune the number of hidden units and then evaluate the trained model with the same sample-based metric.

3. Run the nonparametric baselines
python3 -m bench_models.nonparametric_models

This script evaluates either the covariance and maximum mean discrepancy metrics for larger datasets.

Configuration

The main hyperparameters live in the CONFIG dictionaries inside the scripts.

gbbm.py

Important options include:

  • no_of_parity_samples: number of parity strings sampled per training step
  • no_of_parity_samples_test: number of parity strings used at test time
  • length_cutoff: maximal sampled subset size
  • learning_rate: Adam learning rate
  • ITER: number of optimization steps
  • no_of_layers: number of Gaussian layers
  • n_test_reps: number of repeated test evaluations
  • threshold: switch between parity-based and threshold-style observables
  • edge_mode: interferometer connectivity pattern

Supported edge_mode values:

  • "clements" – dense Clements-style interferometer parameterization
  • "all2all" – all-to-all connectivity schedule
  • "ring" – nearest-neighbor ring connectivity
  • "chow_liu" – connectivity inferred from the data using a Chow–Liu tree
bench_models/train_rbm.py

Key options:

  • hidden_dim
  • learning_rate
  • ITER
  • num_samples
  • num_samples_training
  • n_reps
bench_models/nonparametric_models.py

Key options:

  • n_exps
  • n_reps
  • num_samples
  • test_length_cutoff

Output files

Files produced by gbbm.py

By default, saved under data/:

  • config.json
  • gbbm_losses.npy
  • gbbm_covariance_matrix.npy
  • gbbm_weights.npy
  • gbbm_test_mmds.npy
Files produced by bench_models/train_rbm.py

By default, saved under data/:

  • config_rbm.json
  • rbm_inv_scores.npy (when hidden-dimension tuning is enabled)
  • rbm_mmds.npy
  • rbm_covariance_matrix.npy
Files produced by bench_models/nonparametric_models.py

By default, saved under data/:

  • config_stat.json
  • nonparametric_mmds.npy
  • test_covariance.npy
  • chow_liu_covariances.npy
  • random_covariances.npy

Notes

  • Paths are currently hard-coded to ./data in the scripts.

License

This project is licensed under the Apache License 2.0. See LICENSE for details.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!