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] Metrics do-over 03: Switch over Learner to new MetricsLogger API. #44995

Conversation

sven1977
Copy link
Contributor

Metrics do-over 03: Switch over Learner to new MetricsLogger API.

  • Retire Learner's current register_metric(s) APIs and replace with the new MetricsLogger API, which is also already used by EnvRunners AND Algorithm (if the new stack is activated).
  • TODO: We have to find a good way of transitioning those users that are currently on the hybrid stack and are therefore NOT using MetricsLogger on Algo yet (how to we reduce over the LearnerGroup returned reduced Stats-dicts). Possible solution: Have LearnerGroup act as an interceptor in case enable_rl_module_and_learner is True, but enable_env_runner_and_connector_v2 is False (hybrid stack). In this case, LearnerGroup will reduce the results on behalf of Algorithm and return a simple (non-Stats) dict, which hybrid-stack Algos know how to handle.

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

sven1977 and others added 30 commits March 13, 2024 12:50
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
…nup_examples_folder_03

# Conflicts:
#	rllib/examples/multi_agent/multi_agent_pendulum.py

and wip

Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Signed-off-by: Sven Mika <sven@anyscale.io>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
@sven1977 sven1977 requested a review from a team as a code owner April 28, 2024 16:54
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Copy link
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

approval for docs.

Signed-off-by: sven1977 <svenmika1977@gmail.com>
- after additional_update fixes/cleanups

Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
…ics_do_over_03_learner_on_new_metrics_logger

Signed-off-by: sven1977 <svenmika1977@gmail.com>

# Conflicts:
#	rllib/algorithms/dqn/dqn.py
#	rllib/algorithms/dreamerv3/tf/dreamerv3_tf_learner.py
#	rllib/algorithms/sac/torch/sac_torch_learner.py
#	rllib/core/learner/learner.py
#	rllib/core/learner/tests/test_learner_group.py
…ics_do_over_03_learner_on_new_metrics_logger
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
- added tensor-mode to MetricsLogger, during which tensors can be logged.
- tensor-mode requires to be exited (upon which a tensor dict is returned with the numpy/eager values in the tensors).
- these eager/numpy values must then be assigned again into the MetricsLogger, so we can properly reduce.

Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
…ics_do_over_03_learner_on_new_metrics_logger

Signed-off-by: sven1977 <svenmika1977@gmail.com>

# Conflicts:
#	rllib/algorithms/ppo/ppo_learner.py
#	rllib/algorithms/ppo/tf/ppo_tf_learner.py
#	rllib/algorithms/ppo/torch/ppo_torch_learner.py
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
…ics_do_over_03_learner_on_new_metrics_logger
…ics_do_over_03_learner_on_new_metrics_logger
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
Signed-off-by: sven1977 <svenmika1977@gmail.com>
@sven1977 sven1977 merged commit 8f7dd2e into ray-project:master May 1, 2024
4 of 5 checks passed
@sven1977 sven1977 deleted the metrics_do_over_03_learner_on_new_metrics_logger branch May 1, 2024 19:13
harborn pushed a commit to harborn/ray that referenced this pull request May 8, 2024
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 6, 2024
…r API. (ray-project#44995)

Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 7, 2024
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

3 participants