-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add testing helper for consistent channel/mixture #5247
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
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.
Could we also add similar for mixture ?
Related: #4365 |
def assert_consistent_channel(gate: Any, rtol: float = 1e-5, atol: float = 1e-8): | ||
assert cirq.has_kraus(gate), f"Given gate {gate!r} does not return True cirq.has_kraus." | ||
kraus_ops = cirq.kraus(gate) | ||
assert cirq.is_cptp(kraus_ops=kraus_ops, rtol=rtol, atol=atol), ( | ||
f"Kraus operators for {gate!r} did not sum to identity up to expected tolerances. " | ||
f"Summed to {sum(m.T.conj() @ m for m in kraus_ops)}" | ||
) |
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.
Please also add tests for has_mixture and mixture.
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 is now done
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
Adds a helper that tests that channel kraus operator is cptp (\sum_i A_i^\dagger A_i = I) and that has_kraus is true. Uses this on channels. Adds a helper for testing that mixture's probabilities sum to 1. Uses this on mixtures. Fixes quantumlib#2271
Adds a helper that tests that channel kraus operator is cptp (\sum_i A_i^\dagger A_i = I) and that has_kraus is true. Uses this on channels. Adds a helper for testing that mixture's probabilities sum to 1. Uses this on mixtures. Fixes quantumlib#2271
Adds a helper that tests that channel kraus operator is cptp (\sum_i A_i^\dagger A_i = I) and that has_kraus is true. Uses this on channels.
Adds a helper for testing that mixture's probabilities sum to 1. Uses this on mixtures.
Fixes #2271