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

Recreate full dag instead of inplace substitution in BasisTranslator (backport #12195) #12855

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 30, 2024

Summary

This commit tweaks the internal logic of the basis translator transpiler pass to do a full dag recreation instead of inplace modification. If only a few operations were to be substituted it would probably be more efficient to do an inplace modification, but in general the basis translator ends up replacing far more operations than not. In such cases just iterating over the dag and rebuilding it is more efficient because the overhead of apply_operation_back() is minimal compared to substitute_node_with_dag() (although it's higher than subtitute_node(.., inplace=True)).

Details and comments
This is an automatic backport of pull request #12195 done by Mergify.

…12195)

* Recreate full dag instead of inplace substitution in BasisTranslator

This commit tweaks the internal logic of the basis translator transpiler
pass to do a full dag recreation instead of inplace modification. If
only a few operations were to be substituted it would probably be more
efficient to do an inplace modification, but in general the basis
translator ends up replacing far more operations than not. In such cases
just iterating over the dag and rebuilding it is more efficient because
the overhead of `apply_operation_back()` is minimal compared to
`substitute_node_with_dag()` (although it's higher than
`subtitute_node(.., inplace=True)`).

* Return boolean together with dag in 'apply_translation' to maintain original 'flow_blocks' logic and fix drawer test.

* Remove print

---------

Co-authored-by: Elena Peña Tapia <epenatap@gmail.com>
(cherry picked from commit 37b334f)
@mergify mergify bot requested a review from a team as a code owner July 30, 2024 14:53
@qiskit-bot
Copy link
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 following people are relevant to this code:

  • @Qiskit/terra-core

@github-actions github-actions bot added performance Changelog: None Do not include in changelog labels Jul 30, 2024
@github-actions github-actions bot added this to the 1.2.0 milestone Jul 30, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10164700966

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 1 file are covered.
  • 13 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 89.975%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/parse.rs 6 97.61%
crates/qasm2/src/lex.rs 7 92.11%
Totals Coverage Status
Change from base Build 10151658550: 0.01%
Covered Lines: 66360
Relevant Lines: 73754

💛 - Coveralls

@ElePT ElePT enabled auto-merge July 30, 2024 15:18
@ElePT ElePT added this pull request to the merge queue Jul 30, 2024
Merged via the queue into stable/1.2 with commit 81e8aaf Jul 30, 2024
18 checks passed
@mergify mergify bot deleted the mergify/bp/stable/1.2/pr-12195 branch July 30, 2024 18:02
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 performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants