Skip to content

Ensure uniqueness of nodes in neighbors()#5847

Merged
mergify[bot] merged 3 commits into
Qiskit:masterfrom
delapuente:issue-5530-performance-regression-noise-adaptive
Feb 15, 2021
Merged

Ensure uniqueness of nodes in neighbors()#5847
mergify[bot] merged 3 commits into
Qiskit:masterfrom
delapuente:issue-5530-performance-regression-noise-adaptive

Conversation

@delapuente
Copy link
Copy Markdown
Contributor

Summary

Fixes #5530

Changes in #5411, to use retworkx's neighbors() function, replaces the
returned dict with an iterator. In the dict version, neighbor node indices
are the keys and therefore, they are unique. In the iterator version, node
indices appear multiple times, once per edge in multigraphs.

This commit uses a Python set to preserve the semantics of the old version
ensuring the uniqueness of the nodes.

Details and comments

Changes in Qiskit#5411, to use retworkx's neighbors() function, replaces the
returned dict with an iterator. In the dict version, neighbor node indices
are the keys and therefore, they are unique. In the iterator version, node
indices appear multiple times, once per edge in multigraphs.

This commit use a Python set to preserve the semantics of the old version
ensuring the uniqueness of the nodes.
@delapuente delapuente requested a review from a team as a code owner February 15, 2021 03:04
Copy link
Copy Markdown
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

This LGTM, it might be good to leave a comment here about why we're casting to a set. Assuming we fix the behavior on the retworkx side the set() cast will be unnecessary with a future retworkx release (and will add overhead). But not worth blocking over.

@mergify mergify Bot merged commit ede453c into Qiskit:master Feb 15, 2021
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Mar 3, 2021
In Qiskit#5847 we added a set() cast to calls to retworkx's graph neighbors
method. This was to workaround a bug in retworkx where duplicate node
indices would be returned if there were parallel edges to a successor
node. In the recent retworkx 0.8.0 release this issue has been fixed
[1][2] so there is no need to cast to a set anymore. Removing the set
cast will remove a duplicate iteration (to generate the set) over the
neighbors list, marginally improving performance.

[1] https://retworkx.readthedocs.io/en/stable/release_notes.html#bug-fixes
[2] Qiskit/rustworkx@49727f8
mergify Bot pushed a commit that referenced this pull request Mar 3, 2021
In #5847 we added a set() cast to calls to retworkx's graph neighbors
method. This was to workaround a bug in retworkx where duplicate node
indices would be returned if there were parallel edges to a successor
node. In the recent retworkx 0.8.0 release this issue has been fixed
[1][2] so there is no need to cast to a set anymore. Removing the set
cast will remove a duplicate iteration (to generate the set) over the
neighbors list, marginally improving performance.

[1] https://retworkx.readthedocs.io/en/stable/release_notes.html#bug-fixes
[2] Qiskit/rustworkx@49727f8
@kdk kdk added the Changelog: None Do not include in the GitHub Release changelog. label Mar 31, 2021
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 the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance regressions in NoiseAdaptiveLayout

3 participants