-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Set multiprocessing to spawn for Linux #7804
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
Conversation
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.
Pull Request Overview
This PR aims to fix random failures in multiprocess sampling on Linux by forcing the multiprocessing start method to "spawn".
- Added a platform check for Linux
- Configured the multiprocessing start method to "spawn" when importing the mcmc module
We should be very careful about doing this change as it has been working for decades now just fine and it's the fastest form of starting multiprocessing. Are you doing this because of JAX? Because JAX is still pretty useless without special handling on our side. |
Also there's at least one known issue with spawn: #7790 |
That issue appears to be restricted to MacOS. At the moment I have to manually switch to spawn on pretty much every model I run because it fails so frequently. Do we have any reports of failure using spawn on Linux? |
Can you show some code to see if anybody can reproduce, before changing for everyone? This multiprocessing thing is something I see people come and flip flop around because it fails on their machine, then someone comes and puts it back because the new one fails on their machine. I don't think the issue I linked is due to mac, but due to spawn which mac uses by default. If we make that default in Linux we would also see it. It's just an example of something subtle that may break for existing users who have no problem with fork. Also I think you can change the default python method once and that's what pymc would use? |
Description
Multiprocess sampling often fails randomly on Linux due to the start method defaulting to "fork". This sets it to "spawn" when
mcmc
is imported.Related Issue
Checklist
Type of change
📚 Documentation preview 📚: https://pymc--7804.org.readthedocs.build/en/7804/