-
Notifications
You must be signed in to change notification settings - Fork 7k
[rllib] Add support for vectorize modes in SingleAgentEnvRunner.make_env
#58410
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] Add support for vectorize modes in SingleAgentEnvRunner.make_env
#58410
Conversation
Signed-off-by: Mark Towers <mark@anyscale.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for pre-vectorized environments in SingleAgentEnvRunner by utilizing gymnasium.VectorizeMode.VECTOR_ENTRY_POINT. The changes in SingleAgentEnvRunner.make_env are well-structured to handle different environment registration types and correctly pass configurations. The accompanying tests are thorough, especially the new test_vectorize_mode and test_env_context, and the improvements to test_sample make it more robust.
I've identified a few instances where the dictionary union operator (|) is used, which is incompatible with Python 3.8, a supported version for Ray. I've left comments with suggestions for backward-compatible alternatives. Apart from that, the changes look solid.
Signed-off-by: Mark Towers <mark@anyscale.com>
Signed-off-by: Mark Towers <mark@anyscale.com>
Signed-off-by: Mark Towers <mark@anyscale.com>
Signed-off-by: Mark Towers <mark@anyscale.com>
simonsays1980
left a comment
There was a problem hiding this 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 tuning @pseudo-rnd-thoughts !
# Conflicts: # rllib/env/tests/test_single_agent_env_runner.py
Signed-off-by: Mark Towers <mark@anyscale.com>
Signed-off-by: Mark Towers <mark@anyscale.com>
Signed-off-by: Mark Towers <mark@anyscale.com>
…_env` (ray-project#58410) ## Description Allow users to use environments that are already vectorized for `SingleAgentEnvRunner` With `gymnasium.make_vec`, users have the option to either use the `SyncVectorEnv` to vectorize a base environment or to directly create a vector environment using the `vectorize_mode: gymnasium.VectorizeMode`. This PR utilises the `env_runners(gym_env_vectorize_mode=...)` argument to support `VectorizeMode.VECTOR_ENTRY_POINT` ``` import gymnasium as gym config = ... config.env_runners( gym_env_vectorize_mode=gym.VectorizeMode.VECTOR_ENTRY_POINT, ) ``` An important change related to this PR is that the values accepted for the vectorize mode is either the enum (`VectorizedMode.ASYNC`, etc) or the enum values (`"async"`, etc) as before it was the string version was the enum name (`"ASYNC"`) rather than the enum value itself. ## Related issues Completion of ray-project#57643, ## Additional information ray-project#58397 must be merged first We should apply a similar change to the `MultiAgentEnvRunner.make_env` --------- Signed-off-by: Mark Towers <mark@anyscale.com> Co-authored-by: Mark Towers <mark@anyscale.com> Signed-off-by: Aydin Abiar <aydin@anyscale.com>
…_env` (ray-project#58410) ## Description Allow users to use environments that are already vectorized for `SingleAgentEnvRunner` With `gymnasium.make_vec`, users have the option to either use the `SyncVectorEnv` to vectorize a base environment or to directly create a vector environment using the `vectorize_mode: gymnasium.VectorizeMode`. This PR utilises the `env_runners(gym_env_vectorize_mode=...)` argument to support `VectorizeMode.VECTOR_ENTRY_POINT` ``` import gymnasium as gym config = ... config.env_runners( gym_env_vectorize_mode=gym.VectorizeMode.VECTOR_ENTRY_POINT, ) ``` An important change related to this PR is that the values accepted for the vectorize mode is either the enum (`VectorizedMode.ASYNC`, etc) or the enum values (`"async"`, etc) as before it was the string version was the enum name (`"ASYNC"`) rather than the enum value itself. ## Related issues Completion of ray-project#57643, ## Additional information ray-project#58397 must be merged first We should apply a similar change to the `MultiAgentEnvRunner.make_env` --------- Signed-off-by: Mark Towers <mark@anyscale.com> Co-authored-by: Mark Towers <mark@anyscale.com> Signed-off-by: YK <1811651+ykdojo@users.noreply.github.com>
…_env` (ray-project#58410) ## Description Allow users to use environments that are already vectorized for `SingleAgentEnvRunner` With `gymnasium.make_vec`, users have the option to either use the `SyncVectorEnv` to vectorize a base environment or to directly create a vector environment using the `vectorize_mode: gymnasium.VectorizeMode`. This PR utilises the `env_runners(gym_env_vectorize_mode=...)` argument to support `VectorizeMode.VECTOR_ENTRY_POINT` ``` import gymnasium as gym config = ... config.env_runners( gym_env_vectorize_mode=gym.VectorizeMode.VECTOR_ENTRY_POINT, ) ``` An important change related to this PR is that the values accepted for the vectorize mode is either the enum (`VectorizedMode.ASYNC`, etc) or the enum values (`"async"`, etc) as before it was the string version was the enum name (`"ASYNC"`) rather than the enum value itself. ## Related issues Completion of ray-project#57643, ## Additional information ray-project#58397 must be merged first We should apply a similar change to the `MultiAgentEnvRunner.make_env` --------- Signed-off-by: Mark Towers <mark@anyscale.com> Co-authored-by: Mark Towers <mark@anyscale.com>
Description
Allow users to use environments that are already vectorized for
SingleAgentEnvRunnerWith
gymnasium.make_vec, users have the option to either use theSyncVectorEnvto vectorize a base environment or to directly create a vector environment using thevectorize_mode: gymnasium.VectorizeMode.This PR utilises the
env_runners(gym_env_vectorize_mode=...)argument to supportVectorizeMode.VECTOR_ENTRY_POINTAn important change related to this PR is that the values accepted for the vectorize mode is either the enum (
VectorizedMode.ASYNC, etc) or the enum values ("async", etc) as before it was the string version was the enum name ("ASYNC") rather than the enum value itself.Related issues
Completion of #57643,
Additional information
#58397 must be merged first
We should apply a similar change to the
MultiAgentEnvRunner.make_env