-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[RLlib] Clean up deprecated concat_samples calls #31391
[RLlib] Clean up deprecated concat_samples calls #31391
Conversation
rllib/evaluation/sampler.py
Outdated
@@ -92,7 +92,7 @@ def next(self) -> SampleBatchType: | |||
batches = [self.get_data()] | |||
batches.extend(self.get_extra_batches()) | |||
if len(batches) > 1: |
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.
I don't think you need this if-else check anymore, Do you? What would concat_samples do if you have a list with only one item in it?
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.
Good catch, thanks!
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.
concat batches does not know wether it is normally handling MA or SA batches. To avoid abscure errors where we simply pass an empty single agent batch down the line when the sampler samples no batches at all, I think we should raise an error here. There are currently no cases of this happening I think.
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.
yes I think that's a good idea.
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.
LGTM. Just one semi-nit comment :)
@@ -344,7 +344,7 @@ def check_buffer_is_ready(_policy_id): | |||
if check_buffer_is_ready(policy_id): | |||
samples.append(mix_batches(policy_id).as_multi_agent()) | |||
|
|||
return MultiAgentBatch.concat_samples(samples) | |||
return concat_samples(samples) if samples else MultiAgentBatch({}, 0) |
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.
I would prefer writing this part like the following, it's much simpler and also explicit about the output being a MultiAgentBatch type.
concat_samples_into_ma_batch(samples)
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.
Also you didn't get rid of MultiAgentBatch.concat_samples()
entirely in file. I found one that is slightly above this line. Might be worth doing a search and replace? I wonder why this is not caught on the unittests if the error on deprecation is raised.
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.
Mhhh that's weird. I'll check again, thanks! I'll follow the nits
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.
I looked again and didn't find any occurences. But some occurences of concat_samples()
which I turned into concat_samples_into_ma_batch()
! Lmk if you can point to the MultiAgentBatch.concat_samples() calls
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.
PyCharm also does not give me any results through search..
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.
Sorry, wrong call. :)
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.
LGTM. Plz merge once all the tests pass.
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.
much appreciated
3eccf8f
to
1c120b9
Compare
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
3070c7e
to
497c5d0
Compare
@gjoliver No idea why actor_manager tests kept failing. After rebasing three times they are green 🤔 |
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]> Signed-off-by: tmynn <[email protected]>
Signed-off-by: Artur Niederfahrenhorst [email protected]
Why are these changes needed?
We are still using our own deprecated API for caoncating samples.
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.