-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implemented 8n T complexity decomposition of LessThanEqual gate #6156
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
Conversation
@mpharrigan this is now ready for review @babbush @Strilanc fyi this is an implementation of your design. |
if context is None: | ||
context = cirq.DecompositionContext(cirq.ops.SimpleQubitManager()) | ||
|
||
P, Q, target = (qubits[: self.x_bitsize], qubits[self.x_bitsize : -1], qubits[-1]) |
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.
can we use pep8 variable names here
why are we not using GateWithRegisters
?
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 gate was created as a cirq.ArithmeticGate, should I change that?
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.
It can be done later, but I think would work nicely here since you manually have to segregate the qubits into registers during decomposte at present.
this is ready for another look @mpharrigan |
if d == 0: | ||
return infra.TComplexity(t=8 * n - 4, clifford=46 * n - 17) | ||
elif d == 1: | ||
return infra.TComplexity(t=8 * n, clifford=46 * n + 3 + 2 * is_second_longer) | ||
else: | ||
return infra.TComplexity( | ||
t=8 * n + 4 * d - 4, clifford=46 * n + 17 * d - 14 + 2 * is_second_longer | ||
) |
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.
bump
def _has_unitary_(self): | ||
return True |
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.
bump
# TODO: Do not decompose {cq.And, cq.LessThanEqualGate, cq.LessThanGate} because the | ||
# `cq.map_clean_and_borrowable_qubits` currently gets confused and is not able to re-map qubits | ||
# optimally; which results in a higher number of ancillas thus the tests fails due to OOO. |
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.
bump
@mpharrigan this is ready for another look |
|
||
from cirq._compat import cached_property |
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.
question: why can't we use functools.cached_property
in cirq?
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.
Fix all the links to the referenced paper, but LGTM
@@ -130,6 +131,147 @@ def _t_complexity_(self) -> infra.TComplexity: | |||
) | |||
|
|||
|
|||
@attr.frozen | |||
class BiQubitsMixer(infra.GateWithRegisters): | |||
"""Implements the COMPARE2 (Fig. 1) https://www.nature.com/articles/s41534-018-0071-5#Sec8 |
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 links to the acknowledgements section lol. Please remove the #Sec8
.
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.
sec8
is the "Electronic supplementary material" which is where the decomposition is. it's not part of the main paper but is in the supplementary material
This is the Comparison Oracle from https://static-content.springer.com/esm/art%3A10.1038%2Fs41534-018-0071-5/MediaObjects/41534_2018_71_MOESM1_ESM.pdf