You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use a parallel pettingzoo environment with a gym.spaces.Dict action space using a ProbabilisticActor to sample the actions. The _step_parallel method does not handle this case properly.
To Reproduce
Define a parallel pettingzoo environment with a dictionary action space and pass a tensordict where the leaves of the actions have shape (2, 2).
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/collectors/collectors.py", line 1052, in iterator
tensordict_out = self.rollout()
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/_utils.py", line 546, in unpack_rref_and_invoke_function
return func(self, *args, **kwargs)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/collectors/collectors.py", line 1187, in rollout
env_output, env_next_output = self.env.step_and_maybe_reset(env_input)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/envs/common.py", line 3257, in step_and_maybe_reset
tensordict = self.step(tensordict)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/envs/common.py", line 1844, in step
next_tensordict = self._step(tensordict)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/envs/transforms/transforms.py", line 794, in _step
next_tensordict = self.base_env._step(tensordict_in)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/envs/libs/pettingzoo.py", line 600, in _step
) = self._step_parallel(tensordict)
File "<project>/rltest/.venv/lib/python3.10/site-packages/torchrl/envs/libs/pettingzoo.py", line 738, in _step_parallel
action_dict[agent] = group_action_np[index]
KeyError: 0
Expected behavior
I can use dictionary action spaces without workarounds.
System info
Describe the characteristic of your environment:
Python 3.12
torchrl/tensordict main branch
Reason and Possible fixes
This wrapper for the wrapper seems to work for Dict action spaces but probably breaks other cases:
Describe the bug
I am trying to use a parallel pettingzoo environment with a
gym.spaces.Dict
action space using aProbabilisticActor
to sample the actions. The_step_parallel
method does not handle this case properly.To Reproduce
Define a parallel pettingzoo environment with a dictionary action space and pass a tensordict where the leaves of the actions have shape
(2, 2)
.The environment in my test repo https://github.com/rerz/rltest should work for this purpose.
Expected behavior
I can use dictionary action spaces without workarounds.
System info
Describe the characteristic of your environment:
Reason and Possible fixes
This wrapper for the wrapper seems to work for
Dict
action spaces but probably breaks other cases:Checklist
The text was updated successfully, but these errors were encountered: