-
Notifications
You must be signed in to change notification settings - Fork 990
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
Add cirq.QubitPermutationGate #3298
Conversation
|
||
|
||
@value.value_equality | ||
class QubitPermutationGate(raw_types.Gate): |
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.
Out of scope for this PR: I initially thought this would be a gate that permutes computational basis. Instead, it permutes qubits which is a less general operation. I think we should also implement the former, but not necessarily in this PR. I guess the reason to have both is that QubitPermutationGate has an efficient _apply_unitary_
.
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 agree. I was just following almost mechanically @mpharrigan's requirements from #2671 - thus this one is the same as the quirk gate minus the name + id. Having a permutation gate on the computational basis states might be 1) valuable for use cases (although I'm not aware of those just yet) 2) an even better option to consolidate the permutation gate hierarchy in the contrib.aqcuaintance package.
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.
Regarding use-cases of the more general permutation gate: unitary corresponding to any bijective function from n-bitstrings to n-bitstrings (including e.g. arithmetic operations) is a permutation matrix. This may not be sufficient grounds for a generic permutation gate since it's reasonable to implement specific gates for such operations instead.
We can defer until we see more use-cases.
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 one comment. Feel free to go ahead and merge once addressed.
Adds cirq.QubitPermutationGate. This is a refactor of cirq.interop.quirk.QuirkPermutationGate.
I also pulled out testing utilities for it from the quirk pacakge into
cirq.testing.assert_equivalent_computational_basis_map
.Fixes #2671.