-
Notifications
You must be signed in to change notification settings - Fork 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 PhasedXZGate._unitary_ #4617
Conversation
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 with some questions.
gate = cirq.PhasedXZGate.from_matrix(unitary) | ||
kraus = cirq.kraus(gate) | ||
assert len(kraus) == 1 | ||
cirq.testing.assert_allclose_up_to_global_phase(kraus[0], unitary, atol=1e-8) |
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: is this tol too high for complex64. I would've expected only around 6-7 decimal digits of reliability.
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 was copy-pasted from other allclose
checks in the same module. I'm inclined to keep it for consistency, but we could certainly relax it throughout the module if desired.
np.array([[0, 1], [1j, 0]]), | ||
], | ||
) | ||
def test_from_matrix_close_kraus(unitary: np.ndarray): |
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 add another test that hits cirq.unitary
as well ?
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.
There is already a test of cirq.unitary
: https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/ops/phased_x_z_gate_test.py#L196. This worked by decomposition even without a _unitary_
implementation, but other protocols like cirq.kraus
didn't.
Fixes #3965. Fixes #4434.