DeepSpeed
DeepSpeed copied to clipboard
Avoid non_blocking copy from GPU to CPU
In Zero3 flow, when we do non_blocking copy from GPU to CPU and then copies the tensor to GPU (using the to() function) there is a race condition between these functions and there may be cases in which the to() function is executed before the copy_() completes. See the following discussion: https://discuss.pytorch.org/t/should-we-set-non-blocking-to-true/38234/17 Therefore I think it is safer to do clone() instead of the non_blocking to().