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