clear FasterCache after done

This commit is contained in:
kijai 2024-10-31 02:03:59 +02:00
parent 57262d9762
commit 0e8f8140e4
2 changed files with 15 additions and 2 deletions

View File

@ -723,8 +723,6 @@ class CogVideoX_Fun_Pipeline_Inpaint(VideoSysPipeline):
device = self._execution_device
#self.vae.to(device)
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
# corresponds to doing no classifier free guidance.
@ -911,6 +909,7 @@ class CogVideoX_Fun_Pipeline_Inpaint(VideoSysPipeline):
for i, t in enumerate(timesteps):
if self.interrupt:
continue
if use_temporal_tiling and isinstance(self.scheduler, CogVideoXDDIMScheduler):
#temporal tiling code based on https://github.com/mayuelala/FollowYourEmoji/blob/main/models/video_pipeline.py
# =====================================================

View File

@ -772,6 +772,13 @@ class CogVideoSampler:
)
if not pipeline["cpu_offloading"]:
pipe.transformer.to(offload_device)
if fastercache is not None:
for block in pipe.transformer.transformer_blocks:
if (hasattr, block, "cached_hidden_states") and block.cached_hidden_states is not None:
block.cached_hidden_states = None
block.cached_encoder_hidden_states = None
mm.soft_empty_cache()
return (pipeline, {"samples": latents})
@ -1012,6 +1019,13 @@ class CogVideoXFunSampler:
)
#if not pipeline["cpu_offloading"]:
# pipe.transformer.to(offload_device)
#clear FasterCache
if fastercache is not None:
for block in pipe.transformer.transformer_blocks:
if (hasattr, block, "cached_hidden_states") and block.cached_hidden_states is not None:
block.cached_hidden_states = None
block.cached_encoder_hidden_states = None
mm.soft_empty_cache()
return (pipeline, {"samples": latents})