Package: root-tomography
Root approach quantum tomographyPython 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.InstallationDefinitionsAlgorithmData formatQuantum state tomographyReferencesLicenseInstallationpip install root-tomographyDefinitionsConsider a quantum state in the Hilbert space of dimension. The root approach to quantum state tomography implies reconstructing a purified quantum stateof sizeinstead of corresponding rank-density matrix. Thus, matrixdefines asquare rootof the density matrix.We measure the reconstruction accuracy by Uhlmann'sfidelitybetween the true stateand the reconstructed state:According to the quantum state estimation theory theinfidelity distributionis bounded by the general chi-squared distribution withdegrees of freedom[1]:whereare positive parameters andare independent random variables with standard normal distribution. The expected value and variance of infidelity are thusAs the infidelity lower bound is inverse proportional to the total sample sizeover all measurements, we also use the so-calledloss functionindependent of the sample size.AlgorithmWe use themaximum likelihoodparameters estimation (MLE). In the case of quantum state tomography MLE results in thelikelihood equation[1]. Taking the density matrix normalization condition, one obtainswhereis a constant (usually equal to the total observed counts) andThe sums are taken over all measurements operators in all measurements schemes. The actual values ofanddepend on the measurements statistics (seeMeasurements statisticssection).An equation solution is obtained by the fixed-point iteration method:Hereis the regularization parameter. We use Moore-Penrose pseudo-inversion to get.The root approach quantum tomography implies setting the model rank. If the rank is unknown we estimate it using theadequacy criterion[1]. To do this we varyfrom 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-model is lower than p-value of the rank-model.Data formatFor thequantum state tomographyone must specify a set of complementary measurement experiments over a quantum state density matrix. Every experiment may be repeated many times with some sets of possible measurement outcomes. The probability to getk-th outcome is determined by the measurement operatoras. The set of measurement operators and the number of experiments repetitions define themeasurements protocol. The number of observations for each outcome define themeasurements results. The following code describe the required data format.proto# List of measurement operators matricesproto[j]# 3d numpy array of measurement operator matrices in j-th measurement schemeproto[j][k,:,:]# Measurement operator matrix for k-th outcome in j-th measurement schemenshots# List of measurement schemes repetitionsnshots[j]# Number of j-th scheme repetitionsclicks# List of outcomesclicks[j]# 1d numpy array of measurement outcomes in j-th schemeclicks[j][k]# Number of k-th outcome observations in j-th schemeOne can specifynshotsas 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 schemenshots[j]# Number of j-th scheme repetitionsclicks[j]# Number of observations in j-th schemeQuantum state tomographyExamples 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.fromroot_tomography.experimentimportproto_measurementfromroot_tomography.entityimportStatedim=4# System dimensionr_true=1# True state rankstate_true=State.random(dim,r_true)# True statenshots=10**3# Total sample sizeproto=proto_measurement("mub",dim=dim)# Generate measurements operatorsTheExperimentclass ofexperimentmodule allows one to store the tomography data.fromroot_tomography.experimentimportExperimentex=Experiment(dim,State)# Generate experiment instanceex.set_data(proto=proto,nshots=nshots)# Set measurements protocolex.set_data(clicks=clicks)# Set measurements dataOne can also perform the measurement simulation.ex.simulate(state_true.dm)# Performs the simulation and stores itThe reconstruction is performed using thereconstruct_statefunction ofestimatormodule. By default the state rank is estimated automatically using the adequacy criteria.fromroot_tomography.estimatorimportreconstruct_statestate_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.995364Using 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. That means that we get the fidelityor higher with probability 95%.fromroot_tomography.boundimportboundfromroot_tomographyimportgchi2d=bound(state_rec,ex)# Calculate variancesfid95=1-gchi2.ppf(d,0.95)# Get fidelity boundprint(f"Fiducial 95% fidelity bound:{fid95:.6f}")Output:Fiducial 95% fidelity bound: 0.992822The following code plots the infidelity distribution based on the true state and shows the fidelity of reconstructed state.importmatplotlib.pyplotaspltd=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()The theoretical infidelity mean and variance could be obtained from the variance vector.sum(d)# Mean infidelity2*sum(d**2)# Infidelity variance1-sum(d)# Mean fidelityReferences[1]Bogdanov Yu. I. Unified statistical method for reconstructing quantum states by purification //JETP108(6)928-935 (2009); doi: 10.1134/S106377610906003XLicenseAll code found in this repository is licensed under GPL v3