Lightning-AI / Lightning-AI/pytorch-lightning
Ensure `torch.nn.Modules` in `DataModule` get moved to proper device
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Description & Motivation
I have on gpu augmentations I perform via some custom `torch.nn.Modules` I define in my `LightningDataModule`. How can I ensure these get moved to the correct device during distributed training so I can use them in the `on_after_batch_transfer` hook?
### Pitch
_No response_
### Alternatives
_No response_
### Additional context
_No response_
cc @borda
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how LightningDataModule handles device placement and how the on_after_batch_transfer hook is invoked during distributed training. The work is done when custom torch.nn.Modules owned by a DataModule are moved to the correct device and can be used safely from that hook.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100