-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Tensordict.to_dict() execution failed
To Reproduce
import torch
from tensordict import TensorDict
def main():
d = {
"key1": {
"subkey1": torch.randn(5, 4, 3, 2, 1),
"subkey2": torch.randn(5, 4, 3, 1, 1),
"subkey3": torch.randn(5, 4, 6),
},
"key2": ["a", "b", "c", "d", "e"],
}
td = TensorDict.from_dict(d, auto_batch_size=True)
rebuild_d = td.to_dict()
if __name__ == "__main__":
main()Traceback (most recent call last):
File "/workspace/xxx/test/test.py", line 24, in <module>
main()
File "/workspace/xxx/test/test.py", line 17, in main
rebuild_d = td.to_dict()
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensordict/base.py", line 11982, in to_dict
value = value.to_dict(
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensordict/tensorclass.py", line 3764, in to_dict
return self.tolist(convert_tensors=convert_tensors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: NonTensorStack.tolist() got an unexpected keyword argument 'convert_tensors'Expected behavior
Execution successful, and rebuild_d equals d
Screenshots
Unnecessary
System info
tensordict version: 0.8.3
numpy version: 1.26.4
python version: 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0]
platform: linux
torch version: 2.8.0a0+5228986c39.nv25.06Additional context
Add any other context about the problem here.
Reason and Possible fixes
If you know or suspect the reason for this bug, paste the code lines and suggest modifications.
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)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working