-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add grover_operator
function
#13365
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR code looks good, I just left a few documentation-related comments (plus reminder to fix the merge conflict).
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the amount of examples you have in the docstring, I would copy-paste one into the reno for quick reference.
@@ -125,9 +144,10 @@ def test_custom_zero_reflection(self): | |||
expected.h(0) # state_in is H | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! thanks for applying the REviwe comments :)
Summary
Part of #13046: The
grover_operator
as 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.