State Tomography
To get the full description of a given quantum state, one performs multiple basis measurements to obtain the density-matrix. There are in-built utilities to perform state tomography as shown in the worked example. This article explains the steps performed in said tomography package.
Basics
Recall that a density matrix \(\rho\) must satisfy:
Hermiticity: \(\rho^\dagger=\rho\)
Unit-Trace: \(\textnormal{tr}(\rho)=1\)
Positive semi-definiteness: \(\rho\) has non-negative eigenvalues
The Hermicitity readily implies the orthogonal (under the inner-product \(\langle A|B\rangle=\textnormal{tr}(AB)\)) Pauli decomposition:
where \((r_x,r_y,r_z)\) is the Bloch-vector with the magnitude being unity for pure-states. It is evident that \(\langle r_m\rangle\equiv\textnormal{tr}(\rho\sigma_m)=r_m\). Thus, one can find the Bloch-vector by measuring along the \(x\), \(y\) and \(z\) axes on the Bloch sphere. This can be achieved by rotating the state’s basis components onto the measurement \(z\)-axis:
\(\langle z\rangle\): just measure
\(\langle x\rangle\): perform a y-rotation \(Y(-\pi/2)\) to rotate \(x\) axis onto the \(z\) axis and then measure
\(\langle y\rangle\): perform a x-rotation \(X(\pi/2)\) to rotate \(y\) axis onto the \(z\) axis and then measure
This procedure of preparing the state three times to perform different basis measurements can help reconstruct the density matrix for a single qubit. To extend the procedure to multiple qubits, realise that an \(N\)-qubit density matrix is simply the tensor product \(\rho_1\otimes\rho_2\otimes...\otimes\rho_N\). Taking the decomposition from before, this leads to a linear combination of all Pauli matrices:
The coefficients \(C_{i_1,...,i_N}\) can be found by performing simultaneous qubit measurements on the \(i_1,...,i_N\) axes. Note that they are by definition joint parity measurements. For example, \(\langle\sigma_z\otimes\sigma_z\rangle\) gives the product of the individual \(z\)-measurements. So if one measures 01 then the first qubit gives +1 while the second qubit gives -1 to both give +1x-1=-1. The measurement bases are done in the same way as the single-qubit case. For example, with 4 qubits, \(C_{1423}\) corresponds to doing nothing on the first qubit (i.e. \(I_2\) requires no measurement), a normal \(z\) measurement on the second qubit, an \(x\) measurement on the third qubit (i.e. via the \(y\) rotation as discussed above) and a \(y\) measurement on the fourth qubit (i.e. via the \(x\) rotation as discussed above).
Thus, the measurement protocol amounts to preparing the state, applying any appropriate basis rotations and measuring all qubits over the \(4^N\) possible states.
Actual Reconstruction
In the experiment one prepares the same state over \(4^N\) sequences to get the coefficients \(C_{i_1,...,i_N}\). Note that for each sequence, one needs to take a set of measurement \(M\) shots (e.g. 1024) to get \(N\) streams of \(M\) numbers (each being either 0 or 1). One could just map \(\{0,1\}\to\{1,-1\}\) and take the product across each measurement shot and then take the average across all \(M\) shots. However, if performing readout correction, there needs to be a vector of populations. This is calculated via:
Treat each \(N\)-vector as a binary number and increment said index in a \(2^N\)-array. For example, for 4 qubits, if the measurement was 1010, then increment index 10.
Divide the \(2^N\)-array by \(M\) to get the mean population probabilities. Apply readout correction to shift the probabilities. This vector is the population vector along the \(N\)-qubit computatational basis.
Now to calculate the expectation \(\langle\sigma_{i_1}\otimes...\otimes\sigma_{i_N}\rangle\), one sums over the probability-weighted sum of all basis vector parities.
To understand the last step, just take the example for two qubits with the probability vector being (0.1,0.4,0.4,0.1) over the basis 00, 01, 10 and 11:
00 contributes +1, 01 contributes -1, 10 contributes -1 and 11 contributes 11
Thus, the expectation is: 0.1-0.4-0.4+0.1 = -0.6
That is, it is a parity measurement where for each computational basis vector, just count the number of 1s; if it is odd, then it’s -1 and +1. Then multiply by the probability and sum over all computational basis vectors.
Upon finding \(C_{i_1,...,i_N}\), one could naively sum it with the appropriate Pauli-matrix tensor products. However, the resulting matrix will likely be an invalid density matrix for it will violate unit-trace and positive semi-definiteness. Thus, the utility class sqdtoolz.Utilities.DataDensityMatrix.DataDensityMatrix employs an optimisation procedure where one first realises that a matrix \(A\) is positive semi-definite if and only if \(A=T^\dagger T\):
Initialise matrix \(T\in\mathbb{C}^{2^N}\times\mathbb{C}^{2^N}\)
Take the candidate \(T\) and calculate \(\rho'=T^\dagger T/\textnormal{tr}(T^\dagger T)\)
Calculate all \(4^N\) values of \(C'_{i_1,...,i_N}=\textnormal{tr}(\rho'(\sigma_{i_1}\otimes...\otimes\sigma_{i_N}))\).
Calculate \(\mathcal{L}=\sum_{i_1,...,i_N}^N(C'_{i_1,...,i_N}-C_{i_1,...,i_N})^2\)
Minimise \(\mathcal{L}\) over the \(2^N\times2^N\times2\) real-valued numbers in \(T\) (going back to step 2 to recalculate the new \(\mathcal{L}\))
The minimiser just uses BFGS via scipy.optimize.minimize. By construction the final \(\rho=T^\dagger T\) yields a valid density matrix.