Repository navigation
Conversation
TransformedEnv._step hands every transform the input data after the whole chain was inverted. Stack, RenameTransform(create_copy=False) and ExcludeTransform(inverse=True) remove entries in their inverse, so a stateful transform placed after them (e.g. RewardSum under the stacked key) silently read its state as missing at every step. Here we add an opt-in Transform._inv_drops_key hook and make Compose raise a ValueError at spec-building time when a transform registers a state entry that an earlier transform's inverse drops. This is primarily a usability improvement to help the user avoid an error-prone transform chain. Stack, RenameTransform and ExcludeTransform are updated to implement inv_drops_key. This commit was co-authored by claude.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4571
Note: Links to docs will display an error until the docs builds have been completed.
|
Contributor
Author
|
@theap06 can i request a review here? |
theap06
self-requested a review
October 23, 2026 05:23
theap06
requested changes
Oct 28, 2026
| # in ``_step``. If the inverse of a previous transform removed it, | ||
| # ``t`` would silently read it as missing at every step. | ||
| for key in self._state_keys(input_spec) - state_keys: | ||
| for previous in self.transforms[:i]: |
Collaborator
There was a problem hiding this comment.
wont this only check transforms before t? the _step runs after the full inverse chain. the check needs to look at the whole chain.
| for key in self._state_keys(input_spec) - state_keys: | ||
| for previous in self.transforms[:i]: | ||
| if previous._inv_drops_key(key): | ||
| raise ValueError( |
Collaborator
There was a problem hiding this comment.
this needs a warning naming the removal version first before it becomes a raised error.
Contributor
Author
|
@theap06 ready for review |
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.
Usability improvement with transforms.
Description
TransformedEnv._step hands every transform the input data after the whole transform chain is inverted. Some transforms ---Stack, RenameTransform(create_copy=False) and ExcludeTransform(inverse=True)--- remove entries in their inverse, so a stateful transform placed after them (e.g. RewardSum under the stacked key) silently read its state as missing at every step.
Here we add an opt-in Transform._inv_drops_key hook and make Compose raise a ValueError at spec-building time when a transform registers a state entry that an earlier transform's inverse drops. This is primarily a usability improvement to help the user avoid an error-prone transform chain.
Stack, RenameTransform and ExcludeTransform are updated to implement inv_drops_key.
Motivation and Context
Types of changes
What types of changes does your code introduce? Remove all that do not apply:
Checklist
Go over all the following points, and put an
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!