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