Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions deepspeed/utils/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ def init_distributed(dist_backend="nccl",
auto_mpi_discovery=True,
distributed_port=TORCH_DISTRIBUTED_DEFAULT_PORT,
verbose=True):
"""
Initialize torch.distributed backend, potentially performing MPI discovery if needed
"""Initialize torch.distributed backend, potentially performing MPI discovery if needed.

Arguments:
dist_backend (str): torch distributed backend, e.g., nccl, mpi, gloo
auto_mpi_discovery (bool): if distributed environment variables are not set, attempt to discover them from MPI
distributed_port (int, optional): torch distributed backend port
verbose (bool, optional): verbose logging
"""
dist_backend: torch distributed backend, e.g., nccl, mpi, gloo

auto_mpi_discovery: if distributed environment variables are not set, attempt to discover them from MPI

distributed_port: torch distributed backend port

verbose: verbose logging
"""
required_env = ["RANK", "WORLD_SIZE", "MASTER_ADDR", "MASTER_PORT", "LOCAL_RANK"]
if auto_mpi_discovery and not all(map(lambda v: v in os.environ, required_env)):
if verbose:
Expand Down
8 changes: 7 additions & 1 deletion docs/code-docs/source/initialize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ to add DeepSpeed's builtin arguments to your application's parser.

Training Initialization
-----------------------
The entrypoint for all training with DeepSpeed is ``deepspeed.initialize()``.
The entrypoint for all training with DeepSpeed is ``deepspeed.initialize()``. Will initialize distributed backend if it is not intialized already.

Example usage:

Expand All @@ -36,3 +36,9 @@ Example usage:
model_parameters=net.parameters())

.. autofunction:: deepspeed.initialize

Distributed Initialization
-----------------------
Optional distributed backend initializating separate from ``deepspeed.initialize()``. Useful in scenarios where the user wants to use torch distributed calls before calling ``deepspeed.initialize()``, such as when using model parallelism, pipeline parallelism, or certain data loader scenarios.

.. autofunction:: deepspeed.init_distributed