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

Make dense layout algorithm deterministic when run in parallel (backport #13133) #13190

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 19, 2024

Summary

The dense layout algorithm is trying to find the densest k subgraph of the connectivity graph. To do this it performs a BFS from each node in the in graph of k nodes to determine the subgraph with the most number of edges. But in cases of ties where there are subgraphs with the same number of edges the exact output would be determined by the iteration order that we're evaluating a BFS search. However, this algorithm runs in parallel in most cases and the exact iteration order isn't going to be stable when running in parallel. It will depend on which threads finish first. This commit fixes this potential non-determinism in the algorithm by defaulting to the lower node index's trial results instead of relying on the execution order. This should mean we return identical results regardless of how many threads are run or how quickly they execute.

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

* Make dense layout algorithm deterministic when run in parallel

The dense layout algorithm is trying to find the densest k subgraph of
the connectivity graph. To do this it performs a BFS from each node in
the in graph of k nodes to determine the subgraph with the most number
of edges. But in cases of ties where there are subgraphs with the same
number of edges the exact output would be determined by the iteration
order that we're evaluating a BFS search. However, this algorithm runs
in parallel in most cases and the exact iteration order isn't going to
be stable when running in parallel. It will depend on which threads
finish first. This commit fixes this potential non-determinism in the
algorithm by defaulting to the lower node index's trial results instead
of relying on the execution order. This should mean we return identical
results regardless of how many threads are run or how quickly they
execute.

* Add release note

* Also handle the use_error case too

(cherry picked from commit 65bb09e)
@mergify mergify bot requested a review from a team as a code owner September 19, 2024 17:20
@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
  • @kevinhartman
  • @mtreinish

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository labels Sep 19, 2024
@github-actions github-actions bot added this to the 1.2.2 milestone Sep 19, 2024
@github-actions github-actions bot added the mod: transpiler Issues and PRs related to Transpiler label Sep 19, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10945840647

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 25 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 89.742%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 6 90.98%
crates/qasm2/src/parse.rs 18 96.69%
Totals Coverage Status
Change from base Build 10938909061: -0.02%
Covered Lines: 66864
Relevant Lines: 74507

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue Sep 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Sep 19, 2024
@mtreinish mtreinish added this pull request to the merge queue Sep 19, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 19, 2024
… (#13190)

* Make dense layout algorithm deterministic when run in parallel

The dense layout algorithm is trying to find the densest k subgraph of
the connectivity graph. To do this it performs a BFS from each node in
the in graph of k nodes to determine the subgraph with the most number
of edges. But in cases of ties where there are subgraphs with the same
number of edges the exact output would be determined by the iteration
order that we're evaluating a BFS search. However, this algorithm runs
in parallel in most cases and the exact iteration order isn't going to
be stable when running in parallel. It will depend on which threads
finish first. This commit fixes this potential non-determinism in the
algorithm by defaulting to the lower node index's trial results instead
of relying on the execution order. This should mean we return identical
results regardless of how many threads are run or how quickly they
execute.

* Add release note

* Also handle the use_error case too

(cherry picked from commit 65bb09e)

Co-authored-by: Matthew Treinish <[email protected]>
Merged via the queue into stable/1.2 with commit 48a961e Sep 19, 2024
18 checks passed
@mtreinish mtreinish deleted the mergify/bp/stable/1.2/pr-13133 branch September 20, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler 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