Skip to content

Commit 4b8e466

Browse files
authored
Add missing Args: entries to scheduler docstrings (#14354)
Add missing Args entries to scheduler docstrings Sixteen scheduler methods had Args: blocks that omitted parameters present in the signature. Adds the missing entries: - noise, on the DPMSolver single/multistep and cosine-multistep update methods (required by the sde-* algorithm types) - mu, on DPMSolverMultistep/Singlestep set_timesteps - device, on CogVideoXDDIM and DDIMInverse set_timesteps - sigma / sigma_next / sigma_before, on the Helios UniPC methods Also corrects the rescale_zero_terminal_snr entry in scheduling_dpm_cogvideox, which documented a `betas` parameter the function does not take (it takes alphas_cumprod). The scheduling_dpmsolver_multistep_inverse change is propagated by make fix-copies, not hand-edited. Documentation only; no behavior change.
1 parent 8a29f31 commit 4b8e466

8 files changed

Lines changed: 46 additions & 2 deletions

src/diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ def dpm_solver_first_order_update(
459459
The direct output from the learned diffusion model.
460460
sample (`torch.Tensor`):
461461
A current instance of a sample created by the diffusion process.
462+
noise (`torch.Tensor`, *optional*):
463+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
464+
one of them, and unused otherwise.
462465
463466
Returns:
464467
`torch.Tensor`:
@@ -497,6 +500,9 @@ def multistep_dpm_solver_second_order_update(
497500
The direct outputs from learned diffusion model at current and latter timesteps.
498501
sample (`torch.Tensor`):
499502
A current instance of a sample created by the diffusion process.
503+
noise (`torch.Tensor`, *optional*):
504+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
505+
one of them, and unused otherwise.
500506
501507
Returns:
502508
`torch.Tensor`:

src/diffusers/schedulers/scheduling_ddim_cogvideox.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ def set_timesteps(
285285
Args:
286286
num_inference_steps (`int`):
287287
The number of diffusion steps used when generating samples with a pre-trained model.
288+
device (`str` or `torch.device`, *optional*):
289+
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
288290
"""
289291

290292
if num_inference_steps > self.config.num_train_timesteps:

src/diffusers/schedulers/scheduling_ddim_inverse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ def set_timesteps(
275275
Args:
276276
num_inference_steps (`int`):
277277
The number of diffusion steps used when generating samples with a pre-trained model.
278+
device (`str` or `torch.device`, *optional*):
279+
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
278280
"""
279281

280282
if num_inference_steps > self.config.num_train_timesteps:

src/diffusers/schedulers/scheduling_dpm_cogvideox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def rescale_zero_terminal_snr(alphas_cumprod):
106106
Rescales betas to have zero terminal SNR Based on https://huggingface.co/papers/2305.08891 (Algorithm 1)
107107
108108
Args:
109-
betas (`torch.Tensor`):
110-
the betas that the scheduler is being initialized with.
109+
alphas_cumprod (`torch.Tensor`):
110+
the cumulative product of alphas that the scheduler is being initialized with.
111111
112112
Returns:
113113
`torch.Tensor`: rescaled betas with zero terminal SNR

src/diffusers/schedulers/scheduling_dpmsolver_multistep.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ def set_timesteps(
379379
The number of diffusion steps used when generating samples with a pre-trained model.
380380
device (`str` or `torch.device`, *optional*):
381381
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
382+
mu (`float`, *optional*):
383+
Exponent for the dynamic time shift. Requires `use_dynamic_shifting` and a `time_shift_type` of
384+
`"exponential"`; when passed, `flow_shift` is set to `exp(mu)`.
382385
timesteps (`list[int]`, *optional*):
383386
Custom timesteps used to support arbitrary timesteps schedule. If `None`, timesteps will be generated
384387
based on the `timestep_spacing` attribute. If `timesteps` is passed, `num_inference_steps` and `sigmas`
@@ -931,6 +934,9 @@ def multistep_dpm_solver_second_order_update(
931934
The direct outputs from learned diffusion model at current and latter timesteps.
932935
sample (`torch.Tensor`, *optional*):
933936
A current instance of a sample created by the diffusion process.
937+
noise (`torch.Tensor`, *optional*):
938+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
939+
one of them, and unused otherwise.
934940
935941
Returns:
936942
`torch.Tensor`:

src/diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ def multistep_dpm_solver_second_order_update(
787787
The direct outputs from learned diffusion model at current and latter timesteps.
788788
sample (`torch.Tensor`, *optional*):
789789
A current instance of a sample created by the diffusion process.
790+
noise (`torch.Tensor`, *optional*):
791+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
792+
one of them, and unused otherwise.
790793
791794
Returns:
792795
`torch.Tensor`:

src/diffusers/schedulers/scheduling_dpmsolver_singlestep.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ def set_timesteps(
342342
The number of diffusion steps used when generating samples with a pre-trained model.
343343
device (`str` or `torch.device`, *optional*):
344344
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
345+
mu (`float`, *optional*):
346+
Exponent for the dynamic time shift. Requires `use_dynamic_shifting` and a `time_shift_type` of
347+
`"exponential"`; when passed, `flow_shift` is set to `exp(mu)`.
345348
timesteps (`list[int]`, *optional*):
346349
Custom timesteps used to support arbitrary spacing between timesteps. If `None`, then the default
347350
timestep spacing strategy of equal spacing between timesteps schedule is used. If `timesteps` is
@@ -776,6 +779,9 @@ def dpm_solver_first_order_update(
776779
The previous discrete timestep in the diffusion chain.
777780
sample (`torch.Tensor`):
778781
A current instance of a sample created by the diffusion process.
782+
noise (`torch.Tensor`, *optional*):
783+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
784+
one of them, and unused otherwise.
779785
780786
Returns:
781787
`torch.Tensor`:
@@ -841,6 +847,9 @@ def singlestep_dpm_solver_second_order_update(
841847
The previous discrete timestep in the diffusion chain.
842848
sample (`torch.Tensor`):
843849
A current instance of a sample created by the diffusion process.
850+
noise (`torch.Tensor`, *optional*):
851+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
852+
one of them, and unused otherwise.
844853
845854
Returns:
846855
`torch.Tensor`:
@@ -952,6 +961,9 @@ def singlestep_dpm_solver_third_order_update(
952961
The previous discrete timestep in the diffusion chain.
953962
sample (`torch.Tensor`):
954963
A current instance of a sample created by diffusion process.
964+
noise (`torch.Tensor`, *optional*):
965+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
966+
one of them, and unused otherwise.
955967
956968
Returns:
957969
`torch.Tensor`:
@@ -1076,6 +1088,9 @@ def singlestep_dpm_solver_update(
10761088
A current instance of a sample created by diffusion process.
10771089
order (`int`):
10781090
The solver order at this step.
1091+
noise (`torch.Tensor`, *optional*):
1092+
Random noise used by the stochastic (`sde-*`) solver variants. Required when `algorithm_type` is set to
1093+
one of them, and unused otherwise.
10791094
10801095
Returns:
10811096
`torch.Tensor`:

src/diffusers/schedulers/scheduling_helios.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ def convert_model_output(
386386
The current discrete timestep in the diffusion chain.
387387
sample (`torch.Tensor`):
388388
A current instance of a sample created by the diffusion process.
389+
sigma (`torch.Tensor`, *optional*):
390+
The sigma of the current step in the noise schedule.
389391
390392
Returns:
391393
`torch.Tensor`:
@@ -470,6 +472,10 @@ def multistep_uni_p_bh_update(
470472
A current instance of a sample created by the diffusion process.
471473
order (`int`):
472474
The order of UniP at this timestep (corresponds to the *p* in UniPC-p).
475+
sigma (`torch.Tensor`, *optional*):
476+
The sigma of the current step in the noise schedule.
477+
sigma_next (`torch.Tensor`, *optional*):
478+
The sigma of the next step in the noise schedule.
473479
474480
Returns:
475481
`torch.Tensor`:
@@ -607,6 +613,10 @@ def multistep_uni_c_bh_update(
607613
The generated sample after the last predictor `x_{t}`.
608614
order (`int`):
609615
The `p` of UniC-p at this step. The effective order of accuracy should be `order + 1`.
616+
sigma_before (`torch.Tensor`, *optional*):
617+
The sigma of the previous step in the noise schedule.
618+
sigma (`torch.Tensor`, *optional*):
619+
The sigma of the current step in the noise schedule.
610620
611621
Returns:
612622
`torch.Tensor`:

0 commit comments

Comments
 (0)