# tensorplay.distributed.elastic.multiprocessing API Source: https://www.tensorplay.cn/docs/api/tensorplay.distributed.elastic.multiprocessing.html ## Functions 2 [#](#api-tensorplay.distributed.elastic.multiprocessing.start_processes) ### start_processes function[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.start_processes.html) ```python tensorplay.distributed.elastic.multiprocessing.start_processes(*args, **kwargs) ``` [#](#api-tensorplay.distributed.elastic.multiprocessing.to_map) ### to_map function[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.to_map.html) ```python tensorplay.distributed.elastic.multiprocessing.to_map(val_or_map: Std | dict[int, Std], local_world_size: int) → dict[int, Std] ``` Expand a per-rank redirection spec into one entry per local rank. ## Classes 5 [#](#api-tensorplay.distributed.elastic.multiprocessing.PContext) ### PContext class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.PContext.html) ```python class tensorplay.distributed.elastic.multiprocessing.PContext(name: str, entrypoint: ~collections.abc.Callable | str, args: tuple, envs: dict[int, dict[str, str]], logs_specs: ~tensorplay.distributed.elastic.multiprocessing.api.LogsSpecs | None = None, log_dir: str | None = None, redirects: ~tensorplay.distributed.elastic.multiprocessing.redirects.Std | dict[int, ~tensorplay.distributed.elastic.multiprocessing.redirects.Std] = , tee: ~tensorplay.distributed.elastic.multiprocessing.redirects.Std | dict[int, ~tensorplay.distributed.elastic.multiprocessing.redirects.Std] = , log_line_prefixes: dict[int, str] | None = None, duplicate_stdout_filters: list[str] | None = None, duplicate_stderr_filters: list[str] | None = None) ``` Base class owning a homogeneous group of worker processes. ```python close(death_sig: Signals | None = None, timeout: int = 30) → None ``` Terminate all workers with death_sig, escalating to kill. ```python poll() → RunProcsResult | None ``` Return the terminal result, or None while workers are running. ```python start() → None ``` Launch all workers. ```python wait(timeout: float = -1, period: float = 1) → RunProcsResult | None ``` Block until completion (or timeout seconds); returns the result. [#](#api-tensorplay.distributed.elastic.multiprocessing.ProcessFailure) ### ProcessFailure class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.ProcessFailure.html) ```python class tensorplay.distributed.elastic.multiprocessing.ProcessFailure(local_rank: int, pid: int, exitcode: int, error_file: str | None = None, error_file_data: dict[str, Any] | None = None, message: str = '', timestamp: int = 0) ``` Structured failure of one worker process. [#](#api-tensorplay.distributed.elastic.multiprocessing.Redirects) ### Redirects class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.Redirects.html) ```python class tensorplay.distributed.elastic.multiprocessing.Redirects(stdouts: Std | dict[int, ~tensorplay.distributed.elastic.multiprocessing.redirects.Std]=, stderrs: Std | dict[int, ~tensorplay.distributed.elastic.multiprocessing.redirects.Std]=) ``` Per-stream redirection modes for a worker group. [#](#api-tensorplay.distributed.elastic.multiprocessing.RunProcsResult) ### RunProcsResult class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.RunProcsResult.html) ```python class tensorplay.distributed.elastic.multiprocessing.RunProcsResult(state: str = 'UNKNOWN', return_values: dict[int, ~typing.Any]=, failures: dict[int, ~tensorplay.distributed.elastic.multiprocessing.errors.ProcessFailure]=, stdouts: dict[int, str]=, stderrs: dict[int, str]=) ``` Outcome of monitoring a worker group to completion. ```python is_failed() → bool ``` Whether any worker failed. [#](#api-tensorplay.distributed.elastic.multiprocessing.Std) ### Std class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.Std.html) ```python class tensorplay.distributed.elastic.multiprocessing.Std(*values) ``` Which standard streams a worker’s output should go to. ```python as_integer_ratio() ``` Return a pair of integers, whose ratio is equal to the original int. The ratio is in lowest terms and has a positive denominator. ``` >>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1) ``` ```python bit_count() ``` Number of ones in the binary representation of the absolute value of self. Also known as the population count. ``` >>> bin(13) '0b1101' >>> (13).bit_count() 3 ``` ```python bit_length() ``` Number of bits necessary to represent self in binary. ``` >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` ```python conjugate() ``` Returns self, the complex conjugate of any int. ```python denominator ``` the denominator of a rational number in lowest terms ```python classmethod from_bytes(bytes, byteorder='big', *, signed=False) ``` ```python classmethod from_str(vm: str) → Std | dict[int, Std] ``` Parse to_map-style strings: 0/1/2/3 or i:j:k. The per-rank form maps rank i (or default) to a mode; both 0:1 (shorthand for 0:1:1) and full triples are accepted. ```python imag ``` the imaginary part of a complex number ```python is_integer() ``` Returns True. Exists for duck type compatibility with float.is_integer. ```python numerator ``` the numerator of a rational number in lowest terms ```python real ``` the real part of a complex number ```python to_bytes(length=1, byteorder='big', *, signed=False) ``` ## Exceptions 2 [#](#api-tensorplay.distributed.elastic.multiprocessing.ChildFailedError) ### ChildFailedError exception[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.ChildFailedError.html) ```python exception tensorplay.distributed.elastic.multiprocessing.ChildFailedError(name_or_failures: str | list[tuple[str, ProcessFailure]] | None = None, failures: dict[int, ProcessFailure] | None = None) ``` Raised by the launcher when one or more workers failed. failures is a list of (role_name, ProcessFailure) pairs so the caller can report which role failed and why. [#](#api-tensorplay.distributed.elastic.multiprocessing.SignalException) ### SignalException exception[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.multiprocessing.SignalException.html) ```python exception tensorplay.distributed.elastic.multiprocessing.SignalException(msg: str, sigval: Signals) ```