Skip to content

[Feature] Allow multiple (nested) action, reward, done keys in env,vec_env and collectors #1462

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

Merged
merged 37 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4f597bf
temp
matteobettini Aug 4, 2023
49bc8e5
action
matteobettini Aug 4, 2023
36e1afb
amend
matteobettini Aug 4, 2023
eee5045
Merge branch 'main' into allow-all-specs-compsite
matteobettini Aug 15, 2023
92f62a9
reward spec
matteobettini Aug 15, 2023
5a77edd
reward spec
matteobettini Aug 15, 2023
1c334b1
done spec
matteobettini Aug 15, 2023
7dc7548
done spec
matteobettini Aug 15, 2023
ba13680
fix
matteobettini Aug 15, 2023
2f548ea
rollout and step_mdp
matteobettini Aug 15, 2023
4054f61
fix
matteobettini Aug 15, 2023
a772289
amend
matteobettini Aug 15, 2023
5baa353
added todos for _reset
matteobettini Aug 15, 2023
b6c1047
docs
matteobettini Aug 16, 2023
5f294d6
fix transforms
matteobettini Aug 16, 2023
e20298e
vec_env
matteobettini Aug 16, 2023
873dbbf
collector
matteobettini Aug 16, 2023
4332984
treat done
matteobettini Aug 17, 2023
162e40f
amend
matteobettini Aug 18, 2023
d9c0dbb
amend
matteobettini Aug 18, 2023
451e9a9
collectors and vec_env
matteobettini Aug 18, 2023
e8e410e
TEMP
matteobettini Aug 18, 2023
d3cbd5d
Revert "TEMP"
matteobettini Aug 18, 2023
ea1fe3f
amend
matteobettini Aug 21, 2023
8d5abef
Merge branch 'main' into allow-all-specs-compsite
vmoens Aug 30, 2023
334aa8d
fix review
matteobettini Aug 30, 2023
4830358
Update torchrl/envs/vec_env.py
matteobettini Aug 30, 2023
78be054
Update torchrl/envs/vec_env.py
matteobettini Aug 30, 2023
836d085
Update torchrl/envs/vec_env.py
matteobettini Aug 30, 2023
95dd02c
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
d755d89
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
9187b28
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
19875bd
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
01fc27a
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
790ff36
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
793b738
Update torchrl/envs/common.py
matteobettini Aug 30, 2023
6f1debe
preappend full_ before specs
matteobettini Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/test_envs_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def test_step_mdp_speed(
benchmark(
step_mdp,
td,
action_key=action_key,
reward_key=reward_key,
done_key=done_key,
action_keys=action_key,
reward_keys=reward_key,
done_keys=done_key,
keep_other=keep_other,
exclude_reward=exclude_reward,
exclude_done=exclude_done,
Expand Down
8 changes: 4 additions & 4 deletions docs/source/reference/envs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Each env will have the following attributes:
- :obj:`env.done_spec`: a :class:`~torchrl.data.TensorSpec` object representing
the done-flag spec.
- :obj:`env.input_spec`: a :class:`~torchrl.data.CompositeSpec` object containing
all the input keys (:obj:`"_action_spec"` and :obj:`"_state_spec"`).
all the input keys (:obj:`"full_action_spec"` and :obj:`"full_state_spec"`).
It is locked and should not be modified directly.
- :obj:`env.output_spec`: a :class:`~torchrl.data.CompositeSpec` object containing
all the output keys (:obj:`"_observation_spec"`, :obj:`"_reward_spec"` and :obj:`"_done_spec"`).
all the output keys (:obj:`"full_observation_spec"`, :obj:`"full_reward_spec"` and :obj:`"full_done_spec"`).
It is locked and should not be modified directly.

Importantly, the environment spec shapes should contain the batch size, e.g.
Expand Down Expand Up @@ -340,8 +340,8 @@ single agent standards.
spec if the accessed spec is Composite. Therefore, if in the example above
we run `env.reward_spec` after env creation, we would get the same output as `torch.stack(reward_specs)}`.
To get the full composite spec with the "agents" key, you can run
`env.output_spec["_reward_spec"]`. The same is valid for action and done specs.
Note that `env.reward_spec == env.output_spec["_reward_spec"][env.reward_key]`.
`env.output_spec["full_reward_spec"]`. The same is valid for action and done specs.
Note that `env.reward_spec == env.output_spec["full_reward_spec"][env.reward_key]`.


Transforms
Expand Down
Loading