import{S as ds,i as ls,s as cs,e as s,k as l,w as g,t as i,M as ps,c as o,d as r,m as c,a as n,x as _,h as a,b as d,G as e,g as u,y as v,L as us,q as b,o as y,B as P,v as hs}from"../../../chunks/vendor-hf-doc-builder.js";import{D as W}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ht}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function fs(Tr){let U,qe,x,D,_e,H,ft,ve,mt,Ve,w,be,gt,_t,R,vt,bt,ze,le,yt,Be,ce,Pt,We,J,pe,Ct,Z,Ut,xt,He,F,wt,Y,St,$t,Re,S,I,ye,j,Tt,Pe,Mt,Je,C,Et,Ce,Dt,Ft,Ue,It,Ot,Ze,m,kt,G,At,Nt,xe,Lt,qt,we,Vt,zt,Ye,$,O,Se,K,Bt,$e,Wt,je,h,Q,Ht,ue,Te,Rt,Jt,Zt,T,Yt,he,jt,Gt,fe,Kt,Qt,Xt,k,X,er,Me,tr,rr,A,ee,sr,Ee,or,nr,N,te,ir,re,ar,De,dr,lr,cr,L,se,pr,Fe,ur,hr,q,oe,fr,Ie,mr,gr,V,ne,_r,Oe,vr,Ge,M,z,ke,ie,br,Ae,yr,Ke,E,ae,Pr,de,Cr,Ne,Ur,xr,Qe;return H=new ht({}),j=new ht({}),K=new ht({}),Q=new W({props:{name:"class diffusers.UniPCMultistepScheduler",anchor:"diffusers.UniPCMultistepScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"solver_order",val:": int = 2"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"thresholding",val:": bool = False"},{name:"dynamic_thresholding_ratio",val:": float = 0.995"},{name:"sample_max_value",val:": float = 1.0"},{name:"predict_x0",val:": bool = True"},{name:"solver_type",val:": str = 'bh2'"},{name:"lower_order_final",val:": bool = True"},{name:"disable_corrector",val:": typing.List[int] = []"},{name:"solver_p",val:": SchedulerMixin = None"},{name:"use_karras_sigmas",val:": typing.Optional[bool] = False"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 1000) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.UniPCMultistepScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.0001) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.UniPCMultistepScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.02) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.UniPCMultistepScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>, defaults to <code>&quot;linear&quot;</code>) &#x2014;
The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
<code>linear</code>, <code>scaled_linear</code>, or <code>squaredcos_cap_v2</code>.`,name:"beta_schedule"},{anchor:"diffusers.UniPCMultistepScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, <em>optional</em>) &#x2014;
Pass an array of betas directly to the constructor to bypass <code>beta_start</code> and <code>beta_end</code>.`,name:"trained_betas"},{anchor:"diffusers.UniPCMultistepScheduler.solver_order",description:`<strong>solver_order</strong> (<code>int</code>, default <code>2</code>) &#x2014;
The UniPC order which can be any positive integer. The effective order of accuracy is <code>solver_order + 1</code>
due to the UniC. It is recommended to use <code>solver_order=2</code> for guided sampling, and <code>solver_order=3</code> for
unconditional sampling.`,name:"solver_order"},{anchor:"diffusers.UniPCMultistepScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, defaults to <code>epsilon</code>, <em>optional</em>) &#x2014;
Prediction type of the scheduler function; can be <code>epsilon</code> (predicts the noise of the diffusion process),
<code>sample</code> (directly predicts the noisy sample<code>) or </code>v_prediction\` (see section 2.4 of <a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">Imagen
Video</a> paper).`,name:"prediction_type"},{anchor:"diffusers.UniPCMultistepScheduler.thresholding",description:`<strong>thresholding</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use the &#x201C;dynamic thresholding&#x201D; method. This is unsuitable for latent-space diffusion models such
as Stable Diffusion.`,name:"thresholding"},{anchor:"diffusers.UniPCMultistepScheduler.dynamic_thresholding_ratio",description:`<strong>dynamic_thresholding_ratio</strong> (<code>float</code>, defaults to 0.995) &#x2014;
The ratio for the dynamic thresholding method. Valid only when <code>thresholding=True</code>.`,name:"dynamic_thresholding_ratio"},{anchor:"diffusers.UniPCMultistepScheduler.sample_max_value",description:`<strong>sample_max_value</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The threshold value for dynamic thresholding. Valid only when <code>thresholding=True</code> and <code>predict_x0=True</code>.`,name:"sample_max_value"},{anchor:"diffusers.UniPCMultistepScheduler.predict_x0",description:`<strong>predict_x0</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use the updating algorithm on the predicted x0.`,name:"predict_x0"},{anchor:"diffusers.UniPCMultistepScheduler.solver_type",description:`<strong>solver_type</strong> (<code>str</code>, default <code>bh2</code>) &#x2014;
Solver type for UniPC. It is recommended to use <code>bh1</code> for unconditional sampling when steps &lt; 10, and <code>bh2</code>
otherwise.`,name:"solver_type"},{anchor:"diffusers.UniPCMultistepScheduler.lower_order_final",description:`<strong>lower_order_final</strong> (<code>bool</code>, default <code>True</code>) &#x2014;
Whether to use lower-order solvers in the final steps. Only valid for &lt; 15 inference steps. This can
stabilize the sampling of DPMSolver for steps &lt; 15, especially for steps &lt;= 10.`,name:"lower_order_final"},{anchor:"diffusers.UniPCMultistepScheduler.disable_corrector",description:`<strong>disable_corrector</strong> (<code>list</code>, default <code>[]</code>) &#x2014;
Decides which step to disable the corrector to mitigate the misalignment between <code>epsilon_theta(x_t, c)</code>
and <code>epsilon_theta(x_t^c, c)</code> which can influence convergence for a large guidance scale. Corrector is
usually disabled during the first few steps.`,name:"disable_corrector"},{anchor:"diffusers.UniPCMultistepScheduler.solver_p",description:`<strong>solver_p</strong> (<code>SchedulerMixin</code>, default <code>None</code>) &#x2014;
Any other scheduler that if specified, the algorithm becomes <code>solver_p + UniC</code>.`,name:"solver_p"},{anchor:"diffusers.UniPCMultistepScheduler.use_karras_sigmas",description:`<strong>use_karras_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If <code>True</code>,
the sigmas are determined according to a sequence of noise levels {&#x3C3;i}.`,name:"use_karras_sigmas"},{anchor:"diffusers.UniPCMultistepScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, defaults to <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2 of the <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and
Sample Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.UniPCMultistepScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, defaults to 0) &#x2014;
An offset added to the inference steps. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_one=False</code> to make the last step use step 0 for the previous alpha product like in Stable
Diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L57"}}),X=new W({props:{name:"convert_model_output",anchor:"diffusers.UniPCMultistepScheduler.convert_model_output",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.convert_model_output.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from the learned diffusion model.`,name:"model_output"},{anchor:"diffusers.UniPCMultistepScheduler.convert_model_output.timestep",description:`<strong>timestep</strong> (<code>int</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.UniPCMultistepScheduler.convert_model_output.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L281",returnDescription:`
<p>The converted model output.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),ee=new W({props:{name:"multistep_uni_c_bh_update",anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update",parameters:[{name:"this_model_output",val:": FloatTensor"},{name:"this_timestep",val:": int"},{name:"last_sample",val:": FloatTensor"},{name:"this_sample",val:": FloatTensor"},{name:"order",val:": int"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update.this_model_output",description:`<strong>this_model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The model outputs at <code>x_t</code>.`,name:"this_model_output"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update.this_timestep",description:`<strong>this_timestep</strong> (<code>int</code>) &#x2014;
The current timestep <code>t</code>.`,name:"this_timestep"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update.last_sample",description:`<strong>last_sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The generated sample before the last predictor <code>x_{t-1}</code>.`,name:"last_sample"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update.this_sample",description:`<strong>this_sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The generated sample after the last predictor <code>x_{t}</code>.`,name:"this_sample"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_c_bh_update.order",description:`<strong>order</strong> (<code>int</code>) &#x2014;
The <code>p</code> of UniC-p at this step. The effective order of accuracy should be <code>order + 1</code>.`,name:"order"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L443",returnDescription:`
<p>The corrected sample tensor at the current timestep.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),te=new W({props:{name:"multistep_uni_p_bh_update",anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_p_bh_update",parameters:[{name:"model_output",val:": FloatTensor"},{name:"prev_timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"order",val:": int"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_p_bh_update.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from the learned diffusion model at the current timestep.`,name:"model_output"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_p_bh_update.prev_timestep",description:`<strong>prev_timestep</strong> (<code>int</code>) &#x2014;
The previous discrete timestep in the diffusion chain.`,name:"prev_timestep"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_p_bh_update.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.UniPCMultistepScheduler.multistep_uni_p_bh_update.order",description:`<strong>order</strong> (<code>int</code>) &#x2014;
The order of UniP at this timestep (corresponds to the <em>p</em> in UniPC-p).`,name:"order"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L335",returnDescription:`
<p>The sample tensor at the previous timestep.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),se=new W({props:{name:"scale_model_input",anchor:"diffusers.UniPCMultistepScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L643",returnDescription:`
<p>A scaled input sample.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),oe=new W({props:{name:"set_timesteps",anchor:"diffusers.UniPCMultistepScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"},{anchor:"diffusers.UniPCMultistepScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps should be moved to. If <code>None</code>, the timesteps are not moved.`,name:"device"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L185"}}),ne=new W({props:{name:"step",anchor:"diffusers.UniPCMultistepScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.UniPCMultistepScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.UniPCMultistepScheduler.step.timestep",description:`<strong>timestep</strong> (<code>int</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.UniPCMultistepScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.UniPCMultistepScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/schedulers/dpm_discrete#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_unipc_multistep.py#L554",returnDescription:`
<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/schedulers/dpm_discrete#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> is returned, otherwise a
tuple is returned where the first element is the sample tensor.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/schedulers/dpm_discrete#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),ie=new ht({}),ae=new W({props:{name:"class diffusers.schedulers.scheduling_utils.SchedulerOutput",anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Computed sample <code>(x_{t-1})</code> of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_utils.py#L50"}}),{c(){U=s("meta"),qe=l(),x=s("h1"),D=s("a"),_e=s("span"),g(H.$$.fragment),ft=l(),ve=s("span"),mt=i("UniPCMultistepScheduler"),Ve=l(),w=s("p"),be=s("code"),gt=i("UniPCMultistepScheduler"),_t=i(" is a training-free framework designed for fast sampling of diffusion models. It was introduced in "),R=s("a"),vt=i("UniPC: A Unified Predictor-Corrector Framework for Fast Sampling of Diffusion Models"),bt=i(" by Wenliang Zhao, Lujia Bai, Yongming Rao, Jie Zhou, Jiwen Lu."),ze=l(),le=s("p"),yt=i(`It consists of a corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders.
UniPC is by design model-agnostic, supporting pixel-space/latent-space DPMs on unconditional/conditional sampling. It can also be applied to both noise prediction and data prediction models. The corrector UniC can be also applied after any off-the-shelf solvers to increase the order of accuracy.`),Be=l(),ce=s("p"),Pt=i("The abstract from the paper is:"),We=l(),J=s("p"),pe=s("em"),Ct=i("Diffusion probabilistic models (DPMs) have demonstrated a very promising ability in high-resolution image synthesis. However, sampling from a pre-trained DPM usually requires hundreds of model evaluations, which is computationally expensive. Despite recent progress in designing high-order solvers for DPMs, there still exists room for further speedup, especially in extremely few steps (e.g., 5~10 steps). Inspired by the predictor-corrector for ODE solvers, we develop a unified corrector (UniC) that can be applied after any existing DPM sampler to increase the order of accuracy without extra model evaluations, and derive a unified predictor (UniP) that supports arbitrary order as a byproduct. Combining UniP and UniC, we propose a unified predictor-corrector framework called UniPC for the fast sampling of DPMs, which has a unified analytical form for any order and can significantly improve the sampling quality over previous methods. We evaluate our methods through extensive experiments including both unconditional and conditional sampling using pixel-space and latent-space DPMs. Our UniPC can achieve 3.87 FID on CIFAR10 (unconditional) and 7.51 FID on ImageNet 256times256 (conditional) with only 10 function evaluations. Code is available at "),Z=s("a"),Ut=i("https://github.com/wl-zhao/UniPC"),xt=i("."),He=l(),F=s("p"),wt=i("The original codebase can be found at "),Y=s("a"),St=i("wl-zhao/UniPC"),$t=i("."),Re=l(),S=s("h2"),I=s("a"),ye=s("span"),g(j.$$.fragment),Tt=l(),Pe=s("span"),Mt=i("Tips"),Je=l(),C=s("p"),Et=i("It is recommended to set "),Ce=s("code"),Dt=i("solver_order"),Ft=i(" to 2 for guide sampling, and "),Ue=s("code"),It=i("solver_order=3"),Ot=i(" for unconditional sampling."),Ze=l(),m=s("p"),kt=i("Dynamic thresholding from Imagen ("),G=s("a"),At=i("https://huggingface.co/papers/2205.11487"),Nt=i(`) is supported, and for pixel-space
diffusion models, you can set both `),xe=s("code"),Lt=i("predict_x0=True"),qt=i(" and "),we=s("code"),Vt=i("thresholding=True"),zt=i(" to use dynamic thresholding. This thresholding method is unsuitable for latent-space diffusion models such as Stable Diffusion."),Ye=l(),$=s("h2"),O=s("a"),Se=s("span"),g(K.$$.fragment),Bt=l(),$e=s("span"),Wt=i("UniPCMultistepScheduler"),je=l(),h=s("div"),g(Q.$$.fragment),Ht=l(),ue=s("p"),Te=s("code"),Rt=i("UniPCMultistepScheduler"),Jt=i(" is a training-free framework designed for the fast sampling of diffusion models."),Zt=l(),T=s("p"),Yt=i("This model inherits from "),he=s("a"),jt=i("SchedulerMixin"),Gt=i(" and "),fe=s("a"),Kt=i("ConfigMixin"),Qt=i(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Xt=l(),k=s("div"),g(X.$$.fragment),er=l(),Me=s("p"),tr=i("Convert the model output to the corresponding type the UniPC algorithm needs."),rr=l(),A=s("div"),g(ee.$$.fragment),sr=l(),Ee=s("p"),or=i("One step for the UniC (B(h) version)."),nr=l(),N=s("div"),g(te.$$.fragment),ir=l(),re=s("p"),ar=i("One step for the UniP (B(h) version). Alternatively, "),De=s("code"),dr=i("self.solver_p"),lr=i(" is used if is specified."),cr=l(),L=s("div"),g(se.$$.fragment),pr=l(),Fe=s("p"),ur=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),hr=l(),q=s("div"),g(oe.$$.fragment),fr=l(),Ie=s("p"),mr=i("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),gr=l(),V=s("div"),g(ne.$$.fragment),_r=l(),Oe=s("p"),vr=i(`Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
the multistep UniPC.`),Ge=l(),M=s("h2"),z=s("a"),ke=s("span"),g(ie.$$.fragment),br=l(),Ae=s("span"),yr=i("SchedulerOutput"),Ke=l(),E=s("div"),g(ae.$$.fragment),Pr=l(),de=s("p"),Cr=i("Base class for the output of a scheduler\u2019s "),Ne=s("code"),Ur=i("step"),xr=i(" function."),this.h()},l(t){const p=ps('[data-svelte="svelte-1phssyn"]',document.head);U=o(p,"META",{name:!0,content:!0}),p.forEach(r),qe=c(t),x=o(t,"H1",{class:!0});var Xe=n(x);D=o(Xe,"A",{id:!0,class:!0,href:!0});var Mr=n(D);_e=o(Mr,"SPAN",{});var Er=n(_e);_(H.$$.fragment,Er),Er.forEach(r),Mr.forEach(r),ft=c(Xe),ve=o(Xe,"SPAN",{});var Dr=n(ve);mt=a(Dr,"UniPCMultistepScheduler"),Dr.forEach(r),Xe.forEach(r),Ve=c(t),w=o(t,"P",{});var Le=n(w);be=o(Le,"CODE",{});var Fr=n(be);gt=a(Fr,"UniPCMultistepScheduler"),Fr.forEach(r),_t=a(Le," is a training-free framework designed for fast sampling of diffusion models. It was introduced in "),R=o(Le,"A",{href:!0,rel:!0});var Ir=n(R);vt=a(Ir,"UniPC: A Unified Predictor-Corrector Framework for Fast Sampling of Diffusion Models"),Ir.forEach(r),bt=a(Le," by Wenliang Zhao, Lujia Bai, Yongming Rao, Jie Zhou, Jiwen Lu."),Le.forEach(r),ze=c(t),le=o(t,"P",{});var Or=n(le);yt=a(Or,`It consists of a corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders.
UniPC is by design model-agnostic, supporting pixel-space/latent-space DPMs on unconditional/conditional sampling. It can also be applied to both noise prediction and data prediction models. The corrector UniC can be also applied after any off-the-shelf solvers to increase the order of accuracy.`),Or.forEach(r),Be=c(t),ce=o(t,"P",{});var kr=n(ce);Pt=a(kr,"The abstract from the paper is:"),kr.forEach(r),We=c(t),J=o(t,"P",{});var wr=n(J);pe=o(wr,"EM",{});var Sr=n(pe);Ct=a(Sr,"Diffusion probabilistic models (DPMs) have demonstrated a very promising ability in high-resolution image synthesis. However, sampling from a pre-trained DPM usually requires hundreds of model evaluations, which is computationally expensive. Despite recent progress in designing high-order solvers for DPMs, there still exists room for further speedup, especially in extremely few steps (e.g., 5~10 steps). Inspired by the predictor-corrector for ODE solvers, we develop a unified corrector (UniC) that can be applied after any existing DPM sampler to increase the order of accuracy without extra model evaluations, and derive a unified predictor (UniP) that supports arbitrary order as a byproduct. Combining UniP and UniC, we propose a unified predictor-corrector framework called UniPC for the fast sampling of DPMs, which has a unified analytical form for any order and can significantly improve the sampling quality over previous methods. We evaluate our methods through extensive experiments including both unconditional and conditional sampling using pixel-space and latent-space DPMs. Our UniPC can achieve 3.87 FID on CIFAR10 (unconditional) and 7.51 FID on ImageNet 256times256 (conditional) with only 10 function evaluations. Code is available at "),Z=o(Sr,"A",{href:!0,rel:!0});var Ar=n(Z);Ut=a(Ar,"https://github.com/wl-zhao/UniPC"),Ar.forEach(r),Sr.forEach(r),xt=a(wr,"."),wr.forEach(r),He=c(t),F=o(t,"P",{});var et=n(F);wt=a(et,"The original codebase can be found at "),Y=o(et,"A",{href:!0,rel:!0});var Nr=n(Y);St=a(Nr,"wl-zhao/UniPC"),Nr.forEach(r),$t=a(et,"."),et.forEach(r),Re=c(t),S=o(t,"H2",{class:!0});var tt=n(S);I=o(tt,"A",{id:!0,class:!0,href:!0});var Lr=n(I);ye=o(Lr,"SPAN",{});var qr=n(ye);_(j.$$.fragment,qr),qr.forEach(r),Lr.forEach(r),Tt=c(tt),Pe=o(tt,"SPAN",{});var Vr=n(Pe);Mt=a(Vr,"Tips"),Vr.forEach(r),tt.forEach(r),Je=c(t),C=o(t,"P",{});var me=n(C);Et=a(me,"It is recommended to set "),Ce=o(me,"CODE",{});var zr=n(Ce);Dt=a(zr,"solver_order"),zr.forEach(r),Ft=a(me," to 2 for guide sampling, and "),Ue=o(me,"CODE",{});var Br=n(Ue);It=a(Br,"solver_order=3"),Br.forEach(r),Ot=a(me," for unconditional sampling."),me.forEach(r),Ze=c(t),m=o(t,"P",{});var B=n(m);kt=a(B,"Dynamic thresholding from Imagen ("),G=o(B,"A",{href:!0,rel:!0});var Wr=n(G);At=a(Wr,"https://huggingface.co/papers/2205.11487"),Wr.forEach(r),Nt=a(B,`) is supported, and for pixel-space
diffusion models, you can set both `),xe=o(B,"CODE",{});var Hr=n(xe);Lt=a(Hr,"predict_x0=True"),Hr.forEach(r),qt=a(B," and "),we=o(B,"CODE",{});var Rr=n(we);Vt=a(Rr,"thresholding=True"),Rr.forEach(r),zt=a(B," to use dynamic thresholding. This thresholding method is unsuitable for latent-space diffusion models such as Stable Diffusion."),B.forEach(r),Ye=c(t),$=o(t,"H2",{class:!0});var rt=n($);O=o(rt,"A",{id:!0,class:!0,href:!0});var Jr=n(O);Se=o(Jr,"SPAN",{});var Zr=n(Se);_(K.$$.fragment,Zr),Zr.forEach(r),Jr.forEach(r),Bt=c(rt),$e=o(rt,"SPAN",{});var Yr=n($e);Wt=a(Yr,"UniPCMultistepScheduler"),Yr.forEach(r),rt.forEach(r),je=c(t),h=o(t,"DIV",{class:!0});var f=n(h);_(Q.$$.fragment,f),Ht=c(f),ue=o(f,"P",{});var $r=n(ue);Te=o($r,"CODE",{});var jr=n(Te);Rt=a(jr,"UniPCMultistepScheduler"),jr.forEach(r),Jt=a($r," is a training-free framework designed for the fast sampling of diffusion models."),$r.forEach(r),Zt=c(f),T=o(f,"P",{});var ge=n(T);Yt=a(ge,"This model inherits from "),he=o(ge,"A",{href:!0});var Gr=n(he);jt=a(Gr,"SchedulerMixin"),Gr.forEach(r),Gt=a(ge," and "),fe=o(ge,"A",{href:!0});var Kr=n(fe);Kt=a(Kr,"ConfigMixin"),Kr.forEach(r),Qt=a(ge,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),ge.forEach(r),Xt=c(f),k=o(f,"DIV",{class:!0});var st=n(k);_(X.$$.fragment,st),er=c(st),Me=o(st,"P",{});var Qr=n(Me);tr=a(Qr,"Convert the model output to the corresponding type the UniPC algorithm needs."),Qr.forEach(r),st.forEach(r),rr=c(f),A=o(f,"DIV",{class:!0});var ot=n(A);_(ee.$$.fragment,ot),sr=c(ot),Ee=o(ot,"P",{});var Xr=n(Ee);or=a(Xr,"One step for the UniC (B(h) version)."),Xr.forEach(r),ot.forEach(r),nr=c(f),N=o(f,"DIV",{class:!0});var nt=n(N);_(te.$$.fragment,nt),ir=c(nt),re=o(nt,"P",{});var it=n(re);ar=a(it,"One step for the UniP (B(h) version). Alternatively, "),De=o(it,"CODE",{});var es=n(De);dr=a(es,"self.solver_p"),es.forEach(r),lr=a(it," is used if is specified."),it.forEach(r),nt.forEach(r),cr=c(f),L=o(f,"DIV",{class:!0});var at=n(L);_(se.$$.fragment,at),pr=c(at),Fe=o(at,"P",{});var ts=n(Fe);ur=a(ts,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),ts.forEach(r),at.forEach(r),hr=c(f),q=o(f,"DIV",{class:!0});var dt=n(q);_(oe.$$.fragment,dt),fr=c(dt),Ie=o(dt,"P",{});var rs=n(Ie);mr=a(rs,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),rs.forEach(r),dt.forEach(r),gr=c(f),V=o(f,"DIV",{class:!0});var lt=n(V);_(ne.$$.fragment,lt),_r=c(lt),Oe=o(lt,"P",{});var ss=n(Oe);vr=a(ss,`Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
the multistep UniPC.`),ss.forEach(r),lt.forEach(r),f.forEach(r),Ge=c(t),M=o(t,"H2",{class:!0});var ct=n(M);z=o(ct,"A",{id:!0,class:!0,href:!0});var os=n(z);ke=o(os,"SPAN",{});var ns=n(ke);_(ie.$$.fragment,ns),ns.forEach(r),os.forEach(r),br=c(ct),Ae=o(ct,"SPAN",{});var is=n(Ae);yr=a(is,"SchedulerOutput"),is.forEach(r),ct.forEach(r),Ke=c(t),E=o(t,"DIV",{class:!0});var pt=n(E);_(ae.$$.fragment,pt),Pr=c(pt),de=o(pt,"P",{});var ut=n(de);Cr=a(ut,"Base class for the output of a scheduler\u2019s "),Ne=o(ut,"CODE",{});var as=n(Ne);Ur=a(as,"step"),as.forEach(r),xr=a(ut," function."),ut.forEach(r),pt.forEach(r),this.h()},h(){d(U,"name","hf:doc:metadata"),d(U,"content",JSON.stringify(ms)),d(D,"id","unipcmultistepscheduler"),d(D,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(D,"href","#unipcmultistepscheduler"),d(x,"class","relative group"),d(R,"href","https://huggingface.co/papers/2302.04867"),d(R,"rel","nofollow"),d(Z,"href","https://github.com/wl-zhao/UniPC"),d(Z,"rel","nofollow"),d(Y,"href","https://github.com/wl-zhao/UniPC"),d(Y,"rel","nofollow"),d(I,"id","tips"),d(I,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(I,"href","#tips"),d(S,"class","relative group"),d(G,"href","https://huggingface.co/papers/2205.11487"),d(G,"rel","nofollow"),d(O,"id","diffusers.UniPCMultistepScheduler"),d(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(O,"href","#diffusers.UniPCMultistepScheduler"),d($,"class","relative group"),d(he,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(fe,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),d(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(z,"id","diffusers.schedulers.scheduling_utils.SchedulerOutput"),d(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(z,"href","#diffusers.schedulers.scheduling_utils.SchedulerOutput"),d(M,"class","relative group"),d(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,p){e(document.head,U),u(t,qe,p),u(t,x,p),e(x,D),e(D,_e),v(H,_e,null),e(x,ft),e(x,ve),e(ve,mt),u(t,Ve,p),u(t,w,p),e(w,be),e(be,gt),e(w,_t),e(w,R),e(R,vt),e(w,bt),u(t,ze,p),u(t,le,p),e(le,yt),u(t,Be,p),u(t,ce,p),e(ce,Pt),u(t,We,p),u(t,J,p),e(J,pe),e(pe,Ct),e(pe,Z),e(Z,Ut),e(J,xt),u(t,He,p),u(t,F,p),e(F,wt),e(F,Y),e(Y,St),e(F,$t),u(t,Re,p),u(t,S,p),e(S,I),e(I,ye),v(j,ye,null),e(S,Tt),e(S,Pe),e(Pe,Mt),u(t,Je,p),u(t,C,p),e(C,Et),e(C,Ce),e(Ce,Dt),e(C,Ft),e(C,Ue),e(Ue,It),e(C,Ot),u(t,Ze,p),u(t,m,p),e(m,kt),e(m,G),e(G,At),e(m,Nt),e(m,xe),e(xe,Lt),e(m,qt),e(m,we),e(we,Vt),e(m,zt),u(t,Ye,p),u(t,$,p),e($,O),e(O,Se),v(K,Se,null),e($,Bt),e($,$e),e($e,Wt),u(t,je,p),u(t,h,p),v(Q,h,null),e(h,Ht),e(h,ue),e(ue,Te),e(Te,Rt),e(ue,Jt),e(h,Zt),e(h,T),e(T,Yt),e(T,he),e(he,jt),e(T,Gt),e(T,fe),e(fe,Kt),e(T,Qt),e(h,Xt),e(h,k),v(X,k,null),e(k,er),e(k,Me),e(Me,tr),e(h,rr),e(h,A),v(ee,A,null),e(A,sr),e(A,Ee),e(Ee,or),e(h,nr),e(h,N),v(te,N,null),e(N,ir),e(N,re),e(re,ar),e(re,De),e(De,dr),e(re,lr),e(h,cr),e(h,L),v(se,L,null),e(L,pr),e(L,Fe),e(Fe,ur),e(h,hr),e(h,q),v(oe,q,null),e(q,fr),e(q,Ie),e(Ie,mr),e(h,gr),e(h,V),v(ne,V,null),e(V,_r),e(V,Oe),e(Oe,vr),u(t,Ge,p),u(t,M,p),e(M,z),e(z,ke),v(ie,ke,null),e(M,br),e(M,Ae),e(Ae,yr),u(t,Ke,p),u(t,E,p),v(ae,E,null),e(E,Pr),e(E,de),e(de,Cr),e(de,Ne),e(Ne,Ur),e(de,xr),Qe=!0},p:us,i(t){Qe||(b(H.$$.fragment,t),b(j.$$.fragment,t),b(K.$$.fragment,t),b(Q.$$.fragment,t),b(X.$$.fragment,t),b(ee.$$.fragment,t),b(te.$$.fragment,t),b(se.$$.fragment,t),b(oe.$$.fragment,t),b(ne.$$.fragment,t),b(ie.$$.fragment,t),b(ae.$$.fragment,t),Qe=!0)},o(t){y(H.$$.fragment,t),y(j.$$.fragment,t),y(K.$$.fragment,t),y(Q.$$.fragment,t),y(X.$$.fragment,t),y(ee.$$.fragment,t),y(te.$$.fragment,t),y(se.$$.fragment,t),y(oe.$$.fragment,t),y(ne.$$.fragment,t),y(ie.$$.fragment,t),y(ae.$$.fragment,t),Qe=!1},d(t){r(U),t&&r(qe),t&&r(x),P(H),t&&r(Ve),t&&r(w),t&&r(ze),t&&r(le),t&&r(Be),t&&r(ce),t&&r(We),t&&r(J),t&&r(He),t&&r(F),t&&r(Re),t&&r(S),P(j),t&&r(Je),t&&r(C),t&&r(Ze),t&&r(m),t&&r(Ye),t&&r($),P(K),t&&r(je),t&&r(h),P(Q),P(X),P(ee),P(te),P(se),P(oe),P(ne),t&&r(Ge),t&&r(M),P(ie),t&&r(Ke),t&&r(E),P(ae)}}}const ms={local:"unipcmultistepscheduler",sections:[{local:"tips",title:"Tips"},{local:"diffusers.UniPCMultistepScheduler",title:"UniPCMultistepScheduler"},{local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",title:"SchedulerOutput"}],title:"UniPCMultistepScheduler"};function gs(Tr){return hs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ys extends ds{constructor(U){super();ls(this,U,gs,fs,cs,{})}}export{ys as default,ms as metadata};
