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] Make most RLlib components implementers of the new Checkpointable API for unified checkpointing experience. #46435

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Jul 4, 2024

Make most RLlib components implementers of the new Checkpointable API for unified checkpointing experience.
In particular, these components are:
Learner, LearnerGroup, RLModule (and MARLModule), EnvRunners (single- and multi-agent), ConnectorV2 (and pipelines).

This now allows for maximum flexibility when creating checkpoints of Algorithms and any possible subsets of component(s) of this Algorithm. Each component can define its own subcomponents, each of which will create its own subdirectory in the component's checkpoint dir.

For example, when doing ...

[LearnerGroup].save_to_path([dir])

... the resulting directory tree in [dir] will be:

dir/
    learner/
        rl_module/
            default_policy/
            metadata.json
            state.pkl
            class_and_ctor_args.pkl
        metadata.json
        state.pkl
        class_and_ctor_args.pkl
    metadata.json
    state.pkl
    class_and_ctor_args.pkl

Where

  • metadata.json contains convenience user-readable meta information of the (sub)component saved. This information is NOT part of the state and not required to restore the respective component from disk.
  • state.pkl contains all state information that is NOT part of any subcomponent (which has its own state.pkl file). For example, the optimizer state of a Learner.
  • class_and_ctor_args.pkl stores the class of the (sub)component and its required args and kwargs to create an initial instance. This file is only needed when using the Checkpointable.from_checkpoint([dir]) method to create a new instance (and restore its state from the checkpoint).

Why are these changes needed?

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]>
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…ng_module_state_arg

# Conflicts:
#	rllib/utils/checkpoints.py
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…e_46247_add_module_not_using_module_state_arg

Signed-off-by: sven1977 <[email protected]>

# Conflicts:
#	rllib/algorithms/algorithm.py
#	rllib/core/learner/learner.py
#	rllib/core/learner/learner_group.py
#	rllib/core/rl_module/marl_module.py
#	rllib/core/rl_module/rl_module.py
#	rllib/core/rl_module/tf/tf_rl_module.py
#	rllib/core/rl_module/torch/torch_rl_module.py
#	rllib/env/env_runner.py
#	rllib/env/single_agent_env_runner.py
#	rllib/utils/checkpoints.py
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) July 5, 2024 10:21
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jul 5, 2024
@sven1977 sven1977 disabled auto-merge July 5, 2024 10:21
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 requested review from maxpumperla and a team as code owners July 5, 2024 11:27
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) July 10, 2024 17:30
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
@github-actions github-actions bot disabled auto-merge July 10, 2024 18:54
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…e_46247_add_module_not_using_module_state_arg
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) July 11, 2024 16:32
Signed-off-by: sven1977 <[email protected]>
@github-actions github-actions bot disabled auto-merge July 12, 2024 10:59
@sven1977 sven1977 enabled auto-merge (squash) July 12, 2024 10:59
Signed-off-by: sven1977 <[email protected]>
@github-actions github-actions bot disabled auto-merge July 12, 2024 12:53
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) July 13, 2024 19:23
@sven1977 sven1977 merged commit f123607 into ray-project:master Jul 13, 2024
6 checks passed
@sven1977 sven1977 deleted the issue_46247_add_module_not_using_module_state_arg branch July 14, 2024 09:44
Catch-Bull pushed a commit to Catch-Bull/ray that referenced this pull request Jul 15, 2024
…table` API for unified checkpointing experience. (ray-project#46435)

Signed-off-by: hejialing.hjl <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants