Thanks for explaining this.
You could directly pass the device to the tensor creation: torch.ones(size, device=device), which might be faster than creating these values on the CPU and push them to the GPU.
Were you able to check the memory usage and did you see an increased usage?