Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Propagate args to TransformedEnv's state_dict #944

Merged
merged 1 commit into from
Mar 2, 2023
Merged

[BugFix] Propagate args to TransformedEnv's state_dict #944

merged 1 commit into from
Mar 2, 2023

Conversation

fedebotu
Copy link
Contributor

@fedebotu fedebotu commented Mar 1, 2023

Description

Propagate *args and **kwargs to TransformedEnv's state_dict.

Motivation and Context

Since TorchRL's environments are nn.Module, they contain a state_dict. However, the TransformedEnv 's state_dict class does not accept any *args or *kwargs. This PR fixes that.

Example: I implemented an example notebook of PyTorch Lightning + TorchRL based on the pendulum tutorial with the LightningModule containing both env and policy. The following error is raised:

TypeError: state_dict() got an unexpected keyword argument 'destination'

which happens because of the TransformedEnv class. With the simple change of this PR this does not happen anymore.

Types of changes

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

Checklist

@facebook-github-bot facebook-github-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 Mar 1, 2023
Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vmoens vmoens merged commit c0e8a1c into pytorch:main Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants