Add grover_operator function#13365
Conversation
|
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 11688478692Details
💛 - Coveralls |
and know how :context: is to be used
| For a large number of qubits, the multi-controlled X gate used for the zero-reflection | ||
| can be synthesized in different fashion. Depending on the number of available qubits, |
There was a problem hiding this comment.
| For a large number of qubits, the multi-controlled X gate used for the zero-reflection | |
| can be synthesized in different fashion. Depending on the number of available qubits, | |
| For a large number of qubits, the multi-controlled X gate used for the zero-reflection | |
| can be synthesized in different fashions. Depending on the number of available qubits, |
| # add extra bits that can be used as scratch space | ||
| grover_op.add_bits([Qubit() for _ in range(num_qubits)]) | ||
| print("2q depth w/ scratch qubits:", tqc.depth(filter_function=is_2q)) # < 100 |
There was a problem hiding this comment.
shouldn't you retranspile after adding the extra bits in this example?
| The :func:`.grover_operator` implements the same functionality but keeping the | ||
| :class:`.MCXGate` abstract, such that the compiler may choose the optimal decomposition. |
There was a problem hiding this comment.
What about:
| The :func:`.grover_operator` implements the same functionality but keeping the | |
| :class:`.MCXGate` abstract, such that the compiler may choose the optimal decomposition. | |
| The :func:`.grover_operator` implements the same functionality but keeping the | |
| :class:`.MCXGate` abstract, such that the compiler may choose the optimal decomposition. | |
| We recommend using :func:`.grover_operator` for performance reasons. |
| Grover's algorithm and amplitude estimation/amplification. This function is similar to | ||
| :class:`.GroverOperator`, but does not require choosing the implementation of the | ||
| multi-controlled X gate a-priori and let's the compiler choose the optimal decomposition | ||
| instead. |
There was a problem hiding this comment.
Given the amount of examples you have in the docstring, I would copy-paste one into the reno for quick reference.
| expected.compose(zero_reflection, inplace=True) | ||
| expected.h(0) | ||
| self.assertEqual(expected, grover_op.decompose()) | ||
| self.assertEqual(expected, grover_op if use_function else grover_op.decompose()) |
There was a problem hiding this comment.
This tests makes me think that we should mention in the reno and docstring that the output of the new constructor is a series of gates instead of a "black box". This is actually the main user-facing difference I see (besides the mcx detail)
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
ElePT
left a comment
There was a problem hiding this comment.
LGTM! thanks for applying the REviwe comments :)
Summary
Part of #13046: The
grover_operatoras function.Details and comments
This function is similar to the
GroverOperator, but does not require choosing the implementation of the multi-controlled X gate a-priori and let's the compiler choose the optimal decomposition instead.