Skip to content

Introduce torch_xla.launch()#7648

Merged
zpcore merged 4 commits intomasterfrom
piz/launch
Jul 12, 2024
Merged

Introduce torch_xla.launch()#7648
zpcore merged 4 commits intomasterfrom
piz/launch

Conversation

@zpcore
Copy link
Copy Markdown
Member

@zpcore zpcore commented Jul 9, 2024

Draft of using torch_xla.launch() for torchrun and xmp.spawn()

Unify _mp_fn(xu.getenv_as(xenv.LOCAL_RANK, int), FLAGS) (call with torchrun) or
xmp.spawn(_mp_fn, args=(FLAGS,), nprocs=FLAGS.num_cores)
with

torch_xla.launch(_mp_fn, args=(FLAGS,) , nprocs=FLAGS.num_cores)

@zpcore zpcore changed the title experimental Introduce torch_xla.launch() Jul 9, 2024
@zpcore zpcore marked this pull request as ready for review July 11, 2024 01:16
@zpcore zpcore requested review from JackCaoG and will-cromar July 11, 2024 01:22
Comment thread torch_xla/launch.py Outdated
Comment thread torch_xla/launch.py Outdated
Comment thread torch_xla/launch.py Outdated
Comment thread examples/data_parallel/train_resnet_ddp.py Outdated
Comment thread torch_xla/launch.py Outdated
Comment thread torch_xla/launch.py Outdated
Copy link
Copy Markdown
Collaborator

@will-cromar will-cromar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you for implementing this 😄

def __init__(self):
super().__init__()
dist.init_process_group('xla', init_method='xla://')
super().__init__()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should the super init stay at the top?

Copy link
Copy Markdown
Member Author

@zpcore zpcore Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, super().__init__() will call some functions from runtime, which needs init the TPU backend first.

Comment thread torch_xla/torch_xla.py
@zpcore zpcore merged commit 5b8e8e0 into master Jul 12, 2024
@zpcore zpcore deleted the piz/launch branch July 24, 2024 23:27
@miladm miladm added the usability Bugs/features related to improving the usability of PyTorch/XLA label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

usability Bugs/features related to improving the usability of PyTorch/XLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants