Skip to content

[BugFix] Recurrent policy auto-register with policy_factory#3753

Merged
vmoens merged 2 commits into
gh/vmoens/269/basefrom
gh/vmoens/269/head
May 18, 2026
Merged

[BugFix] Recurrent policy auto-register with policy_factory#3753
vmoens merged 2 commits into
gh/vmoens/269/basefrom
gh/vmoens/269/head

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented May 15, 2026

Stack from ghstack (oldest at bottom):

Fixes two latent bugs the auto-register path exposed:

  • _maybe_append_env_transforms_from_module wrapped the new transforms
    in Compose, which parented the children to a throwaway container.
    InitTracker / TensorDictPrimer then saw parent=None and
    env.action_spec silently broke. Append each transform directly so
    their parent stays the live env.
  • TensorDictPrimer.transform_input_spec crashed on envs with no
    full_state_spec. Initialize an empty Composite first, mirroring
    StepCounter's defensive default.

Add a regression test pinning both: after auto-register the env exposes
is_init and recurrent_state, env.action_spec stays reachable, and
every transform has a live parent.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 15, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 15 New Failures, 20 Unclassified Failures

As of commit ae72264 with merge base 0a01ee8 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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

[ghstack-poisoned]
vmoens added a commit that referenced this pull request May 18, 2026
Fixes two latent bugs the auto-register path exposed:

- `_maybe_append_env_transforms_from_module` wrapped the new transforms
  in `Compose`, which parented the children to a throwaway container.
  `InitTracker` / `TensorDictPrimer` then saw `parent=None` and
  `env.action_spec` silently broke. Append each transform directly so
  their parent stays the live env.
- `TensorDictPrimer.transform_input_spec` crashed on envs with no
  `full_state_spec`. Initialize an empty `Composite` first, mirroring
  `StepCounter`'s defensive default.

Add a regression test pinning both: after auto-register the env exposes
`is_init` and `recurrent_state`, `env.action_spec` stays reachable, and
every transform has a live parent.

ghstack-source-id: b6a6777
Pull-Request: #3753
@vmoens vmoens merged commit ae72264 into gh/vmoens/269/base May 18, 2026
80 of 121 checks passed
@vmoens vmoens deleted the gh/vmoens/269/head branch May 18, 2026 21:01
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. Collectors Integrations/torch_geometric Integrations Modules Transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant