Repository navigation
[Doc] Document Composite.keys() nested walk order - #4477
Open
YeonwooSung wants to merge 2 commits into
Open
YeonwooSung wants to merge 2 commits into
YeonwooSung wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4477
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Documents the nested walk order of
:meth:~torchrl.data.Composite.keys`` as a public contract.keys(include_nested=True, leaves_only=False)follows the same depth-first walk as:meth:tensordict.TensorDict.keys: each nested `:class:`~torchrl.data.Compositeis yielded after its children (child before parent), and siblings keep insertion order. The previous docstring listed["next", ("next", "obs")]as the set of keys, which read as parent-before-child; the runtime order is[("next", "obs"), "next"]. That order is now stated explicitly, with a copy-paste example.:class:~torchrl.data.StackedComposite``keys()gets the same note.The walk is not changed. Empty nested specs can be dropped in one pass over
list(spec.keys(True, False))because children are visited first.Motivation and Context
close #2482
The issue asked whether
CompositeSpec.keys(True, False)is deepest-first so empty nested specs can be deleted in a single scan. It is, matching TensorDict. This PR records that guarantee instead of addingprune_empty()or reversing the walk.Types of changes
Checklist