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:
|
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.
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.
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 <kevin@hart.mn>
* 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 <kevin@hart.mn> Co-authored-by: Kevin Hartman <kevin@hart.mn> 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 <kevin@hart.mn> Co-authored-by: Kevin Hartman <kevin@hart.mn> 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 <mtreinish@kortar.org> Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Summary
When running
transpile()withBackendV2based 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
BackendV2based backends and using those instruction durationsby default for
transpile().Details and comments