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