Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/diffusers/modular_pipelines/cosmos/modular_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ class Cosmos3OmniModularPipeline(ModularPipeline):
inverse_image_resolution_template = "This image is not of {height}x{width} resolution."
inverse_video_resolution_template = "This video is not of {height}x{width} resolution."

def __call__(self, *args, **kwargs):
transformer = getattr(self, "transformer", None)
try:
return super().__call__(*args, **kwargs)
finally:
if hasattr(transformer, "_reset_stateful_cache"):
transformer._reset_stateful_cache()

@property
def vae_scale_factor_spatial(self):
if getattr(self, "vae", None) is not None:
Expand Down
6 changes: 6 additions & 0 deletions src/diffusers/modular_pipelines/modular_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3041,6 +3041,12 @@ def __call__(self, state: PipelineState = None, output: str | list[str] = None,
error_msg = f"Error in block: ({self._blocks.__class__.__name__}):\n"
logger.error(error_msg)
raise
finally:
# Cache hooks (FirstBlockCache, MagCache, ...) keep state across a run. Clear it so the next call
# starts fresh, as `maybe_free_model_hooks` does for standard pipelines.
for component in self.components.values():
if hasattr(component, "_reset_stateful_cache"):
component._reset_stateful_cache()

if output is None:
return state
Expand Down
Loading