Skip to content

[RLlib] New ConnectorV2 API #06: Changes in SingleAgentEpisode & SingleAgentEnvRunner. - #42296

Merged
sven1977 merged 14 commits into
ray-project:masterfrom
sven1977:env_runner_support_connectors_06_small_changes_on_env_runner_and_episode
Jan 12, 2024
Merged

sven1977 merged 14 commits into
ray-project:masterfrom
sven1977:env_runner_support_connectors_06_small_changes_on_env_runner_and_episode

Conversation

@sven1977

@sven1977 sven1977 commented Jan 10, 2024 •

Copy link
Copy Markdown
Contributor

This PR adds some changes to SingleAgentEpisode & SingleAgentEnvRunner:

  • SingleAgentEnvRunner now utilizes the user-configured EnvToModule and ModuleToEnv connector pipelines.

  • Hence, SingleAgentEnvRunner does NOT anymore:

    • Have to deal with internal (RNN) states.
    • Action sampling, logp, probs computations as these are all done automatically in the default ModuleToEnv pipeline.
  • Add set APIs to SingleAgentEpisode, such that custom connectors are able to manipulate an episode's data, e.g. for observation framestacking, reward clipping, etc..

  • New set API had to also be supported then by InfiniteLookbackBuffer, which sits at the core of all episode classes.

  • Updated test cases and added new ones for set APIs.

Why are these changes needed?

Related issue number

Checks

Signed-off-by: sven1977 <[email protected]>
# Close our env object via gymnasium's API.
self.env.close()

# TODO (sven): Replace by default "to-env" connector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not necessary anymore here in EnvRunner.

This is default ModuleToEnv connector behavior now.

@sven1977 sven1977 changed the title [RLlib] EnvRunners support ConnectorV2 API: Changes in SingleAgentEpisode & SingleAgentEnvRunner. [RLlib] New ConnectorV2 API #06: Changes in SingleAgentEpisode & SingleAgentEnvRunner. Jan 10, 2024
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Comment on lines +164 to +172
# TODO (sven): Convert data to proper tensor formats, depending on framework
# used by the RLModule. We cannot do this right now as the RLModule does NOT
# know its own device. Only the Learner knows the device. Also, on the
# EnvRunner side, we assume that it's always the CPU (even though one could
# imagine a GPU-based EnvRunner + RLModule for sampling).
# if rl_module.framework == "torch":
# data = convert_to_torch_tensor(data, device=??)
# elif rl_module.framework == "tf2":
# data =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

uncomment or remove?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a TODO on an open question with the possible code-solution commented out. I'll leave this in. We need to unify this behavior (numpy to tensor) for all connector types in the near future to not cause user confusion.
The blocker right now is the fact that an RLModule does not know its own device today (only Learners do (GPU or CPU) and EnvRunners assume they are always on the CPU). Thus, connectors have to means to perform this conversion step properly.

rl_module=self.module,
episodes=self._episodes,
explore=explore,
# persistent_data=None, #TODO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a TODO here? What is the todo exactly?

data=to_env,
episodes=self._episodes,
explore=explore,
# persistent_data=None, #TODO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same thing

Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@sven1977
sven1977 merged commit 6da2636 into ray-project:master Jan 12, 2024
vickytsang pushed a commit to AMD-Ecosystem/ray that referenced this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rllib RLlib related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants