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

Method _launch_daemonic_procs

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

Source from the content-addressed store, hash-verified

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