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

Parallelize classical value in nonlocal games #876

Merged

Conversation

Shivansh20128
Copy link
Contributor

@Shivansh20128 Shivansh20128 commented Oct 27, 2024

Description

Adding parallelism using multiprocessing python library. Added a new function process_iteration that provides reusability of code. the parallelization is done when num_alice_outputs**num_bob_inputs is more than 1000.
#Resolves #12

Changes

  • Added a helper method to invoke multiprocessing when needed.

Checklist

Before marking your PR ready for review, make sure you checked the following locally. If this is your first PR, you might be notified of some workflow failures after a maintainer has approved the workflow jobs to be run on your PR.

Additional information is available in the documentation.

  • Use ruff for errors related to code style and formatting.
  • Verify all previous and newly added unit tests pass in pytest.
  • Check the documentation build does not lead to any failures. Sphinx build can be checked locally for any failures related to your PR
  • Use linkcheck to check for broken links in the documentation
  • Use doctest to verify the examples in the function docstrings work as expected.

Copy link

codecov bot commented Oct 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.9%. Comparing base (c32edae) to head (c66cc8f).
Report is 116 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master    #876   +/-   ##
======================================
  Coverage    97.9%   97.9%           
======================================
  Files         165     165           
  Lines        3253    3262    +9     
  Branches      713     714    +1     
======================================
+ Hits         3185    3194    +9     
  Misses         44      44           
  Partials       24      24           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shivansh20128 Shivansh20128 marked this pull request as ready for review October 27, 2024 11:33
Copy link
Owner

@vprusso vprusso left a comment

Choose a reason for hiding this comment

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

Cool! Nice work, @Shivansh20128 ! I've added a few comments and also tagged @purva-thakre to review as well.

Out of curiosity, is there any indication as to how much faster the parallel version is compared to the single-core version?

toqito/nonlocal_games/nonlocal_game.py Outdated Show resolved Hide resolved
toqito/nonlocal_games/nonlocal_game.py Show resolved Hide resolved
toqito/nonlocal_games/nonlocal_game.py Show resolved Hide resolved
toqito/nonlocal_games/nonlocal_game.py Outdated Show resolved Hide resolved
@Shivansh20128
Copy link
Contributor Author

Out of curiosity, is there any indication as to how much faster the parallel version is compared to the single-core version?

For this function, my answer would be no. But I used multiprocessing library to run this Python notebook on my system.
For the single core version, the time taken was about 25 seconds, while the parallel version took about 21 seconds.

@vprusso
Copy link
Owner

vprusso commented Oct 27, 2024

Out of curiosity, is there any indication as to how much faster the parallel version is compared to the single-core version?

For this function, my answer would be no. But I used multiprocessing library to run this Python notebook on my system.

For the single core version, the time taken was about 25 seconds, while the parallel version took about 21 seconds.

Interesting. I would have expected that the total time would have been subdivided by the number of cores on the machine, but perhaps 80 percent or so of the time is spent on the non parallelized parts of the process.

Still, since it's faster and not much boilerplate for that boost, I'll still consider that a win!

@vprusso
Copy link
Owner

vprusso commented Oct 28, 2024

Thanks for your recent adaptations to the code, @Shivansh20128 !

This LGTM, but I'll defer to @purva-thakre for the final word. Thank you again for your contributions!

@vprusso
Copy link
Owner

vprusso commented Dec 7, 2024

Thanks again, @Shivansh20128 !

@vprusso vprusso merged commit 0cb040e into vprusso:master Dec 7, 2024
18 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.

Enhancement: Parallelize classical value of nonlocal game
2 participants