-
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
Fix short circuit detection for basis translator #12899
Merged
Merged
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
The BasisTranslator transpiler pass has a check at the very start that is designed to return fast if there is nothing to translate; in other words if the instructions in the circuit are already a subset of instructions supported by the target. This avoid doing a lot of unecessary work to determine this later during the operation of the pass. However, this check was not correctly constructed because of a type mismatch and would only ever get triggered if the input circuit was empty. The source basis is collected as a `Set[Tuple[str, int]]` where each tuple is the name and num of qubits for each operation in the circuit. While the target basis is just a `Set[str]` for the names supported on the target. This mismatch caused the subset check to never return True unless it was empty thereby bypassing the intent of the short circuit path. This commit fixes the logic by constructing a temporary set of just the source names to evaluate whether we should return early or not.
mtreinish
added
performance
Changelog: None
Do not include in changelog
mod: transpiler
Issues and PRs related to Transpiler
labels
Aug 4, 2024
One or more of the following people are relevant to this code:
|
mtreinish
added
the
stable backport potential
The bug might be minimal and/or import enough to be port to stable
label
Aug 4, 2024
Pull Request Test Coverage Report for Build 10236733779Details
💛 - Coveralls |
I did a quick asv run and as expected this shows a performance improvement for cases where the circuit is already in the target gates, which is what happens in the large qasm benchmarks:
|
jakelishman
approved these changes
Aug 8, 2024
mergify bot
pushed a commit
that referenced
this pull request
Aug 8, 2024
The BasisTranslator transpiler pass has a check at the very start that is designed to return fast if there is nothing to translate; in other words if the instructions in the circuit are already a subset of instructions supported by the target. This avoid doing a lot of unecessary work to determine this later during the operation of the pass. However, this check was not correctly constructed because of a type mismatch and would only ever get triggered if the input circuit was empty. The source basis is collected as a `Set[Tuple[str, int]]` where each tuple is the name and num of qubits for each operation in the circuit. While the target basis is just a `Set[str]` for the names supported on the target. This mismatch caused the subset check to never return True unless it was empty thereby bypassing the intent of the short circuit path. This commit fixes the logic by constructing a temporary set of just the source names to evaluate whether we should return early or not. (cherry picked from commit fa5510c)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 8, 2024
The BasisTranslator transpiler pass has a check at the very start that is designed to return fast if there is nothing to translate; in other words if the instructions in the circuit are already a subset of instructions supported by the target. This avoid doing a lot of unecessary work to determine this later during the operation of the pass. However, this check was not correctly constructed because of a type mismatch and would only ever get triggered if the input circuit was empty. The source basis is collected as a `Set[Tuple[str, int]]` where each tuple is the name and num of qubits for each operation in the circuit. While the target basis is just a `Set[str]` for the names supported on the target. This mismatch caused the subset check to never return True unless it was empty thereby bypassing the intent of the short circuit path. This commit fixes the logic by constructing a temporary set of just the source names to evaluate whether we should return early or not. (cherry picked from commit fa5510c) Co-authored-by: Matthew Treinish <[email protected]>
eliarbel
added a commit
to eliarbel/qiskit
that referenced
this pull request
Sep 18, 2024
This is a manual backport of the change introduced in PR Qiskit#12889. It is done manually since in 0.46 we are using PyO3 version 0.19.2 which does not yet have the `Bound` concept PR Qiskit#12889 relies on in the `add_submodule` helper function. In this branch we also need to handle just a subset of submodule functions compared to the ones in Qiskit#12899.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 20, 2024
This is a manual backport of the change introduced in PR #12889. It is done manually since in 0.46 we are using PyO3 version 0.19.2 which does not yet have the `Bound` concept PR #12889 relies on in the `add_submodule` helper function. In this branch we also need to handle just a subset of submodule functions compared to the ones in #12899.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Changelog: None
Do not include in changelog
mod: transpiler
Issues and PRs related to Transpiler
performance
stable backport potential
The bug might be minimal and/or import enough to be port to stable
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
The BasisTranslator transpiler pass has a check at the very start that is designed to return fast if there is nothing to translate; in other words if the instructions in the circuit are already a subset of instructions supported by the target. This avoid doing a lot of unecessary work to determine this later during the operation of the pass. However, this check was not correctly constructed because of a type mismatch and would only ever get triggered if the input circuit was empty. The source basis is collected as a
Set[Tuple[str, int]]
where each tuple is the name and num of qubits for each operation in the circuit. While the target basis is just aSet[str]
for the names supported on the target. This mismatch caused the subset check to never return True unless it was empty thereby bypassing the intent of the short circuit path. This commit fixes the logic by constructing a temporary set of just the source names to evaluate whether we should return early or not.Details and comments