Path: blob/main/notebooks/ch-labs/Lab03_QuantumMeasurement.ipynb
3855 views
Lab 3 Quantum Measurements
Part 1: Measuring the state of a qubit
Goal
Determine the Bloch components of a qubit.
Fundamental to the operation of a quantum computer is the ability to compute the Bloch components of a qubit or qubits. These components correspond to the expectation values of the Pauli operators , and are important quantities for applications such as quantum chemistry and optimization. Unfortunately, it is impossible to simultaneously compute these values, thus requiring many executions of the same circuit. In addition, measurements are restricted to the computational basis (Z-basis) so that each Pauli needs to be rotated to the standard basis to access the x and y components. Here we verify the methods by considering the case of a random vector on the Bloch sphere.
📓 1. Express the expectation values of the Pauli operators for an arbitrary qubit state in the computational basis.
The case for the expectation value of Pauli Z gate is given as an example.
Using the diagonal representation, also known as spectral form or orthonormal decomposition, of Pauli gate and the relations among the Pauli gates (see here), expectation values of gates can be written as
$$\begin{aligned} \langle Z \rangle &=\langle q | Z | q\rangle =\langle q|0\rangle\langle 0|q\rangle - \langle q|1\rangle\langle 1|q\rangle =|\langle 0 |q\rangle|^2 - |\langle 1 | q\rangle|^2\\\\ \langle X \rangle &= \\\\ \langle Y \rangle &= \end{aligned} \\$$, respectively.
Therefore, the expectation values of the Paulis for a qubit state can be obtained by making a measurement in the standard basis after rotating the standard basis frame to lie along the corresponding axis. The probabilities of obtaining the two possible outcomes 0 and 1 are used to evaluate the desired expectation value as the above equations show.
2. Measure the Bloch sphere coordinates of a qubit using the qasm simulator and plot the vector on the bloch sphere.
📓Step A. Create a qubit state using the circuit method, initialize with two random complex numbers as the parameter.
To learn how to use the function initialize, check here. ( go to the arbitrary initialization section. )
📓 Step B. Build the circuits to measure the expectation values of gate based on your answers to the question 1. Run the cell below to estimate the bloch sphere coordinates of the qubit from step A using the qasm simulator.
The circuit for gate measurement is given as an example.
Step C. Plot the vector on the bloch sphere.
Note that the following cell for the interactive bloch_sphere would not run properly unless you work in IQX. You can either use plot_bloch_vector for the non-interactive version or install kaleidoscope by running
in a terminal. You also need to restart your kernel after the installation. To learn more about how to use the interactive bloch sphere, go here.
Part 2: Measuring Energy
Goal
Evaluate the energy levels of the hydrogen ground state using qasm simulator.
The energy of a quantum system can be estimated by measuring the expectation value of its hamiltonian, which is a hermitian operator, through the procedure we mastered in part 1.
The ground state of hydrogen is not defined as a single unique state but actually contains four different states due to the spins of the electron and proton. In part 2 of this lab, we evaluate the energy difference among these four states, which is from the hyperfine splitting, by computing the energy expectation value for the system of two spins with the hamiltonian expressed in Pauli operators. For more information about hyperfine structure, see here
Consider the system with two qubit interaction hamiltonian where and are Pauli gates. Then the energy expectation value of the system can be evaluated by combining the expectation value of each term in the hamiltonian. In this case, .
📓 1. Express the expectation value of each term in the hamiltonian for an arbitrary two qubit state in the computational basis.
The case for the term is given as an example.
2. Measure the expected energy of the system using the qasm simulator when two qubits are entangled. Regard the bell basis, four different entangled states.
📓Step A. Construct the circuits to prepare four different bell states.
Let's label each bell state as,
📓Step B. Create the circuits to measure the expectation value of each term in the hamiltonian based on your answer to the question 1.
Step C. Execute the circuits on qasm simulator by runnng the cell below and evaluate the energy expectation value for each state.
Step D. Understanding the result.
If you found the energy expectation values successfully, you would have obtained exactly the same value, , for the trplet tates, and one lower energy level, for the singlet state .
What we have done here is measuring the energies of the four different spin states corresponding to the ground state of hydrogen and observed hyperfine structure in the energy levels caused by spin-spin coupling. This tiny energy difference between the singlet and triplet states is the reason for the famous 21-cm wavelength radiation used to map the structure of the galaxy.
In the cell below, we varify the wavelength of the emission from the transition between the triplet states and singlet state.
Part 3: Execute the circuits on Quantum Computer
Goal
Re-run the circuits on a IBM quantum system. Perform measurement error mitigations on the result to improve the accuracy in the energy estimation.
Step A. Run the following cells to load your account and select the backend
Step B. Execute the circuits on the quantum system.
In Lab1 when we excuted multiple circuits on a real quantum system, we submitted each circuit as a sperate job which produces the multiple job ids. This time, we put all the circuits in a list and execute the list of the circuits as one job. In this way, all the circuit execution can happen at once, which would possibly decrease your wait time in the queue.
In addition, transpile is not used here as all the circuits that we run consist of one or two qubit gates. We can still specify the initial_layout and optimization_level through execute function. Without using transpile, the transpiled circuits are not accessible which is not a concern for this case.
📓 Check the backend configuration information and error map through the widget to determine your initial_layout.
Run the following cell to execute the circuits with the initial_layout on the backend.
Step C. Estimate the ground state energy levels from the results of the previous step by executing the cells below.
Step D. Measurement error mitigation.
The results you obtained from running the circuits on the quantum system are not exact due to the noise from the various sources such as enery relaxation, dephasing, crosstalk between qubits, etc. In this step, we will alleviate the effects of the noise through the measurement error mitigation. Before we start, watch this video.
📓Construct the circuits to profile the measurement errors of all basis states using the function 'complete_meas_cal'. Obtain the measurement filter object, 'meas_filter', which will be applied to the noisy results to mitigate readout (measurement) error.
For further helpful information to complete this task, check here .
Step E. Interpret the result.
📓 Compute the relative errors ( or the fractional error ) of the energy values for all four states with and without measurement error mitigation.
📓 Compare the size of the errors before and after the measurment error mitigation and discuss about the effect of the readout error regarding the error map information of the backend that you selected.
Your answer: