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

[Bug] accumulative_counts does not apply to parameter_schedulers #1308

Open
HAOCHENYE opened this issue Aug 15, 2023 · 4 comments
Open

[Bug] accumulative_counts does not apply to parameter_schedulers #1308

HAOCHENYE opened this issue Aug 15, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@HAOCHENYE
Copy link
Collaborator

HAOCHENYE commented Aug 15, 2023

The accurate cumulative pipeline should be as follows:

    loss = model(data)
    loss.backward()
    if idx % accumulative_counts == 0:
        optimizer.step()
        scheduler.step()
        optimizer.zero_grad()

However, the condition idx % accumulative_counts is only relevant to the OptimWrapper in this context:

def should_update(self) -> bool:

Meanwhile, the schedulers continue to update the learning rate at their original frequency. In this case, the pipeline looks like this:

    loss = model(data)
    loss.backward()
    if idx % accumulative_counts == 0:
        optimizer.step()
        optimizer.zero_grad()
    scheduler.step()

We need to fix this.

@HAOCHENYE HAOCHENYE added the bug Something isn't working label Aug 15, 2023
@Y-T-G
Copy link

Y-T-G commented Oct 23, 2023

Has this been fixed?

@Y-T-G
Copy link

Y-T-G commented Oct 23, 2023

Does this bug apply if by_epoch=True for param_scheduler?

@HAOCHENYE
Copy link
Collaborator Author

Does this bug apply if by_epoch=True for param_scheduler?

Unfortunately, that's the case. We haven't identified a suitable solution yet, as tightly integrating the functions of OptimWrapper and scheduler isn't advisable.

@flytocc
Copy link

flytocc commented Nov 4, 2023

To modify ParamSchedulerHook?

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

No branches or pull requests

3 participants