Skip to content
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

Avoid Python op creation in BasisTranslator #12705

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented Jul 1, 2024

Summary

This commit updates the BasisTranslator transpiler pass. It builds off
of #12692 and #12701 to adjust access patterns in the python transpiler
path to avoid eagerly creating a Python space operation object. The goal
of this PR is to mitigate the performance regression introduced by the
extra conversion cost of #12459 on the BasisTranslator.

Details and comments

TODO:

This PR is built on top of #12692 and #12701 and will need to rebased after both merge. To view the contents of just this PR you can look at the last commit on the branch (I'll be force pushing updates to that last commit): d95ef61

@mtreinish mtreinish added on hold Can not fix yet performance Changelog: None Do not include in changelog Rust This PR or issue is related to Rust code in the repository mod: transpiler Issues and PRs related to Transpiler labels Jul 1, 2024
@mtreinish mtreinish added this to the 1.2.0 milestone Jul 1, 2024
This commit updates the BasisTranslator transpiler pass. It builds off
of Qiskit#12692 and Qiskit#12701 to adjust access patterns in the python transpiler
path to avoid eagerly creating a Python space operation object. The goal
of this PR is to mitigate the performance regression introduced by the
extra conversion cost of Qiskit#12459 on the BasisTranslator.
@mtreinish mtreinish force-pushed the py-access-rs-basis-translator branch from d95ef61 to 3ce5947 Compare July 3, 2024 18:54
@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 9783354867

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 30 of 30 (100.0%) changed or added relevant lines in 2 files are covered.
  • 11 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.01%) to 89.838%

Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/basis/basis_translator.py 1 97.7%
crates/qasm2/src/lex.rs 4 92.88%
crates/qasm2/src/parse.rs 6 97.61%
Totals Coverage Status
Change from base Build 9782487328: 0.01%
Covered Lines: 65136
Relevant Lines: 72504

💛 - Coveralls

@jakelishman
Copy link
Member

Note: this will conflict with #12730.

@mtreinish mtreinish removed the on hold Can not fix yet label Jul 10, 2024
@mtreinish mtreinish marked this pull request as ready for review July 10, 2024 12:48
@mtreinish mtreinish requested a review from a team as a code owner July 10, 2024 12:48
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core
  • @kevinhartman
  • @mtreinish

@mtreinish mtreinish changed the title [WIP] Avoid Python op creation in BasisTranslator Avoid Python op creation in BasisTranslator Jul 10, 2024
@mtreinish
Copy link
Member Author

I'm marking this as ready to review. From profiling there is still significant overhead in substitute_node_with_dag() that gets called a lot by the basis translator. While I could work on mitigating that I think between #12730 and then eventually #12550 will just take care of that. So if we need to do something for 1.2 there we can handle it in a follow up.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

I'm fine to merge this now, and I'll fix up the merge conflict in #12730. I think that #12730 will already fix very nearly all the remaining overhead in substitute_node_with_dag (all the stuff about "additional wires") around node.op creation, and the last change (an isinstance(node.op, ControlFlowOp)) is trivial.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9874529504

Details

  • 30 of 30 (100.0%) changed or added relevant lines in 2 files are covered.
  • 12 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.007%) to 89.887%

Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/basis/basis_translator.py 1 97.7%
crates/qasm2/src/lex.rs 5 93.13%
crates/qasm2/src/parse.rs 6 97.61%
Totals Coverage Status
Change from base Build 9871528102: -0.007%
Covered Lines: 65741
Relevant Lines: 73137

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue Jul 10, 2024
Merged via the queue into Qiskit:main with commit 1e8205e Jul 10, 2024
15 checks passed
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
This commit updates the BasisTranslator transpiler pass. It builds off
of Qiskit#12692 and Qiskit#12701 to adjust access patterns in the python transpiler
path to avoid eagerly creating a Python space operation object. The goal
of this PR is to mitigate the performance regression introduced by the
extra conversion cost of Qiskit#12459 on the BasisTranslator.
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 Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants