Skip to content

Commit 358d196

Browse files
comfyanonymouspurzbeats
authored andcommitted
Fix h3 fun controlnet with comfy compiler. (#16240)
1 parent 9a8450f commit 358d196

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎comfy_extras/nodes_minimax_h3.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import nodes
1919
import comfy.model_management
20+
import comfy.model_prefetch
2021
import comfy.model_sampling
2122
import comfy.nested_tensor
2223
import comfy.patcher_extension
@@ -478,7 +479,8 @@ def diffusion_model_wrapper(self, executor, x, timestep, context, transformer_op
478479
self.active = self.sigma_end <= sigma <= self.sigma_start
479480
self.control_stream = None
480481
if self.active:
481-
self.prepare_control_latent(x[0].shape)
482+
with comfy.model_prefetch.pause_malloc_graph():
483+
self.prepare_control_latent(x[0].shape)
482484
try:
483485
return executor(x, timestep, context, transformer_options, **kwargs)
484486
finally:
@@ -540,12 +542,15 @@ def __init__(self, control_patch, block_index, previous):
540542
self.previous = previous
541543

542544
def __call__(self, args, extra_args):
543-
self.control_patch.before_block(self.block_index, args)
545+
# Control state must stay outside the base block's allocation scope.
546+
with comfy.model_prefetch.pause_malloc_graph():
547+
self.control_patch.before_block(self.block_index, args)
544548
if self.previous is None:
545549
out = extra_args["original_block"](args)
546550
else:
547551
out = self.previous(args, extra_args)
548-
return self.control_patch.after_block(self.block_index, args, out)
552+
with comfy.model_prefetch.pause_malloc_graph():
553+
return self.control_patch.after_block(self.block_index, args, out)
549554

550555
def to(self, device_or_dtype):
551556
self.control_patch.to(device_or_dtype)

0 commit comments

Comments
 (0)