MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / _launch_daemonic_procs

Method _launch_daemonic_procs

tests/unit/common.py:194–231  ·  view source on GitHub ↗
(self, num_procs, init_method)

Source from the content-addressed store, hash-verified

192 return fixture_kwargs
193
194 def _launch_daemonic_procs(self, num_procs, init_method):
195 # Create process pool or use cached one
196 master_port = None
197
198 if get_accelerator().device_name() == 'hpu':
199 if self.reuse_dist_env:
200 print("Ignoring reuse_dist_env for hpu")
201 self.reuse_dist_env = False
202
203 if self.reuse_dist_env:
204 if num_procs not in self._pool_cache:
205 self._pool_cache[num_procs] = mp.Pool(processes=num_procs)
206 master_port = get_master_port()
207 pool = self._pool_cache[num_procs]
208 else:
209 pool = mp.Pool(processes=num_procs)
210 master_port = get_master_port()
211
212 # Run the test
213 args = [(local_rank, num_procs, master_port, init_method) for local_rank in range(num_procs)]
214 skip_msgs_async = pool.starmap_async(self._dist_run, args)
215
216 try:
217 skip_msgs = skip_msgs_async.get(self.exec_timeout)
218 except mp.TimeoutError:
219 # Shortcut to exit pytest in the case of a hanged test. This
220 # usually means an environment error and the rest of tests will
221 # hang (causing super long unit test runtimes)
222 pytest.exit("Test hanged, exiting", returncode=1)
223 finally:
224 # Regardless of the outcome, ensure proper teardown
225 # Tear down distributed environment and close process pools
226 self._close_pool(pool, num_procs)
227
228 # If we skipped a test, propagate that to this process
229 if any(skip_msgs):
230 assert len(set(skip_msgs)) == 1, "Multiple different skip messages received"
231 pytest.skip(skip_msgs[0])
232
233 def _launch_non_daemonic_procs(self, num_procs, init_method):
234 assert not self.reuse_dist_env, "Cannot reuse distributed environment with non-daemonic processes"

Callers 3

_launch_procsMethod · 0.95
_launch_procsMethod · 0.80
_launch_procsMethod · 0.80

Calls 5

_close_poolMethod · 0.95
get_acceleratorFunction · 0.90
get_master_portFunction · 0.85
device_nameMethod · 0.45
getMethod · 0.45

Tested by 2

_launch_procsMethod · 0.64
_launch_procsMethod · 0.64