-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 control flow to CommutativeCancellation pass #9143
Merged
mtreinish
merged 20 commits into
Qiskit:main
from
ewinston:controlflow/commutative_cancellation
Jul 18, 2023
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
760fbfc
add initial tests
ewinston aeb571e
tests passing
ewinston dfb8d31
Merge branch 'main' into controlflow/commutative_cancellation
ewinston 450e678
remove debug code
ewinston 935d787
Merge branch 'main' into controlflow/commutative_cancellation
ewinston ad93783
fix test for clbits
ewinston 292b0d7
formatting
ewinston 02036f0
Merge branch 'main' into controlflow/commutative_cancellation
jlapeyre 6f30dcf
Merge branch 'main' into controlflow/commutative_cancellation
jlapeyre 893c2c1
Lift creation of PassManager out of loop
jlapeyre 68a8fce
Test commutative cancellation does not cross block boundaries
jlapeyre b6cdab4
Add release note for commutative cancellation in control flow blocks
jlapeyre 0616274
Include CommutativeAnalysis pass explicitly when doing control flow b…
jlapeyre f8c2aaf
Use existing CommutativeCancellation pass in control flow op blocks
jlapeyre 6cce375
Move import of PassManager from method to top of file
jlapeyre cdb6d60
Revert commit f8c2aaf because I missed a fix already to go
jlapeyre 074fb21
Update qiskit/transpiler/passes/optimization/commutative_cancellation.py
jlapeyre 433ac38
Merge branch 'main' into controlflow/commutative_cancellation
jlapeyre eeab1c6
Merge branch 'main' into controlflow/commutative_cancellation
mtreinish 3906813
Merge branch 'main' into controlflow/commutative_cancellation
jlapeyre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
8 changes: 8 additions & 0 deletions
8
releasenotes/notes/add-control-flow-to-commutative-cancellation-pass-85fe310d911d9a00.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
features: | ||
- | | ||
Enabled performing the :class:`qiskit.transpiler.passes.CommutativeCancellation` pass inside the | ||
blocks of :class:`qiskit.circuit.ControlFlowOp`. This pass reorders some commuting gates and | ||
reduces resulting pairs of self-inverse gates. Previously, the blocks in control flow operations | ||
were skipped by this pass. The new feature operates recursively, that is, it will act on control | ||
flow operations inside blocks. |
This file contains 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
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.
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 was debating asking to move this to an instance scope, something like:
self.control_flow_pm
becauseCommutationAnalysis
maintains a cache of commutation relationships which might be useful between multiple runs for >1 control flow block. But my hesitation is around whether sharing the cache between the blocks is sound or not.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.
It should be safe to reuse the cache between different blocks or even runs, since all it stores are gate identities like "CX(0, 1) commutes with Z(0)"; "CX(0, 1) does not commute with S(0)", etc.. I don't know if sharing this information would lead to a performance improvement, I guess it depends how many blocks there are and how similar these are in terms of gates.
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.
Let's move forward here, we can always add this in a quick follow up without too much concern then