Skip to content

Conversation

@cmdout
Copy link

@cmdout cmdout commented Nov 17, 2025

Description

This PR fixes the RSSM rollout state propagation in RSSMRollout.forward.
At each timestep, after computing the prior and posterior, we now:

  • shift ("next", *) keys to current using step_mdp(..., keep_other=True), and
  • merge the next step inputs before continuing the rollout.

Concretely:

  • add step_mdp import, and
  • call step_mdp inside the time loop before selecting in_keys and updating with the next step’s values.

This ensures ("next", "state") and ("next", "belief") are correctly advanced to state and belief for the subsequent step.

Motivation and Context

Previously, the rollout did not propagate state and belief from ("next", ...) back to the current keys, causing the loop to reuse stale state/belief. This broke the intended posterior-to-prior chaining in Dreamer’s RSSM and led to incorrect latent rollouts (and potentially training instability and degraded reconstruction/reward predictions).

The fix aligns the implementation with Dreamer’s design and the world model wiring used elsewhere (e.g., in dreamer_utils._dreamer_make_world_model), where the prior for step t+1 must consume the posterior outputs of step t.

If there is an open issue tracking this bug, please link it here.
Example: close #XXXX

  • 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)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

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.

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 17, 2025

🔗 Helpful Links

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

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

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

@meta-cla
Copy link

meta-cla bot commented Nov 17, 2025

Hi @cmdout!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant