-
Notifications
You must be signed in to change notification settings - Fork 324
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
[Feature Request] Include group-level done fields in the VMAS environment #2536
Comments
Tagging @matteobettini, as you also worked on the VmasEnv. |
Hey thanks for opening this. So the idea is that the location of the done keys of a multiagent env will tell you how the env operates. For example:
In general the rationale is that, if some of the keys need to be expanded later, this can be done at the time you need it in a lazy way. Pre-adding this extra keys and creating new entries in the env tds regardless of whether you will need it could lead to extra computation, due to the fact that torchrl will track a larget done_spec and so on. Another motivation is: Now, by looking at the td coming from a vmas env, you immediatly know that there is not a per-agent done. Let me know what you think |
That makes sense! And I agree that it is more intuitive this way instead of having the fields everywhere. However, IMO it is suboptimal to have to manually patch the data so that it is compatible with the trainer. I'd expect the TorchRL environments and the TorchRL trainers to be plug and play compatible. Or at least to have a default solution for this. I see some options for such a solution:
What do you think of this? |
Yeah 2 is the best. we actually already have that transform in our implementations
We could consider extending it and adding it to the lib! |
Oh, this is great! Should we move this transform to the main lib and also use this in the tutorials? I'm open to working on this. |
I'm open to it, @matteobettini do you remember why it's not part of the core lib? |
I don’t remember. Yes, agreed, we need to extend it and test it a bit bit it would be v useful to have |
We could also consider having a “multiagent” file in the transforms to avoid clutter |
Ofc if the usage is only in MARL settings that makes sense |
Motivation
In the current implementation of the VMAS environment, the done fields are only available on the root of the tensordict. However, for training, it is useful to have them in the group-level.
This is also an issue for the TorchRL tutorial scripts
multiagent_ppo.py
andmultiagent_competitive_ddpg.py
, which have to manually add the done and terminated at group-level with the right shapehttps://github.com/pytorch/rl/blob/main/tutorials/sphinx-tutorials/multiagent_ppo.py#L655
https://github.com/pytorch/rl/blob/main/tutorials/sphinx-tutorials/multiagent_competitive_ddpg.py#L732
The PettingZoo env implementation does include the group-level done fields.
So, can we also include these fields in the VMAS code? If so, I'd be willing to work on this feature.
Checklist
The text was updated successfully, but these errors were encountered: