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 overhead for synthesized nodes lookup (backport #13424) #13425

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 12, 2024

Summary

After #12550 a hash implementation was added to the implementation of DAGOpNode to be able to have identical instances of dag nodes used be usable in a set or dict. This is because after #12550 changed the DAGCircuit so the DAGOpNode instances were just a python view of the data contained in the nodes of a dag. While prior to #12550 the actual DAGOpNode objects were returned by reference from DAG methods. However, this hash implementation has additional overhead compared to the object identity based version used before. This has caused a regression in some cases for high level synthesis when it's checking for nodes it's already synthesized. This commit addresses this by changing the dict key to be the node id instead of the node object. The integer hashing is significantly faster than the object hashing.

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

After #12550 a hash implementation was added to the implementation
of DAGOpNode to be able to have identical instances of dag nodes used be
usable in a set or dict. This is because after #12550 changed the
DAGCircuit so the DAGOpNode instances were just a python view of the
data contained in the nodes of a dag. While prior to #12550 the actual
DAGOpNode objects were returned by reference from DAG methods. However,
this hash implementation has additional overhead compared to the object
identity based version used before. This has caused a regression in some
cases for high level synthesis when it's checking for nodes it's already
synthesized. This commit addresses this by changing the dict key to be
the node id instead of the node object. The integer hashing is
significantly faster than the object hashing.

(cherry picked from commit 8c6ad02)
@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 Nov 12, 2024
@github-actions github-actions bot added this to the 1.3.0 milestone Nov 12, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11803930745

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 16 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 88.919%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.2%
crates/qasm2/src/lex.rs 3 92.48%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 11750990714: -0.01%
Covered Lines: 79051
Relevant Lines: 88902

💛 - Coveralls

@mtreinish mtreinish added this pull request to the merge queue Nov 12, 2024
Merged via the queue into stable/1.3 with commit 0e8414b Nov 12, 2024
20 checks passed
@mtreinish mtreinish deleted the mergify/bp/stable/1.3/pr-13424 branch November 21, 2024 11:36
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.

3 participants