mmengine
mmengine copied to clipboard
[Bug] `accumulative_counts` does not apply to `parameter_schedulers`
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:
https://github.com/open-mmlab/mmengine/blob/a483dba9d15308f9442e87faf80c1d7279137519/mmengine/optim/optimizer/optimizer_wrapper.py#L339
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.
Has this been fixed?
Does this bug apply if by_epoch=True for param_scheduler?
Does this bug apply if
by_epoch=Trueforparam_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.
To modify ParamSchedulerHook?