-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement the inverse of IonQ native gates #5889
Implement the inverse of IonQ native gates #5889
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Thank you for this PR, Tim! Please address the failing automated checks. |
merge with updated upstream
] | ||
], | ||
) | ||
def test_gate_inverse(gate, target, phases): |
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.
Since all targets are identity, you should be able to compute the appropriate matrix inside the test.
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.
fixed
for p in [0, 0.1, 0.4, math.pi / 2, math.pi, 2 * math.pi] | ||
] | ||
+ [ | ||
(ionq.MSGate, numpy.identity(4), {"phi0": p0, "phi1": p1}) # type: ignore |
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 would it take not to ignore type checks? (Applies throughout.)
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.
I looked into how other contributors handled the same issue. Fixed now, and the ignores are removed.
"""Tests that the inverse of natives gate are correct.""" | ||
mat = cirq.protocols.unitary(gate) | ||
mat_inverse = cirq.protocols.unitary(gate**-1) | ||
num_qubits = mat.shape[0] |
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.
Actually, this isn't the number of qubits. It's the Hilbert space dimension, which is two to the power number of qubits. Perhaps
dim = mat.shape[0]
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.
thanks for the catch! Fixed.
Thank you, Tim! :-) |
Implement the inverse of IonQ's native gates, GPIGate, GPI2Gate and MSGate, by implementing `__pow__` method for `power==-1`.
Implement the inverse of IonQ's native gates, GPIGate, GPI2Gate and MSGate, by implementing
__pow__
method forpower==-1
.