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] EnvRunners fix min/max-metrics window sizes (from inf to config.metrics_num_episodes_for_smoothing). #45575

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented May 27, 2024

Why are these changes needed?

The user defines the window size for metrics in metrics_num_episodes_for_smoothing. This needs to be applied to all episode metrics to keep consistency. This PR adds the missing ones for the min/max which would otherwise report something different than the means.

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

@simonsays1980 simonsays1980 self-assigned this May 27, 2024
@simonsays1980 simonsays1980 added rllib RLlib related issues rllib-newstack bug Something that is supposed to be working; but isn't enhancement Request for new feature and/or capability labels May 27, 2024
self.metrics.log_value(EPISODE_RETURN_MIN, ret, reduce="min")
self.metrics.log_value(EPISODE_LEN_MAX, length, reduce="max")
self.metrics.log_value(EPISODE_RETURN_MAX, ret, reduce="max")
self.metrics.log_value(EPISODE_LEN_MIN, length, reduce="min", window=win)
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome! That's why I always felt that min/max stats were lifetime (rather than win=100) :D
Makes perfect sense. Thanks for this fix @simonsays1980 !

Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks a ton for this important fix @simonsays1980

@sven1977 sven1977 marked this pull request as ready for review May 28, 2024 11:51
@sven1977 sven1977 changed the title [RLlib] - Env runners cleanup metrics window sizes [RLlib] EnvRunners fix min/max-metrics window sizes (from inf to config.metrics_num_episodes_for_smoothing). May 28, 2024
@sven1977
Copy link
Contributor

Ah, wait, one fix still necessary. We need to do the same for MultiAgentEnvRunner. Could you change it there are well?

        # For some metrics, log min/max as well.
        self.metrics.log_dict(
            {
                EPISODE_LEN_MIN: length,
                EPISODE_RETURN_MIN: ret,
            },
            reduce="min",
            window=self.config.metrics_num_episodes_for_smoothing,
        )
        self.metrics.log_dict(
            {
                EPISODE_LEN_MAX: length,
                EPISODE_RETURN_MAX: ret,
            },
            reduce="max",
            window=self.config.metrics_num_episodes_for_smoothing,
        )

@sven1977 sven1977 enabled auto-merge (squash) May 28, 2024 13:13
@github-actions github-actions bot disabled auto-merge May 28, 2024 13:13
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label May 28, 2024
@sven1977 sven1977 enabled auto-merge (squash) May 28, 2024 13:14
@sven1977 sven1977 disabled auto-merge May 28, 2024 13:14
@sven1977 sven1977 enabled auto-merge (squash) May 28, 2024 13:50
@sven1977 sven1977 merged commit 5f01083 into ray-project:master May 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't enhancement Request for new feature and/or capability go add ONLY when ready to merge, run all tests rllib RLlib related issues rllib-newstack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants