This Github repository provides a calculation backend for Displaced Gaussian Boson Sampling. It provides methods to convert between graph representation, Gaussian state representation and experiment circuit representation of Displaced Gaussian Boson Sampling (D-GBS). It may provide a useful complement to common quantum optics libraries such as Strawberry Fields and The Walrus. For example, it is more explicit regarding which basis is being used for the Gaussian state representation.
The repository also includes scripts to compute output photon number distribution, benchmark complexity transition of D-GBS, numerically simulate the distribution of zeroes of the loop-Hafnian, and parallel batch-compute loop-Hafnians to analyse their distribution. These methods are used for our paper A complexity transition in displaced Gaussian Boson sampling. Plotting scripts for the figures in the paper are also provided within this repository. Citations where appropriate would be appreciated.
Users interested in using the code are welcome to fork this repository.
The code is written for Python 3.9 and requires the following packages:
numpy == 1.26.3scipy == 1.11.4matplotlib == 3.5.1pandas == 1.3.5sympy == 1.9tqdm=4.65.0networkx == 2.6.3mpmath==1.2.1numba == 0.59.0strawberryfields == 0.23.0thewalrus == 0.19.0
An easy way to install the required packages is to create a conda environment from the environment2.yml file, which
specifies an anaconda environment. In your anaconda prompt or command line, type the following to create the
environment, GBS:
conda env create -f environment_dgbs.ymlThen activate the environment:
conda activate GBSIf you use this code in your research, please cite our paper where appropriate:
Zhenghao Li, Naomi R. Solomons, Jacob F.F. Bulmer, Raj B. Patel, and Ian A. Walmsley, A complexity transition in displaced Gaussian Boson sampling. npj Quantum Inf 11, 119 (2025). https://doi.org/10.1038/s41534-025-01062-5
@article{Li_DGBS_2025,
title={A complexity transition in displaced Gaussian Boson sampling},
volume={11},
url={https://www.nature.com/articles/s41534-025-01062-5},
DOI={https://doi.org/10.1038/s41534-025-01062-5},
number={1},
journal={npj Quantum Information},
publisher={Nature Portfolio},
author={Li, Zhenghao and Solomons, Naomi R. and Bulmer, Jacob F.F. and Patel, Raj B. and Walmsley, Ian A.},
year={2025},
month={Jul}
}