Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AlexandrByzov
Copy link

@AlexandrByzov AlexandrByzov commented Jun 3, 2025

What does this PR do?

PyTorch XLA has deprecated several methods in PyTorch 2.7:

  • Remove torch_xla.core.xla_model.xrt_world_size, replace with torch_xla.runtime.world_size
  • Remove torch_xla.core.xla_model.get_ordinal, replace with torch_xla.runtime.global_ordinal

See here

Fixes #20852

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs): No
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs): Tests were already written
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

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
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--20872.org.readthedocs.build/en/20872/

@github-actions github-actions bot added the fabric lightning.fabric.Fabric label Jun 3, 2025
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 87%. Comparing base (6675932) to head (4e8e86c).
Report is 4 commits behind head on master.

❌ Your patch check has failed because the patch coverage (0%) is below the target coverage (50%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20872   +/-   ##
=======================================
- Coverage      87%      87%   -0%     
=======================================
  Files         268      268           
  Lines       23411    23420    +9     
=======================================
  Hits        20360    20360           
- Misses       3051     3060    +9     

@Borda Borda changed the title bugfix: add support for global_ordinal, local_ordinal, world_size in xla bugfix: add support for global_ordinal, local_ordinal, world_size in xla Jun 6, 2025
Copy link
Member

@Borda Borda left a 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?

@AlexandrByzov
Copy link
Author

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 torch_xla is not used in tests without TPU. Generally, it is very much possible to use XLA with CPU or even GPU, but this will require a large change in tests and probably a separate issue/s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fabric lightning.fabric.Fabric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PyTorch/XLA 2.7
2 participants