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.
Since all targets are identity, you should be able to compute the appropriate matrix inside the test.
| 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.
What would it take not to ignore type checks? (Applies throughout.)
There was a problem hiding this comment.
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.
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.
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.