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

[BugFix] Fix error for incongruent devices in load_state_dict #529

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tensordict/tensordict.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,8 @@ def load_state_dict(
state_dict = copy(state_dict)
self.batch_size = state_dict.pop("__batch_size")
device = state_dict.pop("__device", None)
if device is not None:
if device != self.device:
raise RuntimeError(
"Loading data from another device is not yet supproted."
)
if device is not None and self.device is not None and device != self.device:
raise RuntimeError("Loading data from another device is not yet supported.")

for key, item in state_dict.items():
if isinstance(item, dict):
Expand Down