-
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?
Changes from 13 commits
9bdedd0
4e8e86c
ee41f82
13cf1d0
85bbdce
140ac0b
39bd1b6
e013cb2
a2e66b1
4e00bd4
3c1c5b0
968050e
4a54af6
81ac311
a53a2e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,3 +97,31 @@ def test_detect(monkeypatch): | |
|
||
monkeypatch.setattr(lightning.fabric.accelerators.xla.XLAAccelerator, "is_available", lambda: True) | ||
assert XLAEnvironment.detect() | ||
|
||
|
||
@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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. cc: @AlexandrByzov There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressing the feedback. |
Uh oh!
There was an error while loading. Please reload this page.