You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use HostMesh.spawn's bootstrap_command parameter to setup env vars (#3851)
In the past, the users generally use the `bootstrap` parameter to set up
the env vars. In that approach, under the hood, monarch will spawn [a
`SetupActor`](https://fburl.com/code/4yhl9t6g) on proc mesh, and run
user's `bootstrap` callable inside that actor. In order to spawn the
`SetupActor`, monarch's modules will be imported first. In rare cases,
the monarch import could race with user's callable. For example, On CUDA
12.8, we observed that `import monarch._rust_bindings` lead to
unexpected CDUA initialization, and make user's `CUDA_VISIBLE_DEVICES`
setting too late.
To solve this problem, Monarch added a `bootstrap_command` parameter to
`HostMesh.spawn`, which offers a more reliable way to set up the env
vars. More details can be found in the [monarch
doc](https://github.com/meta-pytorch/monarch/blob/main/docs/source/actors.md?fbclid=IwY2xjawSwpk5wZG9mBGV4dG4DYWVtAjExAGJyaWQRMWRnbDJXbXNxcE1PQ1JEZDNzcnRjBmFwcF9pZAEwAAEeCXQ3kpG94UCcFM00_napubs8BqgLbYoxsHFbaomJr91TOIKjCNFBpmnVA3s_aem_P7ZE0RvYHb-YeFNctT9x-w#bootstrap-command-customization).
Briefly, in this approach, user's env vars are set as part of the
process spawning. Therefore, it is immune to the import race.
Note that the old `bootstrap` parameter is still useful for non-env-var
related setup. For example, in this PR, i still use it for the `import
torch` warm up, a workaround which is necessary for the upstream's
`concurrent import` bug.
0 commit comments