Skip to content

PQCLab/pyRootTomography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

pip install root-tomography

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.

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.

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

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

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

All code found in this repository is licensed under GPL v3

About

Python library for the root approach quantum tomography

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages