Skip to content

Commit 3f20e6b

Browse files
committed
apply suggestions from review
1 parent db125ce commit 3f20e6b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/diffusers/hooks/group_offloading.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -550,27 +550,23 @@ def _apply_group_offloading_leaf_level(
550550
)
551551
_apply_group_offloading_hook(parent_module, group, None)
552552

553-
# This is a dummy group that will handle lazy prefetching from the top-level module to the first leaf module
554-
unmatched_group = ModuleGroup(
555-
modules=[],
556-
offload_device=offload_device,
557-
onload_device=onload_device,
558-
offload_leader=module,
559-
onload_leader=module,
560-
parameters=None,
561-
buffers=None,
562-
non_blocking=False,
563-
stream=None,
564-
cpu_param_dict=None,
565-
onload_self=True,
566-
)
567-
568-
# When using streams, we need to know the layer execution order for applying prefetching (to overlap data transfer
569-
# and computation). Since we don't know the order beforehand, we apply a lazy prefetching hook that will find the
570-
# execution order and apply prefetching in the correct order.
571-
if stream is None:
572-
_apply_group_offloading_hook(module, unmatched_group, None)
573-
else:
553+
if stream is not None:
554+
# When using streams, we need to know the layer execution order for applying prefetching (to overlap data transfer
555+
# and computation). Since we don't know the order beforehand, we apply a lazy prefetching hook that will find the
556+
# execution order and apply prefetching in the correct order.
557+
unmatched_group = ModuleGroup(
558+
modules=[],
559+
offload_device=offload_device,
560+
onload_device=onload_device,
561+
offload_leader=module,
562+
onload_leader=module,
563+
parameters=None,
564+
buffers=None,
565+
non_blocking=False,
566+
stream=None,
567+
cpu_param_dict=None,
568+
onload_self=True,
569+
)
574570
_apply_lazy_group_offloading_hook(module, unmatched_group, None)
575571

576572

0 commit comments

Comments
 (0)