Repository navigation
[BugFix] Keep StepCounter flag propagation within each done group - #4587
mottopanikeiku wants to merge 1 commit into
Conversation
StepCounter propagated truncation (and done, with update_done=True) to nested keys from the first parent key that had a value, even when that parent belonged to an independent sibling group. Skip tuple parents whose prefix differs from the nested key's prefix. Closes pytorch#4586. Assisted-by: Claude Assisted-by: GPT-6 Astra Signed-off-by: mottopanikeiku <176798723+mottopanikeiku@users.noreply.github.com>
|
Hi @mottopanikeiku! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4587
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 263ae5b with merge base e7a05a7 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@bsprenger could you approve the CI workflows for this PR? It is my first one here, so they are waiting for a maintainer. It fixes #4586: with independent done groups, |
coder-jayp
left a comment
There was a problem hiding this comment.
LGTM! Verified that prefix-matching in _propagate_to_nested_keys resolves cross-group leakage without breaking root-level propagation, and the new test thoroughly covers both groups, update_done states, and pre-existing flags.
Description
StepCounterpropagates truncation to nested done entries (and done too, withupdate_done=True) from a parent key. The loops took the first parent key that had a value, even if it belonged to an independent sibling group. So with("left", ...)and("right", ...)groups that each have nested agents,leftreaching its step limit also truncated therightagents, and a group's own limit could fail to reach its agents. I now skip tuple parent keys whose prefix differs from the nested key's prefix. This is the same groupingEnvBaseuses for reset keys. Root string keys still apply to every nested entry, and the existing dimension expansion and logical OR are unchanged. I also added two lines to the class docstring.With the environment from #4586 (two groups of 3 agents,
StepCounter(3),leftat step 2):rightagents truncatedmain[[True], [True], [True]][[False], [False], [False]]Tests:
TestStepCounter.test_stepcounter_independent_nested_groupsgoes through the publicreset()/rollout(). It covers either group truncating, withupdate_doneoff and on, and keeps an agent flag that was already set. All 4 cases fail onmain.test/transforms/test_env_transforms.py::TestStepCounter: 82 passed, 2 skipped.Motivation and Context
Multi-agent environments with independent groups (each with its own done/reset keys) got wrong truncation flags for agents in groups that had not hit their step limit.
close #4586
Types of changes
Checklist
I used AI assistance (Claude and GPT-6 Astra) to find, fix and test this bug.