phayes
phayes is a python package for easy and efficient quantum phase estimation.
Extensive details on Bayesian quantum phase estimation can be found in the accompanying paper, Yamamoto et al, 2023.
Quantum phase estimation
Wiebe et al, 2015,
O'Brien et al, 2018,
van den Berg, 2021 (and
quantum amplitude estimation Suzuki et al, 2019) can be implemented as an instance of Bayesian inference. Shots are generated from a quantum circuit with likelihood
$$p(m \mid \phi, k, \beta) = \frac12\left(1 + (1 - q)\cos(k\phi + \beta - m \pi)\right),$$
where $m \in {0,1}$ is the binary shot produced by the quantum device, $\phi$ is the unknown underlying phase, $q$ is a noise parameter or error rate. $k$ and $\beta$ are circuit parameters that are chosen by the user (or phayes).
Starting with a uniform prior over $\phi$, phayes uses Bayesian inference to hone in on the true value (with uncertainty quantification) through repeated measurements.
Install
pip install phayes
Bayesian updates
The core functions are phayes.get_k_and_beta and phayes.update, which determine the experiment parameters and then update the posterior distribution in light of a new measurement (or series of measurements)
from jax import numpy as jnp
import phayes
num_shots = 100
posterior_state = phayes.init()
for _ in range(num_shots):
k, beta = phayes.get_k_and_beta(posterior_state)
m = get_shot(k, beta)
posterior_state = phayes.update(posterior_state, m, k, beta)
Here the function get_shot executes the quantum circuit above and returns a binary shot (or multiple shots) according the likelihood $p(m\mid \phi, k, \beta)$.
There's more
The probability density function can be visualised easily
prior_state = phayes.init()
m = jnp.array([0, 1, 1, 0, 0, 1])
k = jnp.array([1, 4, 3, 8, 5, 10])
beta = jnp.array([1.4, 0.6, 1.2, 1.1, 1.9, 0.3])
posterior_state = phayes.update(prior_state, m, k, beta)
import matplotlib.pyplot as plt
linsp = jnp.linspace(-jnp.pi, jnp.pi, 1000)
pdf = phayes.pdf(linsp, posterior_state)
plt.plot(linsp, pdf)
phayes also has a host of other useful functions
posterior_mean = phayes.circular_mean(posterior_state)
posterior_circular_variance = phayes.circular_variance(posterior_state)
posterior_holevo_variance = phayes.holevo_variance(posterior_state)
Example notebooks can be found in the examples folder.
Precision
By default JAX uses 32-bit precision, for phase estimation experiments you may well want to enable 64-bit precision by adding the following to the top of your script
from jax.config import config
config.update(“jax_enable_x64”, True)
Citation
@software{phayes,
author={Duffield, Samuel},
title={phayes: A python package for easy and efficient Bayesian quantum phase estimation},
year={2023},
url={https://github.com/CQCL/phayes}
}
Metadata
Release files for phayes 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| phayes-0.1.1.tar.gz | 18.1 kB | Details |
Release files / phayes-0.1.1.tar.gz
| Download URL | phayes-0.1.1.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30bdcbf607ff80c17677442a10d50f57ab5ac7dfd674096985e239ddb6e85daf
|
|
BLAKE2b-256 checksum How to use checksums |
cfc491c7a9c231db70cafa6f4944db482d4e2728135128b4511d0c6b1b50c112
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.10
|