Skip to content

Commit 5467799

Browse files
committed
[monarch] use spawn as multiprocessing start method
Pull Request resolved: #564 Always use spawn as a start method, fork is a giant footgun. We were observing hangs in megatron checkpointing, I suspect this is why. Ref: python/cpython#84559 Differential Revision: [D78465499](https://our.internmc.facebook.com/intern/diff/D78465499/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D78465499/)! ghstack-source-id: 296751863
1 parent ef2f78a commit 5467799

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/monarch/_src/actor/bootstrap_main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import logging
1414
import os
1515
import sys
16+
import multiprocessing
1617

1718
# Import torch to avoid import-time races if a spawned actor tries to import torch.
1819
try:
@@ -63,4 +64,7 @@ def invoke_main():
6364

6465

6566
if __name__ == "__main__":
67+
# Ensure that processes started via `multiprocessing` are spawned, not forked.
68+
# forking is a terrible default, see: https://github.com/python/cpython/issues/84559
69+
multiprocessing.set_start_method("spawn", force=True)
6670
invoke_main() # pragma: no cover

0 commit comments

Comments
 (0)