-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Set start method to fork for MacOs ARM devices #6218
Conversation
Would it break stuff for older macOS? |
I do not think so. I also tested on a 2016 Macbook Pro with i5 intel chip and it works with fork. *edit. Not sure about older operating systems, if that's what you were asking. |
After doing a little digging. Fork seemed to be the default start method for multiprocessing in MacOs (and still is for Unix) prior to python 3.8, after which they changed it to spawn (which does not work currently in pymc). There are some instances of fork crashing due to MacOs specific security features (after Os High Sierra (10.13). Which is resolved by setting The main reason for using spawn over fork is that it is safer, and it is currently the only method available to windows. I'm not sure if given the way that pymc uses multi-processing if the dangers of using fork really apply. If not using fork, then I think there's a lot more work that needs to be done to make spawn/forkserver methods working on M1 Macs. |
This seems like something users should be able to set to their liking. I'd be in favor of having a passable argument for |
Funnily enough, that is already possible in the pm.sample() method. It accepts an arg mp_ctx, which should be a multiprocessing context object. e.g. using the example model in #5339
However, as it stands, anything run on M1 mac will not work without having to define the start method as fork. Would it be better to set the default start method for ARM macs as fork and for intel macs as forkserver as before? So essentially changing the code in parallel_sampling.py to:
|
That sounds reasonable, we can always revert if that starts causing problems. Can we get some more M1 users to confirm that the model in the original issue indeed fails for everyone? |
@drbenvincent confirmed this fixed the same issue for him on a different model. I think we can merge this. |
We shouldn't merge this, but the default based on wether processor is arm or not mentioned in the last comment by the Op: #6218 (comment) |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6218 +/- ##
==========================================
- Coverage 93.58% 89.78% -3.81%
==========================================
Files 101 101
Lines 22136 22131 -5
==========================================
- Hits 20716 19870 -846
- Misses 1420 2261 +841
|
Why not? |
Changing default multiprocessing start method to "fork" for ARM Macs and leaving default "forkserver" for intel macs.
I believe @ricardoV94 wanted to change the then committed code s.t. the default for ARM Macs was specified as "fork" and and for intel Macs as "forkserver" (as it has been). I just committed the change to the code. So it can be checked/merged now if everyone is in agreement. |
@bchen93 Can you clean up the changelist in the top comment? It should mention in bugfixes what you did (use different default when on MacOS ARM). You can leave the other sections empty We use those for the automatically generated release notes. |
Done! |
The parameterization uses the variable `mu` but the docstring uses `mu` in some cases and `theta` in other cases. The fix replaces all `theta` with `mu` to match the argument name for this distribution.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
You seem to have caught unrelated changes in your PR |
Sorry about that. I reverted the commits. |
/pre-commit-run |
Thanks @bchen93! |
What is this PR about?
Fixing an issue with use of parallel sampling on M1 Macs where sampling with more than 1 core results in broken pipe error (#5339).
Changing multiprocessing context from forkserver to fork resolves this issue and does not seem to trigger issue (#3849) which was previously resolved by (#3919).
Checklist
Major / Breaking Changes
Bugfixes / New features
Setting the default multiprocessing context to "fork" for ARM Macs, and "forkserver" for intel-based Macs.
Docs / Maintenance