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] Implementation of MultiAgentEpisodeReplayBuffer for the new API stack. #44450

Merged

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented Apr 3, 2024

Why are these changes needed?

With the new API stack and the EnvRunner API came the necessity to define new replay buffers that can work completely on episode objects and stores the latter. This PR proposes the multi-agent version of these EpisodeReplayBuffers.

Sampling works in independent and synchronized replay mode and can use different n-step for each item.

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 14 commits March 22, 2024 10:38
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…d 'add' method. Fixed a minor bug in the 'MultiAgentEpisode' b/c the 'agent_module_ids' mapping was not assigned in the 'MultiAgentEpisode.__init__'. Furthermore, added some tests for the new buffer.

Signed-off-by: Simon Zehnder <[email protected]>
… either 'independent' or

'synchronized'. There appears to be an inconsistency between the action getters of the SingleAgentEpisode' and the 'MultiAgentEpisode' - the latter retrieves the timestep one earlier than observations.

Signed-off-by: Simon Zehnder <[email protected]>
@sven1977 sven1977 changed the title Multi agent episode replay buffer for the new API stack [RLlib] Implementation of MultiAgentEpisodeReplayBuffer for the new API stack. Apr 3, 2024
@sven1977 sven1977 marked this pull request as ready for review April 3, 2024 13:22

# Stores indices of module (single-agent) timesteps.
self._module_indices: Dict[str, List[Tuple[int]]] = defaultdict(list)
# Stores for each module the episode indices.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same: improve typehint to DefaultDict[ModuleID, Dict[EpisodeID, int]] ? Is int correct here or should this be a 4-tuple as well?

Let's also above declare what "index" means throughout this entire class:
Something like:
"In this class, we use a global indexing system, where an individual index is a 4-tuple, consisting of 1) ...2)... 3)... 4) ..."

sven1977 and others added 13 commits April 4, 2024 16:11
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…api' into multi-agent-episode-replay-buffer

Signed-off-by: Simon Zehnder <[email protected]>
… and 'SingleAgentEpisode'.

Signed-off-by: Simon Zehnder <[email protected]>
Signed-off-by: Simon Zehnder <[email protected]>
…ays1980/ray into multi-agent-episode-replay-buffer

Signed-off-by: Simon Zehnder <[email protected]>
Signed-off-by: Simon Zehnder <[email protected]>
…ts for getters and counters.

Signed-off-by: Simon Zehnder <[email protected]>
rllib/BUILD Outdated
@@ -1524,6 +1524,13 @@ py_test(
srcs = ["utils/replay_buffers/tests/test_episode_replay_buffer.py"]
)

oy_test(
Copy link
Contributor

Choose a reason for hiding this comment

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

-> py_test

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 for the fixes.
I understand we'll uncomment those tests for the new buffer once I have fixed the getter API of MultiAgentEpisode.

rllib/BUILD Outdated Show resolved Hide resolved
@sven1977 sven1977 merged commit 97e910b into ray-project:master Apr 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants