import{S as Ft,i as It,s as Ut,e as s,k as p,w as q,t as a,M as qt,c as o,d as r,m as u,a as n,x as V,h as d,b as i,G as e,g as _,y as H,L as Vt,q as B,o as G,B as J,v as Ht}from"../../../chunks/vendor-hf-doc-builder.js";import{D as we}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as lt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Bt(pt){let v,pe,b,w,Z,E,Se,ee,$e,ue,y,S,te,M,ke,re,Pe,fe,g,Ee,x,Me,xe,K,Ke,Ae,he,A,Te,T,Ce,me,D,$,se,C,Oe,oe,Ne,_e,c,O,Le,k,Fe,N,Ie,Ue,L,qe,Ve,ne,He,Be,l,R,Ge,Je,ie,Re,We,ae,je,ze,de,Qe,Xe,W,Ye,Ze,j,et,tt,z,rt,st,ot,Q,F,nt,P,I,it,ce,at,dt,X,U,ge;return E=new lt({}),M=new lt({}),C=new lt({}),O=new we({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'"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.num_train_timesteps",description:"<strong>num_train_timesteps</strong> (<code>int</code>) &#x2014; number of diffusion steps used to train the model. beta_start (<code>float</code>): the",name:"num_train_timesteps"},{anchor:"diffusers.KDPM2DiscreteScheduler.starting",description:`<strong>starting</strong> <code>beta</code> value of inference. beta_end (<code>float</code>) &#x2014; the final <code>beta</code> value. beta_schedule (<code>str</code>):
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:"starting"},{anchor:"diffusers.KDPM2DiscreteScheduler.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.
options to clip the variance used when adding noise to the denoised sample. Choose from <code>fixed_small</code>,
<code>fixed_small_log</code>, <code>fixed_large</code>, <code>fixed_large_log</code>, <code>learned</code> or <code>learned_range</code>.`,name:"trained_betas"},{anchor:"diffusers.KDPM2DiscreteScheduler.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L55"}}),F=new we({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.Ensures",description:"<strong>Ensures</strong> interchangeability with schedulers that need to scale the denoising model input depending on the &#x2014;",name:"Ensures"},{anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input.current",description:`<strong>current</strong> timestep. &#x2014;
sample (<code>torch.FloatTensor</code>): input sample timestep (<code>int</code>, optional): current timestep`,name:"current"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L124",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new we({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>, 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/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L147"}}),U=new we({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.Predict",description:"<strong>Predict</strong> the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion &#x2014;",name:"Predict"},{anchor:"diffusers.KDPM2DiscreteScheduler.step.process",description:`<strong>process</strong> from the learned model outputs (most often the predicted noise). &#x2014;
model_output (<code>torch.FloatTensor</code> or <code>np.ndarray</code>): direct output from learned diffusion model. timestep
(<code>int</code>): current discrete timestep in the diffusion chain. sample (<code>torch.FloatTensor</code> or <code>np.ndarray</code>):
current instance of sample being created by diffusion process.
return_dict (<code>bool</code>): option for returning tuple rather than SchedulerOutput class`,name:"process"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L227",returnDescription:`
<p><a
  href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> 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><a
  href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),{c(){v=s("meta"),pe=p(),b=s("h1"),w=s("a"),Z=s("span"),q(E.$$.fragment),Se=p(),ee=s("span"),$e=a("DPM Discrete Scheduler inspired by Karras et. al paper"),ue=p(),y=s("h2"),S=s("a"),te=s("span"),q(M.$$.fragment),ke=p(),re=s("span"),Pe=a("Overview"),fe=p(),g=s("p"),Ee=a("Inspired by "),x=s("a"),Me=a("Karras et. al"),xe=a(". Scheduler ported from @crowsonkb\u2019s "),K=s("a"),Ke=a("https://github.com/crowsonkb/k-diffusion"),Ae=a(" library:"),he=p(),A=s("p"),Te=a("All credit for making this scheduler work goes to "),T=s("a"),Ce=a("Katherine Crowson"),me=p(),D=s("h2"),$=s("a"),se=s("span"),q(C.$$.fragment),Oe=p(),oe=s("span"),Ne=a("KDPM2DiscreteScheduler"),_e=p(),c=s("div"),q(O.$$.fragment),Le=p(),k=s("p"),Fe=a("Scheduler created by @crowsonkb in "),N=s("a"),Ie=a("k_diffusion"),Ue=a(`, see:
`),L=s("a"),qe=a("https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),Ve=p(),ne=s("p"),He=a("Scheduler inspired by DPM-Solver-2 and Algorthim 2 from Karras et al. (2022)."),Be=p(),l=s("p"),R=s("a"),Ge=a("~ConfigMixin"),Je=a(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),ie=s("code"),Re=a("__init__"),We=a(`
function, such as `),ae=s("code"),je=a("num_train_timesteps"),ze=a(". They can be accessed via "),de=s("code"),Qe=a("scheduler.config.num_train_timesteps"),Xe=a(`.
`),W=s("a"),Ye=a("SchedulerMixin"),Ze=a(" provides general loading and saving functionality via the "),j=s("a"),et=a("SchedulerMixin.save_pretrained()"),tt=a(` and
`),z=s("a"),rt=a("from_pretrained()"),st=a(" functions."),ot=p(),Q=s("div"),q(F.$$.fragment),nt=p(),P=s("div"),q(I.$$.fragment),it=p(),ce=s("p"),at=a("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),dt=p(),X=s("div"),q(U.$$.fragment),this.h()},l(t){const f=qt('[data-svelte="svelte-1phssyn"]',document.head);v=o(f,"META",{name:!0,content:!0}),f.forEach(r),pe=u(t),b=o(t,"H1",{class:!0});var ve=n(b);w=o(ve,"A",{id:!0,class:!0,href:!0});var ut=n(w);Z=o(ut,"SPAN",{});var ft=n(Z);V(E.$$.fragment,ft),ft.forEach(r),ut.forEach(r),Se=u(ve),ee=o(ve,"SPAN",{});var ht=n(ee);$e=d(ht,"DPM Discrete Scheduler inspired by Karras et. al paper"),ht.forEach(r),ve.forEach(r),ue=u(t),y=o(t,"H2",{class:!0});var be=n(y);S=o(be,"A",{id:!0,class:!0,href:!0});var mt=n(S);te=o(mt,"SPAN",{});var _t=n(te);V(M.$$.fragment,_t),_t.forEach(r),mt.forEach(r),ke=u(be),re=o(be,"SPAN",{});var gt=n(re);Pe=d(gt,"Overview"),gt.forEach(r),be.forEach(r),fe=u(t),g=o(t,"P",{});var Y=n(g);Ee=d(Y,"Inspired by "),x=o(Y,"A",{href:!0,rel:!0});var vt=n(x);Me=d(vt,"Karras et. al"),vt.forEach(r),xe=d(Y,". Scheduler ported from @crowsonkb\u2019s "),K=o(Y,"A",{href:!0,rel:!0});var bt=n(K);Ke=d(bt,"https://github.com/crowsonkb/k-diffusion"),bt.forEach(r),Ae=d(Y," library:"),Y.forEach(r),he=u(t),A=o(t,"P",{});var ct=n(A);Te=d(ct,"All credit for making this scheduler work goes to "),T=o(ct,"A",{href:!0,rel:!0});var yt=n(T);Ce=d(yt,"Katherine Crowson"),yt.forEach(r),ct.forEach(r),me=u(t),D=o(t,"H2",{class:!0});var ye=n(D);$=o(ye,"A",{id:!0,class:!0,href:!0});var Dt=n($);se=o(Dt,"SPAN",{});var wt=n(se);V(C.$$.fragment,wt),wt.forEach(r),Dt.forEach(r),Oe=u(ye),oe=o(ye,"SPAN",{});var St=n(oe);Ne=d(St,"KDPM2DiscreteScheduler"),St.forEach(r),ye.forEach(r),_e=u(t),c=o(t,"DIV",{class:!0});var m=n(c);V(O.$$.fragment,m),Le=u(m),k=o(m,"P",{});var le=n(k);Fe=d(le,"Scheduler created by @crowsonkb in "),N=o(le,"A",{href:!0,rel:!0});var $t=n(N);Ie=d($t,"k_diffusion"),$t.forEach(r),Ue=d(le,`, see:
`),L=o(le,"A",{href:!0,rel:!0});var kt=n(L);qe=d(kt,"https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),kt.forEach(r),le.forEach(r),Ve=u(m),ne=o(m,"P",{});var Pt=n(ne);He=d(Pt,"Scheduler inspired by DPM-Solver-2 and Algorthim 2 from Karras et al. (2022)."),Pt.forEach(r),Be=u(m),l=o(m,"P",{});var h=n(l);R=o(h,"A",{href:!0});var Et=n(R);Ge=d(Et,"~ConfigMixin"),Et.forEach(r),Je=d(h," takes care of storing all config attributes that are passed in the scheduler\u2019s "),ie=o(h,"CODE",{});var Mt=n(ie);Re=d(Mt,"__init__"),Mt.forEach(r),We=d(h,`
function, such as `),ae=o(h,"CODE",{});var xt=n(ae);je=d(xt,"num_train_timesteps"),xt.forEach(r),ze=d(h,". They can be accessed via "),de=o(h,"CODE",{});var Kt=n(de);Qe=d(Kt,"scheduler.config.num_train_timesteps"),Kt.forEach(r),Xe=d(h,`.
`),W=o(h,"A",{href:!0});var At=n(W);Ye=d(At,"SchedulerMixin"),At.forEach(r),Ze=d(h," provides general loading and saving functionality via the "),j=o(h,"A",{href:!0});var Tt=n(j);et=d(Tt,"SchedulerMixin.save_pretrained()"),Tt.forEach(r),tt=d(h,` and
`),z=o(h,"A",{href:!0});var Ct=n(z);rt=d(Ct,"from_pretrained()"),Ct.forEach(r),st=d(h," functions."),h.forEach(r),ot=u(m),Q=o(m,"DIV",{class:!0});var Ot=n(Q);V(F.$$.fragment,Ot),Ot.forEach(r),nt=u(m),P=o(m,"DIV",{class:!0});var De=n(P);V(I.$$.fragment,De),it=u(De),ce=o(De,"P",{});var Nt=n(ce);at=d(Nt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Nt.forEach(r),De.forEach(r),dt=u(m),X=o(m,"DIV",{class:!0});var Lt=n(X);V(U.$$.fragment,Lt),Lt.forEach(r),m.forEach(r),this.h()},h(){i(v,"name","hf:doc:metadata"),i(v,"content",JSON.stringify(Gt)),i(w,"id","dpm-discrete-scheduler-inspired-by-karras-et-al-paper"),i(w,"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(w,"href","#dpm-discrete-scheduler-inspired-by-karras-et-al-paper"),i(b,"class","relative group"),i(S,"id","overview"),i(S,"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(S,"href","#overview"),i(y,"class","relative group"),i(x,"href","https://arxiv.org/abs/2206.00364"),i(x,"rel","nofollow"),i(K,"href","https://github.com/crowsonkb/k-diffusion"),i(K,"rel","nofollow"),i(T,"href","https://github.com/crowsonkb/"),i(T,"rel","nofollow"),i($,"id","diffusers.KDPM2DiscreteScheduler"),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"),i($,"href","#diffusers.KDPM2DiscreteScheduler"),i(D,"class","relative group"),i(N,"href","https://github.com/crowsonkb/k-diffusion"),i(N,"rel","nofollow"),i(L,"href","https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),i(L,"rel","nofollow"),i(R,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),i(W,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),i(j,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),i(z,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),i(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(P,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(c,"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,v),_(t,pe,f),_(t,b,f),e(b,w),e(w,Z),H(E,Z,null),e(b,Se),e(b,ee),e(ee,$e),_(t,ue,f),_(t,y,f),e(y,S),e(S,te),H(M,te,null),e(y,ke),e(y,re),e(re,Pe),_(t,fe,f),_(t,g,f),e(g,Ee),e(g,x),e(x,Me),e(g,xe),e(g,K),e(K,Ke),e(g,Ae),_(t,he,f),_(t,A,f),e(A,Te),e(A,T),e(T,Ce),_(t,me,f),_(t,D,f),e(D,$),e($,se),H(C,se,null),e(D,Oe),e(D,oe),e(oe,Ne),_(t,_e,f),_(t,c,f),H(O,c,null),e(c,Le),e(c,k),e(k,Fe),e(k,N),e(N,Ie),e(k,Ue),e(k,L),e(L,qe),e(c,Ve),e(c,ne),e(ne,He),e(c,Be),e(c,l),e(l,R),e(R,Ge),e(l,Je),e(l,ie),e(ie,Re),e(l,We),e(l,ae),e(ae,je),e(l,ze),e(l,de),e(de,Qe),e(l,Xe),e(l,W),e(W,Ye),e(l,Ze),e(l,j),e(j,et),e(l,tt),e(l,z),e(z,rt),e(l,st),e(c,ot),e(c,Q),H(F,Q,null),e(c,nt),e(c,P),H(I,P,null),e(P,it),e(P,ce),e(ce,at),e(c,dt),e(c,X),H(U,X,null),ge=!0},p:Vt,i(t){ge||(B(E.$$.fragment,t),B(M.$$.fragment,t),B(C.$$.fragment,t),B(O.$$.fragment,t),B(F.$$.fragment,t),B(I.$$.fragment,t),B(U.$$.fragment,t),ge=!0)},o(t){G(E.$$.fragment,t),G(M.$$.fragment,t),G(C.$$.fragment,t),G(O.$$.fragment,t),G(F.$$.fragment,t),G(I.$$.fragment,t),G(U.$$.fragment,t),ge=!1},d(t){r(v),t&&r(pe),t&&r(b),J(E),t&&r(ue),t&&r(y),J(M),t&&r(fe),t&&r(g),t&&r(he),t&&r(A),t&&r(me),t&&r(D),J(C),t&&r(_e),t&&r(c),J(O),J(F),J(I),J(U)}}}const Gt={local:"dpm-discrete-scheduler-inspired-by-karras-et-al-paper",sections:[{local:"overview",title:"Overview"},{local:"diffusers.KDPM2DiscreteScheduler",title:"KDPM2DiscreteScheduler"}],title:"DPM Discrete Scheduler inspired by Karras et. al paper"};function Jt(pt){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zt extends Ft{constructor(v){super();It(this,v,Jt,Bt,Ut,{})}}export{zt as default,Gt as metadata};
