Lightning-AI / Lightning-AI/pytorch-lightning
Using `pyg` sampler causes lightning to skip validation step
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
Bug description
I am trying to use the dynamic batch sampler from torch_geometric (link) for my regression task on graphs. For some reason, using the batch sampler as follows skips the validation step. I think this is linked to this issue. This is how I am setting up my batch sampler,
from torch_geometric.loader import DataLoader
import pytorch_lightning as pl
class BaseDataModule(pl.LightningModule):
# usual init, setup, ....
def train_dataloader(self):
batch_sampler = <instantiate_dynamic_batch_sampler>
return DataLoader(
self.train_dataset,
batch_size=batch_size,
shuffle=shuffle,
batch_sampler=batch_sampler,
**self.kwargs,
)
def val_dataloader(self):
"""Creates val dataloader"""
batch_sampler = <instantiate_dynamic_batch_sampler>
return DataLoader(
self.val_dataset,
batch_size=batch_size,
shuffle=shuffle,
batch_sampler=batch_sampler,
**self.kwargs,
)
What version are you seeing the problem on?
version 2.0.4
How to reproduce the bug
No response
Error messages and logs
# Error messages and logs here please
Environment
Current environment
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):
More info
No response
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
The report names the train_dataloader and val_dataloader entry points but provides no reproduction, test, logs, or environment details. Start by creating a minimal case around these entry points using the torch_geometric dynamic batch sampler and compare validation behavior. Done means a regression test demonstrates that validation runs when this sampler is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100