From 8ad14a52cbc3b3e0d7f97305dc95fee629564b97 Mon Sep 17 00:00:00 2001 From: yiyixuxu Date: Tue, 13 May 2025 23:25:56 +0200 Subject: [PATCH] make generator intermediates (it is mutable) --- .../stable_diffusion_xl/before_denoise.py | 6 +++--- .../modular_pipelines/stable_diffusion_xl/denoise.py | 4 ++-- .../modular_pipelines/stable_diffusion_xl/encoders.py | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/diffusers/modular_pipelines/stable_diffusion_xl/before_denoise.py b/src/diffusers/modular_pipelines/stable_diffusion_xl/before_denoise.py index 6809b4cd8e..8f083f1870 100644 --- a/src/diffusers/modular_pipelines/stable_diffusion_xl/before_denoise.py +++ b/src/diffusers/modular_pipelines/stable_diffusion_xl/before_denoise.py @@ -440,7 +440,6 @@ class StableDiffusionXLInpaintPrepareLatentsStep(PipelineBlock): @property def inputs(self) -> List[Tuple[str, Any]]: return [ - InputParam("generator"), InputParam("latents"), InputParam("num_images_per_prompt", default=1), InputParam("denoising_start"), @@ -459,6 +458,7 @@ class StableDiffusionXLInpaintPrepareLatentsStep(PipelineBlock): @property def intermediates_inputs(self) -> List[str]: return [ + InputParam("generator"), InputParam( "batch_size", required=True, @@ -733,7 +733,6 @@ class StableDiffusionXLImg2ImgPrepareLatentsStep(PipelineBlock): @property def inputs(self) -> List[Tuple[str, Any]]: return [ - InputParam("generator"), InputParam("latents"), InputParam("num_images_per_prompt", default=1), InputParam("denoising_start"), @@ -742,6 +741,7 @@ class StableDiffusionXLImg2ImgPrepareLatentsStep(PipelineBlock): @property def intermediates_inputs(self) -> List[InputParam]: return [ + InputParam("generator"), InputParam("latent_timestep", required=True, type_hint=torch.Tensor, description="The timestep that represents the initial noise level for image-to-image/inpainting generation. Can be generated in set_timesteps step."), InputParam("image_latents", required=True, type_hint=torch.Tensor, description="The latents representing the reference image for image-to-image/inpainting generation. Can be generated in vae_encode step."), InputParam("batch_size", required=True, type_hint=int, description="Number of prompts, the final batch size of model inputs should be batch_size * num_images_per_prompt. Can be generated in input step."), @@ -879,7 +879,6 @@ class StableDiffusionXLPrepareLatentsStep(PipelineBlock): return [ InputParam("height"), InputParam("width"), - InputParam("generator"), InputParam("latents"), InputParam("num_images_per_prompt", default=1), ] @@ -887,6 +886,7 @@ class StableDiffusionXLPrepareLatentsStep(PipelineBlock): @property def intermediates_inputs(self) -> List[InputParam]: return [ + InputParam("generator"), InputParam( "batch_size", required=True, diff --git a/src/diffusers/modular_pipelines/stable_diffusion_xl/denoise.py b/src/diffusers/modular_pipelines/stable_diffusion_xl/denoise.py index f605d0ab00..b29920764a 100644 --- a/src/diffusers/modular_pipelines/stable_diffusion_xl/denoise.py +++ b/src/diffusers/modular_pipelines/stable_diffusion_xl/denoise.py @@ -485,13 +485,13 @@ class StableDiffusionXLDenoiseLoopAfterDenoiser(PipelineBlock): @property def inputs(self) -> List[Tuple[str, Any]]: return [ - InputParam("generator"), InputParam("eta", default=0.0), ] @property def intermediates_inputs(self) -> List[str]: return [ + InputParam("generator"), InputParam( "latents", required=True, @@ -554,13 +554,13 @@ class StableDiffusionXLInpaintDenoiseLoopAfterDenoiser(PipelineBlock): @property def inputs(self) -> List[Tuple[str, Any]]: return [ - InputParam("generator"), InputParam("eta", default=0.0), ] @property def intermediates_inputs(self) -> List[str]: return [ + InputParam("generator"), InputParam( "timesteps", required=True, diff --git a/src/diffusers/modular_pipelines/stable_diffusion_xl/encoders.py b/src/diffusers/modular_pipelines/stable_diffusion_xl/encoders.py index 3c84fc71c8..ca4efe2c4a 100644 --- a/src/diffusers/modular_pipelines/stable_diffusion_xl/encoders.py +++ b/src/diffusers/modular_pipelines/stable_diffusion_xl/encoders.py @@ -568,7 +568,6 @@ class StableDiffusionXLVaeEncoderStep(PipelineBlock): def inputs(self) -> List[InputParam]: return [ InputParam("image", required=True), - InputParam("generator"), InputParam("height"), InputParam("width"), ] @@ -576,6 +575,7 @@ class StableDiffusionXLVaeEncoderStep(PipelineBlock): @property def intermediates_inputs(self) -> List[InputParam]: return [ + InputParam("generator"), InputParam("dtype", type_hint=torch.dtype, description="Data type of model tensor inputs"), InputParam("preprocess_kwargs", type_hint=Optional[dict], description="A kwargs dictionary that if specified is passed along to the `ImageProcessor` as defined under `self.image_processor` in [diffusers.image_processor.VaeImageProcessor]")] @@ -680,7 +680,6 @@ class StableDiffusionXLInpaintVaeEncoderStep(PipelineBlock): return [ InputParam("height"), InputParam("width"), - InputParam("generator"), InputParam("image", required=True), InputParam("mask_image", required=True), InputParam("padding_mask_crop"), @@ -688,7 +687,10 @@ class StableDiffusionXLInpaintVaeEncoderStep(PipelineBlock): @property def intermediates_inputs(self) -> List[InputParam]: - return [InputParam("dtype", type_hint=torch.dtype, description="The dtype of the model inputs")] + return [ + InputParam("dtype", type_hint=torch.dtype, description="The dtype of the model inputs"), + InputParam("generator"), + ] @property def intermediates_outputs(self) -> List[OutputParam]: