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] Cleanup examples folder (vol 30): BC pretraining, then PPO finetuning (new API stack with RLModule checkpoints). #47838

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Sep 27, 2024

Cleanup examples folder (vol 30): BC pretraining, then PPO finetuning (new API stack with RLModule checkpoints).

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]>
Copy link
Collaborator

@simonsays1980 simonsays1980 left a comment

Choose a reason for hiding this comment

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

Awesome example. Maybe adding the avg time for reaching 450 points without pretraining to show the advantage of pretraining.

best_result = results.get_best_result(metric_key)
rl_module_checkpoint = (
Path(best_result.checkpoint.path)
/ COMPONENT_LEARNER_GROUP
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!!!

| total time (s) | episode_return_mean | num_env_steps_traine |
| | | d_lifetime |
|------------------+------------------------|------------------------|
| 11.4828 | 250.5 | 42394 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome 11 seconds for 250 points. 51 iterations per 11 seconds is pretty fast.

| total time (s) | episode_return_mean | num_episodes_lifetime |
| | | |
+------------------+------------------------+------------------------+
| 32.7647 | 450.76 | 406 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dom we have by case a number how long it takes to train PPO from zero to 450?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's probably not much slower, if at all. But I think this is not the main point here (we know PPO is super fast learning CartPole). The main goal here is to show that:
a) you can use simple custom Models w/o having to sub-class algo-specific RLModule classes!! <- this is huge and thanks to the new RLModule API concept.
b) it doesn't tank (catastrophic forgetting) after transfer from BC to PPO :)

@@ -857,6 +857,7 @@ def setup(self, config: AlgorithmConfig) -> None:
env_steps_sampled=self.metrics.peek(
NUM_ENV_STEPS_SAMPLED_LIFETIME, default=0
),
rl_module_state=rl_module_state,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bug!

@@ -1362,7 +1362,11 @@ def run_rllib_example_script_experiment(
args.as_test = True

# Initialize Ray.
ray.init(num_cpus=args.num_cpus or None, local_mode=args.local_mode)
ray.init(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added reinit error ignore:
In case one calls this utility function twice in an example script.

@sven1977 sven1977 enabled auto-merge (squash) September 27, 2024 10:37
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Sep 27, 2024
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) September 27, 2024 12:44
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) September 27, 2024 15:36
Signed-off-by: sven1977 <[email protected]>
@sven1977 sven1977 enabled auto-merge (squash) September 28, 2024 13:27
@sven1977 sven1977 merged commit b676d02 into ray-project:master Sep 28, 2024
6 checks passed
@sven1977 sven1977 deleted the cleanup_examples_folder_30_bc_train_ppo_finetune branch September 28, 2024 17:27
@sven1977 sven1977 added rllib RLlib related issues rllib-offline-rl Offline RL problems rllib-docs-or-examples Issues related to RLlib documentation or rllib/examples rllib-newstack labels Sep 29, 2024
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[email protected]>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
…netuning (new API stack with RLModule checkpoints). (ray-project#47838)

Signed-off-by: ujjawal-khare <[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 rllib RLlib related issues rllib-docs-or-examples Issues related to RLlib documentation or rllib/examples rllib-newstack rllib-offline-rl Offline RL problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants