-
Notifications
You must be signed in to change notification settings - Fork 433
[Feature] Added num_envs parameter in GymEnv to call multiple environments in one call #3343
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3343
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Cancelled Job, 3 PendingAs of commit 2d34456 with merge base 736d6aa ( NEW FAILURE - The following job has failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
305fe34 to
1a24ab5
Compare
torchrl/envs/libs/gym.py
Outdated
| ``1`` (a single env is to be run). When ``num_envs > 1``, a :class:`~torchrl.envs.ParallelEnv` | ||
| will be returned. |
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.
This is bc-breaking, let's not do that. If a PEnv needs to be used let's let the users ask for it explicitly in some way
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.
Sure. Agree on this. I will keep it similar to my last PR
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.
Hmm not sure what you mean. Maybe we don't need it for gym since it already exists? Alternatively we can change the arg name to make it explicit it's torchrl-parallel (since it's nightly we can also change it in dm-control for consistency)
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.
Like what I actually meant was following the same structure or flow we did for DMControl but as you said that gym already has the feature for running multiple envs we can do it for other environments instead of this one
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.
And yes your latter idea for torchrl-parallel seems awesome and we can go ahead with it?
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.
let's just convene on a kwarg name?
num_envs: gym API
num_workers: torchrl?
Maybe not super explicit
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.
Yes. Seems good.
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.
Should I close this one in that case as gym envs already have num_envs parameter ? and start on the ones that don't have it ?
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.
I thought we said we'd keep the new feature but with a different name?
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.
Oh. sorry. I lost some track on that. Yes. I will keep the feature
torchrl/envs/libs/gym.py
Outdated
| ``1`` (a single env is to be run). When ``num_envs > 1``, a :class:`~torchrl.envs.ParallelEnv` | ||
| will be returned. |
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.
I thought we said we'd keep the new feature but with a different name?
|
@vmoens All changes noted 🫡 |
from the CI |
|
@vmoens I fixed the failing tests |
|
From https://github.com/pytorch/rl/actions/runs/21169673684/job/60889590869?pr=3343 |
|
Tests give really weird errors on gym 0.19: |
|
Got similar error on |
|
The code I just pushed works for all versions except gym==0.19 and 0.20 maybe because of the windows compatibility error |
|
might work on CI but didn't work locally |
No it did not haha |
|
🥲🥲🥲 |
- Remove incorrect CUDA skip decorator (test doesn't use CUDA) - Use Pendulum-v1 instead of CartPole-v1 because CartPole can terminate early due to pole falling, especially with frame_skip=4, causing the rollout assertion to fail (expected 5 steps, got 3)
Use PENDULUM_VERSIONED() instead of hardcoded "Pendulum-v1" to support older gym versions that only have "Pendulum-v0".
- Fix import ordering - Add missing space after == - Add newline at end of file - Remove trailing whitespace
Description
Describe your changes in detail.
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax
close #15213if this solves the issue #15213Types of changes
What types of changes does your code introduce? Remove all that do not apply:
Checklist
Go over all the following points, and put an
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!