Generative modeling with Gaussian Boson Sampling: classically trainable Bosonic Born Machines
Overview
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.pyMain training script for the Gaussian Bosonic Born Machine.utils.pyHelper functions for parity-string sampling, empirical expectation values, covariance estimation, and maximum mean discrepancy evaluation.bench_models/train_rbm.pyTrains an RBM baseline and evaluates it with the same sample-based metric.bench_models/nonparametric_models.pyBenchmarks simple nonparametric baselines, including Chow–Liu tree models.requirements.txtPython 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:
jaxoptaxnumpymatplotlibtqdmpgmpypiquasso==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:
- loads
data/training_set.npyanddata/test_set.npy, - initializes a multilayer Gaussian model,
- optimizes the parameters with Adam,
- 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 stepno_of_parity_samples_test: number of parity strings used at test timelength_cutoff: maximal sampled subset sizelearning_rate: Adam learning rateITER: number of optimization stepsno_of_layers: number of Gaussian layersn_test_reps: number of repeated test evaluationsthreshold: switch between parity-based and threshold-style observablesedge_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_dimlearning_rateITERnum_samplesnum_samples_trainingn_reps
bench_models/nonparametric_models.py
Key options:
n_expsn_repsnum_samplestest_length_cutoff
Output files
Files produced by gbbm.py
By default, saved under data/:
config.jsongbbm_losses.npygbbm_covariance_matrix.npygbbm_weights.npygbbm_test_mmds.npy
Files produced by bench_models/train_rbm.py
By default, saved under data/:
config_rbm.jsonrbm_inv_scores.npy(when hidden-dimension tuning is enabled)rbm_mmds.npyrbm_covariance_matrix.npy
Files produced by bench_models/nonparametric_models.py
By default, saved under data/:
config_stat.jsonnonparametric_mmds.npytest_covariance.npychow_liu_covariances.npyrandom_covariances.npy
Notes
- Paths are currently hard-coded to
./datain the scripts.
License
This project is licensed under the Apache License 2.0. See LICENSE for details.
Publication
doi:10.48550/arxiv.2603.11195Zoltán Kolarovszki, Bence Bakó, Michał Oszmaniec, Changhun Oh, Zoltán Zimborás
Versions
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!