Skip to content

[RLlib] Cleanup examples folder #14: Add example script for how to resume a tune.Tuner.fit() experiment from a checkpoint. - #45681

Merged
sven1977 merged 7 commits into
ray-project:masterfrom
sven1977:cleanup_examples_folder_14_continue_training_from_checkpoint
Jun 3, 2024
Merged

sven1977 merged 7 commits into
ray-project:masterfrom
sven1977:cleanup_examples_folder_14_continue_training_from_checkpoint

Conversation

@sven1977

@sven1977 sven1977 commented Jun 3, 2024 •

Copy link
Copy Markdown
Contributor

Cleanup examples folder #14: Add example script for how to resume a tune.Tuner.fit() experiment from a checkpoint.

  • Contains also a bug fix for MetricsLogger and Stats and a small API change wrt. MetricsLogger.peek() (key instead of *key to unify signature with all the other methods of MetricsLogger).

Why are these changes needed?

Related issue number

Checks

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

@simonsays1980 simonsays1980 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Invaluable example for users!

tuner = tune.Tuner(
trainable=config.algo_class,
param_space=config,
run_config=air.RunConfig(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In regard to the future deprecation of air: Can we use ray.train.RunConfig here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

param_space=config,
run_config=air.RunConfig(
callbacks=tune_callbacks,
checkpoint_config=air.CheckpointConfig(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here: can we use ray.train.CheckpointConfig?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

results = tuner.fit()
experiment_name = Path(results.experiment_path).name

# Extract the latest checkpoint from the results and confirm it's the right one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's state this comment differently. The get_best_result gets us only in this specific setup and only with a checkpoint frequency of 1 the latest checkpoint, otherwise we get the one with the highest episode_return_mean from whenever this happened.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch! Yes, in this example, we should probably just use the last checkpoint, not necessarily the best. ...

# TODO (simon): Change to -800 once the metrics are fixed. Currently
# the combined return is not correctly computed.
f"{ENV_RUNNER_RESULTS}/episode_return_mean": -400,
f"{ENV_RUNNER_RESULTS}/{EPISODE_RETURN_MEAN}": -800,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great catch!

@sven1977
sven1977 enabled auto-merge (squash) June 3, 2024 10:08
@github-actions
github-actions Bot disabled auto-merge June 3, 2024 10:08
@github-actions github-actions Bot added the go add ONLY when ready to merge, run all tests label Jun 3, 2024
@sven1977
sven1977 enabled auto-merge (squash) June 3, 2024 10:18
Signed-off-by: sven1977 <[email protected]>
@github-actions
github-actions Bot disabled auto-merge June 3, 2024 11:38
@sven1977
sven1977 enabled auto-merge (squash) June 3, 2024 13:28
@sven1977
sven1977 merged commit 440aa81 into ray-project:master Jun 3, 2024
@sven1977
sven1977 deleted the cleanup_examples_folder_14_continue_training_from_checkpoint branch June 3, 2024 14:44
richardsliu pushed a commit to richardsliu/ray that referenced this pull request Jun 12, 2024
…r how to resume a tune.Tuner.fit() experiment from a checkpoint. (ray-project#45681)

Signed-off-by: Richard Liu <[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.

2 participants