import{S as Nt,i as It,s as Lt,e as r,k as c,w as K,t as a,M as qt,c as o,d as s,m as l,a as n,x as k,h as d,b as i,G as e,g as h,y as A,L as Bt,q as O,o as C,B as F,v as Ut}from"../../../chunks/vendor-hf-doc-builder.js";import{D as le}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ft}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Vt(mt){let g,ue,_,y,Z,N,Te,ee,Ke,pe,f,ke,te,Ae,Oe,I,Ce,Fe,L,Ne,Ie,he,$,Le,q,qe,Be,fe,v,P,se,B,Ue,re,Ve,me,u,U,Ge,V,He,G,Re,ze,Je,b,We,j,Ye,je,Q,Qe,Xe,Ze,w,H,et,oe,tt,st,M,R,rt,ne,ot,nt,E,z,it,ie,at,ge,D,x,ae,J,dt,de,ct,_e,S,W,lt,Y,ut,ce,pt,ht,ve;return N=new ft({}),B=new ft({}),U=new le({props:{name:"class diffusers.KDPM2DiscreteScheduler",anchor:"diffusers.KDPM2DiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.00085"},{name:"beta_end",val:": float = 0.012"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.00085) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.KDPM2DiscreteScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.012) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.KDPM2DiscreteScheduler.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> or <code>scaled_linear</code>.`,name:"beta_schedule"},{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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/v0.21.0/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L71"}}),H=new le({props:{name:"scale_model_input",anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input.timestep",description:`<strong>timestep</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The current timestep in the diffusion chain.`,name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L176",returnDescription:`
<p>A scaled input sample.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),R=new le({props:{name:"set_timesteps",anchor:"diffusers.KDPM2DiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"num_train_timesteps",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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/v0.21.0/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L206"}}),z=new le({props:{name:"step",anchor:"diffusers.KDPM2DiscreteScheduler.step",parameters:[{name:"model_output",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.21.0/en/api/schedulers/singlestep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L321",returnDescription:`
<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/v0.21.0/en/api/schedulers/singlestep_dpm_solver#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/v0.21.0/en/api/schedulers/singlestep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),J=new ft({}),W=new le({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/v0.21.0/src/diffusers/schedulers/scheduling_utils.py#L50"}}),{c(){g=r("meta"),ue=c(),_=r("h1"),y=r("a"),Z=r("span"),K(N.$$.fragment),Te=c(),ee=r("span"),Ke=a("KDPM2DiscreteScheduler"),pe=c(),f=r("p"),ke=a("The "),te=r("code"),Ae=a("KDPM2DiscreteScheduler"),Oe=a(" is inspired by the "),I=r("a"),Ce=a("Elucidating the Design Space of Diffusion-Based Generative Models"),Fe=a(" paper, and the scheduler is ported from and created by "),L=r("a"),Ne=a("Katherine Crowson"),Ie=a("."),he=c(),$=r("p"),Le=a("The original codebase can be found at "),q=r("a"),qe=a("crowsonkb/k-diffusion"),Be=a("."),fe=c(),v=r("h2"),P=r("a"),se=r("span"),K(B.$$.fragment),Ue=c(),re=r("span"),Ve=a("KDPM2DiscreteScheduler"),me=c(),u=r("div"),K(U.$$.fragment),Ge=c(),V=r("p"),He=a("KDPM2DiscreteScheduler is inspired by the DPMSolver2 and Algorithm 2 from the "),G=r("a"),Re=a(`Elucidating the Design Space of
Diffusion-Based Generative Models`),ze=a(" paper."),Je=c(),b=r("p"),We=a("This model inherits from "),j=r("a"),Ye=a("SchedulerMixin"),je=a(" and "),Q=r("a"),Qe=a("ConfigMixin"),Xe=a(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Ze=c(),w=r("div"),K(H.$$.fragment),et=c(),oe=r("p"),tt=a(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),st=c(),M=r("div"),K(R.$$.fragment),rt=c(),ne=r("p"),ot=a("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),nt=c(),E=r("div"),K(z.$$.fragment),it=c(),ie=r("p"),at=a(`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`),ge=c(),D=r("h2"),x=r("a"),ae=r("span"),K(J.$$.fragment),dt=c(),de=r("span"),ct=a("SchedulerOutput"),_e=c(),S=r("div"),K(W.$$.fragment),lt=c(),Y=r("p"),ut=a("Base class for the output of a scheduler\u2019s "),ce=r("code"),pt=a("step"),ht=a(" function."),this.h()},l(t){const p=qt('[data-svelte="svelte-1phssyn"]',document.head);g=o(p,"META",{name:!0,content:!0}),p.forEach(s),ue=l(t),_=o(t,"H1",{class:!0});var be=n(_);y=o(be,"A",{id:!0,class:!0,href:!0});var gt=n(y);Z=o(gt,"SPAN",{});var _t=n(Z);k(N.$$.fragment,_t),_t.forEach(s),gt.forEach(s),Te=l(be),ee=o(be,"SPAN",{});var vt=n(ee);Ke=d(vt,"KDPM2DiscreteScheduler"),vt.forEach(s),be.forEach(s),pe=l(t),f=o(t,"P",{});var T=n(f);ke=d(T,"The "),te=o(T,"CODE",{});var bt=n(te);Ae=d(bt,"KDPM2DiscreteScheduler"),bt.forEach(s),Oe=d(T," is inspired by the "),I=o(T,"A",{href:!0,rel:!0});var Dt=n(I);Ce=d(Dt,"Elucidating the Design Space of Diffusion-Based Generative Models"),Dt.forEach(s),Fe=d(T," paper, and the scheduler is ported from and created by "),L=o(T,"A",{href:!0,rel:!0});var St=n(L);Ne=d(St,"Katherine Crowson"),St.forEach(s),Ie=d(T,"."),T.forEach(s),he=l(t),$=o(t,"P",{});var De=n($);Le=d(De,"The original codebase can be found at "),q=o(De,"A",{href:!0,rel:!0});var yt=n(q);qe=d(yt,"crowsonkb/k-diffusion"),yt.forEach(s),Be=d(De,"."),De.forEach(s),fe=l(t),v=o(t,"H2",{class:!0});var Se=n(v);P=o(Se,"A",{id:!0,class:!0,href:!0});var $t=n(P);se=o($t,"SPAN",{});var Pt=n(se);k(B.$$.fragment,Pt),Pt.forEach(s),$t.forEach(s),Ue=l(Se),re=o(Se,"SPAN",{});var wt=n(re);Ve=d(wt,"KDPM2DiscreteScheduler"),wt.forEach(s),Se.forEach(s),me=l(t),u=o(t,"DIV",{class:!0});var m=n(u);k(U.$$.fragment,m),Ge=l(m),V=o(m,"P",{});var ye=n(V);He=d(ye,"KDPM2DiscreteScheduler is inspired by the DPMSolver2 and Algorithm 2 from the "),G=o(ye,"A",{href:!0,rel:!0});var Mt=n(G);Re=d(Mt,`Elucidating the Design Space of
Diffusion-Based Generative Models`),Mt.forEach(s),ze=d(ye," paper."),ye.forEach(s),Je=l(m),b=o(m,"P",{});var X=n(b);We=d(X,"This model inherits from "),j=o(X,"A",{href:!0});var Et=n(j);Ye=d(Et,"SchedulerMixin"),Et.forEach(s),je=d(X," and "),Q=o(X,"A",{href:!0});var xt=n(Q);Qe=d(xt,"ConfigMixin"),xt.forEach(s),Xe=d(X,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),X.forEach(s),Ze=l(m),w=o(m,"DIV",{class:!0});var $e=n(w);k(H.$$.fragment,$e),et=l($e),oe=o($e,"P",{});var Tt=n(oe);tt=d(Tt,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Tt.forEach(s),$e.forEach(s),st=l(m),M=o(m,"DIV",{class:!0});var Pe=n(M);k(R.$$.fragment,Pe),rt=l(Pe),ne=o(Pe,"P",{});var Kt=n(ne);ot=d(Kt,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),Kt.forEach(s),Pe.forEach(s),nt=l(m),E=o(m,"DIV",{class:!0});var we=n(E);k(z.$$.fragment,we),it=l(we),ie=o(we,"P",{});var kt=n(ie);at=d(kt,`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`),kt.forEach(s),we.forEach(s),m.forEach(s),ge=l(t),D=o(t,"H2",{class:!0});var Me=n(D);x=o(Me,"A",{id:!0,class:!0,href:!0});var At=n(x);ae=o(At,"SPAN",{});var Ot=n(ae);k(J.$$.fragment,Ot),Ot.forEach(s),At.forEach(s),dt=l(Me),de=o(Me,"SPAN",{});var Ct=n(de);ct=d(Ct,"SchedulerOutput"),Ct.forEach(s),Me.forEach(s),_e=l(t),S=o(t,"DIV",{class:!0});var Ee=n(S);k(W.$$.fragment,Ee),lt=l(Ee),Y=o(Ee,"P",{});var xe=n(Y);ut=d(xe,"Base class for the output of a scheduler\u2019s "),ce=o(xe,"CODE",{});var Ft=n(ce);pt=d(Ft,"step"),Ft.forEach(s),ht=d(xe," function."),xe.forEach(s),Ee.forEach(s),this.h()},h(){i(g,"name","hf:doc:metadata"),i(g,"content",JSON.stringify(Gt)),i(y,"id","kdpm2discretescheduler"),i(y,"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"),i(y,"href","#kdpm2discretescheduler"),i(_,"class","relative group"),i(I,"href","https://huggingface.co/papers/2206.00364"),i(I,"rel","nofollow"),i(L,"href","https://github.com/crowsonkb/"),i(L,"rel","nofollow"),i(q,"href","https://github.com/crowsonkb/k-diffusion"),i(q,"rel","nofollow"),i(P,"id","diffusers.KDPM2DiscreteScheduler"),i(P,"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"),i(P,"href","#diffusers.KDPM2DiscreteScheduler"),i(v,"class","relative group"),i(G,"href","https://huggingface.co/papers/2206.00364"),i(G,"rel","nofollow"),i(j,"href","/docs/diffusers/v0.21.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),i(Q,"href","/docs/diffusers/v0.21.0/en/api/configuration#diffusers.ConfigMixin"),i(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(x,"id","diffusers.schedulers.scheduling_utils.SchedulerOutput"),i(x,"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"),i(x,"href","#diffusers.schedulers.scheduling_utils.SchedulerOutput"),i(D,"class","relative group"),i(S,"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,g),h(t,ue,p),h(t,_,p),e(_,y),e(y,Z),A(N,Z,null),e(_,Te),e(_,ee),e(ee,Ke),h(t,pe,p),h(t,f,p),e(f,ke),e(f,te),e(te,Ae),e(f,Oe),e(f,I),e(I,Ce),e(f,Fe),e(f,L),e(L,Ne),e(f,Ie),h(t,he,p),h(t,$,p),e($,Le),e($,q),e(q,qe),e($,Be),h(t,fe,p),h(t,v,p),e(v,P),e(P,se),A(B,se,null),e(v,Ue),e(v,re),e(re,Ve),h(t,me,p),h(t,u,p),A(U,u,null),e(u,Ge),e(u,V),e(V,He),e(V,G),e(G,Re),e(V,ze),e(u,Je),e(u,b),e(b,We),e(b,j),e(j,Ye),e(b,je),e(b,Q),e(Q,Qe),e(b,Xe),e(u,Ze),e(u,w),A(H,w,null),e(w,et),e(w,oe),e(oe,tt),e(u,st),e(u,M),A(R,M,null),e(M,rt),e(M,ne),e(ne,ot),e(u,nt),e(u,E),A(z,E,null),e(E,it),e(E,ie),e(ie,at),h(t,ge,p),h(t,D,p),e(D,x),e(x,ae),A(J,ae,null),e(D,dt),e(D,de),e(de,ct),h(t,_e,p),h(t,S,p),A(W,S,null),e(S,lt),e(S,Y),e(Y,ut),e(Y,ce),e(ce,pt),e(Y,ht),ve=!0},p:Bt,i(t){ve||(O(N.$$.fragment,t),O(B.$$.fragment,t),O(U.$$.fragment,t),O(H.$$.fragment,t),O(R.$$.fragment,t),O(z.$$.fragment,t),O(J.$$.fragment,t),O(W.$$.fragment,t),ve=!0)},o(t){C(N.$$.fragment,t),C(B.$$.fragment,t),C(U.$$.fragment,t),C(H.$$.fragment,t),C(R.$$.fragment,t),C(z.$$.fragment,t),C(J.$$.fragment,t),C(W.$$.fragment,t),ve=!1},d(t){s(g),t&&s(ue),t&&s(_),F(N),t&&s(pe),t&&s(f),t&&s(he),t&&s($),t&&s(fe),t&&s(v),F(B),t&&s(me),t&&s(u),F(U),F(H),F(R),F(z),t&&s(ge),t&&s(D),F(J),t&&s(_e),t&&s(S),F(W)}}}const Gt={local:"kdpm2discretescheduler",sections:[{local:"diffusers.KDPM2DiscreteScheduler",title:"KDPM2DiscreteScheduler"},{local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",title:"SchedulerOutput"}],title:"KDPM2DiscreteScheduler"};function Ht(mt){return Ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wt extends Nt{constructor(g){super();It(this,g,Ht,Vt,Lt,{})}}export{Wt as default,Gt as metadata};
