Iterative Quantum Amplitude Estimation#1780
Conversation
|
👋 Hey, looks like you've updated some demos! 🐘 Don't forget to update the Please hide this comment once the field(s) are updated. Thanks! |
Your preview is ready 🎉!You can view your changes here
|
alexandra-frca
left a comment
There was a problem hiding this comment.
I've looked through the demo and it's looking super nice! I love the images and the intuitive explanations. On a first reading there are a few things I'd suggest changing for accuracy or clarity, as well as a few bug/typo corrections, and suggestions of minor things to add; I wrote them below. I started organizing my comments by paragraph but ended up grouping them by point instead to avoid repetition; where necessary I quote enough of the text that you can find the section easily.
Some descriptions confused me a bit so apologies if I misunderstood some of your points. If there's anything you'd like to discuss in person, let me know, I'd be happy to. In some cases I suggest sentences that may be clearer/more rigorous as a starting point but feel free to rewrite them to your taste!
- Some context is a bit confusing or inaccurate
- I would reframe the opening around QAE rather than classical search. Grover is relevant background, but not the motivation here, since the demo is about QAE and not search.
- I'm not sure what you mean by Monte Carlo methods alleviating the cost in Grover search. Do you mean alleviating the cost in integration, which is possible application of QAE?
- I wouldn't call QAE a "generalization" of Grover search: it is a different algorithm that shares the same framework but solves a different problem. The goal of Grover search is to find a marked item (or several), the goal of QAE is to estimate how much probability mass lies in the marked subspace. I think the confusion here may be due to the content of [2]. They have two separate contributions: i) generalizing Grover's algorithm to cases where the initialization operator is not a Hadamard transform, and ii) introducing QAE. I wouldn't focus on point (i) since this tutorial is about QAE.
- I would remove the sentence "a superposition state with uneven probabilities", which risks implying the wrong circuit structure. The description is a bit confusing. The clean high level view is: canonical QAE applies phase estimation to the Grover operator, whose eigenphases translate into estimates for the amplitude.
- The phrase "estimate the probability that a certain state exists within a data set" doesn't seem accurate, a better formulation is "estimate the probability of measuring a marked outcome after a given state preparation unitary". This doesn't directly map into a classical meaning due to the nature of the task, but you can say e.g. that the classical equivalent would be estimating the parameter of a Bernoulli distribution based on samples. There is an equivalence between this distribution and the initial quantum state (measuring it directly amounts to taking a classical sample), but in the quantum case we can amplify it before measuring.
- "QAE is a major improvement on its predecessors" what predecessors do you mean? BHMT was the first proposal
- The explanation of the difference between canonical and iterative QAE could be sharper. The main takeaway is that QAE relies on a single deeper and wider circuit (with auxiliary qubits and a ladder of controlled Grover operations followed by a QFT), while IQAE relies on a sequence of simpler circuits (each with an adaptively chosen sequence of non-controlled Grover operations) to, as you say, progressively zoom in on the solution. Maybe you could phrase this a bit more clearly?
- QAE doesn't "take advantage of the benefits of a quantum search algorithm", but rather quantum amplitude amplification
- In the paragraph "In [1], an alternative is proposed", the second sentence makes k seem fixed, should be clearer there is a cycle where k is chosen adaptively for each iteration. In the third sentence I'd remove the "and applied" because it's superfluous, and the paragraph doesn't clearly describe the circuit structure. Something like "IQAE runs a sequence of circuits with non controlled powers of the Grover operator, Q^k, choosing k adaptively based on previous iterations". Also, I'd avoid repeating ideas, such as the definition of the amplitude here, which is already in the beginning
- "a large k corresponding to a high probability oscillation frequency and, therefore, a high resolution" this makes one ask, why not use k as large as possible from the start? Maybe mention there is a tradeoff because high frequencies lead to ambiguity (which is better detailed in your description of findnextk later)
- "Thus, if an adequately sized k is identified, a high accuracy estimation for the “good” state amplitude can be calculated" this would seem to suggest there is only one k as opposed to an adaptively chosen sequence
- "Think, for example, of measuring a probability of 40%. Without information on the range in which this measurement falls, it is impossible to know whether you are approaching a peak or a plateau in the sinusoidal probability curve" I don't understand these 2 sentences. I would say your following sentence starting by "in addition" fully describes the point of the half plane condition
- "Efficient and justifiable implementation of Grover’s algorithm, however, requires the number of solutions to be known and that the input state exists in an equally weighted superposition, limiting its applications." - generalizations of Grover search to unknown numbers of solutions and general states are straightforward, neither of these is a bottleneck
- "a randomly weighted superposition of all combinations of the input qubits should be generated" - I would clarify that this is chosen as a toy example and in a real world scenario the operator is determined by the problem. I would also rephrase this as "the initial state is [...]" and remove "should be generated"
- Some terms go against standard terminology
- "O(N) efficiency": I'd replace "efficiency" by cost, runtime, query cost or sample complexity depending on context
- "Scale intensely with complexity": I'd replace "complexity" by problem size, size of the search space or number of samples/trials depending on context, and avoid subjective words like "intensely" (related to point 3 below)
- "Efficient": this has the meaning of "polynomial cost" in CS, which applies to all algorithms here, so I'd avoid that term, especially saying one algorithm is efficient and the other is not
- "Concentration": replace by probability or amplitude or probability mass or fraction or percentage depending on context
- "In theory": I would omit this when talking about proven algorithmic statements
- "identify the probability that a given entry in a data set is a multiple of 8" -> estimate the fraction of states that are multiples of 8
- "To carry this search out, we will define an operator A that maps a set of input qubits onto the problem [...] should impose a unitary operation on the input states that invokes a superposition state that is identical to |\psi_{IQAE}>" -> "Constructing the Grover operator requires the problem-specific initialization operator, A|0>^{\otimes n} = |\psi_{IQAE}>, and its inverse"
- "the final 3 qubits in each string [...]" -> "the oracle checks the 3 least significant qubits [...]"
- "each iteration of the IQAE algorithm will yield the following state" I'd clarify this is the general formula for k steps of amplitude amplification, not specific to IQAE
- "theta is related to the angle that the state is rotated by Grover’s operator" -> "theta is determined by the initial state amplitude" (the Grover operator angle is a consequence of this, not the cause)
- "even/uneven" superposition -> uniform/non-uniform
- "the exponential scale of the input state with number of qubits" - here it seems important to clarify this applies to classical simulation, not if we run this on a quantum computer
- Some claims are too strong
- The claims about "efficiency", "feasibility", and drastic quantum improvements are too bold. It's just a quadratic speed up, which can be more resource-efficient but is not enough to make "infeasible" become "feasible"
- The sentence "since quantum computing, in theory, enables efficient parallel computation, its utility in search techniques is clear". It seems to equate superposition with classical parallelism, making the solution straightforward by "evaluating many guesses at once". Given the measurement problem I wouldn't say the utility of QC in search is clear, since it requires a creative/non-obvious orchestration of quantum effects (superposition and interference)
- The claims about usage in "near term hardware" are overstated. What is understood as "near term hardware" would not be able to fruitfully execute IQAE either. I agree that hardware limitations are a relevant point, but I'd stick to talking about reducing hardware requirements more objectively, since this still requires very deep circuits and assumes them to have ideal behavior (no noise)
- "When defining the operator, the global phase term can be neglected since it does not impact the final measurement" -> I'd add a note that for canonical QAE this phase does make a difference
- Regarding the code
- The 'catalyst_bool = False' case doesn't run due to a bug. Q(i) should be Q()
control_wiresincludes not just controls but also target for MCX right? I'd rename to avoid confusion- FlipSign uses different ranges of qubits for each 'catalyst_bool' case
- Due to a typo the function 'FindNextK' is returning the global variable HalfPlane_Bool instead of the local variable 'HalfPlane_bool'
- You don't implement some algorithm details like the no overshooting condition and the combination of data for matchink k's, right? If so that makes sense for a pedagogical demo but should be mentioned the algorithm is a bit simplified
- When you say that to check the result the state is "measured in a single shot", I think you mean you access the analytic probability from the simulator (which technically corresponds to infinite shots)
- In your drawing the Z operator is spanning all qubits, even though it only acts on one (the ancilla)
- Regarding "#Beginning search in the upper quadrant - this differs from the paper, is this correct?". Not sure I understand the comment, the paper does start search in the first quadrant, that's our initial range for theta
- "the outcome will change between runs of the full script" maybe you could use a random seed for reproducibility?
- Suggested additions
- I'd add a link to the demo on amplitude amplification and phase estimation right in the beginning so people can see related content more easily (since canonical QAE is a mix of these 2)
- Cite other hybrid/iterative amplitude estimation algorithms, some of which came before IQAE. There are others but I would include at least: https://arxiv.org/abs/1904.10246 https://arxiv.org/abs/1908.10846 https://arxiv.org/abs/2003.02417 https://arxiv.org/abs/2412.04394. If you want to briefly describe them or the differences I can help out
- Mention this IQAE algorithm does not achieve the full quadratic speed up (due to some double log factors iirc) but has since been modified to do so, cite https://arxiv.org/abs/2208.14612
- Mention limitations: while IQAE requires simpler circuits than canonical, the circuit depth still scales exponentially with the number of iterations, and a perfect model is assumed for the quantum device (in particular, no decoherence)
- In the conclusion, when discussing demonstrations of IQAE, I would cite the references you have in mind for each case
- I'd also mention the most natural application: calculating expectation values of observables, eg in quantum chemistry
- Many applications, such as risk analysis, are a particular case of Monte Carlo integration, which is a more general application of QAE, so I would mention MCI first
- I'd link to the phase estimation tutorial when describing canonical QAE https://pennylane.ai/demos/tutorial_qpe
- Typos
- "Implememting" in the title
- L in PennyLane should be capitalized. Also most demos of this type don't mention PennyLane in the title despite using it, I don't know if that's the standard?
- cos, sin often don't have the backslash \ so they don't format correctly
- The findnextk "1. For an initial guess [...]" is missing a superscript i in the right boundary of theta
- "Chernoff-Hoeffding method, [missing 'which'] shifts"
- "is [missing 'the'] change between the previous"
- "qubits to so that MCX" -> remove "to"
- "simple success criteria" -> criterion
- ie. -> i.e.
| # :align: center | ||
| # :width: 50% | ||
| # | ||
| # Due to the repeated applications of the Grover operator (the exact number of which, as will be explored soon, grows quickly between iterations), the computational demand of this algorithm can become quickly unmanageable. To mitigate this, `PennyLane's Catalyst compiler <https://pennylane.ai/blog/2023/03/introducing-catalyst-quantum-just-in-time-compilation>`_ can be used to compile the :math:`\mathcal{Q}` loop and reduce the demand. For small systems (like, for example, 5 qubits), the difference is negligible but becomes more apparent as the system grows. |
There was a problem hiding this comment.
| # Due to the repeated applications of the Grover operator (the exact number of which, as will be explored soon, grows quickly between iterations), the computational demand of this algorithm can become quickly unmanageable. To mitigate this, `PennyLane's Catalyst compiler <https://pennylane.ai/blog/2023/03/introducing-catalyst-quantum-just-in-time-compilation>`_ can be used to compile the :math:`\mathcal{Q}` loop and reduce the demand. For small systems (like, for example, 5 qubits), the difference is negligible but becomes more apparent as the system grows. | |
| # Due to the repeated applications of the Grover operator (the exact number of which, as will be explored soon, grows quickly between iterations), the computational demand of this algorithm can become quickly unmanageable. To mitigate this, `PennyLane's Catalyst compiler <https://pennylane.ai/blog/2023/03/introducing-catalyst-quantum-just-in-time-compilation>`_ can be used to compile the :math:`\mathcal{Q}` loop and reduce the demand. For small systems (like, for example, 5 qubits), the benefit is negligible but becomes more apparent as the system grows. |
|
|
||
| In this implementation, the goal of the IQAE algorithm will be to estimate the fraction of states that are multiples of 8. When encoded in binary, multiples of 8 will always have 0 in the three least significant positions, which serves as a simple success criterion for the algorithm (i.e. a "good" state will always have 0s in the 3 least significant positions). | ||
|
|
||
| To carry this search out, we define an operator :math:`\mathcal{A}` satisfying :math:`\mathcal{A}|0\rangle^{\otimes n}=|\Psi_{IQAE}\rangle`, where :math:`n` is the total number of qubits in the system. This operator is determined by the application. |
There was a problem hiding this comment.
There is an inconsistency in notation. Here, there are
| To carry this search out, we define an operator :math:`\mathcal{A}` satisfying :math:`\mathcal{A}|0\rangle^{\otimes n}=|\Psi_{IQAE}\rangle`, where :math:`n` is the total number of qubits in the system. This operator is determined by the application. | |
| To carry this search out, we define an operator :math:`\mathcal{A}` satisfying :math:`\mathcal{A}|0\rangle^{\otimes n+1}=|\Psi_{IQAE}\rangle`, where :math:`n` is the total number of qubits in the good and bad states. This operator is determined by the application. |
|
|
||
| Though QAE is a major improvement on the classical case, its reliance on QPE makes it too resource-intensive to run on near-term hardware. This is because QPE depends on QFT, whose circuit width and depth increase rapidly with the intended precision. If we want to, therefore, employ QAE using near-term hardware, we need to find a way to avoid using QPE. | ||
|
|
||
| In 2021, an alternative, more efficient method was proposed: Iterative Quantum Amplitude Estimation (IQAE) [#Grinko2021]_. Essentially, IQAE is a quantum-classical hybrid algorithm that breaks down the very deep, very wide circuit approach used in QAE into a series of simpler circuits that execute the Grover operator :math:`k` times sequentially, with the value of :math:`k` changing via classical optimization in each sequential circuit to iteratively "zoom in" on the solution. So, rather than trying to take a single-shot approach that requires resources to be allocated to auxiliary registers and controlled applications of the Grover operator, IQAE carries out several oscillations between classical optimizations of :math:`k` and quantum circuit execution and measurement, using the outcome of each quantum iteration to inform the classical step. |
There was a problem hiding this comment.
| In 2021, an alternative, more efficient method was proposed: Iterative Quantum Amplitude Estimation (IQAE) [#Grinko2021]_. Essentially, IQAE is a quantum-classical hybrid algorithm that breaks down the very deep, very wide circuit approach used in QAE into a series of simpler circuits that execute the Grover operator :math:`k` times sequentially, with the value of :math:`k` changing via classical optimization in each sequential circuit to iteratively "zoom in" on the solution. So, rather than trying to take a single-shot approach that requires resources to be allocated to auxiliary registers and controlled applications of the Grover operator, IQAE carries out several oscillations between classical optimizations of :math:`k` and quantum circuit execution and measurement, using the outcome of each quantum iteration to inform the classical step. | |
| In 2021, an alternative, more efficient method was proposed: Iterative Quantum Amplitude Estimation (IQAE) [#Grinko2021]_. Essentially, IQAE is a quantum-classical hybrid algorithm that breaks down the very deep, very wide circuit approach used in QAE into a series of simpler circuits that execute the Grover operator :math:`k` times sequentially, with the value of :math:`k` changing via classical optimization in each sequential circuit to iteratively "zoom in" on the solution. | |
| So, rather than trying to take a single-shot approach that requires resources to be allocated to auxiliary registers and controlled applications of the Grover operator, IQAE carries out several oscillations between classical optimizations of :math:`k` and quantum circuit execution and measurement, using the outcome of each quantum iteration to inform the classical step. |
| # .. math:: | ||
| # \mathcal{Q}=-\mathcal{A}\mathcal{S}_0\mathcal{A}^{-1}\mathcal{S}_{\psi_1}. | ||
| # | ||
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` flips everything except the :math:`|0\rangle` state (see figures 1 through 3 in the `amplitude amplification <https://pennylane.ai/qml/demos/tutorial_intro_amplitude_amplification/>`_ demo for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :func:`~qp.GroverOperator` function, which assumes a uniform superposition. |
There was a problem hiding this comment.
This S_0 description is inconsistent with your description of "The S_0 operator is analogous to a simple FlipSign() operation defined to act on the state" below.
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` flips everything except the :math:`|0\rangle` state (see figures 1 through 3 in the `amplitude amplification <https://pennylane.ai/qml/demos/tutorial_intro_amplitude_amplification/>`_ demo for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :func:`~qp.GroverOperator` function, which assumes a uniform superposition. | |
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` flips everything except the :math:`|0\rangle` state (see figures 1 through 3 in the :doc:`amplitude amplification demo <demos/tutorial_intro_amplitude_amplification>` for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :func:`~qp.GroverOperator` function, which assumes a uniform superposition. |
There was a problem hiding this comment.
Also try out :class:~pennylane.GroverOperator instead of :func:~qp.GroverOperator
| .. math:: | ||
| \mathbb{P}(|1\rangle_{eval})=\sin^2((2k+1)\theta_a). | ||
|
|
||
| From this, it is clear that the probability is correlated to the angle imposed by the Grover operator. This relationship can be made clearer by taking into consideration the fact that :math:`\mathcal{Q}` invokes a :math:`2\theta_a` rotation in a 2D space defined by the "good" and "bad" state axes each time it is applied. So, if we can figure out the angle that has been imposed on the state as a result of the operator application, we can obtain the probability of extracting a "good" state. Since we do not aspire to use QPE, our best bet is to use our iterative :math:`k` value combined with a measurement of the quantum circuit that outputs an intermediate amplitude guess. The above equation also shows that the size of :math:`k` determines the resolution of the search, with a large :math:`k` corresponding to a high probability oscillation frequency and, therefore, a high resolution. If the frequency becomes too high, however, the measurement outcomes can become ambiguous, once again justifying the iterative approach to ensure an ideal :math:`k` value is found using sequential information collected from the system [#Grinko2021]_. |
There was a problem hiding this comment.
| From this, it is clear that the probability is correlated to the angle imposed by the Grover operator. This relationship can be made clearer by taking into consideration the fact that :math:`\mathcal{Q}` invokes a :math:`2\theta_a` rotation in a 2D space defined by the "good" and "bad" state axes each time it is applied. So, if we can figure out the angle that has been imposed on the state as a result of the operator application, we can obtain the probability of extracting a "good" state. Since we do not aspire to use QPE, our best bet is to use our iterative :math:`k` value combined with a measurement of the quantum circuit that outputs an intermediate amplitude guess. The above equation also shows that the size of :math:`k` determines the resolution of the search, with a large :math:`k` corresponding to a high probability oscillation frequency and, therefore, a high resolution. If the frequency becomes too high, however, the measurement outcomes can become ambiguous, once again justifying the iterative approach to ensure an ideal :math:`k` value is found using sequential information collected from the system [#Grinko2021]_. | |
| From this, it is clear that the probability is correlated to the angle imposed by the Grover operator. This relationship can be made clearer by taking into consideration the fact that :math:`\mathcal{Q}` invokes a :math:`2\theta_a` rotation in a 2D space defined by the "good" and "bad" state axes each time it is applied. So, if we can figure out the angle that has been imposed on the state as a result of the operator application, we can obtain the probability of extracting a "good" state. Since we do not aspire to use QPE, our best bet is to use our iterative :math:`k` value combined with a measurement of the quantum circuit that outputs an intermediate amplitude guess. | |
| The above equation also shows that the size of :math:`k` determines the resolution of the search, with a large :math:`k` corresponding to a high probability oscillation frequency and, therefore, a high resolution. If the frequency becomes too high, however, the measurement outcomes can become ambiguous, once again justifying the iterative approach to ensure an ideal :math:`k` value is found using sequential information collected from the system [#Grinko2021]_. |
| # | ||
| # The FindNextK function validates this condition. The logic is as follows: | ||
| # | ||
| # 1. For an initial guess :math:`k_i` yielding confidence interval :math:`[\theta_{min}^i,\theta_{max}^i]=[\theta_{lower}K_i,\theta_{upper}K_i]`, the function will return the current guess of :math:`k` if either both the upper and lower bounds are less than pi (i.e., they fall in the upper half of the unit circle) or both the upper and lower bounds are greater than pi (i.e. they fall in the lower half of the unit circle). |
There was a problem hiding this comment.
| # 1. For an initial guess :math:`k_i` yielding confidence interval :math:`[\theta_{min}^i,\theta_{max}^i]=[\theta_{lower}K_i,\theta_{upper}K_i]`, the function will return the current guess of :math:`k` if either both the upper and lower bounds are less than pi (i.e., they fall in the upper half of the unit circle) or both the upper and lower bounds are greater than pi (i.e. they fall in the lower half of the unit circle). | |
| # 1. For an initial guess :math:`k_i` yielding confidence interval :math:`[\theta_{min}^i,\theta_{max}^i]=[\theta_{lower}K_i,\theta_{upper}K_i]`, the function will return the current guess of :math:`k` if either both the upper and lower bounds are less than :math:`\pi` (i.e., they fall in the upper half of the unit circle) or both the upper and lower bounds are greater than :math:`\pi` (i.e. they fall in the lower half of the unit circle). |
| ############################################################################## | ||
| # Conclusion | ||
| # ---------- | ||
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made ([#Fukuzawa2023]_) to meet this metric. As alluded to, IQAE has the potential to make notable impacts in various applications, such as in the calculation of expectation values in applications like quantum chemistry. Proposals have also been put forward to employ IQAE in areas such as risk analysis, financial portfolio modelling and optimization, and power grid analysis. The true feasibility of using IQAE (and, really, any other quantum algorithm) in these applications will become clearer as quantum hardware advances in capability and usability. There are, of course, limitations to IQAE's feasibility, particularly that the circuit depth grows with the number of iterations. Despite this, IQAE shows an example of how quantum-classical hybrid approaches can be used to achieve speedup compared to classical methods and resource requirement reduction compared to other quantum methods. |
There was a problem hiding this comment.
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made ([#Fukuzawa2023]_) to meet this metric. As alluded to, IQAE has the potential to make notable impacts in various applications, such as in the calculation of expectation values in applications like quantum chemistry. Proposals have also been put forward to employ IQAE in areas such as risk analysis, financial portfolio modelling and optimization, and power grid analysis. The true feasibility of using IQAE (and, really, any other quantum algorithm) in these applications will become clearer as quantum hardware advances in capability and usability. There are, of course, limitations to IQAE's feasibility, particularly that the circuit depth grows with the number of iterations. Despite this, IQAE shows an example of how quantum-classical hybrid approaches can be used to achieve speedup compared to classical methods and resource requirement reduction compared to other quantum methods. | |
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made ([#Fukuzawa2023]_) to meet this metric. | |
| As alluded to, IQAE has the potential to make notable impacts in various applications, such as in the calculation of expectation values in applications like quantum chemistry. Proposals have also been put forward to employ IQAE in areas such as risk analysis, financial portfolio modelling and optimization, and power grid analysis. The true feasibility of using IQAE (and, really, any other quantum algorithm) in these applications will become clearer as quantum hardware advances in capability and usability. | |
| There are, of course, limitations to IQAE's feasibility, particularly that the circuit depth grows with the number of iterations. Despite this, IQAE shows an example of how quantum-classical hybrid approaches can be used to achieve speedup compared to classical methods and resource requirement reduction compared to other quantum methods. |
|
|
||
| import pennylane as qp | ||
| import numpy as np | ||
| import matplotlib.pyplot as plt |
There was a problem hiding this comment.
You don't need this because you never call matplotlib in this demo!
| #Define IQAE parameters | ||
| eps = 0.0001 #Precision | ||
| alpha = 0.01 #Confidence | ||
| HalfPlane_Bool = False |
There was a problem hiding this comment.
It appears that this is overwritten within the functions
| # The confidence intervals can be determined using the Chernoff-Hoeffding bound, where the margin of error is given by :math:`\epsilon_{a_i}`. From [#Grinko2021]_. | ||
| # | ||
| # .. math:: | ||
| # \epsilon_{a_i}=\sqrt{\frac{1}{2N}\log{\frac{2T}{\alpha}}}. |
There was a problem hiding this comment.
The variable N is overloaded because it referred to the dimensionality of the Hilbert space before.
| # With ``FindNextK()`` defined, the IQAE algorithm can now be implemented! The main objective of this function is to apply the :math:`k` value returned by ``FindNextK()`` to the previously defined quantum circuit, obtain a measurement, and determine if this measurement is adequately accurate with respect to a defined tolerance or if the confidence interval should be updated and passed back into the classical function for another iteration. The logic is as follows: | ||
| # | ||
| # 1. Call ``circuit()`` after ``FindNextK()`` outputs a guess for :math:`k` and take a probability measurement. | ||
| # 2. Use this value to update the confidence interval, in which both the upper and lower bound on the angles and probabilities are computed from the measured amplitude. |
There was a problem hiding this comment.
| # 2. Use this value to update the confidence interval, in which both the upper and lower bound on the angles and probabilities are computed from the measured amplitude. | |
| # 2. Use this value to update the confidence interval, in which both the upper and lower bounds on the angles and probabilities are computed from the measured amplitude. |
|
|
||
| If, for example, you want to find a specific element in a list of length N, basic classical, unstructured search techniques require individual guesses to be evaluated sequentially. This implies a :math:`\mathcal{O}(N)` cost. Though not necessarily prohibitive, this cost behaviour implies that large lists will be difficult to search through as resource limits are reached. :doc:`Grover's algorithm <demos/tutorial_grovers_algorithm>` improved on these techniques by taking advantage of quantum information processing methods, improving cost to :math:`\mathcal{O}(\sqrt{N})`. | ||
|
|
||
| In 2000, the quantum amplitude estimation (QAE) algorithm was put forward as a method to estimate the fraction of states that satisfy a given criterion, if it exists in the set at all [#Brassard2000]_. Here, a superposition state is operated on by the Grover operator :math:`2^n` times in a controlled ladder approach, where :math:`n` is the size of the evaluation register. The rotation and amplification induced by the Grover operator encodes an amplitude in an evaluation register indicating the fraction of "good" states that meet the target criterion in a data set, which is obtained through quantum processing via :doc:`quantum Fourier transform (QFT) <demos/tutorial_qft>` to carry out quantum phase estimation (QPE). |
There was a problem hiding this comment.
Grammar suggestion
| In 2000, the quantum amplitude estimation (QAE) algorithm was put forward as a method to estimate the fraction of states that satisfy a given criterion, if it exists in the set at all [#Brassard2000]_. Here, a superposition state is operated on by the Grover operator :math:`2^n` times in a controlled ladder approach, where :math:`n` is the size of the evaluation register. The rotation and amplification induced by the Grover operator encodes an amplitude in an evaluation register indicating the fraction of "good" states that meet the target criterion in a data set, which is obtained through quantum processing via :doc:`quantum Fourier transform (QFT) <demos/tutorial_qft>` to carry out quantum phase estimation (QPE). | |
| In 2000, the quantum amplitude estimation (QAE) algorithm was put forward as a method to estimate the fraction of states that satisfy a given criterion, if it exists in the set at all [#Brassard2000]_. Here, a superposition state is operated on by the Grover operator :math:`2^n` times in a controlled ladder approach, where :math:`n` is the size of the evaluation register. The rotation and amplification induced by the Grover operator encode an amplitude in an evaluation register indicating the fraction of "good" states that meet the target criterion in a data set, which is obtained through quantum processing via :doc:`quantum Fourier transform (QFT) <demos/tutorial_qft>` to carry out quantum phase estimation (QPE). |
| .. math:: | ||
| \mathcal{Q}^k\mathcal{A}|0\rangle_{bits}|0\rangle_{eval} = \cos((2k+1)\theta_a)|\psi_0\rangle_n|0\rangle_{eval}+\sin((2k+1)\theta_a)|\psi_1\rangle_n|1\rangle_{eval} | ||
|
|
||
| where :math:`\mathcal{Q}` is the Grover operator and :math:`\theta_a` is related to the angle that the state is rotated by Grover's operator (note :math:`a=\sin^2(\theta_a)`), and :math:`k` is the number of times that the Grover operator is applied to the state in a single IQAE iteration. The specifications of this equation are covered thoroughly in [#Brassard2000]_, but the important result is that the probability of measuring a "good" state at the end of an iteration is given by |
There was a problem hiding this comment.
| where :math:`\mathcal{Q}` is the Grover operator and :math:`\theta_a` is related to the angle that the state is rotated by Grover's operator (note :math:`a=\sin^2(\theta_a)`), and :math:`k` is the number of times that the Grover operator is applied to the state in a single IQAE iteration. The specifications of this equation are covered thoroughly in [#Brassard2000]_, but the important result is that the probability of measuring a "good" state at the end of an iteration is given by | |
| where :math:`\mathcal{Q}` is the Grover operator and :math:`\theta_a` is related to the angle by which the state is rotated by Grover's operator (note :math:`a=\sin^2(\theta_a)`), and :math:`k` is the number of times that the Grover operator is applied to the state in a single IQAE iteration. The specifications of this equation are covered thoroughly in [#Brassard2000]_, but the important result is that the probability of measuring a "good" state at the end of an iteration is given by |
|
Thank you for your comments and suggestions, @drdren! I made the suggested corrections, updated the figures, and reworked wording where necessary. Let me know if there are any additional issues! |
| # | ||
| # These operators can be used to build the final, iterative circuit in which the number of Grover operator applications will vary per iteration. | ||
| # | ||
| # .. figure:: ../demonstrations_v2/iterative_quantum_amplitude_estimation/pennylane-demo-iterative-quantum-amplitude-estimation-Full_Circuit_Drawing.png |
There was a problem hiding this comment.
Hi! Should the eval qubit be called eval instead of r?
|
|
||
| It is expensive to guess. | ||
|
|
||
| If, for example, you want to find a specific element in a list of length N, basic classical, unstructured search techniques require individual guesses to be evaluated sequentially. This implies a :math:`\mathcal{O}(N)` cost. Though not necessarily prohibitive, this cost behaviour implies that large lists will be difficult to search through as resource limits are reached. :doc:`Grover's algorithm <demos/tutorial_grovers_algorithm>` improved on these techniques by taking advantage of quantum information processing methods, improving cost to :math:`\mathcal{O}(\sqrt{N})`. |
There was a problem hiding this comment.
To match the asymptotes below.
| If, for example, you want to find a specific element in a list of length N, basic classical, unstructured search techniques require individual guesses to be evaluated sequentially. This implies a :math:`\mathcal{O}(N)` cost. Though not necessarily prohibitive, this cost behaviour implies that large lists will be difficult to search through as resource limits are reached. :doc:`Grover's algorithm <demos/tutorial_grovers_algorithm>` improved on these techniques by taking advantage of quantum information processing methods, improving cost to :math:`\mathcal{O}(\sqrt{N})`. | |
| If, for example, you want to find a specific element in a list of length $N$, basic classical, unstructured search techniques require individual guesses to be evaluated sequentially. This implies a :math:`\mathcal{O}(N)` cost. Though not necessarily prohibitive, this cost behaviour implies that large lists will be difficult to search through as resource limits are reached. :doc:`Grover's algorithm <demos/tutorial_grovers_algorithm>` improved on these techniques by taking advantage of quantum information processing methods, improving cost to :math:`\mathcal{O}(\sqrt{N})`. |
| # .. math:: | ||
| # \mathcal{Q}=-\mathcal{A}\mathcal{S}_0\mathcal{A}^{-1}\mathcal{S}_{\psi_1}. | ||
| # | ||
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` should flip the phase of the :math:`|0\rangle` state (see figures 1 through 3 in the :doc:`amplitude amplification demo <demos/tutorial_intro_amplitude_amplification>` for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :class:~pennylane.GroverOperator function, which assumes a uniform superposition. |
There was a problem hiding this comment.
Presently, the link is not rendering. Let's try this.
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` should flip the phase of the :math:`|0\rangle` state (see figures 1 through 3 in the :doc:`amplitude amplification demo <demos/tutorial_intro_amplitude_amplification>` for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :class:~pennylane.GroverOperator function, which assumes a uniform superposition. | |
| # In which :math:`\mathcal{S}_{\psi_1}` acts as the oracle and flips the phase of (marks) a "good" state and :math:`\mathcal{S}_0` should flip the phase of the :math:`|0\rangle` state (see figures 1 through 3 in the :doc:`amplitude amplification demo <demos/tutorial_intro_amplitude_amplification>` for an intuitive visualization). Since this is a non-uniform superposition, the operator that facilitates this process needs to be defined rather than using PennyLane's built-in :class:`~.pennylane.GroverOperator` function, which assumes a uniform superposition. |
| # .. math:: | ||
| # \mathbb{P}(|1\rangle)=\frac{1-\cos((4k+2)\theta_a)}{2}=\frac{1-\cos(K_i\theta_a)}{2}. | ||
| # | ||
| # Letting :math:`K_i=4k+2` be the frequency term. |
There was a problem hiding this comment.
| # Letting :math:`K_i=4k+2` be the frequency term. | |
| # Letting :math:`K_i=4k+2` be the frequency. |
| # 3. Compute the overlap between the previous confidence interval and the new confidence interval, taking this to be your final upper and lower bound definition. | ||
| # 4. Check to see if the difference between the new upper and lower bounds is smaller than :math:`\epsilon`, which represents a chosen accuracy parameter. If not, pass the final upper and lower bounds back into ``FindNextK()`` and repeat. If yes, return the probability amplitudes associated with the upper and lower amplitudes. | ||
| # | ||
| # The confidence intervals can be determined using the Chernoff-Hoeffding bound, where the margin of error is given by :math:`\epsilon_{a_i}`. From [#Grinko2021]_. |
There was a problem hiding this comment.
". From [1]." read strangely to me.
| # The confidence intervals can be determined using the Chernoff-Hoeffding bound, where the margin of error is given by :math:`\epsilon_{a_i}`. From [#Grinko2021]_. | |
| # The confidence intervals can be determined using the Chernoff-Hoeffding bound, where the margin of error is given by :math:`\epsilon_{a_i}` from [#Grinko2021]_, |
| ############################################################################## | ||
| # Conclusion | ||
| # ---------- | ||
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made ([#Fukuzawa2023]_) to meet this metric. |
There was a problem hiding this comment.
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made ([#Fukuzawa2023]_) to meet this metric. | |
| # QAE was put forward as a generalized adaptation of quantum search methods, which hinted at the viability of quantum computers as a notable improvement on existing technologies early on. IQAE pushed forward with this task, showing not only that quantum hardware has the potential to provide advantages in estimation algorithms but that classical feedback loops can be employed to reduce implementation limitations. The implementation shown here does not achieve full quadratic speedup compared to classical estimation methods, but advancements have been subsequently made [#Fukuzawa2023]_ to meet this metric. |
drdren
left a comment
There was a problem hiding this comment.
Hi @nobese , excellent work! I left some comments whose suggestions I'd like to see addressed in the next draft, but I am happy to give my approval now if you will implement them. Don't forget to modify the dates before merging.
Title: Iterative Quantum Amplitude Estimation in Pennylane
Summary: Classical search algorithms are expensive. To make use of the speedup provided by near-term quantum hardware, algorithms that carry out search tasks without requiring the resources demanded by quantum phase estimation must be found. Iterative quantum amplitude estimation (IQAE), a quantum-classical hybrid algorithm that builds on the logic of Grover's algorithm and the generality of quantum amplitude estimation (QAE) to evaluate the probability of measuring a specific type of entry in a data set, is one such example. This demo builds on the theory of Grover's algorithm and QAE to present the IQAE algorithm and carry out a simple implementation in Pennylane.
Relevant references: [1] Grinko, D., Gacon, J., Zoufal, C., & Woerner, S. (2021). Iterative quantum amplitude estimation. npj Quantum Information, 7(52). https://doi.org/10.1038/s41534-021-00379-1
[2] Brassard, G., Høyer, P., Mosca, M., & Tapp, A. (2002). Quantum Amplitude Amplification and Estimation. Contemporary Mathematics, 305, 53-74. https://arxiv.org/abs/quant-ph/0005055
Possible Drawbacks: There is no definitive demo on QAE, which may appear as a knowledge gap. The IQAE outline in this demo, however, may be adequate to address this.
Related GitHub Issues: N/A
If you are writing a demonstration, please answer these questions to facilitate the marketing process.
GOALS — Why are we working on this now?
Eg. Promote a new PL feature or show a PL implementation of a recent paper.
The goal of this demo is to:
AUDIENCE — Who is this for?
Eg. Chemistry researchers, PL educators, beginners in quantum computing.
The reader of this demo is assumed to be familiar with Grover’s search algorithm and the general concept of canonical quantum amplitude estimation.
KEYWORDS — What words should be included in the marketing post?
Search algorithm, amplitude estimation, quantum-classical, NISQ
Which of the following types of documentation is most similar to your file?
(more details here)