From 46013e8e3fcf6e6b712079fe8f306ac8b449bacd Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 8 Sep 2022 14:04:09 +0200 Subject: [PATCH] [Docs] Fix scheduler docs (#421) * [Docs] Fix scheduler docs * up * Apply suggestions from code review --- docs/source/api/schedulers.mdx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/source/api/schedulers.mdx b/docs/source/api/schedulers.mdx index 1deff1a4bb..1b17c2ba19 100644 --- a/docs/source/api/schedulers.mdx +++ b/docs/source/api/schedulers.mdx @@ -14,7 +14,8 @@ specific language governing permissions and limitations under the License. Diffusers contains multiple pre-built schedule functions for the diffusion process. -## What is a schduler? +## What is a scheduler? + The schedule functions, denoted *Schedulers* in the library take in the output of a trained model, a sample which the diffusion process is iterating on, and a timestep to return a denoised sample. - Schedulers define the methodology for iteratively adding noise to an image or for updating a sample based on model outputs. @@ -23,73 +24,77 @@ The schedule functions, denoted *Schedulers* in the library take in the output o - Schedulers are often defined by a *noise schedule* and an *update rule* to solve the differential equation solution. ### Discrete versus continuous schedulers + All schedulers take in a timestep to predict the updated version of the sample being diffused. The timesteps dictate where in the diffusion process the step is, where data is generated by iterating forward in time and inference is executed by propagating backwards through timesteps. -Different algorithms use timesteps that both discrete (accepting `int` inputs), such as the [`DDPMScheduler`] or [`PNDMScheduler`], and continuous (accepting 'float` inputs), such as the score-based schedulers [`ScoreSdeVeScheduler`] or [`ScoreSdeVpScheduler`]. +Different algorithms use timesteps that both discrete (accepting `int` inputs), such as the [`DDPMScheduler`] or [`PNDMScheduler`], and continuous (accepting `float` inputs), such as the score-based schedulers [`ScoreSdeVeScheduler`] or [`ScoreSdeVpScheduler`]. ## Designing Re-usable schedulers + The core design principle between the schedule functions is to be model, system, and framework independent. This allows for rapid experimentation and cleaner abstractions in the code, where the model prediction is separated from the sample update. To this end, the design of schedulers is such that: + - Schedulers can be used interchangeably between diffusion models in inference to find the preferred trade-off between speed and generation quality. - Schedulers are currently by default in PyTorch, but are designed to be framework independent (partial Numpy support currently exists). ## API + The core API for any new scheduler must follow a limited structure. - Schedulers should provide one or more `def step(...)` functions that should be called to update the generated sample iteratively. - Schedulers should provide a `set_timesteps(...)` method that configures the parameters of a schedule function for a specific inference task. - Schedulers should be framework-agonstic, but provide a simple functionality to convert the scheduler into a specific framework, such as PyTorch with a `set_format(...)` method. -### Core The base class [`SchedulerMixin`] implements low level utilities used by multiple schedulers. -#### SchedulerMixin +### SchedulerMixin [[autodoc]] SchedulerMixin -#### SchedulerOutput +### SchedulerOutput The class [`SchedulerOutput`] contains the ouputs from any schedulers `step(...)` call. + [[autodoc]] schedulers.scheduling_utils.SchedulerOutput -### Existing Schedulers +### Implemented Schedulers #### Denoising diffusion implicit models (DDIM) Original paper can be found here. -[[autodoc]] schedulers.scheduling_ddim.DDIMScheduler +[[autodoc]] DDIMScheduler #### Denoising diffusion probabilistic models (DDPM) Original paper can be found [here](https://arxiv.org/abs/2010.02502). -[[autodoc]] schedulers.scheduling_ddpm.DDPMScheduler +[[autodoc]] DDPMScheduler #### Varience exploding, stochastic sampling from Karras et. al Original paper can be found [here](https://arxiv.org/abs/2006.11239). -[[autodoc]] schedulers.scheduling_karras_ve.KarrasVeScheduler +[[autodoc]] KarrasVeScheduler #### Linear multistep scheduler for discrete beta schedules Original implementation can be found [here](https://arxiv.org/abs/2206.00364). -[[autodoc]] schedulers.scheduling_lms_discrete.LMSDiscreteScheduler +[[autodoc]] LMSDiscreteScheduler #### Pseudo numerical methods for diffusion models (PNDM) Original implementation can be found [here](https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181). -[[autodoc]] schedulers.scheduling_pndm.PNDMScheduler +[[autodoc]] PNDMScheduler #### variance exploding stochastic differential equation (SDE) scheduler Original paper can be found [here](https://arxiv.org/abs/2011.13456). -[[autodoc]] schedulers.scheduling_sde_ve.ScoreSdeVeScheduler +[[autodoc]] ScoreSdeVeScheduler #### variance preserving stochastic differential equation (SDE) scheduler