Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
set pg names
  • Loading branch information
tushar00jain committed Oct 29, 2025
commit 7e6afe5c2eb4dbd6d02f16f19f3170390c2b912c
3 changes: 2 additions & 1 deletion torchtitan/distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def maybe_enable_amp(


def init_distributed(
comm_config: CommConfig, enable_cpu_backend: bool = False, base_folder: str = ""
comm_config: CommConfig, enable_cpu_backend: bool = False, base_folder: str = "", ranks: list[int] = []
):
def _warn_overwrite_env(env, val):
if env in os.environ:
Expand Down Expand Up @@ -276,6 +276,7 @@ def _get_distributed_backend(enable_cpu_backend):
torch.distributed.init_process_group(
backend=_get_distributed_backend(enable_cpu_backend),
timeout=timedelta(seconds=comm_config.init_timeout_seconds),
_ranks=ranks,
)


Expand Down
10 changes: 10 additions & 0 deletions torchtitan/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ def __init__(self, job_config: JobConfig):
# Device has to be set before creating TorchFT manager.
device_module.set_device(self.device)

ranks = []
ft_config = job_config.fault_tolerance
if ft_config.enable:
group_size = ft_config.group_size
replica_id = ft_config.replica_id
first_rank = replica_id * group_size
last_rank = first_rank + group_size - 1
ranks = list(range(first_rank, last_rank + 1))

# init distributed and build meshes
dist_utils.init_distributed(
job_config.comm,
enable_cpu_backend=job_config.training.enable_cpu_offload,
base_folder=job_config.job.dump_folder,
ranks=ranks,
)

job_config.maybe_log()
Expand Down
Loading