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 on_checkpoint_loaded callback AND also store eval workers' policy_mapping_fn in algo state. #40350

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Oct 14, 2023

This PR fixes a problem with heavily customized eval WorkerSet setups, policy sets, and mapping functions.

Why are these changes needed?

When a user overrides the on_algorithm_init callback in order to setup special evaluation policies inside the evaluation worker set, including a new eval policy mapping function, then upon restoring this algorithm from a checkpoint, the eval policy_mapping_fn information would be overridden by the main policy_mapping_fn (b/c that one is the only one stored in the checkpoint).

To solve this problem and to add additional handles for users with such complex customization needs, this PR:

  • Stores the eval workers' policy_mapping_fn in the algorithm state, in case this mapping is different from the main mapping function.
  • Adds on_checkpoint_loaded() callback called after the Algorithm was restored from a checkpoint (Algorithm.load_checkpoint() has completed).
  • New test cases have been added for both features.

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 :(

Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@@ -74,6 +83,29 @@ def setUpClass(cls):
def tearDownClass(cls):
ray.shutdown()

def test_on_init_and_checkpoint_loaded(self):
config = (
PGConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

We are moving PG to rllib contrib. use PPO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@kouroshHakha
Copy link
Contributor

some GPU restoration tests have not passed.

Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…ot_checkpointed' into issue59_eval_policy_mapping_fn_not_checkpointed
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 merged commit bdc9f83 into ray-project:master Oct 19, 2023
21 of 28 checks passed
jonathan-anyscale pushed a commit to jonathan-anyscale/ray that referenced this pull request Oct 26, 2023
jonathan-anyscale pushed a commit to jonathan-anyscale/ray that referenced this pull request Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants