Skip to content

[BugFix] Run ModuleTransform on reset when it declares observations - #4771

Open
theap06 wants to merge 4 commits into
pytorch:mainfrom
theap06:pr/module-transform-reset
Open

theap06 wants to merge 4 commits into
pytorch:mainfrom
theap06:pr/module-transform-reset

Conversation

@theap06

@theap06 theap06 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

A ModuleTransform with observation_spec_transform now also runs on reset when every key it reads is in the reset output, so the observations it declares exist from the first step and check_env_specs and collectors no longer fail; a module that reads step-only keys such as "reward" still runs only after steps, and its reward and done outputs are never written at reset. Inverse transforms and transforms without observation_spec_transform are unchanged.

Motivation and Context

Found while adding a success classifier's prediction to a robosuite env with ModuleTransform.

Stack (merge in this order; #4771, #4772, #4773 and #4799 are independent of each other and each is based on main, #4774 needs all four):

  1. [BugFix] Run ModuleTransform on reset when it declares observations #4771 [BugFix] Run ModuleTransform on reset when it declares observations (this PR)
  2. [Feature] InterventionModule for human or scripted takeovers #4772 [Feature] InterventionModule for human or scripted takeovers
  3. [Feature] Mixed-source replay with ReplayBufferEnsemble #4773 [Feature] Mixed-source replay with ReplayBufferEnsemble
  4. [Feature] SACLoss backup_entropy option #4799 [Feature] SACLoss backup_entropy option
  5. [Algorithm] HIL-SERL in simulation #4774 [Algorithm] HIL-SERL in simulation
  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

A ModuleTransform with observation_spec_transform adds observations to the
spec but only ran after steps, so reset outputs lacked them: check_env_specs
failed and collectors could not stack the first step with the rest. With
observation_spec_transform set, the module now also runs at reset.
Transforms without it are unchanged.
@pytorch-bot

pytorch-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4771

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 2 Unrelated Failures

As of commit fa8e0ef with merge base df1db3d (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 23, 2026
@theap06 theap06 mentioned this pull request Nov 23, 2026
4 of 6 tasks
A module that reads a key only present after a step, such as reward, now
keeps the previous behavior and runs only after steps, instead of raising a
KeyError at reset.
Running the module at reset wrote every output into the reset data, so a module that also writes a reward or done entry put a reward computed from the reset observation at the root. At reset the module now reads only its inputs and only its non-reward, non-done outputs are written back.
The reset filter used the parent env's reward and done keys, so a reward key
added by the transform's own reward_spec_transform was still written at reset,
and inside a RayModuleTransform actor, which has no parent, every output was.
Reset now writes only the outputs present in the transformed observation spec,
and nothing when there is no parent env.
@theap06
theap06 marked this pull request as ready for review November 29, 2026 09:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant