Skip to content

Conversation

@justusschock
Copy link
Member

@justusschock justusschock commented Nov 3, 2025

What does this PR do?

Adds a name function to Accelerator interface.

Allows accelerator type checks that are agnostic to the package.

E.g. isinstance(accelerator, lightning.fabric.CUDAAccelerator) doesn't work for lightning_fabric.CUDAAccelerator.
And in the future we can check for accelerator.name() == "cuda".

All of those checks we have inside the package are converted properly, but external code cannot properly rely on package-agnostic type-checks.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • 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)
  • 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

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

github-actions bot commented Nov 3, 2025

⚡ Required checks status: All passing 🟢

Groups summary

🟢 pytorch_lightning: Tests workflow
Check ID Status
pl-cpu-guardian success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py.

🟢 pytorch_lightning: lit GPU
Check ID Status
pytorch.yml / Lit Job (nvidia/cuda:12.1.1-devel-ubuntu22.04, pytorch, 3.10) success
pytorch.yml / Lit Job (lightning, 3.12) success
pytorch.yml / Lit Job (pytorch, 3.12) success

These checks are required after the changes to src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py, src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py.

🟢 Benchmarks
Check ID Status
benchmark.yml / Lit Job (fabric) success
benchmark.yml / Lit Job (pytorch) success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py.

🟢 fabric: Docs
Check ID Status
docs-make (fabric, doctest) success
docs-make (fabric, html) success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py.

🟢 pytorch_lightning: Docs
Check ID Status
docs-make (pytorch, doctest) success
docs-make (pytorch, html) success

These checks are required after the changes to src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py.

🟢 lightning_fabric: CPU workflow
Check ID Status
fabric-cpu-guardian success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, tests/tests_fabric/accelerators/test_registry.py.

🟢 lightning_fabric: lit GPU
Check ID Status
fabric.yml / Lit Job (nvidia/cuda:12.1.1-devel-ubuntu22.04, fabric, 3.10) success
fabric.yml / Lit Job (fabric, 3.12) success
fabric.yml / Lit Job (lightning, 3.12) success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, tests/tests_fabric/accelerators/test_registry.py.

🟢 mypy
Check ID Status
mypy success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py.

🟢 install
Check ID Status
install-pkg-guardian success

These checks are required after the changes to src/lightning/fabric/accelerators/accelerator.py, src/lightning/fabric/accelerators/cpu.py, src/lightning/fabric/accelerators/cuda.py, src/lightning/fabric/accelerators/mps.py, src/lightning/fabric/accelerators/xla.py, src/lightning/pytorch/accelerators/cpu.py, src/lightning/pytorch/accelerators/cuda.py, src/lightning/pytorch/accelerators/mps.py, src/lightning/pytorch/accelerators/xla.py.


Thank you for your contribution! 💜

Note
This comment is automatically generated and updates for 70 minutes every 180 seconds. If you have any other questions, contact carmocca for help.

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87%. Comparing base (739cf13) to head (fa06094).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #21325     +/-   ##
=========================================
+ Coverage      80%      87%     +7%     
=========================================
  Files         270      270             
  Lines       23764    23799     +35     
=========================================
+ Hits        19040    20629   +1589     
+ Misses       4724     3170   -1554     

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Nov 3, 2025
@github-actions github-actions bot added docs Documentation related dependencies Pull requests that update a dependency file labels Nov 3, 2025
@justusschock justusschock changed the title Add name to accelerator interface [blocked by #21327] Add name to accelerator interface Nov 3, 2025
@justusschock justusschock changed the base branch from master to remove_habana November 3, 2025 11:55
Base automatically changed from remove_habana to master November 3, 2025 17:11
@justusschock justusschock changed the title [blocked by #21327] Add name to accelerator interface Add name to accelerator interface Nov 3, 2025
@tchaton tchaton merged commit 32442c2 into master Nov 4, 2025
112 of 113 checks passed
@tchaton tchaton deleted the add_name_to_accelerator_interface branch November 4, 2025 08:47
justusschock added a commit that referenced this pull request Nov 5, 2025
@justusschock justusschock mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file docs Documentation related fabric lightning.fabric.Fabric pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants