-
Notifications
You must be signed in to change notification settings - Fork 335
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
[BugFix] [Feature] Multi-agent collectors #828
Conversation
TODO:
|
In the current state, this PR works when Now, we should discuss how we want to change the behavior of Let's take an example to discuss new possibilities, here is the setup:
Now in case we start collecting, what should the batch_size be at the output? We are interested the case Here are the options for me. ## Option 1 For the
Then, for the case of
Option 2Alternatively, since this adds yet another dimension in an arbitrary place. We could make so that after collection, collectors squash all the batch dims into 1 single dim according to the mask. This would mean that the collectors with
Then, for the case of
My takeI really like option 2, but it might be needed to keep a batch_size that contains env.batch_size for some reasons. Let me know. It might be worth noting that is we do 1, 2 should be easily derivable and not the opposite. |
Related to #845 |
I couldn't agree more. I think |
@vmoens I would really like to have time-dimension padding for my recurrent models. Can we keep this as a helper feature somewhere? |
Definitely! What we think is to have it as an option, turned off by default |
So @vmoens if we keep |
That works for me. |
Oh I didn't see those, I was blindly only using the tests in |
Now we should be good. |
Also attempts to fix #846 with the warning solution |
Ok, then I would re-open the issue (or keep it open) to make this warning an error. WDYT? |
Yes, I'll leave a comment on that issue to say that we want to implement the error solution |
# Conflicts: # test/test_collector.py # torchrl/collectors/collectors.py # torchrl/collectors/utils.py
This PR also impacts the way frames are counted after collection. Currently, in the codebase frames are counted either as While these counting mechanisms will still work for enviornments with non set With this PR I have made so that there are new ways to get the number of collected frames.
|
Hi @matteobettini |
yep no probs! |
# Conflicts: # test/test_collector.py # torchrl/collectors/collectors.py # torchrl/collectors/utils.py
torchrl/collectors/collectors.py
Outdated
mask_env_batch_size (Sequence[bool], optional): a sequence of bools of the same length as env.batch_size, | ||
with a value of True it indicates to consider the corresponding dimension of env.batch_size as part of the | ||
batch of environments used to collect frames. A value of False it indicates NOT to consider that dimension | ||
as part of the batch of environments used to collect frames (used for agent dimension in multi-agent settings). | ||
Default is None (corresponding to all True). |
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.
mask_env_batch_size (Sequence[bool], optional): a sequence of bools of the same length as env.batch_size, | |
with a value of True it indicates to consider the corresponding dimension of env.batch_size as part of the | |
batch of environments used to collect frames. A value of False it indicates NOT to consider that dimension | |
as part of the batch of environments used to collect frames (used for agent dimension in multi-agent settings). | |
Default is None (corresponding to all True). | |
mask_env_batch_size (Sequence[bool], optional): a sequence of bools of the same length as env.batch_size. | |
A value of ``True`` indicates that the corresponding dimension of ``env.batch_size`` is to be included in the computation of the number of frames collected. A value of ``False`` indicates NOT to consider this particular dimension | |
as part of the batch of environments used to collect frames (e.g. used for agent dimension in multi-agent settings). | |
Defaults to ``True`` for all dims. |
@matteobettini
Two questions here:
- What if we provide envs with a different batch size? (It should break when putting the tensordicts together in the sync case but it should work in the async case)...
- What to do with non batch-locked envs (ie envs that are purely stateless and just read and write in a tensordict). Should we consider this case too, and constrain the
mask_env_batch_size
to have a length that match the batch dimensions of the tensordicts?
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.
@matteobettini Two questions here:
- What if we provide envs with a different batch size? (It should break when putting the tensordicts together in the sync case but it should work in the async case)...
The sync case will try to cat them so i think it would break. The async case will just return the one that finishes first i guess?
- What to do with non batch-locked envs (ie envs that are purely stateless and just read and write in a tensordict). Should we consider this case too, and constrain the
mask_env_batch_size
to have a length that match the batch dimensions of the tensordicts?
In this case the mask will be checked to match env.batch_size. If during execution the batch size changes the mask will not work I guess. We could also uese a mask which is just a list of dimensions to exclude from being considered as part of the batch, something like
batch_excluded_dims=[0,2]
Which would work as long as those dimension are part of the batch_size of the non-batch locked env.
Co-authored-by: Vincent Moens <vincentmoens@gmail.com>
Co-authored-by: Vincent Moens <vincentmoens@gmail.com>
Co-authored-by: Vincent Moens <vincentmoens@gmail.com>
# Conflicts: # test/test_collector.py # torchrl/collectors/collectors.py
Description
This PR introduces the mask, described in #807, which can be used in multi-agent settings to decide what parts of env batch size to consider for collection
Example