1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-29 07:22:12 +03:00

raise as early as possible in group offloading

This commit is contained in:
sayakpaul
2025-06-24 14:17:37 +05:30
parent 474a248f10
commit 0d1cd52e4c

View File

@@ -63,6 +63,9 @@ class ModuleGroup:
onload_self: bool = True,
offload_to_disk_path: Optional[str] = None,
) -> None:
if stream is None and record_stream:
raise ValueError("`record_stream` cannot be True when `stream` is None.")
self.modules = modules
self.offload_device = offload_device
self.onload_device = onload_device
@@ -96,9 +99,6 @@ class ModuleGroup:
else:
self.cpu_param_dict = self._init_cpu_param_dict()
if self.stream is None and self.record_stream:
raise ValueError("`record_stream` cannot be True when `stream` is None.")
def _init_cpu_param_dict(self):
cpu_param_dict = {}
if self.stream is None:
@@ -513,6 +513,9 @@ def apply_group_offloading(
else:
raise ValueError("Using streams for data transfer requires a CUDA device, or an Intel XPU device.")
if not use_stream and record_stream:
raise ValueError("`record_stream` cannot be True when `use_stream=False`.")
_raise_error_if_accelerate_model_or_sequential_hook_present(module)
if offload_type == "block_level":