import{S as Lt,i as It,s as Ut,e as s,k as p,w as q,t as i,M as qt,c as o,d as r,m as f,a as n,x as V,h as d,b as a,G as e,g as _,y as H,L as Vt,q as R,o as B,B as G,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 Rt(pt){let v,pe,b,w,Z,E,Se,ee,$e,fe,y,S,te,x,ke,re,Pe,ue,g,Ee,M,xe,Me,K,Ke,Ae,he,A,Te,T,Ce,me,D,$,se,C,Ne,oe,Oe,_e,c,N,Fe,k,Le,O,Ie,Ue,F,qe,Ve,ne,He,Re,l,J,Be,Ge,ae,Je,We,ie,Ye,je,de,ze,Qe,W,Xe,Ze,Y,et,tt,j,rt,st,ot,z,L,nt,P,I,at,ce,it,dt,Q,U,ge;return E=new lt({}),x=new lt({}),C=new lt({}),N=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'"},{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>) &#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"},{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L71"}}),L=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#L168",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#L191"}}),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#L290",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=i("DPM Discrete Scheduler inspired by Karras et. al paper"),fe=p(),y=s("h2"),S=s("a"),te=s("span"),q(x.$$.fragment),ke=p(),re=s("span"),Pe=i("Overview"),ue=p(),g=s("p"),Ee=i("Inspired by "),M=s("a"),xe=i("Karras et. al"),Me=i(". Scheduler ported from @crowsonkb\u2019s "),K=s("a"),Ke=i("https://github.com/crowsonkb/k-diffusion"),Ae=i(" library:"),he=p(),A=s("p"),Te=i("All credit for making this scheduler work goes to "),T=s("a"),Ce=i("Katherine Crowson"),me=p(),D=s("h2"),$=s("a"),se=s("span"),q(C.$$.fragment),Ne=p(),oe=s("span"),Oe=i("KDPM2DiscreteScheduler"),_e=p(),c=s("div"),q(N.$$.fragment),Fe=p(),k=s("p"),Le=i("Scheduler created by @crowsonkb in "),O=s("a"),Ie=i("k_diffusion"),Ue=i(`, see:
`),F=s("a"),qe=i("https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),Ve=p(),ne=s("p"),He=i("Scheduler inspired by DPM-Solver-2 and Algorthim 2 from Karras et al. (2022)."),Re=p(),l=s("p"),J=s("a"),Be=i("~ConfigMixin"),Ge=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),ae=s("code"),Je=i("__init__"),We=i(`
function, such as `),ie=s("code"),Ye=i("num_train_timesteps"),je=i(". They can be accessed via "),de=s("code"),ze=i("scheduler.config.num_train_timesteps"),Qe=i(`.
`),W=s("a"),Xe=i("SchedulerMixin"),Ze=i(" provides general loading and saving functionality via the "),Y=s("a"),et=i("SchedulerMixin.save_pretrained()"),tt=i(` and
`),j=s("a"),rt=i("from_pretrained()"),st=i(" functions."),ot=p(),z=s("div"),q(L.$$.fragment),nt=p(),P=s("div"),q(I.$$.fragment),at=p(),ce=s("p"),it=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),dt=p(),Q=s("div"),q(U.$$.fragment),this.h()},l(t){const u=qt('[data-svelte="svelte-1phssyn"]',document.head);v=o(u,"META",{name:!0,content:!0}),u.forEach(r),pe=f(t),b=o(t,"H1",{class:!0});var ve=n(b);w=o(ve,"A",{id:!0,class:!0,href:!0});var ft=n(w);Z=o(ft,"SPAN",{});var ut=n(Z);V(E.$$.fragment,ut),ut.forEach(r),ft.forEach(r),Se=f(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),fe=f(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(x.$$.fragment,_t),_t.forEach(r),mt.forEach(r),ke=f(be),re=o(be,"SPAN",{});var gt=n(re);Pe=d(gt,"Overview"),gt.forEach(r),be.forEach(r),ue=f(t),g=o(t,"P",{});var X=n(g);Ee=d(X,"Inspired by "),M=o(X,"A",{href:!0,rel:!0});var vt=n(M);xe=d(vt,"Karras et. al"),vt.forEach(r),Me=d(X,". Scheduler ported from @crowsonkb\u2019s "),K=o(X,"A",{href:!0,rel:!0});var bt=n(K);Ke=d(bt,"https://github.com/crowsonkb/k-diffusion"),bt.forEach(r),Ae=d(X," library:"),X.forEach(r),he=f(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=f(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),Ne=f(ye),oe=o(ye,"SPAN",{});var St=n(oe);Oe=d(St,"KDPM2DiscreteScheduler"),St.forEach(r),ye.forEach(r),_e=f(t),c=o(t,"DIV",{class:!0});var m=n(c);V(N.$$.fragment,m),Fe=f(m),k=o(m,"P",{});var le=n(k);Le=d(le,"Scheduler created by @crowsonkb in "),O=o(le,"A",{href:!0,rel:!0});var $t=n(O);Ie=d($t,"k_diffusion"),$t.forEach(r),Ue=d(le,`, see:
`),F=o(le,"A",{href:!0,rel:!0});var kt=n(F);qe=d(kt,"https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),kt.forEach(r),le.forEach(r),Ve=f(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),Re=f(m),l=o(m,"P",{});var h=n(l);J=o(h,"A",{href:!0});var Et=n(J);Be=d(Et,"~ConfigMixin"),Et.forEach(r),Ge=d(h," takes care of storing all config attributes that are passed in the scheduler\u2019s "),ae=o(h,"CODE",{});var xt=n(ae);Je=d(xt,"__init__"),xt.forEach(r),We=d(h,`
function, such as `),ie=o(h,"CODE",{});var Mt=n(ie);Ye=d(Mt,"num_train_timesteps"),Mt.forEach(r),je=d(h,". They can be accessed via "),de=o(h,"CODE",{});var Kt=n(de);ze=d(Kt,"scheduler.config.num_train_timesteps"),Kt.forEach(r),Qe=d(h,`.
`),W=o(h,"A",{href:!0});var At=n(W);Xe=d(At,"SchedulerMixin"),At.forEach(r),Ze=d(h," provides general loading and saving functionality via the "),Y=o(h,"A",{href:!0});var Tt=n(Y);et=d(Tt,"SchedulerMixin.save_pretrained()"),Tt.forEach(r),tt=d(h,` and
`),j=o(h,"A",{href:!0});var Ct=n(j);rt=d(Ct,"from_pretrained()"),Ct.forEach(r),st=d(h," functions."),h.forEach(r),ot=f(m),z=o(m,"DIV",{class:!0});var Nt=n(z);V(L.$$.fragment,Nt),Nt.forEach(r),nt=f(m),P=o(m,"DIV",{class:!0});var De=n(P);V(I.$$.fragment,De),at=f(De),ce=o(De,"P",{});var Ot=n(ce);it=d(Ot,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Ot.forEach(r),De.forEach(r),dt=f(m),Q=o(m,"DIV",{class:!0});var Ft=n(Q);V(U.$$.fragment,Ft),Ft.forEach(r),m.forEach(r),this.h()},h(){a(v,"name","hf:doc:metadata"),a(v,"content",JSON.stringify(Bt)),a(w,"id","dpm-discrete-scheduler-inspired-by-karras-et-al-paper"),a(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"),a(w,"href","#dpm-discrete-scheduler-inspired-by-karras-et-al-paper"),a(b,"class","relative group"),a(S,"id","overview"),a(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"),a(S,"href","#overview"),a(y,"class","relative group"),a(M,"href","https://arxiv.org/abs/2206.00364"),a(M,"rel","nofollow"),a(K,"href","https://github.com/crowsonkb/k-diffusion"),a(K,"rel","nofollow"),a(T,"href","https://github.com/crowsonkb/"),a(T,"rel","nofollow"),a($,"id","diffusers.KDPM2DiscreteScheduler"),a($,"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"),a($,"href","#diffusers.KDPM2DiscreteScheduler"),a(D,"class","relative group"),a(O,"href","https://github.com/crowsonkb/k-diffusion"),a(O,"rel","nofollow"),a(F,"href","https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L188"),a(F,"rel","nofollow"),a(J,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),a(W,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),a(Y,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),a(j,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),a(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(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,u){e(document.head,v),_(t,pe,u),_(t,b,u),e(b,w),e(w,Z),H(E,Z,null),e(b,Se),e(b,ee),e(ee,$e),_(t,fe,u),_(t,y,u),e(y,S),e(S,te),H(x,te,null),e(y,ke),e(y,re),e(re,Pe),_(t,ue,u),_(t,g,u),e(g,Ee),e(g,M),e(M,xe),e(g,Me),e(g,K),e(K,Ke),e(g,Ae),_(t,he,u),_(t,A,u),e(A,Te),e(A,T),e(T,Ce),_(t,me,u),_(t,D,u),e(D,$),e($,se),H(C,se,null),e(D,Ne),e(D,oe),e(oe,Oe),_(t,_e,u),_(t,c,u),H(N,c,null),e(c,Fe),e(c,k),e(k,Le),e(k,O),e(O,Ie),e(k,Ue),e(k,F),e(F,qe),e(c,Ve),e(c,ne),e(ne,He),e(c,Re),e(c,l),e(l,J),e(J,Be),e(l,Ge),e(l,ae),e(ae,Je),e(l,We),e(l,ie),e(ie,Ye),e(l,je),e(l,de),e(de,ze),e(l,Qe),e(l,W),e(W,Xe),e(l,Ze),e(l,Y),e(Y,et),e(l,tt),e(l,j),e(j,rt),e(l,st),e(c,ot),e(c,z),H(L,z,null),e(c,nt),e(c,P),H(I,P,null),e(P,at),e(P,ce),e(ce,it),e(c,dt),e(c,Q),H(U,Q,null),ge=!0},p:Vt,i(t){ge||(R(E.$$.fragment,t),R(x.$$.fragment,t),R(C.$$.fragment,t),R(N.$$.fragment,t),R(L.$$.fragment,t),R(I.$$.fragment,t),R(U.$$.fragment,t),ge=!0)},o(t){B(E.$$.fragment,t),B(x.$$.fragment,t),B(C.$$.fragment,t),B(N.$$.fragment,t),B(L.$$.fragment,t),B(I.$$.fragment,t),B(U.$$.fragment,t),ge=!1},d(t){r(v),t&&r(pe),t&&r(b),G(E),t&&r(fe),t&&r(y),G(x),t&&r(ue),t&&r(g),t&&r(he),t&&r(A),t&&r(me),t&&r(D),G(C),t&&r(_e),t&&r(c),G(N),G(L),G(I),G(U)}}}const Bt={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 Gt(pt){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends Lt{constructor(v){super();It(this,v,Gt,Rt,Ut,{})}}export{jt as default,Bt as metadata};
