Skip to content

Commit 2a28f6d

Browse files
committed
style.
1 parent f25ea18 commit 2a28f6d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/diffusers/hooks/group_offloading.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ def __init__(
7575

7676
if self.stream is not None and self.cpu_param_dict is None:
7777
raise ValueError("`cpu_param_dict` must be provided when using stream for data transfer.")
78-
78+
7979
if self.record_stream and not self.stream:
8080
raise ValueError("`record_stream` cannot be True when `stream` is None.")
8181

8282
def onload_(self):
8383
r"""Onloads the group of modules to the onload_device."""
8484
context = nullcontext() if self.stream is None else torch.cuda.stream(self.stream)
8585
current_stream = torch.cuda.current_stream() if self.record_stream else None
86-
86+
8787
if self.stream is not None:
8888
# Wait for previous Host->Device transfer to complete
8989
self.stream.synchronize()
@@ -283,7 +283,7 @@ def apply_group_offloading(
283283
num_blocks_per_group: Optional[int] = None,
284284
non_blocking: bool = False,
285285
use_stream: bool = False,
286-
record_stream: bool = False
286+
record_stream: bool = False,
287287
) -> None:
288288
r"""
289289
Applies group offloading to the internal layers of a torch.nn.Module. To understand what group offloading is, and
@@ -381,7 +381,7 @@ def _apply_group_offloading_block_level(
381381
onload_device: torch.device,
382382
non_blocking: bool,
383383
stream: Optional[torch.cuda.Stream] = None,
384-
record_stream: Optional[bool] = False
384+
record_stream: Optional[bool] = False,
385385
) -> None:
386386
r"""
387387
This function applies offloading to groups of torch.nn.ModuleList or torch.nn.Sequential blocks. In comparison to
@@ -482,7 +482,7 @@ def _apply_group_offloading_leaf_level(
482482
onload_device: torch.device,
483483
non_blocking: bool,
484484
stream: Optional[torch.cuda.Stream] = None,
485-
record_stream: Optional[bool] = False
485+
record_stream: Optional[bool] = False,
486486
) -> None:
487487
r"""
488488
This function applies offloading to groups of leaf modules in a torch.nn.Module. This method has minimal memory

src/diffusers/models/modeling_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,14 @@ def enable_group_offload(
585585
f"open an issue at https://github.com/huggingface/diffusers/issues."
586586
)
587587
apply_group_offloading(
588-
self, onload_device, offload_device, offload_type, num_blocks_per_group, non_blocking, use_stream, record_stream
588+
self,
589+
onload_device,
590+
offload_device,
591+
offload_type,
592+
num_blocks_per_group,
593+
non_blocking,
594+
use_stream,
595+
record_stream,
589596
)
590597

591598
def save_pretrained(

0 commit comments

Comments
 (0)