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

[RLlib] Add option to use torch.lr_scheduler classes for learning rate schedules. #47453

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented Sep 2, 2024

Why are these changes needed?

In many state-of-the-art papers complex learning rate schedules are used (for example cosinus learning rate schedules). Most learning rate schedules are implemented in the torch.lr_scheduler module, but cannot be used in RLlib's algorithms, yet. This PR proposes a way to add a list of (module-specific) learning rate schedulers for each optimizer. This empowers users to use all kind of learning rate schedules and simplifies reproducing or verifying results from state-of-the-art papers as well as supplementing industrial appications with appropriate learning rate schedules.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

…hms. Either a list of schedulers sequentially applied or a dicitonary mapping module IDs to their list of schedulers respectively.

Signed-off-by: simonsays1980 <simon.zehnder@gmail.com>
@simonsays1980 simonsays1980 marked this pull request as ready for review September 2, 2024 15:00
@simonsays1980 simonsays1980 added rllib RLlib related issues rllib-torch The problems that only happen in torch on rllib labels Sep 2, 2024
Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is experimental for now (and similar to the grad scaler class option), let's merge it as-is. We do have to revisit the Learner API and figure out how to better allow for these more complex Learner customizations:

  • Using a custom optimizer (non-Adam).
  • Using a custom lr scheduler.
  • Using a second/third/... optimizer (per RLModule).
  • Using custom grad scaling behavior.

One important learning from the old API stack was that we shouldn't build in all kinds of loose features like this, b/c users don't really benefit from these in that they still don't understand what's going on under the hood and how RLlib translates these extra, convenience options into Learner logic. In the long run, I do think it's better to improve the root Learner API instead, then have example scripts that show how these customizations can be done (w/o us having to provide all these extra config options and built-in logics). But this is a mid-term TODO and cleanup request ...

@sven1977 sven1977 changed the title [RLlib] - Add option to use torch.lr_scheduler classes for learning rate schedules. [RLlib] Add option to use torch.lr_scheduler classes for learning rate schedules. Sep 3, 2024
@sven1977 sven1977 enabled auto-merge (squash) September 3, 2024 10:53
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Sep 3, 2024
@sven1977 sven1977 merged commit e147e31 into ray-project:master Sep 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests rllib RLlib related issues rllib-torch The problems that only happen in torch on rllib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants