[CUDA] Remove the uncessary CUDA_GUARD (#160249)

`CUDA_GUARD` is unnecessary in `initDeviceStreamState`, because
the `initSingleStream` has already done it.

29712314dd/c10/cuda/CUDAStream.cpp (L202-L203)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/160249
Approved by: https://github.com/Skylion007
This commit is contained in:
FFFrog 2025-08-09 23:47:14 +08:00 committed by PyTorch MergeBot
parent 8ae4d2652f
commit dc0d18e023

View File

@ -216,9 +216,6 @@ static void initSingleStream(int p, DeviceIndex device_index, int i) {
// Creates the low and high priority stream pools for the specified device
// Warning: only call once per device!
static void initDeviceStreamState(DeviceIndex device_index) {
// Switches to the requested device so streams are properly associated
// with it.
CUDAGuard device_guard{device_index};
for (const auto i : c10::irange(kStreamsPerPool)) {
for (const auto p : c10::irange(max_stream_priorities)) {
initSingleStream(p, device_index, i);