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

Docs and test code for PrioritizedEpisodeReplayBuffer. #43458

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented Feb 27, 2024

Why are these changes needed?

We move from plain timesteps to episodes in the buffer. This needs some rigorous documentation with appropriate test code to show users how to use a class.

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: Simon Zehnder <simon.zehnder@gmail.com>
@simonsays1980 simonsays1980 changed the title Docs and test code for 'PrioritizedReplayBuffer'. Docs and test code for 'PrioritizedEpisodeReplayBuffer'. Feb 27, 2024
@simonsays1980 simonsays1980 changed the title Docs and test code for 'PrioritizedEpisodeReplayBuffer'. Docs and test code for PrioritizedEpisodeReplayBuffer. Feb 27, 2024
capacity: The total number of timesteps to be storable in this buffer.
Will start ejecting old episodes once this limit is reached.
batch_size_B: The number of rows in a SampleBatch returned from `sample()`.
batch_length_T: The length of each row in a SampleBatch returned from
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we specify here, how this arg is related to n-step? My understanding is: Not at all, correct?

So, batch_length_T is the same as in DreamerV3, meaning if >1, then my returned batch will contain B rows, each row consisting of T consecutive-in-an-episode(!) n-step tuples, correct?

If so, can we give these details here in the description of the arg?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ar rhis moment batch_öength_T=1 is the only possible option. As this is a method inherited from EpisodeReplayBuffer this argument has to be there.

@@ -259,8 +371,8 @@ def sample(
next_observations = [[] for _ in range(batch_size_B)]
actions = [[] for _ in range(batch_size_B)]
rewards = [[] for _ in range(batch_size_B)]
is_terminated = [[False] * batch_length_T for _ in range(batch_size_B)]
is_truncated = [[False] * batch_length_T for _ in range(batch_size_B)]
is_terminated = [[False] for _ in range(batch_size_B)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain, why this fix? B/c a returned batch only has one terminated/truncated flag per batch row?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mainly because each batch row has only a single tuple. See my comment above.

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, just a few questions and nits to fix before we can merge.

@sven1977 sven1977 marked this pull request as ready for review February 27, 2024 14:46
@sven1977 sven1977 added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Feb 27, 2024
simonsays1980 and others added 7 commits February 28, 2024 11:54
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
…om:simonsays1980/ray into docs-for-prioritized-episode-replay-buffer

Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
@sven1977 sven1977 merged commit 87ec8f6 into ray-project:master Mar 6, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants