import{S as At,i as Pt,s as Tt,e as n,k as p,w as F,t as i,M as Ct,c as s,d as r,m as h,a as o,x as I,h as c,b as a,G as e,g,y as U,L as Mt,q,o as V,B,v as Ot}from"../../../chunks/vendor-hf-doc-builder.js";import{D as be}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as st}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Nt(ot){let v,ce,b,$,Y,x,ye,Z,we,de,y,S,ee,D,$e,te,Se,le,_,Ee,H,ke,xe,A,De,He,ue,P,Ae,T,Pe,fe,w,E,re,C,Te,ne,Ce,pe,l,M,Me,G,Oe,O,Ne,Ke,d,J,Le,Fe,se,Ie,Ue,oe,qe,Ve,ae,Be,Ge,R,Je,Re,W,We,je,j,ze,Qe,Xe,z,N,Ye,k,K,Ze,ie,et,tt,Q,L,he;return x=new st({}),D=new st({}),C=new st({}),M=new be({props:{name:"class diffusers.HeunDiscreteScheduler",anchor:"diffusers.HeunDiscreteScheduler",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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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_heun_discrete.py#L55"}}),N=new be({props:{name:"scale_model_input",anchor:"diffusers.HeunDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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_heun_discrete.py#L123",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),K=new be({props:{name:"set_timesteps",anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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_heun_discrete.py#L142"}}),L=new be({props:{name:"step",anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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_heun_discrete.py#L189",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=n("meta"),ce=p(),b=n("h1"),$=n("a"),Y=n("span"),F(x.$$.fragment),ye=p(),Z=n("span"),we=i("Heun scheduler inspired by Karras et. al paper"),de=p(),y=n("h2"),S=n("a"),ee=n("span"),F(D.$$.fragment),$e=p(),te=n("span"),Se=i("Overview"),le=p(),_=n("p"),Ee=i("Algorithm 1 of "),H=n("a"),ke=i("Karras et. al"),xe=i(`.
Scheduler ported from @crowsonkb\u2019s `),A=n("a"),De=i("https://github.com/crowsonkb/k-diffusion"),He=i(" library:"),ue=p(),P=n("p"),Ae=i("All credit for making this scheduler work goes to "),T=n("a"),Pe=i("Katherine Crowson"),fe=p(),w=n("h2"),E=n("a"),re=n("span"),F(C.$$.fragment),Te=p(),ne=n("span"),Ce=i("HeunDiscreteScheduler"),pe=p(),l=n("div"),F(M.$$.fragment),Me=p(),G=n("p"),Oe=i(`Implements Algorithm 2 (Heun steps) from Karras et al. (2022). for discrete beta schedules. Based on the original
k-diffusion implementation by Katherine Crowson:
`),O=n("a"),Ne=i("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L90"),Ke=p(),d=n("p"),J=n("a"),Le=i("~ConfigMixin"),Fe=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=n("code"),Ie=i("__init__"),Ue=i(`
function, such as `),oe=n("code"),qe=i("num_train_timesteps"),Ve=i(". They can be accessed via "),ae=n("code"),Be=i("scheduler.config.num_train_timesteps"),Ge=i(`.
`),R=n("a"),Je=i("SchedulerMixin"),Re=i(" provides general loading and saving functionality via the "),W=n("a"),We=i("SchedulerMixin.save_pretrained()"),je=i(` and
`),j=n("a"),ze=i("from_pretrained()"),Qe=i(" functions."),Xe=p(),z=n("div"),F(N.$$.fragment),Ye=p(),k=n("div"),F(K.$$.fragment),Ze=p(),ie=n("p"),et=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),tt=p(),Q=n("div"),F(L.$$.fragment),this.h()},l(t){const u=Ct('[data-svelte="svelte-1phssyn"]',document.head);v=s(u,"META",{name:!0,content:!0}),u.forEach(r),ce=h(t),b=s(t,"H1",{class:!0});var me=o(b);$=s(me,"A",{id:!0,class:!0,href:!0});var at=o($);Y=s(at,"SPAN",{});var it=o(Y);I(x.$$.fragment,it),it.forEach(r),at.forEach(r),ye=h(me),Z=s(me,"SPAN",{});var ct=o(Z);we=c(ct,"Heun scheduler inspired by Karras et. al paper"),ct.forEach(r),me.forEach(r),de=h(t),y=s(t,"H2",{class:!0});var ge=o(y);S=s(ge,"A",{id:!0,class:!0,href:!0});var dt=o(S);ee=s(dt,"SPAN",{});var lt=o(ee);I(D.$$.fragment,lt),lt.forEach(r),dt.forEach(r),$e=h(ge),te=s(ge,"SPAN",{});var ut=o(te);Se=c(ut,"Overview"),ut.forEach(r),ge.forEach(r),le=h(t),_=s(t,"P",{});var X=o(_);Ee=c(X,"Algorithm 1 of "),H=s(X,"A",{href:!0,rel:!0});var ft=o(H);ke=c(ft,"Karras et. al"),ft.forEach(r),xe=c(X,`.
Scheduler ported from @crowsonkb\u2019s `),A=s(X,"A",{href:!0,rel:!0});var pt=o(A);De=c(pt,"https://github.com/crowsonkb/k-diffusion"),pt.forEach(r),He=c(X," library:"),X.forEach(r),ue=h(t),P=s(t,"P",{});var rt=o(P);Ae=c(rt,"All credit for making this scheduler work goes to "),T=s(rt,"A",{href:!0,rel:!0});var ht=o(T);Pe=c(ht,"Katherine Crowson"),ht.forEach(r),rt.forEach(r),fe=h(t),w=s(t,"H2",{class:!0});var _e=o(w);E=s(_e,"A",{id:!0,class:!0,href:!0});var mt=o(E);re=s(mt,"SPAN",{});var gt=o(re);I(C.$$.fragment,gt),gt.forEach(r),mt.forEach(r),Te=h(_e),ne=s(_e,"SPAN",{});var _t=o(ne);Ce=c(_t,"HeunDiscreteScheduler"),_t.forEach(r),_e.forEach(r),pe=h(t),l=s(t,"DIV",{class:!0});var m=o(l);I(M.$$.fragment,m),Me=h(m),G=s(m,"P",{});var nt=o(G);Oe=c(nt,`Implements Algorithm 2 (Heun steps) from Karras et al. (2022). for discrete beta schedules. Based on the original
k-diffusion implementation by Katherine Crowson:
`),O=s(nt,"A",{href:!0,rel:!0});var vt=o(O);Ne=c(vt,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L90"),vt.forEach(r),nt.forEach(r),Ke=h(m),d=s(m,"P",{});var f=o(d);J=s(f,"A",{href:!0});var bt=o(J);Le=c(bt,"~ConfigMixin"),bt.forEach(r),Fe=c(f," takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=s(f,"CODE",{});var yt=o(se);Ie=c(yt,"__init__"),yt.forEach(r),Ue=c(f,`
function, such as `),oe=s(f,"CODE",{});var wt=o(oe);qe=c(wt,"num_train_timesteps"),wt.forEach(r),Ve=c(f,". They can be accessed via "),ae=s(f,"CODE",{});var $t=o(ae);Be=c($t,"scheduler.config.num_train_timesteps"),$t.forEach(r),Ge=c(f,`.
`),R=s(f,"A",{href:!0});var St=o(R);Je=c(St,"SchedulerMixin"),St.forEach(r),Re=c(f," provides general loading and saving functionality via the "),W=s(f,"A",{href:!0});var Et=o(W);We=c(Et,"SchedulerMixin.save_pretrained()"),Et.forEach(r),je=c(f,` and
`),j=s(f,"A",{href:!0});var kt=o(j);ze=c(kt,"from_pretrained()"),kt.forEach(r),Qe=c(f," functions."),f.forEach(r),Xe=h(m),z=s(m,"DIV",{class:!0});var xt=o(z);I(N.$$.fragment,xt),xt.forEach(r),Ye=h(m),k=s(m,"DIV",{class:!0});var ve=o(k);I(K.$$.fragment,ve),Ze=h(ve),ie=s(ve,"P",{});var Dt=o(ie);et=c(Dt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Dt.forEach(r),ve.forEach(r),tt=h(m),Q=s(m,"DIV",{class:!0});var Ht=o(Q);I(L.$$.fragment,Ht),Ht.forEach(r),m.forEach(r),this.h()},h(){a(v,"name","hf:doc:metadata"),a(v,"content",JSON.stringify(Kt)),a($,"id","heun-scheduler-inspired-by-karras-et-al-paper"),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","#heun-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(H,"href","https://arxiv.org/abs/2206.00364"),a(H,"rel","nofollow"),a(A,"href","https://github.com/crowsonkb/k-diffusion"),a(A,"rel","nofollow"),a(T,"href","https://github.com/crowsonkb/"),a(T,"rel","nofollow"),a(E,"id","diffusers.HeunDiscreteScheduler"),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.HeunDiscreteScheduler"),a(w,"class","relative group"),a(O,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L90"),a(O,"rel","nofollow"),a(J,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),a(R,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),a(W,"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(k,"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(l,"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),g(t,ce,u),g(t,b,u),e(b,$),e($,Y),U(x,Y,null),e(b,ye),e(b,Z),e(Z,we),g(t,de,u),g(t,y,u),e(y,S),e(S,ee),U(D,ee,null),e(y,$e),e(y,te),e(te,Se),g(t,le,u),g(t,_,u),e(_,Ee),e(_,H),e(H,ke),e(_,xe),e(_,A),e(A,De),e(_,He),g(t,ue,u),g(t,P,u),e(P,Ae),e(P,T),e(T,Pe),g(t,fe,u),g(t,w,u),e(w,E),e(E,re),U(C,re,null),e(w,Te),e(w,ne),e(ne,Ce),g(t,pe,u),g(t,l,u),U(M,l,null),e(l,Me),e(l,G),e(G,Oe),e(G,O),e(O,Ne),e(l,Ke),e(l,d),e(d,J),e(J,Le),e(d,Fe),e(d,se),e(se,Ie),e(d,Ue),e(d,oe),e(oe,qe),e(d,Ve),e(d,ae),e(ae,Be),e(d,Ge),e(d,R),e(R,Je),e(d,Re),e(d,W),e(W,We),e(d,je),e(d,j),e(j,ze),e(d,Qe),e(l,Xe),e(l,z),U(N,z,null),e(l,Ye),e(l,k),U(K,k,null),e(k,Ze),e(k,ie),e(ie,et),e(l,tt),e(l,Q),U(L,Q,null),he=!0},p:Mt,i(t){he||(q(x.$$.fragment,t),q(D.$$.fragment,t),q(C.$$.fragment,t),q(M.$$.fragment,t),q(N.$$.fragment,t),q(K.$$.fragment,t),q(L.$$.fragment,t),he=!0)},o(t){V(x.$$.fragment,t),V(D.$$.fragment,t),V(C.$$.fragment,t),V(M.$$.fragment,t),V(N.$$.fragment,t),V(K.$$.fragment,t),V(L.$$.fragment,t),he=!1},d(t){r(v),t&&r(ce),t&&r(b),B(x),t&&r(de),t&&r(y),B(D),t&&r(le),t&&r(_),t&&r(ue),t&&r(P),t&&r(fe),t&&r(w),B(C),t&&r(pe),t&&r(l),B(M),B(N),B(K),B(L)}}}const Kt={local:"heun-scheduler-inspired-by-karras-et-al-paper",sections:[{local:"overview",title:"Overview"},{local:"diffusers.HeunDiscreteScheduler",title:"HeunDiscreteScheduler"}],title:"Heun scheduler inspired by Karras et. al paper"};function Lt(ot){return Ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends At{constructor(v){super();Pt(this,v,Lt,Nt,Tt,{})}}export{qt as default,Kt as metadata};
