Skip to content

Commit cef93c7

Browse files
suofacebook-github-bot
authored andcommitted
use spawn as multiprocessing start method (#564)
Summary: 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 ghstack-source-id: 296986085 Reviewed By: highker Differential Revision: D78465499 fbshipit-source-id: e62353ffc6d5b45de688e9b846c702fce64a29f9
1 parent da21e29 commit cef93c7

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
@@ -11,6 +11,7 @@
1111
import asyncio
1212
import importlib.resources
1313
import logging
14+
import multiprocessing
1415
import os
1516
import sys
1617

@@ -64,4 +65,7 @@ def invoke_main():
6465

6566

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

0 commit comments

Comments
 (0)