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

Fix dtype for MPS in reinforcement learning example #19982

Merged
merged 5 commits into from
Jun 21, 2024
Merged
Changes from 2 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
4 changes: 3 additions & 1 deletion examples/fabric/reinforcement_learning/train_fabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def main(args: argparse.Namespace):
# Single environment step
next_obs, reward, done, truncated, info = envs.step(action.cpu().numpy())
done = torch.logical_or(torch.tensor(done), torch.tensor(truncated))
rewards[step] = torch.tensor(reward, device=device).view(-1)
rewards[step] = torch.tensor(
reward, device=device, dtype=torch.float32 if device.type == "mps" else None
).view(-1)
awaelchli marked this conversation as resolved.
Show resolved Hide resolved
next_obs, next_done = torch.tensor(next_obs, device=device), done.to(device)

if "final_info" in info:
Expand Down
Loading