import{S as At,i as Pt,s as Tt,e as s,k as p,w as F,t as i,M as Ct,c as n,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 nt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Nt(ot){let _,ce,b,$,Y,x,ye,Z,we,de,y,S,ee,D,$e,te,Se,le,v,Ee,H,ke,xe,A,De,He,ue,P,Ae,T,Pe,fe,w,E,re,C,Te,se,Ce,pe,l,M,Me,G,Oe,O,Ne,Ke,d,J,Le,Fe,ne,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 nt({}),D=new nt({}),C=new nt({}),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/v0.11.0/src/diffusers/schedulers/scheduling_heun_discrete.py#L25"}}),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/v0.11.0/src/diffusers/schedulers/scheduling_heun_discrete.py#L90",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/v0.11.0/src/diffusers/schedulers/scheduling_heun_discrete.py#L109"}}),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/v0.11.0/src/diffusers/schedulers/scheduling_heun_discrete.py#L156",returnDescription:`
<p><a
  href="/docs/diffusers/v0.11.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.11.0/en/api/schedulers/overview#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),{c(){_=s("meta"),ce=p(),b=s("h1"),$=s("a"),Y=s("span"),F(x.$$.fragment),ye=p(),Z=s("span"),we=i("Heun scheduler inspired by Karras et. al paper"),de=p(),y=s("h2"),S=s("a"),ee=s("span"),F(D.$$.fragment),$e=p(),te=s("span"),Se=i("Overview"),le=p(),v=s("p"),Ee=i("Algorithm 1 of "),H=s("a"),ke=i("Karras et. al"),xe=i(`.
Scheduler ported from @crowsonkb\u2019s `),A=s("a"),De=i("https://github.com/crowsonkb/k-diffusion"),He=i(" library:"),ue=p(),P=s("p"),Ae=i("All credit for making this scheduler work goes to "),T=s("a"),Pe=i("Katherine Crowson"),fe=p(),w=s("h2"),E=s("a"),re=s("span"),F(C.$$.fragment),Te=p(),se=s("span"),Ce=i("HeunDiscreteScheduler"),pe=p(),l=s("div"),F(M.$$.fragment),Me=p(),G=s("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=s("a"),Ne=i("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L90"),Ke=p(),d=s("p"),J=s("a"),Le=i("~ConfigMixin"),Fe=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),ne=s("code"),Ie=i("__init__"),Ue=i(`
function, such as `),oe=s("code"),qe=i("num_train_timesteps"),Ve=i(". They can be accessed via "),ae=s("code"),Be=i("scheduler.config.num_train_timesteps"),Ge=i(`.
`),R=s("a"),Je=i("SchedulerMixin"),Re=i(" provides general loading and saving functionality via the "),W=s("a"),We=i("SchedulerMixin.save_pretrained()"),je=i(` and
`),j=s("a"),ze=i("from_pretrained()"),Qe=i(" functions."),Xe=p(),z=s("div"),F(N.$$.fragment),Ye=p(),k=s("div"),F(K.$$.fragment),Ze=p(),ie=s("p"),et=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),tt=p(),Q=s("div"),F(L.$$.fragment),this.h()},l(t){const u=Ct('[data-svelte="svelte-1phssyn"]',document.head);_=n(u,"META",{name:!0,content:!0}),u.forEach(r),ce=h(t),b=n(t,"H1",{class:!0});var me=o(b);$=n(me,"A",{id:!0,class:!0,href:!0});var at=o($);Y=n(at,"SPAN",{});var it=o(Y);I(x.$$.fragment,it),it.forEach(r),at.forEach(r),ye=h(me),Z=n(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=n(t,"H2",{class:!0});var ge=o(y);S=n(ge,"A",{id:!0,class:!0,href:!0});var dt=o(S);ee=n(dt,"SPAN",{});var lt=o(ee);I(D.$$.fragment,lt),lt.forEach(r),dt.forEach(r),$e=h(ge),te=n(ge,"SPAN",{});var ut=o(te);Se=c(ut,"Overview"),ut.forEach(r),ge.forEach(r),le=h(t),v=n(t,"P",{});var X=o(v);Ee=c(X,"Algorithm 1 of "),H=n(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=n(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=n(t,"P",{});var rt=o(P);Ae=c(rt,"All credit for making this scheduler work goes to "),T=n(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=n(t,"H2",{class:!0});var ve=o(w);E=n(ve,"A",{id:!0,class:!0,href:!0});var mt=o(E);re=n(mt,"SPAN",{});var gt=o(re);I(C.$$.fragment,gt),gt.forEach(r),mt.forEach(r),Te=h(ve),se=n(ve,"SPAN",{});var vt=o(se);Ce=c(vt,"HeunDiscreteScheduler"),vt.forEach(r),ve.forEach(r),pe=h(t),l=n(t,"DIV",{class:!0});var m=o(l);I(M.$$.fragment,m),Me=h(m),G=n(m,"P",{});var st=o(G);Oe=c(st,`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(st,"A",{href:!0,rel:!0});var _t=o(O);Ne=c(_t,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L90"),_t.forEach(r),st.forEach(r),Ke=h(m),d=n(m,"P",{});var f=o(d);J=n(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 "),ne=n(f,"CODE",{});var yt=o(ne);Ie=c(yt,"__init__"),yt.forEach(r),Ue=c(f,`
function, such as `),oe=n(f,"CODE",{});var wt=o(oe);qe=c(wt,"num_train_timesteps"),wt.forEach(r),Ve=c(f,". They can be accessed via "),ae=n(f,"CODE",{});var $t=o(ae);Be=c($t,"scheduler.config.num_train_timesteps"),$t.forEach(r),Ge=c(f,`.
`),R=n(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=n(f,"A",{href:!0});var Et=o(W);We=c(Et,"SchedulerMixin.save_pretrained()"),Et.forEach(r),je=c(f,` and
`),j=n(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=n(m,"DIV",{class:!0});var xt=o(z);I(N.$$.fragment,xt),xt.forEach(r),Ye=h(m),k=n(m,"DIV",{class:!0});var _e=o(k);I(K.$$.fragment,_e),Ze=h(_e),ie=n(_e,"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),_e.forEach(r),tt=h(m),Q=n(m,"DIV",{class:!0});var Ht=o(Q);I(L.$$.fragment,Ht),Ht.forEach(r),m.forEach(r),this.h()},h(){a(_,"name","hf:doc:metadata"),a(_,"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/v0.11.0/en/api/configuration#diffusers.ConfigMixin"),a(R,"href","/docs/diffusers/v0.11.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),a(W,"href","/docs/diffusers/v0.11.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),a(j,"href","/docs/diffusers/v0.11.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(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,_),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,v,u),e(v,Ee),e(v,H),e(H,ke),e(v,xe),e(v,A),e(A,De),e(v,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,se),e(se,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,ne),e(ne,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(_),t&&r(ce),t&&r(b),B(x),t&&r(de),t&&r(y),B(D),t&&r(le),t&&r(v),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(_){super();Pt(this,_,Lt,Nt,Tt,{})}}export{qt as default,Kt as metadata};
