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] Prioritized version of an episode-based replay buffer. #42832

Merged

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented Jan 30, 2024

Why are these changes needed?

Changing to the new EnvRunner API for sampling and therein to focus on episodes instead of batches, we need to have replay buffers that can handle episodes. The EpisodeReplayBuffer was a simple replay buffer to deal with sequences, but offers no prioritized replay. This PR wants to change that by adding a prioritized replay buffer based on storing episodes and replay the transitions within in a prioritized way.

Related issue number

#42369

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

…change 'self_indices' from 'list' to ' dict' to lookup indices at indices of 'SegmentTree's.

Signed-off-by: Simon Zehnder <[email protected]>
Signed-off-by: Simon Zehnder <[email protected]>
…Buffer' and added 'update_priorities()', 'set_state()' and 'get_state()'.

Signed-off-by: Simon Zehnder <[email protected]>
@sven1977 sven1977 self-assigned this Jan 31, 2024
@sven1977 sven1977 changed the title Prioritized episode replay buffer [RLlib] Prioritized version of an episode-based replay buffer. Jan 31, 2024
…used. It needs a multi-agent version of the episode replay buffer, however.

Signed-off-by: Simon Zehnder <[email protected]>
@@ -21,6 +23,38 @@
logger = logging.getLogger(__name__)


def update_priorities_in_episode_replay_buffer(
replay_buffer: EpisodeReplayBuffer,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: PrioritizedEpisodeReplayBuffer ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically yes, but if it is not a prioritized buffer the function just skips and returns. Like this we can use normal buffers or prioritized ones. The other possibility is to test for the kind of buffer in the algorithms.

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.

@sven1977 sven1977 merged commit d8d775f into ray-project:master Feb 1, 2024
9 checks passed
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.

2 participants