Skip to content

[Feature] Learning rate scheduling callback from yaml#220

Draft
Xmaster6y wants to merge 8 commits intofacebookresearch:mainfrom
Xmaster6y:callbacks
Draft

[Feature] Learning rate scheduling callback from yaml#220
Xmaster6y wants to merge 8 commits intofacebookresearch:mainfrom
Xmaster6y:callbacks

Conversation

@Xmaster6y
Copy link
Contributor

@Xmaster6y Xmaster6y commented Jul 24, 2025

What does this PR do?

It implements a callback LRSchedulerCallback to use torch scheduling classes. For further extension, this callback is integrated within the config group callback. The Callback & CallbackNotifier classes were extended to enable callbacks to save data in the state dict (e.g. learning rate schedulers).

It can be loaded using:

defaults:
  ...
  - callback@callbacks.c1: lr_scheduler
  - _self_

Depending on the class, additional arguments can be provided:

callbacks:
  c1:
    scheduler_class: torch.optim.lr_scheduler.CosineAnnealingLR
    scheduler_params:
      T_max: 500
      eta_min: 0.0

It can also be disabled:

defaults:
  ...
  - callback@callbacks: null
  - _self_

or left empty:

defaults:
  ...
  - _self_

To discuss

Maybe the defaults should be without any callback (can be left empty), yet the current LR scheduling doesn't change much training with basic configs. Maybe we should also save the optimizer within the experiment?

Defaults could also look like that:

scheduler_class: torch.optim.lr_scheduler.CosineAnnealingLR

scheduler_params:
  T_max: 500
  eta_min: 0.0

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 24, 2025
@matteobettini
Copy link
Contributor

matteobettini commented Oct 18, 2025

This PR is amazing thanks!

There is a lot tho to discuss at once, would it be possible to shard into three:

  • new callback for state dict
  • new scheduler callback
  • hydra callbacks

Ty

@Xmaster6y
Copy link
Contributor Author

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants