-
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 error in Target non-global operation method with ideal gates #7554
Conversation
This commit fixes an issue in the Target get_non_global_operation_names() method. Previously this method would crash when you had a target with it's instruction properties set to None (which is typically used for an ideal simulator).
Pull Request Test Coverage Report for Build 1740055295
💛 - Coveralls |
This commit fixes an issue when running transpile() with a BackendV2 based backend that has ideal operation defined in it's target. A Target that has an operation with its qargs set as None means it's ideally defined on all qubits (or all combinations of qubits for >1 qubit operations). However, the pre-processing of the target in the transpile() method was not taking this into account and would fail if a backend with this set was used.
In the previous commit there were some issues in the tweaks made to the transpile() function to parse the timing_constraints argument. The basic flow we wanted for the standalone target case is to create a TimingConstraints object directly from that Target. However, the internal function was expect only a dict was passed in and tried to create a TimingConstraints object from it. The previous commit tried to address this but neglected the standard use with a dict. This commit corrects this oversight and tweaks the logic to handle a predefined TimingConstraint object first and then fallsback to the other behavior.
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.
This all looks sensible to me. Good to plug the gaps in testing that we must have let slip through the first time.
if target is not None: | ||
if coupling_map is None: | ||
coupling_map = target.coupling_map() | ||
coupling_map = target.build_coupling_map() | ||
if basis_gates is None: | ||
basis_gates = target.operation_names() | ||
basis_gates = target.operation_names |
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.
If there were type hints in this function, pylint
would have caught this ;)
* Fix error in Target non-global operation method with ideal gates This commit fixes an issue in the Target get_non_global_operation_names() method. Previously this method would crash when you had a target with it's instruction properties set to None (which is typically used for an ideal simulator). * Fix issue with transpile() on BackendV2 with ideal operation This commit fixes an issue when running transpile() with a BackendV2 based backend that has ideal operation defined in it's target. A Target that has an operation with its qargs set as None means it's ideally defined on all qubits (or all combinations of qubits for >1 qubit operations). However, the pre-processing of the target in the transpile() method was not taking this into account and would fail if a backend with this set was used. * Tweak timing constraints parsing in transpile() In the previous commit there were some issues in the tweaks made to the transpile() function to parse the timing_constraints argument. The basic flow we wanted for the standalone target case is to create a TimingConstraints object directly from that Target. However, the internal function was expect only a dict was passed in and tried to create a TimingConstraints object from it. The previous commit tried to address this but neglected the standard use with a dict. This commit corrects this oversight and tweaks the logic to handle a predefined TimingConstraint object first and then fallsback to the other behavior. (cherry picked from commit fe5acd4)
…) (#7561) * Fix error in Target non-global operation method with ideal gates This commit fixes an issue in the Target get_non_global_operation_names() method. Previously this method would crash when you had a target with it's instruction properties set to None (which is typically used for an ideal simulator). * Fix issue with transpile() on BackendV2 with ideal operation This commit fixes an issue when running transpile() with a BackendV2 based backend that has ideal operation defined in it's target. A Target that has an operation with its qargs set as None means it's ideally defined on all qubits (or all combinations of qubits for >1 qubit operations). However, the pre-processing of the target in the transpile() method was not taking this into account and would fail if a backend with this set was used. * Tweak timing constraints parsing in transpile() In the previous commit there were some issues in the tweaks made to the transpile() function to parse the timing_constraints argument. The basic flow we wanted for the standalone target case is to create a TimingConstraints object directly from that Target. However, the internal function was expect only a dict was passed in and tried to create a TimingConstraints object from it. The previous commit tried to address this but neglected the standard use with a dict. This commit corrects this oversight and tweaks the logic to handle a predefined TimingConstraint object first and then fallsback to the other behavior. (cherry picked from commit fe5acd4) Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This commit fixes an issue in the Target
get_non_global_operation_names() method. Previously this method would
crash when you had a target with it's instruction properties set to
None (which is typically used for an ideal simulator).
Details and comments