Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@matteobettini
Copy link
Contributor

There are many places where _reset is just intantieated using the batch_size, while in reality it needs to follow the done_spec.

In particular, in transforms, how do we enforce this?

@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 21, 2023
@vmoens
Copy link
Collaborator

vmoens commented Mar 21, 2023

There are many places where _reset is just intantieated using the batch_size, while in reality it needs to follow the done_spec.

In particular, in transforms, how do we enforce this?

you can do transform.parent.done_spec and get the done_spec as needed. Would that work?

@matteobettini
Copy link
Contributor Author

Init tracker will also create a key that follows done_spec.

)
if not break_when_any_done and done.any():
_reset = done.view(tensordict.shape)
_reset = done
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we'd like to clone it to be 100% sure that any downstream modification won't have surprising effects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, i didn't add it as it was not there before but seems needed

)
input_spec["step_count"] = UnboundedDiscreteTensorSpec(
shape=input_spec.shape,
shape=self.parent.done_spec.shape,
Copy link
Contributor Author

@matteobettini matteobettini Mar 21, 2023

Choose a reason for hiding this comment

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

In the tests, there is no parent env so

AttributeError: 'NoneType' object has no attribute 'done_spec'

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should default to the tensordict shape if there is not parent env.

@matteobettini matteobettini changed the title make _reset follow done_spec make "_reset", "step_count", and other done_based keys follow done_spec Mar 21, 2023
@matteobettini
Copy link
Contributor Author

I think we should be ready.

All in all I think this also acted as a cleanup as i got to remove some squeezes and views.

I hope to have found all occurrences of done-related keys. Let's hope I dodn't miss any

@matteobettini matteobettini changed the title make "_reset", "step_count", and other done_based keys follow done_spec [BugFix] make "_reset", "step_count", and other done_based keys follow done_spec Mar 24, 2023
# collectors do not support passing other tensors than `"_reset"`
# to `reset()`.
if len(self.env.batch_size):
self._tensordict.masked_fill_(done_or_terminated, 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What was the utility of ths?

It was assuming that the done_spec is expandable to the other key specs

@vmoens vmoens added the bug Something isn't working label Mar 24, 2023
Copy link
Collaborator

@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
Copy link
Collaborator

vmoens commented Mar 26, 2023

the tests with vmas are broken and it seems to be related to this PR :)

@vmoens vmoens merged commit 75fc4da into pytorch:main Mar 26, 2023
@matteobettini matteobettini deleted the reset_done_spec branch March 26, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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