-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 ContractIdleWiresInControlFlow
optimisation pass
#13779
Open
jakelishman
wants to merge
2
commits into
Qiskit:main
Choose a base branch
from
jakelishman:control-flow/strip-data-dependency
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add ContractIdleWiresInControlFlow
optimisation pass
#13779
jakelishman
wants to merge
2
commits into
Qiskit:main
from
jakelishman:control-flow/strip-data-dependency
Conversation
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
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 13419299916Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This transpiler pass removes data dependencies on idle qubits from control-flow operations. For example, given a circuit such as:: from qiskit.circuit import QuantumCircuit qc = QuantumCircuit(1, 1) qc.x(0) with qc.if_test((qc.clbits[0], True)): qc.x(0) qc.x(0) qc.x(0) the current optimisation passes will collapse the inner control-flow block to the identity, but the qubit dependency will remain, preventing the outer two X gates from being cancelled. This pass removes the now-spurious dependency, making it possible to detect and remove the two X gates in a follow-up loop iteration. As an accidental side-effect of their algorithms, the control-flow-aware routing passes currently do this when they run. This aims to move the logic into a suitable place to run before routing (so the spurious dependency never arises in routing in the first place) and in the low-level optimisation stage. The aim of this pass is also to centralise the logic, so when the addition of the new `box` scope with different semantics around whether a wire is truly idle in the box or not, the routers aren't accidentally breaking them, and it's clearer when the modifications happen.
c3ba4bf
to
ff133cf
Compare
Rebased over main and no longer on hold. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Changelog: New Feature
Include in the "Added" section of the changelog
mod: transpiler
Issues and PRs related to Transpiler
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.
Summary
This transpiler pass removes data dependencies on idle qubits from control-flow operations. For example, given a circuit such as::
the current optimisation passes will collapse the inner control-flow block to the identity, but the qubit dependency will remain, preventing the outer two X gates from being cancelled. This pass removes the now-spurious dependency, making it possible to detect and remove the two X gates in a follow-up loop iteration.
As an accidental side-effect of their algorithms, the control-flow-aware routing passes currently do this when they run. This aims to move the logic into a suitable place to run before routing (so the spurious dependency never arises in routing in the first place) and in the low-level optimisation stage.
The aim of this pass is also to centralise the logic, so when the addition of the new
box
scope with different semantics around whether a wire is truly idle in the box or not, the routers aren't accidentally breaking them, and it's clearer when the modifications happen.Details and comments
Built on top of #13774, since it's very convenient to have that method for writing the tests. This is one part of #13768.
I haven't hooked this up to the preset pass-managers in this commit; I wanted to do that after #13768 is fixed properly and potentially once
box
itself has landed.