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