8000 Fix OneCycle step length when in multiprocess by muellerzr · Pull Request #385 · huggingface/accelerate · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix OneCycle step length when in multiprocess #385

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

Merged
merged 3 commits into from
May 23, 2022
Merged

Fix OneCycle step length when in multiprocess #385

merged 3 commits into from
May 23, 2022

Conversation

muellerzr
Copy link
Contributor
@muellerzr muellerzr commented May 23, 2022

Fix improper number of times OneCycle scheduler is called

What does this add?

This PR fixes an issue where torch.optim.lr_scheduler.OneCycle.step expects to be called a particular number of times, and will raise an issue when called more than this. The typical scenario of when this happens is when the user did not specify drop_last=True in their DataLoaders. For now this is specific to OneCycle, but the API will ideally be consistent if another scheduler is added to Pytorch that uses this same method of tracking maximum steps.

Note: All other schedulers work, it's just OneCycle that does not

Why is it needed?

The cv_examples currently all break in multiproc settings, due to the incorrect number of times .step() is being called

What parts of the API does this impact?

User-facing:

Nothing

Internal structure:

Adds the following check if not self.split_batches:

for _ in range(num_processes):
+    if getattr(self.scheduler, "total_steps", 0) < self.scheduler.last_epoch:
        self.scheduler.step(*args, **kwargs)

@muellerzr muellerzr added bug Something isn't working enhancement New feature or request labels May 23, 2022
@muellerzr muellerzr requested a review from sgugger May 23, 2022 15:35
@muellerzr muellerzr marked this pull request as draft May 23, 2022 15:41
@muellerzr muellerzr marked this pull request as ready for review May 23, 2022 15:54
@HuggingFaceDocBuilderDev
Copy link
HuggingFaceDocBuilderDev commented May 23, 2022

The documentation is not available anymore as the PR was closed or merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0