Skip to content

Deprecation warning from SequentialLR #76113

@xkszltl

Description

@xkszltl

🐛 Describe the bug

This is probably from sub-scheduler when SequentialLR calls them with epoch arg.

/usr/local/lib/python3.6/dist-packages/torch/optim/lr_scheduler.py:154: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.
  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)

Related code:

Comment should also be fixed:

For compatibility with 3rd-party sub-scheduler who's still relying on epoch arg, you may:

  • Add a member switch to temporarily suppress this warnings when called directly by SequentialLR, and revert it at the end of step().
  • Or whitelist pytorch's own types with warnings in SequentialLR to use non-epoch signature.
    You may also need to check the type of self before printing that warning, to keep it quiet on derived types.

Versions

Commit 29a45f0

cc @ezyang @gchanan @zou3519

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions