-
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 instruction durations in transpile() with BackendV2 #8001
Conversation
When running transpile() with BackendV2 based backends the instruction durations property from the backend would not be processed correctly resulting in the absence of the default durations for instructions supported on the target backend. This commit fixes this by correctly handling BackendV2 based backends and using those instruction durations by default for transpile().
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
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.
LGTM
Pull Request Test Coverage Report for Build 2258271688
💛 - Coveralls |
except AttributeError: | ||
pass | ||
backend_version = getattr(backend, "version", 0) | ||
if backend_version <= 1: |
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.
We have added a lot of these in different places. I wonder if there is a better way to handle the versions better than if-else statements. I imagine it would be very tedious to update these code (and may miss some) when we have a newer version of backend.
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.
The way the transpile function is structured right now there isn't really a better way to handle this. I think in the near term I'm going to look at rewriting how we pass backend information to the pass managers here and use a Target
as the single object we pass to the pass manager constructor. As I agree this code is super hard to deal with (not just for this reason, but also because it makes things like #7789 hard too) and very error prone.
Co-authored-by: Kevin Hartman <[email protected]>
* Fix instruction durations in transpile() with BackendV2 When running transpile() with BackendV2 based backends the instruction durations property from the backend would not be processed correctly resulting in the absence of the default durations for instructions supported on the target backend. This commit fixes this by correctly handling BackendV2 based backends and using those instruction durations by default for transpile(). * Update test/python/compiler/test_transpiler.py Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 49f39e3)
…) (#8010) * Fix instruction durations in transpile() with BackendV2 (#8001) * Fix instruction durations in transpile() with BackendV2 When running transpile() with BackendV2 based backends the instruction durations property from the backend would not be processed correctly resulting in the absence of the default durations for instructions supported on the target backend. This commit fixes this by correctly handling BackendV2 based backends and using those instruction durations by default for transpile(). * Update test/python/compiler/test_transpiler.py Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 49f39e3) * Handle still-supported BaseBackend for 0.20 * Fix handling of legacy base backend version Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Jake Lishman <[email protected]>
Summary
When running
transpile()
withBackendV2
based backends the instructiondurations property from the backend would not be processed correctly
resulting in the absence of the default durations for instructions
supported on the target backend. This commit fixes this by correctly
handling
BackendV2
based backends and using those instruction durationsby default for
transpile()
.Details and comments