Expectations for custom data parallel implementations #3471
-
I have a need to use a custom With Lightning, the API and docs are unclear as to whether I need to extend The LightningModule API docs suggest However, there are spots in Lightning which rely on checking isinstance of the custom Lightning overrides: https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/trainer/model_connector.py#L31-L34 1 The Lightning DDP also forwards calls to train/val/test step. Is this a requirement for custom DDP implementations when used with Lightning? TLDR: should I subclass Also asked here: https://forums.pytorchlightning.ai/t/expectations-for-custom-data-parallel-implementations/162 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Almost certainly you need to inherit LightningDistributedDataParallel for the reasons you have already mentioned. As @williamFalcon already explained, this is probably not what should be done today. I have come across this as well. There are libraries like torchgeometry that have a custom DataParallel class and I believe it is currently not possible to just drop that into Lightning, because of the reasons you have already mentioned. |
Beta Was this translation helpful? Give feedback.
-
@awaelchli it seems like the workaround for now is to extend |
Beta Was this translation helpful? Give feedback.
-
@williamFalcon PTAL |
Beta Was this translation helpful? Give feedback.
-
@ananthsub Not sure if you have seen it already, there is now a DDP Plugin in which you can override the DistributedDataParallel. It can be passed into the trainer via plugins list. |
Beta Was this translation helpful? Give feedback.
-
yup I saw. that resolves this issue 👍 |
Beta Was this translation helpful? Give feedback.
@ananthsub Not sure if you have seen it already, there is now a DDP Plugin in which you can override the DistributedDataParallel. It can be passed into the trainer via plugins list.
https://pytorch-lightning.readthedocs.io/en/latest/plugins.html?highlight=DDPPlugin