mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-07-05 11:37:14 +00:00
[hotfix]fixed bugs of assigning grad states to non leaf nodes (#711)
* fixed bugs of assigning grad states to non leaf nodes * use detach()
This commit is contained in:
parent
eda30a058e
commit
140263a394
@ -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…
Reference in New Issue
Block a user