`UniPCMultistepScheduler` is a training-free framework designed for the fast sampling of diffusion models. This model inherits from [`SchedulerMixin`] and [`ConfigMixin`]. Check the superclass documentation for the generic methods the library implements for all schedulers such as loadi
| 20 | |
| 21 | |
| 22 | class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin): |
| 23 | """ |
| 24 | `UniPCMultistepScheduler` is a training-free framework designed for the fast sampling of diffusion models. |
| 25 | |
| 26 | This model inherits from [`SchedulerMixin`] and [`ConfigMixin`]. Check the superclass documentation for the generic |
| 27 | methods the library implements for all schedulers such as loading and saving. |
| 28 | |
| 29 | Args: |
| 30 | num_train_timesteps (`int`, defaults to 1000): |
| 31 | The number of diffusion steps to train the model. |
| 32 | solver_order (`int`, default `2`): |
| 33 | The UniPC order which can be any positive integer. The effective order of accuracy is `solver_order + 1` |
| 34 | due to the UniC. It is recommended to use `solver_order=2` for guided sampling, and `solver_order=3` for |
| 35 | unconditional sampling. |
| 36 | prediction_type (`str`, defaults to "flow_prediction"): |
| 37 | Prediction type of the scheduler function; must be `flow_prediction` for this scheduler, which predicts |
| 38 | the flow of the diffusion process. |
| 39 | thresholding (`bool`, defaults to `False`): |
| 40 | Whether to use the "dynamic thresholding" method. This is unsuitable for latent-space diffusion models such |
| 41 | as Stable Diffusion. |
| 42 | dynamic_thresholding_ratio (`float`, defaults to 0.995): |
| 43 | The ratio for the dynamic thresholding method. Valid only when `thresholding=True`. |
| 44 | sample_max_value (`float`, defaults to 1.0): |
| 45 | The threshold value for dynamic thresholding. Valid only when `thresholding=True` and `predict_x0=True`. |
| 46 | predict_x0 (`bool`, defaults to `True`): |
| 47 | Whether to use the updating algorithm on the predicted x0. |
| 48 | solver_type (`str`, default `bh2`): |
| 49 | Solver type for UniPC. It is recommended to use `bh1` for unconditional sampling when steps < 10, and `bh2` |
| 50 | otherwise. |
| 51 | lower_order_final (`bool`, default `True`): |
| 52 | Whether to use lower-order solvers in the final steps. Only valid for < 15 inference steps. This can |
| 53 | stabilize the sampling of DPMSolver for steps < 15, especially for steps <= 10. |
| 54 | disable_corrector (`list`, default `[]`): |
| 55 | Decides which step to disable the corrector to mitigate the misalignment between `epsilon_theta(x_t, c)` |
| 56 | and `epsilon_theta(x_t^c, c)` which can influence convergence for a large guidance scale. Corrector is |
| 57 | usually disabled during the first few steps. |
| 58 | solver_p (`SchedulerMixin`, default `None`): |
| 59 | Any other scheduler that if specified, the algorithm becomes `solver_p + UniC`. |
| 60 | use_karras_sigmas (`bool`, *optional*, defaults to `False`): |
| 61 | Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`, |
| 62 | the sigmas are determined according to a sequence of noise levels {σi}. |
| 63 | use_exponential_sigmas (`bool`, *optional*, defaults to `False`): |
| 64 | Whether to use exponential sigmas for step sizes in the noise schedule during the sampling process. |
| 65 | timestep_spacing (`str`, defaults to `"linspace"`): |
| 66 | The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and |
| 67 | Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information. |
| 68 | steps_offset (`int`, defaults to 0): |
| 69 | An offset added to the inference steps, as required by some model families. |
| 70 | final_sigmas_type (`str`, defaults to `"zero"`): |
| 71 | The final `sigma` value for the noise schedule during the sampling process. If `"sigma_min"`, the final |
| 72 | sigma is the same as the last sigma in the training schedule. If `zero`, the final sigma is set to 0. |
| 73 | """ |
| 74 | |
| 75 | _compatibles = [e.name for e in KarrasDiffusionSchedulers] |
| 76 | order = 1 |
| 77 | |
| 78 | @register_to_config |
| 79 | def __init__( |