Skip to main content

Python library for the root approach quantum tomography

Project description

Root approach quantum tomography

Python library for the discrete variables quantum state tomography using root approach and maximum likelihood estimation. The library contains a set of tools for quantum state reconstruction by the complementary measurements results, estimation of statistical adequacy and theoretical analysis of reconstruction fidelity.

Installation

pip install root-tomography

Definitions

Consider a quantum state in the Hilbert space of dimension d. The root approach to quantum state tomography implies reconstructing a purified quantum state psi of size d-by-r instead of corresponding rank-r density matrix rho=psi*psi. Thus, matrix psi defines a square root of the density matrix.

We measure the reconstruction accuracy by Uhlmann's fidelity between the true state rho and the reconstructed state sigma:

fidelity

According to the quantum state estimation theory the infidelity distribution is bounded by the general chi-squared distribution with nu degrees of freedom [1]:

infidelity as random variable

where d_j are positive parameters and xi_j are independent random variables with standard normal distribution. The expected value and variance of infidelity are thus

infidelity mean and variance

As the infidelity lower bound is inverse proportional to the total sample size N over all measurements, we also use the so-called loss function L=N*mean(1-F) independent of the sample size.

Algorithm

We use the maximum likelihood parameters estimation (MLE). In the case of quantum state tomography MLE results in the likelihood equation [1]. Taking the density matrix normalization condition, one obtains

likelihood equation

where mu is a constant (usually equal to the total observed counts sum(k_j)) and

J definitions

The sums are taken over all measurements operators in all measurements schemes. The actual values of b_0 and b_j depend on the measurements statistics (see Measurements statistics section).

An equation solution is obtained by the fixed-point iteration method:

fixed-point iterations

Here a is the regularization parameter. We use Moore-Penrose pseudo-inversion to get psi_0.

The root approach quantum tomography implies setting the model rank r. If the rank is unknown we estimate it using the adequacy criterion [1]. To do this we vary r from 1 to its maximal value until the reconstruction result becomes statistically significant at some pre-chosen significance level. The procedure is also terminated if the p-value of the rank-(r+1) model is lower than p-value of the rank-r model.

Data format

For the quantum state tomography one must specify a set of complementary measurement experiments over a quantum state density matrix rho. Every experiment may be repeated many times with some sets of possible measurement outcomes. The probability to get k-th outcome is determined by the measurement operator P_k as p_k=trace(rho*P_k). The set of measurement operators and the number of experiments repetitions define the measurements protocol. The number of observations for each outcome define the measurements results. The following code describe the required data format.

proto  # List of measurement operators matrices
proto[j]  # 3d numpy array of measurement operator matrices in j-th measurement scheme
proto[j][k, :, :]  # Measurement operator matrix for k-th outcome in j-th measurement scheme
nshots  # List of measurement schemes repetitions
nshots[j]  # Number of j-th scheme repetitions
clicks  # List of outcomes
clicks[j]  # 1d numpy array of measurement outcomes in j-th scheme
clicks[j][k]  # Number of k-th outcome observations in j-th scheme

One can specify nshots as a single integer describing the total sample size. Then it is automatically divided equally over all measurement schemes.

One can also pass a 3d numpy array for measurement operators and a 1d array for measurements results implying only a single possible outcome in each measurement:

proto[j, :, :]  # Measurement operator matrix for j-th measurement scheme
nshots[j]  # Number of j-th scheme repetitions
clicks[j]  # Number of observations in j-th scheme

Quantum state tomography

Examples directory of the project contains a set of examples that show basic features of the library. Below we briefly review the quantum state tomography example.

Consider an example of a pure ququart state reconstruction using mutually-unbiased bases measurement protocol.

from root_tomography.experiment import proto_measurement
from root_tomography.entity import State

dim = 4  # System dimension
r_true = 1  # True state rank
state_true = State.random(dim, r_true)  # True state
nshots = 10 ** 3  # Total sample size
proto = proto_measurement("mub", dim=dim)  # Generate measurements operators

The Experiment class of experiment module allows one to store the tomography data.

from root_tomography.experiment import Experiment

ex = Experiment(dim, State)  # Generate experiment instance
ex.set_data(proto=proto, nshots=nshots)  # Set measurements protocol
ex.set_data(clicks=clicks)  # Set measurements data

One can also perform the measurement simulation.

ex.simulate(state_true.dm)  # Performs the simulation and stores it

The reconstruction is performed using the reconstruct_state function of estimator module. By default the state rank is estimated automatically using the adequacy criteria.

from root_tomography.estimator import reconstruct_state

state_rec = reconstruct_state(ex, display=10)
fid = State.fidelity(state_true, state_rec)
print(f"Fidelity: {fid:.6f}")

Output:

=== Automatic rank estimation ===
=> Try rank 1
Optimization: fixed point iteration method
Iteration 37 		 Delta 9.42e-09
=> Rank 1 is statistically significant at significance level 0.05000. Procedure terminated.
Fidelity: 0.995364

Using the fiducial approach and the theoretical infidelity distribution one can use the reconstruction result to estimate the guaranteed reconstruction fidelity. In the following code we estimate the 95%-probability fidelity bound F_95. That means that we get the fidelity F_95 or higher with probability 95%.

from root_tomography.bound import bound
from root_tomography import gchi2

d = bound(state_rec, ex)  # Calculate variances
fid95 = 1 - gchi2.ppf(d, 0.95)  # Get fidelity bound
print(f"Fiducial 95% fidelity bound: {fid95:.6f}")

Output:

Fiducial 95% fidelity bound: 0.992822

The following code plots the infidelity distribution based on the true state and shows the fidelity of reconstructed state.

import matplotlib.pyplot as plt

d = bound(state_true, ex)
p, df = gchi2.pdf(d)
plt.figure("Infidelity")
plt.plot(df, p, label="Theory")
plt.plot([1-fid, 1-fid], [0, max(p)*1.05], label="Reconstruction")
plt.xlabel("infidelity")
plt.legend()
plt.show()

Theoretical distribution and reconstruction result

The theoretical infidelity mean and variance could be obtained from the variance vector.

sum(d)  # Mean infidelity
2 * sum(d ** 2)  # Infidelity variance
1-sum(d)  # Mean fidelity

References

[1] Bogdanov Yu. I. Unified statistical method for reconstructing quantum states by purification // JETP 108(6) 928-935 (2009); doi: 10.1134/S106377610906003X

License

All code found in this repository is licensed under GPL v3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

root-tomography-0.7.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

root_tomography-0.7-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file root-tomography-0.7.tar.gz.

File metadata

  • Download URL: root-tomography-0.7.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for root-tomography-0.7.tar.gz
Algorithm Hash digest
SHA256 7736398bbd2091bbb738db47101334b50b85894991e980e794e9c918d3843754
MD5 682c321d1d0933b0e49869ef279795d6
BLAKE2b-256 3286e90ce24765ed748e628ffd8087863158b2a9c3ef7ee211265bee11233521

See more details on using hashes here.

File details

Details for the file root_tomography-0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for root_tomography-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 61834e2958bbe5a842f4db55ffee4f920d226619beb795758e90b83dca5fcfc9
MD5 bd49aff2e65442bdbeecee5bce431d3a
BLAKE2b-256 1b15443c0cdd89ceac46ef12144ecaca4c8ebbb1e8f556414a5869d7e3cac7ed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page