Path: blob/main/notebooks/ch-labs/Lab05_AccuracyQPE.ipynb
3855 views
Lab 5 Accuracy of Quantum Phase Estimation
Prerequisite
Other relevant materials
[QCQI] Michael A. Nielsen and Isaac L. Chuang. 2011. Quantum Computation and Quantum Information
Part 1: Performance of Quantum Phase Estimation
Goal
Investigate the relationship between the number of qubits required for the desired accuracy of the phase estimation with high probability.
The accuracy of the estimated value through Quantum Phase Estimation (QPE) and its probability of success depend on the number of qubits employed in QPE circuits. Therefore, one might want to know the necessary number of qubits to achieve the targeted level of QPE performance, especially when the phase that needs to be determined cannot be decomposed in a finite bit binary expansion. In Part 1 of this lab, we examine the number of qubits required to accomplish the desired accuracy and the probability of success in determining the phase through QPE.
1. Find the probability of obtaining the estimation for a phase value accurate to successfully with four counting qubits.
📓Step A. Set up the QPE circuit with four counting qubits and save the circuit to the variable 'qc4'. Execute 'qc4' on a qasm simulator. Plot the histogram of the result.
Check the QPE chapter in Qiskit textbook ( go to 3. Example: Getting More Precision section here ) for the circuit.
Having performed Step A successfully, you will have obtained a distribution similar to the one shown below with the highest probability at 0101 which corresponds to the estimated value, 0.3125.

Since the number of counting qubits used for the circuit is four, the best estimated value should be accurate to . However, there are multiple possible outcomes as cannot be expressed in a finite number of bits, the estimation by QPE here is not always bounded by this accuracy.
Running the following cell shows the same histogram but with all possible estimated values on the x-axis.
Suppose the outcome of the final measurement is , and let the best estimation which is 0.3125 for this case.
📓Step B. Find , the maximum difference in integer from the best estimation 0101 so that all the outcomes, 'm's, would approximate to an accuracy when .
In this case, the values of and are and , respectively.
For example, under , the considered outcomes are 0100, 0101, 0110 which correspond to the values of : , respectively, and all of them approximate the value to an accuracy .
📓Step C. Compute the probability of obtaining an approximation correct to an accuracy . Verify that the computed probability value is larger or equal to where is the number of counting bits and the is the desired accuracy.
Now it is easy to evaluate the probability of the success from the histogram since all the outcomes that approximate to the accuracy can be found based on the maximum difference from the best estimate.
2. Compute the probability of success for the accuracy when the number of counting qubits, , varies from four to nine. Compare your result with the equation when is the desired accuracy and is 1 - probability of success.
The following plot shows the relationship between the number of counting qubit, t, and the minimum probability of success to approximate the phase to an accuracy . Check the Ch. 5.2.1 Performance and requirements in [QCQI].
📓Step A. Construct QPE circuit to estimate when with for the different number of counting qubits, , when . Store all the circuits in a list variable 'circ' to simulate all the circuits at once as we did in Lab3.
📓Step B. Determine , the maximum difference in integer from the best estimation for the different numer of counting qubits, . Verify the relationship where since the desired accuracy is in this case.
If you successfully calculated values for all the counting qubits, , you will be able to generate the following graph that verifies the relationship with the values that you computed.

📓Step C. Evaluate the probability of success estimating to an accuracy for all the values of , the number of counting qubits. Save the probabilities to the list variable, 'prob_success'.
📓Step D. Overlay the results of Step C on the graph that shows the relationship between the number of counting qubits, , and the minimum probability of success to approximate the phase to an accuracy . Understand the result.

Your plot should be similar to the above one. The line plot in the left pannel shows the minimum success probability to estimate within the accuracy as the number of counting qubits varies. The overlayed orange dots are the same values, but from the simulation, which confirms the relationship the line plot represents as the lower bound. The right pannel displays the same result but zoomed by adjusting the y-axis range.
The following graph exhibits the relationships with different accuracy levels. The relationship, , indicates the number of counting qubits to estimate to an accuracy with probability of success at least , as we validated above.
Part 2: QPE on Noisy Quantum System
Goal
Run the QPE circuit on a real quantum system to understand the result and limitations when using noisy quantum systems
The accuracy anaylsis that we performed in Part 1 would not be correct when the QPE circuit is executed on present day noisy quantum systems. In part 2, we will obtain QPE results by running the circuit on a backend from IBM Quantum Experience to examine how noise affects the outcome and learn techniques to reduce its impact.
📓Step A. Load your account and select the backend from your provider.
📓Step B. Generate multiple ( as many as you want ) transpiled circuits of qc4 that you set up in Part 1 at the beginning. Choose one with the minimum circuit depth, and the other with the maximum circuit depth.
Transpile the circuit with the parameter optimization_level = 3 to reduce the error in the result. As we learned in Lab 1, Qiskit by default uses a stochastic swap mapper to place the needed SWAP gates, which varies the tranpiled circuit results even under the same runtime settings. Therefore, to achieve shorter depth transpiled circuit for smaller error in the outcome, transpile qc4 multiple times and choose one with the minimum circuit depth. Select the maximum circuit depth one as well for comparison purposes.
📓Step C. Execute both circuits on the backend that you picked. Plot the histogram for the results and compare them with the simulation result in Part 1.
The following shows the sample result.

Step D. Measurement Error Mitigation
In the previous step, we utilized our knowledge about Qiskit transpiler to get the best result. Here, we try to mitigate the errors in the result further through the measurement mitigation technique that we learned in Lab 3.
📓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.
📓Plot the histogram of the results before and after the measurement error mitigation to exhibit the improvement.
The following plot shows the sample result.

The figure below displays a simulation result with the sample final results from both the best and worst SWAP mapping cases after applying the measurement error mitigation. In Lab 3, as the major source of the error was from the measurement, after the error mitigation procedure, the outcomes were significantly improved. For QPE case, however, the measurement error doesn't seem to be the foremost cause for the noise in the result; CNOT gate errors dominate the noise profile. In this case, choosing the transpiled circuit with the least depth was the crucial procedure to reduce the errors in the result.
