import{S as Hr,i as Kr,s as Rr,e as o,k as c,w as b,t as i,M as Gr,c as s,d as r,m as p,a as n,x as y,h as a,b as d,G as e,g as _,y as x,L as Jr,q as P,o as C,B as U,v as Yr}from"../../../chunks/vendor-hf-doc-builder.js";import{D as te}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as lr}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function jr(cr){let w,Fe,S,T,pe,V,Ye,ue,je,De,$,F,he,W,Qe,fe,Xe,ke,re,Ze,Oe,v,et,B,tt,rt,z,ot,st,Ae,oe,nt,Ie,M,D,me,H,it,_e,at,Ne,l,K,dt,ge,lt,ct,se,pt,R,ut,ht,E,ft,ve,mt,_t,be,gt,vt,bt,g,yt,G,xt,Pt,ye,Ct,Ut,xe,wt,St,$t,h,ne,Mt,Et,Pe,Tt,Ft,Ce,Dt,kt,Ue,Ot,At,ie,It,Nt,ae,Lt,qt,de,Vt,Wt,Bt,k,J,zt,we,Ht,Kt,O,Y,Rt,Se,Gt,Jt,A,j,Yt,Q,jt,$e,Qt,Xt,Zt,I,X,er,Me,tr,rr,N,Z,or,Ee,sr,nr,L,ee,ir,Te,ar,Le;return V=new lr({}),W=new lr({}),H=new lr({}),K=new te({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>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.UniPCMultistepScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#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>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.UniPCMultistepScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</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>, optional) &#x2014;
option to pass an array of betas directly to the constructor to bypass <code>beta_start</code>, <code>beta_end</code> etc.`,name:"trained_betas"},{anchor:"diffusers.UniPCMultistepScheduler.solver_order",description:`<strong>solver_order</strong> (<code>int</code>, default <code>2</code>) &#x2014;
the order of UniPC, also the p in UniPC-p; can be any positive integer. Note that the effective order of
accuracy is <code>solver_order + 1</code> due to the UniC. We recommend 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>, default <code>epsilon</code>, optional) &#x2014;
prediction type of the scheduler function, one of <code>epsilon</code> (predicting the noise of the diffusion
process), <code>sample</code> (directly predicting the noisy sample<code>) or </code>v_prediction\` (see section 2.4
<a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">https://imagen.research.google/video/paper.pdf</a>)`,name:"prediction_type"},{anchor:"diffusers.UniPCMultistepScheduler.thresholding",description:`<strong>thresholding</strong> (<code>bool</code>, default <code>False</code>) &#x2014;
whether to use the &#x201C;dynamic thresholding&#x201D; method (introduced by Imagen, <a href="https://arxiv.org/abs/2205.11487" rel="nofollow">https://arxiv.org/abs/2205.11487</a>).
For pixel-space diffusion models, you can set both <code>predict_x0=True</code> and <code>thresholding=True</code> to use the
dynamic thresholding. Note that the thresholding method 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>, default <code>0.995</code>) &#x2014;
the ratio for the dynamic thresholding method. Default is <code>0.995</code>, the same as Imagen
(<a href="https://arxiv.org/abs/2205.11487" rel="nofollow">https://arxiv.org/abs/2205.11487</a>).`,name:"dynamic_thresholding_ratio"},{anchor:"diffusers.UniPCMultistepScheduler.sample_max_value",description:`<strong>sample_max_value</strong> (<code>float</code>, default <code>1.0</code>) &#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>, default <code>True</code>) &#x2014;
whether to use the updating algrithm on the predicted x0. See <a href="https://arxiv.org/abs/2211.01095" rel="nofollow">https://arxiv.org/abs/2211.01095</a> for details`,name:"predict_x0"},{anchor:"diffusers.UniPCMultistepScheduler.solver_type",description:`<strong>solver_type</strong> (<code>str</code>, default <code>bh2</code>) &#x2014;
the solver type of UniPC. We recommend use <code>bh1</code> for unconditional sampling when steps &lt; 10, and use <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. We empirically
find this trick can stabilize the sampling of DPM-Solver 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;
decide which step to disable the corrector. For large guidance scale, the misalignment between the
<code>epsilon_theta(x_t, c)</code>and <code>epsilon_theta(x_t^c, c)</code> might influence the convergence. This can be mitigated
by disable the corrector at the first few steps (e.g., disable_corrector=[0])`,name:"disable_corrector"},{anchor:"diffusers.UniPCMultistepScheduler.solver_p",description:`<strong>solver_p</strong> (<code>SchedulerMixin</code>, default <code>None</code>) &#x2014;
can be any other scheduler. If specified, the algorithm will become solver_p + UniC.`,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;
This parameter controls whether to use Karras sigmas (Karras et al. (2022) scheme) for step sizes in the
noise schedule during the sampling process. If True, the sigmas will be determined according to a sequence
of noise levels {&#x3C3;i} as defined in Equation (5) of the paper <a href="https://arxiv.org/pdf/2206.00364.pdf" rel="nofollow">https://arxiv.org/pdf/2206.00364.pdf</a>.`,name:"use_karras_sigmas"},{anchor:"diffusers.UniPCMultistepScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, default <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2. of <a href="https://arxiv.org/abs/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>, default <code>0</code>) &#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, as done in
stable diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L57"}}),J=new te({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; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.UniPCMultistepScheduler.convert_model_output.timestep",description:"<strong>timestep</strong> (<code>int</code>) &#x2014; 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;
current instance of sample being created by diffusion process.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L297",returnDescription:`
<p>the converted model output.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Y=new te({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. Note that the effective order of accuracy
should be order + 1`,name:"order"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L453",returnDescription:`
<p>the corrected sample tensor at the current timestep.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),j=new te({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;
direct outputs from 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; 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;
current instance of sample being created by 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 step, also the p in UniPC-p.",name:"order"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L348",returnDescription:`
<p>the sample tensor at the previous timestep.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),X=new te({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; input sample",name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L643",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Z=new te({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>, optional) &#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/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L201"}}),ee=new te({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; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.UniPCMultistepScheduler.step.timestep",description:"<strong>timestep</strong> (<code>int</code>) &#x2014; current discrete timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.UniPCMultistepScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.`,name:"sample"},{anchor:"diffusers.UniPCMultistepScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than SchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/schedulers/scheduling_unipc_multistep.py#L559",returnDescription:`
<p><code>~scheduling_utils.SchedulerOutput</code> if <code>return_dict</code> is
True, otherwise a <code>tuple</code>. When returning a tuple, the first element is the sample tensor.</p>
`,returnType:`
<p><code>~scheduling_utils.SchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){w=o("meta"),Fe=c(),S=o("h1"),T=o("a"),pe=o("span"),b(V.$$.fragment),Ye=c(),ue=o("span"),je=i("UniPC"),De=c(),$=o("h2"),F=o("a"),he=o("span"),b(W.$$.fragment),Qe=c(),fe=o("span"),Xe=i("Overview"),ke=c(),re=o("p"),Ze=i("UniPC is a training-free framework designed for the fast sampling of diffusion models, which consists of a corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders."),Oe=c(),v=o("p"),et=i("For more details about the method, please refer to the "),B=o("a"),tt=i("paper"),rt=i(" and the "),z=o("a"),ot=i("code"),st=i("."),Ae=c(),oe=o("p"),nt=i("Fast Sampling of Diffusion Models with Exponential Integrator."),Ie=c(),M=o("h2"),D=o("a"),me=o("span"),b(H.$$.fragment),it=c(),_e=o("span"),at=i("UniPCMultistepScheduler"),Ne=c(),l=o("div"),b(K.$$.fragment),dt=c(),ge=o("p"),lt=i(`UniPC is a training-free framework designed for the fast sampling of diffusion models, which consists of a
corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders. UniPC is
by desinged model-agnostic, supporting pixel-space/latent-space DPMs on unconditional/conditional sampling. It can
also be applied to both noise prediction model and data prediction model. The corrector UniC can be also applied
after any off-the-shelf solvers to increase the order of accuracy.`),ct=c(),se=o("p"),pt=i("For more details, see the original paper: "),R=o("a"),ut=i("https://arxiv.org/abs/2302.04867"),ht=c(),E=o("p"),ft=i(`Currently, we support the multistep UniPC for both noise prediction models and data prediction models. We recommend
to use `),ve=o("code"),mt=i("solver_order=2"),_t=i(" for guided sampling, and "),be=o("code"),gt=i("solver_order=3"),vt=i(" for unconditional sampling."),bt=c(),g=o("p"),yt=i("We also support the \u201Cdynamic thresholding\u201D method in Imagen ("),G=o("a"),xt=i("https://arxiv.org/abs/2205.11487"),Pt=i(`). For pixel-space
diffusion models, you can set both `),ye=o("code"),Ct=i("predict_x0=True"),Ut=i(" and "),xe=o("code"),wt=i("thresholding=True"),St=i(` to use the dynamic thresholding. Note
that the thresholding method is unsuitable for latent-space diffusion models (such as stable-diffusion).`),$t=c(),h=o("p"),ne=o("a"),Mt=i("~ConfigMixin"),Et=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),Pe=o("code"),Tt=i("__init__"),Ft=i(`
function, such as `),Ce=o("code"),Dt=i("num_train_timesteps"),kt=i(". They can be accessed via "),Ue=o("code"),Ot=i("scheduler.config.num_train_timesteps"),At=i(`.
`),ie=o("a"),It=i("SchedulerMixin"),Nt=i(" provides general loading and saving functionality via the "),ae=o("a"),Lt=i("SchedulerMixin.save_pretrained()"),qt=i(` and
`),de=o("a"),Vt=i("from_pretrained()"),Wt=i(" functions."),Bt=c(),k=o("div"),b(J.$$.fragment),zt=c(),we=o("p"),Ht=i("Convert the model output to the corresponding type that the algorithm PC needs."),Kt=c(),O=o("div"),b(Y.$$.fragment),Rt=c(),Se=o("p"),Gt=i("One step for the UniC (B(h) version)."),Jt=c(),A=o("div"),b(j.$$.fragment),Yt=c(),Q=o("p"),jt=i("One step for the UniP (B(h) version). Alternatively, "),$e=o("code"),Qt=i("self.solver_p"),Xt=i(" is used if is specified."),Zt=c(),I=o("div"),b(X.$$.fragment),er=c(),Me=o("p"),tr=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),rr=c(),N=o("div"),b(Z.$$.fragment),or=c(),Ee=o("p"),sr=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),nr=c(),L=o("div"),b(ee.$$.fragment),ir=c(),Te=o("p"),ar=i("Step function propagating the sample with the multistep UniPC."),this.h()},l(t){const f=Gr('[data-svelte="svelte-1phssyn"]',document.head);w=s(f,"META",{name:!0,content:!0}),f.forEach(r),Fe=p(t),S=s(t,"H1",{class:!0});var qe=n(S);T=s(qe,"A",{id:!0,class:!0,href:!0});var pr=n(T);pe=s(pr,"SPAN",{});var ur=n(pe);y(V.$$.fragment,ur),ur.forEach(r),pr.forEach(r),Ye=p(qe),ue=s(qe,"SPAN",{});var hr=n(ue);je=a(hr,"UniPC"),hr.forEach(r),qe.forEach(r),De=p(t),$=s(t,"H2",{class:!0});var Ve=n($);F=s(Ve,"A",{id:!0,class:!0,href:!0});var fr=n(F);he=s(fr,"SPAN",{});var mr=n(he);y(W.$$.fragment,mr),mr.forEach(r),fr.forEach(r),Qe=p(Ve),fe=s(Ve,"SPAN",{});var _r=n(fe);Xe=a(_r,"Overview"),_r.forEach(r),Ve.forEach(r),ke=p(t),re=s(t,"P",{});var gr=n(re);Ze=a(gr,"UniPC is a training-free framework designed for the fast sampling of diffusion models, which consists of a corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders."),gr.forEach(r),Oe=p(t),v=s(t,"P",{});var le=n(v);et=a(le,"For more details about the method, please refer to the "),B=s(le,"A",{href:!0,rel:!0});var vr=n(B);tt=a(vr,"paper"),vr.forEach(r),rt=a(le," and the "),z=s(le,"A",{href:!0,rel:!0});var br=n(z);ot=a(br,"code"),br.forEach(r),st=a(le,"."),le.forEach(r),Ae=p(t),oe=s(t,"P",{});var yr=n(oe);nt=a(yr,"Fast Sampling of Diffusion Models with Exponential Integrator."),yr.forEach(r),Ie=p(t),M=s(t,"H2",{class:!0});var We=n(M);D=s(We,"A",{id:!0,class:!0,href:!0});var xr=n(D);me=s(xr,"SPAN",{});var Pr=n(me);y(H.$$.fragment,Pr),Pr.forEach(r),xr.forEach(r),it=p(We),_e=s(We,"SPAN",{});var Cr=n(_e);at=a(Cr,"UniPCMultistepScheduler"),Cr.forEach(r),We.forEach(r),Ne=p(t),l=s(t,"DIV",{class:!0});var u=n(l);y(K.$$.fragment,u),dt=p(u),ge=s(u,"P",{});var Ur=n(ge);lt=a(Ur,`UniPC is a training-free framework designed for the fast sampling of diffusion models, which consists of a
corrector (UniC) and a predictor (UniP) that share a unified analytical form and support arbitrary orders. UniPC is
by desinged model-agnostic, supporting pixel-space/latent-space DPMs on unconditional/conditional sampling. It can
also be applied to both noise prediction model and data prediction model. The corrector UniC can be also applied
after any off-the-shelf solvers to increase the order of accuracy.`),Ur.forEach(r),ct=p(u),se=s(u,"P",{});var dr=n(se);pt=a(dr,"For more details, see the original paper: "),R=s(dr,"A",{href:!0,rel:!0});var wr=n(R);ut=a(wr,"https://arxiv.org/abs/2302.04867"),wr.forEach(r),dr.forEach(r),ht=p(u),E=s(u,"P",{});var ce=n(E);ft=a(ce,`Currently, we support the multistep UniPC for both noise prediction models and data prediction models. We recommend
to use `),ve=s(ce,"CODE",{});var Sr=n(ve);mt=a(Sr,"solver_order=2"),Sr.forEach(r),_t=a(ce," for guided sampling, and "),be=s(ce,"CODE",{});var $r=n(be);gt=a($r,"solver_order=3"),$r.forEach(r),vt=a(ce," for unconditional sampling."),ce.forEach(r),bt=p(u),g=s(u,"P",{});var q=n(g);yt=a(q,"We also support the \u201Cdynamic thresholding\u201D method in Imagen ("),G=s(q,"A",{href:!0,rel:!0});var Mr=n(G);xt=a(Mr,"https://arxiv.org/abs/2205.11487"),Mr.forEach(r),Pt=a(q,`). For pixel-space
diffusion models, you can set both `),ye=s(q,"CODE",{});var Er=n(ye);Ct=a(Er,"predict_x0=True"),Er.forEach(r),Ut=a(q," and "),xe=s(q,"CODE",{});var Tr=n(xe);wt=a(Tr,"thresholding=True"),Tr.forEach(r),St=a(q,` to use the dynamic thresholding. Note
that the thresholding method is unsuitable for latent-space diffusion models (such as stable-diffusion).`),q.forEach(r),$t=p(u),h=s(u,"P",{});var m=n(h);ne=s(m,"A",{href:!0});var Fr=n(ne);Mt=a(Fr,"~ConfigMixin"),Fr.forEach(r),Et=a(m," takes care of storing all config attributes that are passed in the scheduler\u2019s "),Pe=s(m,"CODE",{});var Dr=n(Pe);Tt=a(Dr,"__init__"),Dr.forEach(r),Ft=a(m,`
function, such as `),Ce=s(m,"CODE",{});var kr=n(Ce);Dt=a(kr,"num_train_timesteps"),kr.forEach(r),kt=a(m,". They can be accessed via "),Ue=s(m,"CODE",{});var Or=n(Ue);Ot=a(Or,"scheduler.config.num_train_timesteps"),Or.forEach(r),At=a(m,`.
`),ie=s(m,"A",{href:!0});var Ar=n(ie);It=a(Ar,"SchedulerMixin"),Ar.forEach(r),Nt=a(m," provides general loading and saving functionality via the "),ae=s(m,"A",{href:!0});var Ir=n(ae);Lt=a(Ir,"SchedulerMixin.save_pretrained()"),Ir.forEach(r),qt=a(m,` and
`),de=s(m,"A",{href:!0});var Nr=n(de);Vt=a(Nr,"from_pretrained()"),Nr.forEach(r),Wt=a(m," functions."),m.forEach(r),Bt=p(u),k=s(u,"DIV",{class:!0});var Be=n(k);y(J.$$.fragment,Be),zt=p(Be),we=s(Be,"P",{});var Lr=n(we);Ht=a(Lr,"Convert the model output to the corresponding type that the algorithm PC needs."),Lr.forEach(r),Be.forEach(r),Kt=p(u),O=s(u,"DIV",{class:!0});var ze=n(O);y(Y.$$.fragment,ze),Rt=p(ze),Se=s(ze,"P",{});var qr=n(Se);Gt=a(qr,"One step for the UniC (B(h) version)."),qr.forEach(r),ze.forEach(r),Jt=p(u),A=s(u,"DIV",{class:!0});var He=n(A);y(j.$$.fragment,He),Yt=p(He),Q=s(He,"P",{});var Ke=n(Q);jt=a(Ke,"One step for the UniP (B(h) version). Alternatively, "),$e=s(Ke,"CODE",{});var Vr=n($e);Qt=a(Vr,"self.solver_p"),Vr.forEach(r),Xt=a(Ke," is used if is specified."),Ke.forEach(r),He.forEach(r),Zt=p(u),I=s(u,"DIV",{class:!0});var Re=n(I);y(X.$$.fragment,Re),er=p(Re),Me=s(Re,"P",{});var Wr=n(Me);tr=a(Wr,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Wr.forEach(r),Re.forEach(r),rr=p(u),N=s(u,"DIV",{class:!0});var Ge=n(N);y(Z.$$.fragment,Ge),or=p(Ge),Ee=s(Ge,"P",{});var Br=n(Ee);sr=a(Br,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Br.forEach(r),Ge.forEach(r),nr=p(u),L=s(u,"DIV",{class:!0});var Je=n(L);y(ee.$$.fragment,Je),ir=p(Je),Te=s(Je,"P",{});var zr=n(Te);ar=a(zr,"Step function propagating the sample with the multistep UniPC."),zr.forEach(r),Je.forEach(r),u.forEach(r),this.h()},h(){d(w,"name","hf:doc:metadata"),d(w,"content",JSON.stringify(Qr)),d(T,"id","unipc"),d(T,"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(T,"href","#unipc"),d(S,"class","relative group"),d(F,"id","overview"),d(F,"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(F,"href","#overview"),d($,"class","relative group"),d(B,"href","https://arxiv.org/abs/2302.04867"),d(B,"rel","nofollow"),d(z,"href","https://github.com/wl-zhao/UniPC"),d(z,"rel","nofollow"),d(D,"id","diffusers.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","#diffusers.UniPCMultistepScheduler"),d(M,"class","relative group"),d(R,"href","https://arxiv.org/abs/2302.04867"),d(R,"rel","nofollow"),d(G,"href","https://arxiv.org/abs/2205.11487"),d(G,"rel","nofollow"),d(ne,"href","/docs/diffusers/v0.18.0/en/api/configuration#diffusers.ConfigMixin"),d(ie,"href","/docs/diffusers/v0.18.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(ae,"href","/docs/diffusers/v0.18.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),d(de,"href","/docs/diffusers/v0.18.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),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(O,"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(I,"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(l,"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,f){e(document.head,w),_(t,Fe,f),_(t,S,f),e(S,T),e(T,pe),x(V,pe,null),e(S,Ye),e(S,ue),e(ue,je),_(t,De,f),_(t,$,f),e($,F),e(F,he),x(W,he,null),e($,Qe),e($,fe),e(fe,Xe),_(t,ke,f),_(t,re,f),e(re,Ze),_(t,Oe,f),_(t,v,f),e(v,et),e(v,B),e(B,tt),e(v,rt),e(v,z),e(z,ot),e(v,st),_(t,Ae,f),_(t,oe,f),e(oe,nt),_(t,Ie,f),_(t,M,f),e(M,D),e(D,me),x(H,me,null),e(M,it),e(M,_e),e(_e,at),_(t,Ne,f),_(t,l,f),x(K,l,null),e(l,dt),e(l,ge),e(ge,lt),e(l,ct),e(l,se),e(se,pt),e(se,R),e(R,ut),e(l,ht),e(l,E),e(E,ft),e(E,ve),e(ve,mt),e(E,_t),e(E,be),e(be,gt),e(E,vt),e(l,bt),e(l,g),e(g,yt),e(g,G),e(G,xt),e(g,Pt),e(g,ye),e(ye,Ct),e(g,Ut),e(g,xe),e(xe,wt),e(g,St),e(l,$t),e(l,h),e(h,ne),e(ne,Mt),e(h,Et),e(h,Pe),e(Pe,Tt),e(h,Ft),e(h,Ce),e(Ce,Dt),e(h,kt),e(h,Ue),e(Ue,Ot),e(h,At),e(h,ie),e(ie,It),e(h,Nt),e(h,ae),e(ae,Lt),e(h,qt),e(h,de),e(de,Vt),e(h,Wt),e(l,Bt),e(l,k),x(J,k,null),e(k,zt),e(k,we),e(we,Ht),e(l,Kt),e(l,O),x(Y,O,null),e(O,Rt),e(O,Se),e(Se,Gt),e(l,Jt),e(l,A),x(j,A,null),e(A,Yt),e(A,Q),e(Q,jt),e(Q,$e),e($e,Qt),e(Q,Xt),e(l,Zt),e(l,I),x(X,I,null),e(I,er),e(I,Me),e(Me,tr),e(l,rr),e(l,N),x(Z,N,null),e(N,or),e(N,Ee),e(Ee,sr),e(l,nr),e(l,L),x(ee,L,null),e(L,ir),e(L,Te),e(Te,ar),Le=!0},p:Jr,i(t){Le||(P(V.$$.fragment,t),P(W.$$.fragment,t),P(H.$$.fragment,t),P(K.$$.fragment,t),P(J.$$.fragment,t),P(Y.$$.fragment,t),P(j.$$.fragment,t),P(X.$$.fragment,t),P(Z.$$.fragment,t),P(ee.$$.fragment,t),Le=!0)},o(t){C(V.$$.fragment,t),C(W.$$.fragment,t),C(H.$$.fragment,t),C(K.$$.fragment,t),C(J.$$.fragment,t),C(Y.$$.fragment,t),C(j.$$.fragment,t),C(X.$$.fragment,t),C(Z.$$.fragment,t),C(ee.$$.fragment,t),Le=!1},d(t){r(w),t&&r(Fe),t&&r(S),U(V),t&&r(De),t&&r($),U(W),t&&r(ke),t&&r(re),t&&r(Oe),t&&r(v),t&&r(Ae),t&&r(oe),t&&r(Ie),t&&r(M),U(H),t&&r(Ne),t&&r(l),U(K),U(J),U(Y),U(j),U(X),U(Z),U(ee)}}}const Qr={local:"unipc",sections:[{local:"overview",title:"Overview"},{local:"diffusers.UniPCMultistepScheduler",title:"UniPCMultistepScheduler"}],title:"UniPC"};function Xr(cr){return Yr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ro extends Hr{constructor(w){super();Kr(this,w,Xr,jr,Rr,{})}}export{ro as default,Qr as metadata};
