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

Not knowing Which key is causing shape mismatch #2222

Closed
aminrezaee opened this issue Jun 11, 2024 · 3 comments · Fixed by #2223
Closed

Not knowing Which key is causing shape mismatch #2222

aminrezaee opened this issue Jun 11, 2024 · 3 comments · Fixed by #2223

Comments

@aminrezaee
Copy link

Hi there. I'm having problems with my environment rollout. Sometimes my environment shapes are changing somehow. If in the except block I'm going to mention, you don't set any type for the exception it would be much better. Because alongside the exception about shape mismatch another exception would raise saying which key caused this problem.
here is the line I'm suggesting to change:
https://github.com/pytorch/rl/blob/3787a9edeea03cb9e98b928824072b939c327776/torchrl/data/tensor_specs.py#L3978C20-L3978C28
and here is the line a raising shape mismatch:

raise RuntimeError(

note that if the shapes of observations are different currently just the shape mismatch exception would be raised due to different exception types.

@vmoens
Copy link
Contributor

vmoens commented Jun 11, 2024

Sometimes my environment shapes are changing somehow

Is this expected? We have allowed dynamic shapes in nightlies, it will be part of the next major release. You can just set -1 to the shapes that should change.

RE your suggestion:
what about capturing this RuntimeError separately, and tell user which key is the culprit of the shape mismatch?

@aminrezaee
Copy link
Author

aminrezaee commented Jun 11, 2024

Is this expected?

No. The changes of shapes aren't desired. My codes are having a bug.

what about capturing this RuntimeError separately

I agree. That would be nicer.

@vmoens
Copy link
Contributor

vmoens commented Jun 11, 2024

Ok I guess my initial understanding was that you were expecting your shapes to change and wanted to work around the exceptions, I now understand that the problem is that the exception are not informative enough
I can patch that quickly!
If you can think of anything else that would help you debug this sort of situation I'd be happy to help

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 a pull request may close this issue.

2 participants