-
Notifications
You must be signed in to change notification settings - Fork 306
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 Volume Interpolator #2226
base: main
Are you sure you want to change the base?
Parallelize Volume Interpolator #2226
Conversation
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Thank you for submitting a pull request (PR) to PlasmaPy! ✨ The future of the project depends on contributors like you, so we deeply appreciate it! 🌱 Our contributor guide has information on:
The bottom of this page shows several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. 😺 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well. 🌸 You can find us in our chat room or weekly community meeting & office hours. Here are some tips:
If this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. ✅ If you don't get a review within a few days, please feel free to send us a reminder. Please also use SI units within PlasmaPy, except when there is strong justification otherwise or in some examples. We thank you once again! |
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Update requirements Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Signed-off-by: Roberts, Jayden <jaro@lle.rochester.edu>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2226 +/- ##
=======================================
Coverage 98.21% 98.21%
=======================================
Files 98 98
Lines 8568 8584 +16
=======================================
+ Hits 8415 8431 +16
Misses 153 153
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a pretty clean start! Some additional stuff I'd like to see
-
Some tests that show that this is actually faster, and under what conditions. It may be we want to have running in parallel/dask be an option and raise a warning if people use it with very small numbers of particles or something? These don't need to be CI tests, just something you run and report the results in this PR thread so we have a record of it.
-
Apply the same method to the nearest neighbor interpolator so we have it in both cases.
-
I presume this is the case since all the tests seem to be passing, but just confirm that the interpolator is giving the same result as before. If you keep 'serial' as an option, you could write a simple test that ensures that they give the same answer.
plasmapy/plasma/grids.py
Outdated
@@ -1132,60 +1133,16 @@ def nearest_neighbor_interpolator( | |||
] | |||
return output[0] if len(output) == 1 else tuple(output) | |||
|
|||
def volume_averaged_interpolator( | |||
self, pos: Union[np.ndarray, u.Quantity], *args, persistent=False | |||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even the private static method should have a docstring that defines what each of these variables is
Signed-off-by: JaydenR2305 <109694185+JaydenR2305@users.noreply.github.com>
Signed-off-by: JaydenR2305 <109694185+JaydenR2305@users.noreply.github.com>
Signed-off-by: JaydenR2305 <109694185+JaydenR2305@users.noreply.github.com>
Signed-off-by: JaydenR2305 <109694185+JaydenR2305@users.noreply.github.com>
Signed-off-by: JaydenR2305 <109694185+JaydenR2305@users.noreply.github.com>
@JaydenR2305 This SE page looks relevant: https://stackoverflow.com/questions/53351060/dask-shared-memory-in-parallel-model One comment suggests the Edit: and this link within: https://stackoverflow.com/questions/10721915/shared-memory-objects-in-multiprocessing |
I have changed from our current implementation of the volume interpolation to SciPy's which has offered a roughly 50% speed improvement. I wonder if it would be beneficial to partition the grid using some sort of octree approach and then passing the respective particles along for parallel processing? |
Hm, I'm surprised its fast but I guess the RegularGridInterpolator with the
Yes I think that's a good way to do it: the challenge is still how to share the grid across branches? Making copies would be the easiest, but could be memory prohibitive for large grids? In that case the ideal number of cores would depend both on the ncores available and on the amount of RAM available. |
Resolves #1728
Use Dask to parallelize the
volume_averaged_interpolator
method defined in theCartesianGrid
object