-
Notifications
You must be signed in to change notification settings - Fork 3.5k
bugfix: add support for global_ordinal
, local_ordinal
, world_size
in xla
#20872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
bugfix: add support for global_ordinal
, local_ordinal
, world_size
in xla
#20872
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #20872 +/- ##
========================================
- Coverage 87% 86% -0%
========================================
Files 268 268
Lines 23411 23451 +40
========================================
- Hits 20360 20278 -82
- Misses 3051 3173 +122 |
global_ordinal
, local_ordinal
, world_size
in xla
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for this finding!
could you pls add test to cover this new behaviour?
can this XLA be also run without TPU?
Thank you for taking the time to review. I implemented a test with mocks, because as far as I understand |
if _XLA_GREATER_EQUAL_2_1: | ||
from torch_xla import runtime as xr | ||
|
||
return xr.world_size() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! Just to clarify — shouldn't this be _XLA_GREATER_EQUAL_2_7
instead? Pls let me know if I’m missing something here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the review and suggestions!
Yes, the old methods were deprecated in 2.7, but the new methods were introduced already in 2.1. You could see it here: https://github.com/pytorch/xla/releases/tag/v2.1.0, MR#5011
world_size
: https://github.com/pytorch/xla/pull/5011/files#diff-b5151ded18fbfdf1debacf597819bd88f7954b7f67f951fa8e131340805e5df5R129global_ordinal
: https://github.com/pytorch/xla/pull/5011/files#diff-b5151ded18fbfdf1debacf597819bd88f7954b7f67f951fa8e131340805e5df5R152local_ordinal
: https://github.com/pytorch/xla/pull/5011/files#diff-b5151ded18fbfdf1debacf597819bd88f7954b7f67f951fa8e131340805e5df5R162
I did not want to introduce more flags when the current ones should do the job, hence this usage of 2.1.
I also just now ran this on Google Collab just to check if there were any differences in version 2.1, but it seems that the outputs are identical:
import torch_xla
from torch_xla import runtime as xr
import torch_xla.core.xla_model as xm
print("TORCH XLA VERSION: ", torch_xla.__version__)
assert xr.world_size() == xm.xrt_world_size()
assert xr.local_ordinal() == xm.get_local_ordinal()
assert xr.global_ordinal() == xm.get_ordinal()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, got it! Thanks a lot for the clarification, @AlexandrByzov.
I mistakenly assumed those methods got introduced in 2.7 — my bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this question, it would provide a context to this decision for others too!
Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
What does this PR do?
PyTorch XLA has deprecated several methods in PyTorch 2.7:
See here
Fixes #20852
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20872.org.readthedocs.build/en/20872/