transpile_swaps for Circuit and InstructionVisitor#450
Merged
thierry-martinez merged 4 commits intoTeamGraphix:masterfrom Feb 27, 2026
Merged
transpile_swaps for Circuit and InstructionVisitor#450thierry-martinez merged 4 commits intoTeamGraphix:masterfrom
transpile_swaps for Circuit and InstructionVisitor#450thierry-martinez merged 4 commits intoTeamGraphix:masterfrom
Conversation
This commit implements a function `transpile_swaps` that returns a new circuit equivalent to the original one but without SWAP gates. This commit also introduces a class `InstructionVisitor` for rewriting circuit instructions. Visitors are used in `transpile_swaps` and `map_angle`, which is now rewritten without using the type-unsafe `dataclasses.replace`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #450 +/- ##
==========================================
+ Coverage 88.09% 88.29% +0.20%
==========================================
Files 44 44
Lines 6449 6535 +86
==========================================
+ Hits 5681 5770 +89
+ Misses 768 765 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emlynsg
approved these changes
Feb 25, 2026
Contributor
emlynsg
left a comment
There was a problem hiding this comment.
I had to look up this Visitor construction, since it seems like a bit of boilerplate, but I'm convinced now it's a good way to do things.
matulni
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit implements a function
transpile_swapsthat returns a new circuit equivalent to the original one but without SWAP gates.This commit also introduces a class
InstructionVisitorfor rewriting circuit instructions. Visitors are used intranspile_swapsandmap_angle, which is now rewritten without using the type-unsafedataclasses.replace.