Browse Source

[hotfix]fixed bugs of assigning grad states to non leaf nodes (#711)

* fixed bugs of assigning grad states to non leaf nodes

* use detach()
pull/712/head
LuGY 3 years ago committed by GitHub
parent
commit
140263a394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      colossalai/utils/activation_checkpoint.py

2
colossalai/utils/activation_checkpoint.py

@ -12,7 +12,7 @@ def copy_to_device(obj, device):
if torch.is_tensor(obj):
# Notice:
# When in no_grad context, requires_gard is False after movement
ret = obj.to(device)
ret = obj.to(device).detach()
ret.requires_grad = obj.requires_grad
return ret
elif isinstance(obj, list):

Loading…
Cancel
Save