Skip to content
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

Set torch.utils.data.DataLoader.batch_sampler epoch if defined #3123

Closed
Ghelfi opened this issue Mar 18, 2024 · 2 comments
Closed

Set torch.utils.data.DataLoader.batch_sampler epoch if defined #3123

Ghelfi opened this issue Mar 18, 2024 · 2 comments
Labels
enhancement New (engineering) enhancements, such as features or API changes.

Comments

@Ghelfi
Copy link
Contributor

Ghelfi commented Mar 18, 2024

🚀 Feature Request

Current implementation of composer trainer call the DistributedSampler.set_epoch method only on the Dataloader.sampler attribute but not on the Dataloader.batch_sampler, even if it is defined.
One example here.

Motivation

When doing distributed learning based on batch sampler one might want the epoch to be properly set on the batch_sampler since it is usually used to seed new seed over time.
This could be useful for Metric learning where batch_sampler can be a worth feature.
For now composer trainer only handle regular sampler.

Implementation

I'll propose a PR with a technical implementation. The idea is to check if batch_sampler is defined, in which case we can set the epoch properly, else we do it on the regular sampler (always defined in torch.utils.data.DalaLoader).

@Ghelfi Ghelfi added the enhancement New (engineering) enhancements, such as features or API changes. label Mar 18, 2024
@Ghelfi
Copy link
Contributor Author

Ghelfi commented Mar 18, 2024

The proposed PR: #3124

@Ghelfi
Copy link
Contributor Author

Ghelfi commented Apr 3, 2024

Merged by @mvpatel2000. Closing the issue.

@Ghelfi Ghelfi closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New (engineering) enhancements, such as features or API changes.
Projects
None yet
Development

No branches or pull requests

1 participant