-
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
Reuse parameterless gates in Optimize1qGatesDecomposition #10986
Closed
+8
−3
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
This commit is a small optimization inside the Optimize1qGatesDecomposition pass. The last stage of the pass is taking a circuit sequence and using it to construct an equivalent 1q dag. To do this the pass iterates over the returned circuit sequence from the 1q synthesis routine and looks up the gate name in a mapping to gate classes, and creates a new object of that class with any angles provided. However, for XGate and SXGate there are no angles, and since Qiskit#10314 merged there is extra overhead with the repeated construction of these gate classes (see Qiskit#10867 for more details). Since these gates are now singletons since Qiskit#10314 it is safe to just reuse the same instance because calling XGate() will return that instance anyway. This commit updates the DAGCircuit construction to just reuse the same instance if the gate in circuit sequence is for x or sx.
One or more of the the following people are requested to review this:
|
Asv isn't showing any performance improvement here, but I'm starting to doubt that we're catching anything useful with the asv benchmarks in their current form (also the ripple adder benchmarks are broken because they do
|
mtreinish
changed the title
Reuse paramterless gates in Optimize1qGatesDecomposition
Reuse parameterless gates in Optimize1qGatesDecomposition
Oct 12, 2023
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.
Summary
This commit is a small optimization inside the Optimize1qGatesDecomposition pass. The last stage of the pass is taking a circuit sequence and using it to construct an equivalent 1q dag. To do this the pass iterates over the returned circuit sequence from the 1q synthesis routine and looks up the gate name in a mapping to gate classes, and creates a new object of that class with any angles provided. However, for XGate and SXGate there are no angles, and since #10314 merged there is extra overhead with the repeated construction of these gate classes (see #10867 for more details). Since these gates are now singletons since #10314 it is safe to just reuse the same instance because calling XGate() will return that instance anyway. This commit updates the DAGCircuit construction to just reuse the same instance if the gate in circuit sequence is for x or sx.
Details and comments