Path: blob/main/notebooks/ch-labs/Lab06_IterativePhaseEstimation.ipynb
3855 views
Lab 6 Iterative Phase Estimation Algorithm
Part 1: Implementation of Iterative Phase Estimation algorithm
Goal
Estimate a phase value on a system of two qubits through Iterative Phase Estimation (IPE) algorithm.
Having gone through previous labs, you should have noticed that the "length" of a quantum circuit is the primary factor when determining the magnitude of the errors in the resulting output distribution; quantum circuits with greater depth have decreased fidelity. Therefore, implementing algorithms based on shallow depth circuits is of the great importance in near-term quantum computing. In Lab 5, we learn one such algorithm for estimating quantum phase called the Iterative Phase Estimation (IPE) algorithm which requires a system comprised of only a single auxiliary qubit and evaluate the phase through a repetative process.
1. Understand a circuit with non-unitary operations.
Before we learn how the IPE algorithm works, lets review reset and conditional operations in Qiskit that go into building a IPE circuit. Read the Qiskit tutorial here ( go to Non-unitary operations section ) to understand how to build a circuit that performs conditional operations and reset.
📓Step A. Run the following cell and predict the outcome of the circuit.
Execute the cell below to see the result.
📓Step B. Complete the rest of the circuit so that the auxiliary qubit ( top qubit ) after the reset would be in the state if the value of the classical bit is one or remains zero state otherwise.
Running the following cell to display the result.
2. Iterative Phase Estimation (IPE) Algorithm.
The Quantum Phase Estimation (QPE) circuit that we have learned and used previously is limited by the number of qubits necessary for the algorithm’s precision. Every additional qubit has added costs in terms of noise and hardware requirements; noisy results that we obtained from executing the QPE circuit on a real quantum device in Lab 4 would get worse as the number of the qubits on the circuit increases. The IPE algorithm implements quantum phase estimation with only a single auxiliary qubit, and the accuracy of the algorithm is restricted by the number of iterations rather than the number of counting qubits. Therefore, IPE circuits are of practical interest and are of foremost importance for near-term quantum computing as QPE is an essential element in many quantum algorithms.
Consider the problem of finding given and such that , with . Let's assume for now that can be written as , where we have previously defined the notation .
Assume that is a unitary operator acting on one qubit. We therefore need a system of two qubits, and , where is auxiliary qubit and the qubit represents the physical system on which operates. Having them initialized as and , application of control-U between and times would change the state of to . That is, the phase of has been kicked back into as many times as the control operation has been performed.
Therefore,
for , the phase encoded into would be and
for , the phase would be and
for , and
for , .
Note that for the last case with , the state of is ; if and if which would produce outcomes and respectively when it gets measured in x-basis.
In the first step of the IPE algorithm, we directly measure the least significant bit of the phase , , by initializing the 2-qubit registers as described above ( and ), performing control- operations between the qubits, and measuring in the x-basis.
For the second step, we initialize the systems in the same way and apply control- operations. The relative phase in after these operations is now . To extract the phase bit , first perform a phase correction by rotating around the axis of angle , which results in the state of to be . Perform a measurement on in x-basis to obtain the phase bit .
Therefore, the th step of the IPE, getting , consists of the register initialization ( in , in ), the application of control- times, a rotation around of angle , and a measurement of in x-basis: a Hadamard transform to , and a measurement of in the standard basis. Note that remains in the state throughout the algorithm.
3. Estimate the phase of the -gate implementing IPE algorithm.
Review the section 2. Example: T-gate in Ch.3.8 Quantum Phase Estimation and the section 4. Measuring in Different Bases in Ch.1.4 Single Qubit Gates
As we already learned the Qiskit textbook, the phase of a T-gate is exactly expressed using three bits.
📓Step A. Obtain the least significant phase bit of the -gate by setting up the circuit T_x3 properly and assign the value to the variable x_3.
In the previous section, the first step explains how to construct the circuit to extract the least significant phase bit.
📓Step B. Extract the middle phase bit of the -gate by creating the circuit T_x2 with phase correction using x_3 value from Step A. Assign the outcome bit to the variable x_2.
Read the the second step in the previous section.
📓Step C. Find the most significant phase bit of the -gate and assign it to the variable x_1.
Therefore, the -gate phase bit that you found is 0.x_1x_2x_3. Run the following cell to check if your answer is correct by comparing your phase bit x_1x_2x_3 with 001, the answer in the Qiskit textbook, which corresponds to ( = 0.125), the phase of the -gate.
📓Step D. Construct the full IPE circuit and pass it to the variable qc_T ; Put the all steps that you performed into one circuit utilizing conditional operations and reset.
Instead of using three seperate circuits to extract each phase bit value, build one circuit; perform a reset operation on the auxiliary qubit after each bit gets measured into a classical register. Therefore, the circuit requires three classical registers for this example; the least significant bit measured into the classical register, c[0] and the most significant bit measured into c[2]. Implement conditional operator between the auxiliary qubit and the classical register for the phase correction.
Step E. Excute the following cell to perform the simulation and display the result.
Part 2: Comparison between QPE and IPE results in the presence of noise
Goal
Understand the importance of implementing shallow circuit algorithms on current noisy quantum computers.
In Part 2 of Lab 4, we executed a Quantum Phase Estimation (QPE) circuit on a real quantum device. Having recognized the limits of the performance due to noise that presents in current quantum system, we utilized several techniques to reduce its influence on the outcome. However, the final result that was obtained, even after all these procedures, is still far from ideal. Here, we implement Iterative Phase Estimation (IPE) algorithm to overcome the effect of noise in phase estimation to a great extent and compare the result with the QPE outcome.
To investigate the impact of the noise from real quantum system on the outcome, we will perform noisy simulations of IPE circuit employing the Qiskit Aer noise module which produces a simplified noise model for an IBM quantum system. To learn more about noisy simulation, read here.
As in Lab 4, we consider to estimate the phase of p gate with . Suppose that the accuracy of the estimation that we desire here is same as when the QPE circuit has four counting qubits, which determines the number of iteration and classical registers required for the IPE circuit.
📓Step A. How many classical registers is needed? Assign the value to the variable n.
📓Step B. Construct the IPE circuit in the following cell.
Step C. Run the cell below to create the QPE circuit for the comparison.
📓Step D. Transpile the circuits for the backend ibmq_Athens.
Run the following cell to check the properties of the backend, ibmq_Athens. Pick an initial_layout, and transpile the IPE circuit setting optimization_level = 3, and save the transpiled circuit to the variable IPE_trans. Print out the depth of the transpiled circuit.
Execute the cell below to transpile QPE circuit.
Step E. Run the following cells to perform the noise simulation of the transipiled circuits.
Step F. Execute the cell below to compute the exact phase estimation results.
Step G. Show the comparison figure by running the following cell.
If you create the IPE circuit successfully to estimate the phase, , you would get the similar plots as shown below.
