-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Remove AccleratorConnector.devices
and Deprecate Trainer.devices
in favor of Trainer.device_ids
and Trainer.num_devices
#12126
Comments
I think |
I'm okay with keeping 1/ whatever gets passed in I feel given it's an parameter passed to trainer, but might not be what is really used as If we decide to keep, and agree with what to return, I am okay to keep it. Thoughts? @carmocca, @four4fish, @ananthsub |
I plan to use the newly introduced There's another related issue #11624 |
+1, I think the trainer device properties ending stage for 1.6 release should be :
@DuYicong515 Do you mind create a issue to state this and implementation order? It will be easier to get feedback and bring everyone to the same page. |
Filed #12171 |
Let me close this one since it's covered in #12171 |
Proposed refactor
Remove
https://github.com/PyTorchLightning/pytorch-lightning/blob/7e2f9fbad555242b0ceb2a24e5e4c004f0701bae/pytorch_lightning/trainer/connectors/accelerator_connector.py#L788-L794
Introduce
Trainer.device_ids
which returns a list of device indexes, andTrainer.num_devices
which returnslen(Trainer.device_ids)
.Deprecate
Trainer.devices
in favor ofTrainer.device_ids
andTrainer.num_devices
https://github.com/PyTorchLightning/pytorch-lightning/blob/7e2f9fbad555242b0ceb2a24e5e4c004f0701bae/pytorch_lightning/trainer/connectors/accelerator_connector.py#L788-L794
Motivation
Accelerator.devices
was not used within PyTorchLightning other thanTrainer.devices
, also its implementation looks more likenum_devices
. SinceAccelerator.devices
is not meant to be a public property, we can remove that in favor of usingTrainer.num_devices
externally.Introduce
Trainer.device_ids
that returns list of device indexes to deprecateTrainer.devices
. It could be used to get the device indexes, and also list of devices combing indexes +Trainer.acclerator
.Currently
Trainer.devices
wasn't used within PytorchLightning other than tests, and its name is quite confusing -- it returns number of devices instead of list of devices/or device indexes.Trainer.num_devices
which is derived fromTrainer.device_ids
can also help with several Trainer properties migration since we plan to remove bunch of unused properties inAcceleratorConnector
(part of #11449) includingnum_processes
,tpu_cores
,ipus
andnum_gpus
.Pitch
cc @justusschock @awaelchli @rohitgr7 @four4fish
If you enjoy Lightning, check out our other projects! ⚡
Metrics: Machine learning metrics for distributed, scalable PyTorch applications.
Lite: enables pure PyTorch users to scale their existing code on any kind of device while retaining full control over their own loops and optimization logic.
Flash: The fastest way to get a Lightning baseline! A collection of tasks for fast prototyping, baselining, fine-tuning, and solving problems with deep learning.
Bolts: Pretrained SOTA Deep Learning models, callbacks, and more for research and production with PyTorch Lightning and PyTorch.
Lightning Transformers: Flexible interface for high-performance research using SOTA Transformers leveraging Pytorch Lightning, Transformers, and Hydra.
The text was updated successfully, but these errors were encountered: