Skip to content

Add parallelism to cloness_centrality #1392

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

Merged
merged 26 commits into from
Apr 9, 2025

Conversation

IvanIsCoding
Copy link
Collaborator

This PR makes closeness_centrality and newman_weighted_closeness_centrality parallel for better performance. This is possible because the task is embarrassingly parallel.

We probably missed this in #593 but #1385 reminded me of it.

The parallelism is toggled via the parallel_threshold just like other centrality methods.

@coveralls
Copy link

coveralls commented Feb 28, 2025

Pull Request Test Coverage Report for Build 14346065276

Details

  • 89 of 89 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 95.84%

Totals Coverage Status
Change from base Build 14345039299: 0.5%
Covered Lines: 18637
Relevant Lines: 19446

💛 - Coveralls

@IvanIsCoding
Copy link
Collaborator Author

Because #1387, I added a test to boost the coverage in the report. I am confident the Rust tests guarantee the correctness so for now that is a stop gap

@IvanIsCoding IvanIsCoding added this to the 0.17.0 milestone Mar 1, 2025
Copy link
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 makes a lot of sense to run this with rayon. Thanks for doing this. I just left a couple of comments inline the main one is I think we can do this without a mutex using a rayon iterator collection into the vec which should be faster..

@IvanIsCoding IvanIsCoding requested a review from mtreinish March 19, 2025 12:52
Copy link
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.

Overall this looks much better to me now, thanks for making the change. I just had a couple of small inline comments about the release notes and the docstring updates. But code-wise I think this is good to go.

@IvanIsCoding IvanIsCoding requested a review from mtreinish April 8, 2025 03:39
Copy link
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.

I think this looks fine now, besides the lint failure. The RAYON_NUM_THREADS doesn't look like it's in the Python docs though, we normally document it there too because it's an env variable and works from python too.

@IvanIsCoding
Copy link
Collaborator Author

Let me update the Python docs and fix the formatting

@IvanIsCoding IvanIsCoding requested a review from mtreinish April 8, 2025 22:20
@mtreinish mtreinish added this pull request to the merge queue Apr 9, 2025
Merged via the queue into Qiskit:main with commit 08c21ec Apr 9, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants