rl
rl copied to clipboard
[BUG] AssertionError: Action for agent agent_0 has shape 600, but should have shape 2
Describe the bug
When running the example ./sota-implementations/multiagent/sac.py, it encountered this assertion error.
To Reproduce
Steps to reproduce the behavior.
python ./sota-implementations/multiagent/sac.py
Traceback (most recent call last):
File "/path/to/torchrl/rl/./sota-implementations/multiagent/sac.py", line 240, in train
for i, tensordict_data in enumerate(collector):
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/collectors/collectors.py", line 342, in __iter__
yield from self.iterator()
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/collectors/collectors.py", line 1257, in iterator
tensordict_out = self.rollout()
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/_utils.py", line 662, in unpack_rref_and_invoke_function
return func(self, *args, **kwargs)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/collectors/collectors.py", line 1522, in rollout
env_output, env_next_output = self.env.step_and_maybe_reset(env_input)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/envs/common.py", line 3670, in step_and_maybe_reset
tensordict = self.step(tensordict)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/envs/common.py", line 2102, in step
next_tensordict = self._step(tensordict)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/envs/transforms/transforms.py", line 1159, in _step
next_tensordict = self.base_env._step(tensordict_in)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/torchrl/envs/libs/vmas.py", line 570, in _step
obs, rews, dones, infos = self._env.step(action)
File "/path/to/miniconda3/envs/torchrl/lib/python3.10/site-packages/vmas/simulator/environment/environment.py", line 253, in step
assert actions[i].shape[1] == self.get_agent_action_size(self.agents[i]), (
AssertionError: Action for agent agent_0 has shape 600, but should have shape 2
System info
import torchrl, numpy, sys
print(torchrl.__version__, numpy.__version__, sys.version, sys.platform)
TorchRL 0.10.0
tensordict 0.10.0
numpy 2.2.6
sys 3.10.18 (main, Jun 5 2025, 13:14:17) [GCC 11.2.0] linux
Reason and Possible fixes
Maybe the actor's n_agent_outputs should be modified
Checklist
- [x] I have checked that there is no similar issue in the repo (required)
- [x] I have read the documentation (required)
- [x] I have provided a minimal working example to reproduce the bug (required)
I can reproduce, on it!
cc @matteobettini if you can think of something