Skip to content

Fix instruction durations in transpile() with BackendV2#8001

Merged
mergify[bot] merged 4 commits into
Qiskit:mainfrom
mtreinish:fix-inst-dur-v2-transpile
May 2, 2022
Merged

Fix instruction durations in transpile() with BackendV2#8001
mergify[bot] merged 4 commits into
Qiskit:mainfrom
mtreinish:fix-inst-dur-v2-transpile

Conversation

@mtreinish
Copy link
Copy Markdown
Member

Summary

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().

Details and comments

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().
@mtreinish mtreinish added stable backport potential Make Mergify open a backport PR to the most recent stable branch on merge. Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. labels Apr 29, 2022
@mtreinish mtreinish added this to the 0.20.2 milestone Apr 29, 2022
@mtreinish mtreinish requested a review from kevinhartman April 29, 2022 21:31
@mtreinish mtreinish requested a review from a team as a code owner April 29, 2022 21:31
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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:

  • @Qiskit/terra-core

kevinhartman
kevinhartman previously approved these changes Apr 29, 2022
Copy link
Copy Markdown
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread test/python/compiler/test_transpiler.py Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 29, 2022

Pull Request Test Coverage Report for Build 2258271688

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 84.327%

Totals Coverage Status
Change from base Build 2257981816: 0.004%
Covered Lines: 54523
Relevant Lines: 64657

💛 - Coveralls

except AttributeError:
pass
backend_version = getattr(backend, "version", 0)
if backend_version <= 1:
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Member Author

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 <kevin@hart.mn>
@mergify mergify Bot merged commit 49f39e3 into Qiskit:main May 2, 2022
mergify Bot added a commit that referenced this pull request May 2, 2022
* 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)
@mtreinish mtreinish deleted the fix-inst-dur-v2-transpile branch May 2, 2022 15:24
mergify Bot added a commit that referenced this pull request May 4, 2022
…) (#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. stable backport potential Make Mergify open a backport PR to the most recent stable branch on merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants