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
undo_swaps #1960
undo_swaps #1960
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov Report
@@ Coverage Diff @@
## master #1960 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 225 226 +1
Lines 17312 17346 +34
=======================================
+ Hits 17107 17141 +34
Misses 205 205
Continue to review full report at Codecov.
|
very nice solution! |
Thanks @josh146 😊 |
[sc-11831] |
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.
Hey @KetpuntoG, thank you for contributing this transform, great idea for an optimization :)
A few minor comments below.
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Context: The
Permute
operation uses many SWAP gates to be implemented. In (#1324) a study was proposed to make this operator native todefault_qubit
in order to make the circuit more efficient. Instead, I have created a transformation that removes all the SWAP gates from the circuit by playing with the wires of the operations. I think it is a more efficient and flexible solution.Description of the Change:
With a single reading of the circuit from right to left, all SWAPS in the circuit can be eliminated.
Example:
Without
undo_swaps
:0: ──H──╭SWAP──╭SWAP──Y──┤ ⟨Z⟩
1: ──X──╰SWAP──│────────┤
2: ──────────╰SWAP─────┤
With
undo_swaps
:0: ──Y──┤ ⟨Z⟩
1: ──H──┤
2: ──X──┤
Benefits:
The computational cost of the circuit calculation is reduced.
Related GitHub Issues:
(#1324)