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

Correct call to torch.no_grad #5124

Merged
2 changes: 1 addition & 1 deletion pytorch_lightning/utilities/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,6 @@ def all_gather_ddp_if_available(
if sync_grads:
return AllGatherGrad.apply(tensor, group)
else:
with torch.no_grad:
with torch.no_grad():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it mean we have not ever called/tested this line? @tchaton

return AllGatherGrad.apply(tensor, group)
return tensor