DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

Avoid non_blocking copy from GPU to CPU

Open mmhab opened this issue 3 years ago • 0 comments

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().

mmhab avatar May 02 '23 14:05 mmhab