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

Tensor shape error in sac_continuous_action_torchcompile.py on Mac #15

Open
ran-weii opened this issue Nov 11, 2024 · 1 comment
Open

Comments

@ran-weii
Copy link

ran-weii commented Nov 11, 2024

Hi, thanks for this cool project!

I was running sac_continuous_action_torchcompile.py and wanted to do a comparison of compile vs no compile on Mac M3. I changed line 172 to use MPS instead of CUDA.

I ran into a weird issue on line 222 which calculates the MSE loss:

RuntimeError: impl: target and input tensors must have identical shapes

I checked val.view(-1) and next_q_value actually have the same shape. So I don't understand why this error happens.

I was able to solve it by changing to the following loss computation:

loss_val = torch.pow(vals.view(-1) - next_q_value, 2).mean()

I don't know if this will affect performance significantly (I doubt).

I installed both torchrl and tensordict from source if that matters.

@vmoens
Copy link
Contributor

vmoens commented Nov 14, 2024

I raised an issue with this: pytorch/pytorch#140704
Let's hope it gets fixed!

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

No branches or pull requests

2 participants