Skip to content
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

Optimize decomposition of cirq.QubitPermutationGate #5097

Closed
tanujkhattar opened this issue Mar 18, 2022 · 2 comments · Fixed by #6588
Closed

Optimize decomposition of cirq.QubitPermutationGate #5097

tanujkhattar opened this issue Mar 18, 2022 · 2 comments · Fixed by #6588
Labels
area/decompose area/optimization Numerical optimization good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/health For CI/testing/release process/refactoring/technical debt items

Comments

@tanujkhattar
Copy link
Collaborator

Description of the issue
#5093 introduced a default decomposition for cirq.QubitPermutationGate using odd-even sort to decompose the gate into minimum number of adjacent swap operations.

We should optimize this decomposition assuming all to all connectivity and minimizing resulting circuit depth.

Cirq version
0.14dev

@tanujkhattar tanujkhattar added kind/health For CI/testing/release process/refactoring/technical debt items area/decompose area/optimization Numerical optimization labels Mar 18, 2022
@dstrain115 dstrain115 added the good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" label Feb 9, 2024
@migueltorrescosta
Copy link
Contributor

I'd like to take on this task. Before working on a solution, are there recommended / standardized ways to solve this issue? If not I'd be keen on developing my own :)

@NoureldinYosri
Copy link
Collaborator

the optimal number of swaps needed to sort a permuation = n - number of cycles. The standard way to sort permutations using swaps is to break down the permutation into cycles and then sort each cycles using cycle_length - 1 swaps. for example if the permuation is (1, 3, 2) then the cycles are (1,) and (2, 3) the first cycle is already sorted but the the second cycle needs one swap operation.

another example is (7, 6, 4, 5, 3, 4, 1, 10, 8, 9) in this cases the cycles are (1, 7), (2, 6, 4, 5, 3), (8, 10, 9) the first one needs 1 swap, the second needs 4 swaps (2, 6), (2, 4), (2, 5), (2, 3) the third one needs two swaps (8, 10) (8, 9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/decompose area/optimization Numerical optimization good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/health For CI/testing/release process/refactoring/technical debt items
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants