-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #20872 +/- ##
=========================================
+ Coverage 49% 87% +38%
=========================================
Files 265 268 +3
Lines 23255 23320 +65
=========================================
+ Hits 11317 20318 +9001
+ Misses 11938 3002 -8936 |
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 |
Co-authored-by: Bhimraj Yadav <[email protected]>
Co-authored-by: Bhimraj Yadav <[email protected]>
…deprecated-methods
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need further help see our docs: https://lightning.ai/docs/pytorch/latest/generated/CONTRIBUTING.html#pull-request or ask the assistance of a core contributor here or on Discord. Thank you for your contributions. |
…deprecated-methods
Is there anything else that can be done for this MR @Borda ? I will be glad to work on it further |
…deprecated-methods
…deprecated-methods
…deprecated-methods
…deprecated-methods
…deprecated-methods
@mock.patch.dict(os.environ, {}, clear=True) | ||
@mock.patch("lightning.fabric.accelerators.xla._XLA_GREATER_EQUAL_2_1", True) | ||
@mock.patch("lightning.fabric.plugins.environments.xla._XLA_GREATER_EQUAL_2_1", True) | ||
def test_attributes_from_xla_greater_21_used(xla_available, monkeypatch): | ||
"""Test XLA environment attributes when using XLA runtime >= 2.1.""" | ||
|
||
env = XLAEnvironment() | ||
|
||
with ( | ||
mock.patch("torch_xla.runtime.world_size", return_value=4), | ||
mock.patch("torch_xla.runtime.global_ordinal", return_value=2), | ||
mock.patch("torch_xla.runtime.local_ordinal", return_value=1), | ||
): | ||
env.world_size.cache_clear() | ||
env.global_rank.cache_clear() | ||
env.local_rank.cache_clear() | ||
|
||
assert env.world_size() == 4 | ||
assert env.global_rank() == 2 | ||
assert env.local_rank() == 1 | ||
|
||
env.set_world_size(100) | ||
assert env.world_size() == 4 | ||
|
||
env.set_global_rank(100) | ||
assert env.global_rank() == 2 |
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.
can we pls split it into smaller tests
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.
cc: @AlexandrByzov
…deprecated-methods
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/