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

[BUG] Calling to fails on MultiDiscreteTensorSpec #2203

Closed
3 tasks done
Quinticx opened this issue Jun 6, 2024 · 0 comments · Fixed by #2204
Closed
3 tasks done

[BUG] Calling to fails on MultiDiscreteTensorSpec #2203

Quinticx opened this issue Jun 6, 2024 · 0 comments · Fixed by #2204
Assignees
Labels
bug Something isn't working

Comments

@Quinticx
Copy link
Contributor

Quinticx commented Jun 6, 2024

Describe the bug

When calling to on a MultiDiscreteTensorSpec, it fails with
TypeError: MultiDiscreteTensorSpec.__init__() got an unexpected keyword argument 'n'

To Reproduce

Steps to reproduce the behavior.

import torchrl 
actions=MultiDiscreteTensorSpec(nvec=[2])
actions.to(dest="cuda:0")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "../python3.10/site-packages/torchrl/data/tensor_specs.py", line 3212, in to
    return self.__class__(
TypeError: MultiDiscreteTensorSpec.__init__() got an unexpected keyword argument 'n'

Expected behavior

The MultiDiscreteTensorSpec should be sent to device cuda:0.

System info

import torchrl, numpy, sys
print(torchrl.__version__, numpy.__version__, sys.version, sys.platform)
0.4.0 1.26.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] linux

Reason and Possible fixes

Changing to nvec here fixes the issue.

return self.__class__(
            nvec=self.nvec.to(dest),
            shape=None,
            device=dest_device,
            dtype=dest_dtype,
            mask=mask,
        )

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)
@Quinticx Quinticx added the bug Something isn't working label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants