[Fix]: Inline H2D during CUDA graph capture to avoid stream isolation in Offloader (#29166)

Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
This commit is contained in:
Shijin Zhang
2026-06-30 17:49:58 -07:00
committed by GitHub
parent a01afdd526
commit 5b76f55d90
+11 -1
View File
@@ -306,6 +306,10 @@ class _ModuleOffloader(ABC):
param_offloader.post_init()
def start_onload(self):
if torch.cuda.is_current_stream_capturing():
self._device_tensors = self._create_device_tensors()
self._load_event = None
return
self.alt_stream.wait_stream(torch.cuda.current_stream())
with torch.cuda.stream(self.alt_stream):
self._device_tensors = self._create_device_tensors()
@@ -318,7 +322,13 @@ class _ModuleOffloader(ABC):
def wait_and_get_device_tensors(self):
assert self._device_tensors is not None
self._load_event.wait()
if torch.cuda.is_current_stream_capturing():
if self._load_event is not None:
self._device_tensors = self._create_device_tensors()
self._load_event = None
return self._device_tensors
if self._load_event is not None:
self._load_event.wait()
return self._device_tensors
def _create_device_tensors(self):