Unverified Commit beb85668 authored by hlky's avatar hlky Committed by GitHub
Browse files

Fix `num_images_per_prompt>1` with Skip Guidance Layers in `StableDiffusion3Pipeline` (#10086)

parent a9d3f6c3
...@@ -907,11 +907,7 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle ...@@ -907,11 +907,7 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
continue continue
# expand the latents if we are doing classifier free guidance # expand the latents if we are doing classifier free guidance
latent_model_input = ( latent_model_input = torch.cat([latents] * 2) if self.do_classifier_free_guidance else latents
torch.cat([latents] * 2)
if self.do_classifier_free_guidance and skip_guidance_layers is None
else latents
)
# broadcast to batch dimension in a way that's compatible with ONNX/Core ML # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
timestep = t.expand(latent_model_input.shape[0]) timestep = t.expand(latent_model_input.shape[0])
...@@ -935,6 +931,8 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle ...@@ -935,6 +931,8 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
else False else False
) )
if skip_guidance_layers is not None and should_skip_layers: if skip_guidance_layers is not None and should_skip_layers:
timestep = t.expand(latents.shape[0])
latent_model_input = latents
noise_pred_skip_layers = self.transformer( noise_pred_skip_layers = self.transformer(
hidden_states=latent_model_input, hidden_states=latent_model_input,
timestep=timestep, timestep=timestep,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment