[FSDP tests] Fork CPU ranks from a forkserver instead of spawning them (#50444)
* [FSDP tests] Fork CPU ranks from a forkserver instead of spawning them
On CPU, start the FSDP test ranks from a forkserver that has preloaded the test module, so they share the imports
(torch, transformers, the testing utils, ~450 MB per rank) instead of redoing them. `spawn` is kept on accelerators
and outside Linux. Plain `fork` is not used: the pytest(-xdist) process has already used its OpenMP thread pool,
which deadlocks the first parallel op of a forked child.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address review: reuse device type helper, shorter docstring, mp.set_forkserver_preload
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Co-authored-by: Ferdinand Mom <47445085+3outeille@users.noreply.github.com>