Skip to content

Commit a2d424e

Browse files
authored
Add sigmas to pipelines using FlowMatch (#10116)
1 parent 25ddc79 commit a2d424e

9 files changed

+44
-58
lines changed

src/diffusers/pipelines/aura_flow/pipeline_aura_flow.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ def __call__(
387387
prompt: Union[str, List[str]] = None,
388388
negative_prompt: Union[str, List[str]] = None,
389389
num_inference_steps: int = 50,
390-
timesteps: List[int] = None,
391390
sigmas: List[float] = None,
392391
guidance_scale: float = 3.5,
393392
num_images_per_prompt: Optional[int] = 1,
@@ -424,10 +423,6 @@ def __call__(
424423
sigmas (`List[float]`, *optional*):
425424
Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
426425
`num_inference_steps` and `timesteps` must be `None`.
427-
timesteps (`List[int]`, *optional*):
428-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
429-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
430-
passed will be used. Must be in descending order.
431426
guidance_scale (`float`, *optional*, defaults to 5.0):
432427
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
433428
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -522,9 +517,7 @@ def __call__(
522517
# 4. Prepare timesteps
523518

524519
# sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps)
525-
timesteps, num_inference_steps = retrieve_timesteps(
526-
self.scheduler, num_inference_steps, device, timesteps, sigmas
527-
)
520+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
528521

529522
# 5. Prepare latents.
530523
latent_channels = self.transformer.config.in_channels

src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def __call__(
733733
height: Optional[int] = None,
734734
width: Optional[int] = None,
735735
num_inference_steps: int = 28,
736-
timesteps: List[int] = None,
736+
sigmas: Optional[List[float]] = None,
737737
guidance_scale: float = 7.0,
738738
control_guidance_start: Union[float, List[float]] = 0.0,
739739
control_guidance_end: Union[float, List[float]] = 1.0,
@@ -778,10 +778,10 @@ def __call__(
778778
num_inference_steps (`int`, *optional*, defaults to 50):
779779
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
780780
expense of slower inference.
781-
timesteps (`List[int]`, *optional*):
782-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
783-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
784-
passed will be used. Must be in descending order.
781+
sigmas (`List[float]`, *optional*):
782+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
783+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
784+
will be used.
785785
guidance_scale (`float`, *optional*, defaults to 5.0):
786786
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
787787
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -998,7 +998,7 @@ def __call__(
998998
assert False
999999

10001000
# 4. Prepare timesteps
1001-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
1001+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
10021002
num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
10031003
self._num_timesteps = len(timesteps)
10041004

src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ def __call__(
787787
height: Optional[int] = None,
788788
width: Optional[int] = None,
789789
num_inference_steps: int = 28,
790-
timesteps: List[int] = None,
790+
sigmas: Optional[List[float]] = None,
791791
guidance_scale: float = 7.0,
792792
control_guidance_start: Union[float, List[float]] = 0.0,
793793
control_guidance_end: Union[float, List[float]] = 1.0,
@@ -833,10 +833,10 @@ def __call__(
833833
num_inference_steps (`int`, *optional*, defaults to 50):
834834
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
835835
expense of slower inference.
836-
timesteps (`List[int]`, *optional*):
837-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
838-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
839-
passed will be used. Must be in descending order.
836+
sigmas (`List[float]`, *optional*):
837+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
838+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
839+
will be used.
840840
guidance_scale (`float`, *optional*, defaults to 5.0):
841841
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
842842
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -1033,7 +1033,7 @@ def __call__(
10331033
controlnet_pooled_projections = controlnet_pooled_projections or pooled_prompt_embeds
10341034

10351035
# 4. Prepare timesteps
1036-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
1036+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
10371037
num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
10381038
self._num_timesteps = len(timesteps)
10391039

src/diffusers/pipelines/lumina/pipeline_lumina.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ def __call__(
617617
width: Optional[int] = None,
618618
height: Optional[int] = None,
619619
num_inference_steps: int = 30,
620-
timesteps: List[int] = None,
621620
guidance_scale: float = 4.0,
622621
negative_prompt: Union[str, List[str]] = None,
623622
sigmas: List[float] = None,
@@ -649,10 +648,6 @@ def __call__(
649648
num_inference_steps (`int`, *optional*, defaults to 30):
650649
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
651650
expense of slower inference.
652-
timesteps (`List[int]`, *optional*):
653-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
654-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
655-
passed will be used. Must be in descending order.
656651
sigmas (`List[float]`, *optional*):
657652
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
658653
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
@@ -776,9 +771,7 @@ def __call__(
776771
prompt_attention_mask = torch.cat([prompt_attention_mask, negative_prompt_attention_mask], dim=0)
777772

778773
# 4. Prepare timesteps
779-
timesteps, num_inference_steps = retrieve_timesteps(
780-
self.scheduler, num_inference_steps, device, timesteps, sigmas
781-
)
774+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
782775

783776
# 5. Prepare latents.
784777
latent_channels = self.transformer.config.in_channels

src/diffusers/pipelines/pag/pipeline_pag_sd_3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def __call__(
693693
height: Optional[int] = None,
694694
width: Optional[int] = None,
695695
num_inference_steps: int = 28,
696-
timesteps: List[int] = None,
696+
sigmas: Optional[List[float]] = None,
697697
guidance_scale: float = 7.0,
698698
negative_prompt: Optional[Union[str, List[str]]] = None,
699699
negative_prompt_2: Optional[Union[str, List[str]]] = None,
@@ -735,10 +735,10 @@ def __call__(
735735
num_inference_steps (`int`, *optional*, defaults to 50):
736736
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
737737
expense of slower inference.
738-
timesteps (`List[int]`, *optional*):
739-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
740-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
741-
passed will be used. Must be in descending order.
738+
sigmas (`List[float]`, *optional*):
739+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
740+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
741+
will be used.
742742
guidance_scale (`float`, *optional*, defaults to 7.0):
743743
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
744744
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -890,7 +890,7 @@ def __call__(
890890
pooled_prompt_embeds = torch.cat([negative_pooled_prompt_embeds, pooled_prompt_embeds], dim=0)
891891

892892
# 4. Prepare timesteps
893-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
893+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
894894
num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
895895
self._num_timesteps = len(timesteps)
896896

src/diffusers/pipelines/pag/pipeline_pag_sd_3_img2img.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def __call__(
733733
image: PipelineImageInput = None,
734734
strength: float = 0.6,
735735
num_inference_steps: int = 50,
736-
timesteps: List[int] = None,
736+
sigmas: Optional[List[float]] = None,
737737
guidance_scale: float = 7.0,
738738
negative_prompt: Optional[Union[str, List[str]]] = None,
739739
negative_prompt_2: Optional[Union[str, List[str]]] = None,
@@ -783,10 +783,10 @@ def __call__(
783783
num_inference_steps (`int`, *optional*, defaults to 50):
784784
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
785785
expense of slower inference.
786-
timesteps (`List[int]`, *optional*):
787-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
788-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
789-
passed will be used. Must be in descending order.
786+
sigmas (`List[float]`, *optional*):
787+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
788+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
789+
will be used.
790790
guidance_scale (`float`, *optional*, defaults to 7.0):
791791
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
792792
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -936,7 +936,7 @@ def __call__(
936936
image = self.image_processor.preprocess(image)
937937

938938
# 4. Prepare timesteps
939-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
939+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
940940
timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device)
941941
latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt)
942942
# 5. Prepare latent variables

src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def __call__(
679679
height: Optional[int] = None,
680680
width: Optional[int] = None,
681681
num_inference_steps: int = 28,
682-
timesteps: List[int] = None,
682+
sigmas: Optional[List[float]] = None,
683683
guidance_scale: float = 7.0,
684684
negative_prompt: Optional[Union[str, List[str]]] = None,
685685
negative_prompt_2: Optional[Union[str, List[str]]] = None,
@@ -723,10 +723,10 @@ def __call__(
723723
num_inference_steps (`int`, *optional*, defaults to 50):
724724
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
725725
expense of slower inference.
726-
timesteps (`List[int]`, *optional*):
727-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
728-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
729-
passed will be used. Must be in descending order.
726+
sigmas (`List[float]`, *optional*):
727+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
728+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
729+
will be used.
730730
guidance_scale (`float`, *optional*, defaults to 7.0):
731731
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
732732
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -883,7 +883,7 @@ def __call__(
883883
pooled_prompt_embeds = torch.cat([negative_pooled_prompt_embeds, pooled_prompt_embeds], dim=0)
884884

885885
# 4. Prepare timesteps
886-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
886+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
887887
num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
888888
self._num_timesteps = len(timesteps)
889889

src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def __call__(
713713
image: PipelineImageInput = None,
714714
strength: float = 0.6,
715715
num_inference_steps: int = 50,
716-
timesteps: List[int] = None,
716+
sigmas: Optional[List[float]] = None,
717717
guidance_scale: float = 7.0,
718718
negative_prompt: Optional[Union[str, List[str]]] = None,
719719
negative_prompt_2: Optional[Union[str, List[str]]] = None,
@@ -753,10 +753,10 @@ def __call__(
753753
num_inference_steps (`int`, *optional*, defaults to 50):
754754
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
755755
expense of slower inference.
756-
timesteps (`List[int]`, *optional*):
757-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
758-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
759-
passed will be used. Must be in descending order.
756+
sigmas (`List[float]`, *optional*):
757+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
758+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
759+
will be used.
760760
guidance_scale (`float`, *optional*, defaults to 7.0):
761761
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
762762
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -893,7 +893,7 @@ def __call__(
893893
image = self.image_processor.preprocess(image)
894894

895895
# 4. Prepare timesteps
896-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
896+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
897897
timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device)
898898
latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt)
899899

src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def __call__(
806806
padding_mask_crop: Optional[int] = None,
807807
strength: float = 0.6,
808808
num_inference_steps: int = 50,
809-
timesteps: List[int] = None,
809+
sigmas: Optional[List[float]] = None,
810810
guidance_scale: float = 7.0,
811811
negative_prompt: Optional[Union[str, List[str]]] = None,
812812
negative_prompt_2: Optional[Union[str, List[str]]] = None,
@@ -874,10 +874,10 @@ def __call__(
874874
num_inference_steps (`int`, *optional*, defaults to 50):
875875
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
876876
expense of slower inference.
877-
timesteps (`List[int]`, *optional*):
878-
Custom timesteps to use for the denoising process with schedulers which support a `timesteps` argument
879-
in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
880-
passed will be used. Must be in descending order.
877+
sigmas (`List[float]`, *optional*):
878+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
879+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
880+
will be used.
881881
guidance_scale (`float`, *optional*, defaults to 7.0):
882882
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
883883
`guidance_scale` is defined as `w` of equation 2. of [Imagen
@@ -1007,7 +1007,7 @@ def __call__(
10071007
pooled_prompt_embeds = torch.cat([negative_pooled_prompt_embeds, pooled_prompt_embeds], dim=0)
10081008

10091009
# 3. Prepare timesteps
1010-
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, timesteps)
1010+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, sigmas=sigmas)
10111011
timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device)
10121012
# check that number of inference steps is not < 1 - as this doesn't make sense
10131013
if num_inference_steps < 1:

0 commit comments

Comments
 (0)