import{S as qt,i as Kt,s as Ut,e as s,k as f,w as k,t as i,M as Vt,c as o,d as r,m as u,a as n,x as T,h as a,b as c,G as e,g,y as O,L as Bt,q as P,o as C,B as A,v as Ht}from"../../../chunks/vendor-hf-doc-builder.js";import{D as le}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ht}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function zt(mt){let _,fe,v,$,X,F,Me,Y,xe,ue,b,y,Z,N,Ee,ee,ke,pe,D,Te,I,Oe,Pe,he,S,L,te,q,Ce,re,Ae,me,d,K,Fe,J,Ne,U,Ie,qe,l,R,Ke,Ue,se,Ve,Be,oe,He,ze,ne,Ge,Je,W,Re,We,j,je,Qe,Q,Xe,Ye,Ze,w,V,et,ie,tt,rt,M,B,st,H,ot,ae,nt,it,at,x,z,ct,ce,dt,lt,E,G,ft,de,ut,ge;return F=new ht({}),N=new ht({}),q=new ht({}),K=new le({props:{name:"class diffusers.LMSDiscreteScheduler",anchor:"diffusers.LMSDiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"use_karras_sigmas",val:": typing.Optional[bool] = False"},{name:"prediction_type",val:": str = 'epsilon'"}],parametersDescription:[{anchor:"diffusers.LMSDiscreteScheduler.num_train_timesteps",description:"<strong>num_train_timesteps</strong> (<code>int</code>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.LMSDiscreteScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#x2014; the starting <code>beta</code> value of inference.",name:"beta_start"},{anchor:"diffusers.LMSDiscreteScheduler.beta_end",description:"<strong>beta_end</strong> (<code>float</code>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.LMSDiscreteScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</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.LMSDiscreteScheduler.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.`,name:"trained_betas"},{anchor:"diffusers.LMSDiscreteScheduler.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"},{anchor:"diffusers.LMSDiscreteScheduler.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.17.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L77"}}),V=new le({props:{name:"get_lms_coefficient",anchor:"diffusers.LMSDiscreteScheduler.get_lms_coefficient",parameters:[{name:"order",val:""},{name:"t",val:""},{name:"current_order",val:""}],parametersDescription:[{anchor:"diffusers.LMSDiscreteScheduler.get_lms_coefficient.order",description:"<strong>order</strong> (TODO) &#x2014;",name:"order"},{anchor:"diffusers.LMSDiscreteScheduler.get_lms_coefficient.t",description:"<strong>t</strong> (TODO) &#x2014;",name:"t"},{anchor:"diffusers.LMSDiscreteScheduler.get_lms_coefficient.current_order",description:"<strong>current_order</strong> (TODO) &#x2014;",name:"current_order"}],source:"https://github.com/huggingface/diffusers/blob/v0.17.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L174"}}),B=new le({props:{name:"scale_model_input",anchor:"diffusers.LMSDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.LMSDiscreteScheduler.scale_model_input.sample",description:"<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014; input sample",name:"sample"},{anchor:"diffusers.LMSDiscreteScheduler.scale_model_input.timestep",description:"<strong>timestep</strong> (<code>float</code> or <code>torch.FloatTensor</code>) &#x2014; the current timestep in the diffusion chain",name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/v0.17.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L153",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),z=new le({props:{name:"set_timesteps",anchor:"diffusers.LMSDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.LMSDiscreteScheduler.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.LMSDiscreteScheduler.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.17.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L196"}}),G=new le({props:{name:"step",anchor:"diffusers.LMSDiscreteScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": FloatTensor"},{name:"order",val:": int = 4"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LMSDiscreteScheduler.step.model_output",description:"<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.LMSDiscreteScheduler.step.timestep",description:"<strong>timestep</strong> (<code>float</code>) &#x2014; current timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.LMSDiscreteScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.
order &#x2014; coefficient for multi-step inference.`,name:"sample"},{anchor:"diffusers.LMSDiscreteScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than LMSDiscreteSchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.17.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L267",returnDescription:`
<p><code>~schedulers.scheduling_utils.LMSDiscreteSchedulerOutput</code> 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><code>~schedulers.scheduling_utils.LMSDiscreteSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){_=s("meta"),fe=f(),v=s("h1"),$=s("a"),X=s("span"),k(F.$$.fragment),Me=f(),Y=s("span"),xe=i("Linear multistep scheduler for discrete beta schedules"),ue=f(),b=s("h2"),y=s("a"),Z=s("span"),k(N.$$.fragment),Ee=f(),ee=s("span"),ke=i("Overview"),pe=f(),D=s("p"),Te=i("Original implementation can be found "),I=s("a"),Oe=i("here"),Pe=i("."),he=f(),S=s("h2"),L=s("a"),te=s("span"),k(q.$$.fragment),Ce=f(),re=s("span"),Ae=i("LMSDiscreteScheduler"),me=f(),d=s("div"),k(K.$$.fragment),Fe=f(),J=s("p"),Ne=i(`Linear Multistep Scheduler for discrete beta schedules. Based on the original k-diffusion implementation by
Katherine Crowson:
`),U=s("a"),Ie=i("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),qe=f(),l=s("p"),R=s("a"),Ke=i("~ConfigMixin"),Ue=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=s("code"),Ve=i("__init__"),Be=i(`
function, such as `),oe=s("code"),He=i("num_train_timesteps"),ze=i(". They can be accessed via "),ne=s("code"),Ge=i("scheduler.config.num_train_timesteps"),Je=i(`.
`),W=s("a"),Re=i("SchedulerMixin"),We=i(" provides general loading and saving functionality via the "),j=s("a"),je=i("SchedulerMixin.save_pretrained()"),Qe=i(` and
`),Q=s("a"),Xe=i("from_pretrained()"),Ye=i(" functions."),Ze=f(),w=s("div"),k(V.$$.fragment),et=f(),ie=s("p"),tt=i("Compute a linear multistep coefficient."),rt=f(),M=s("div"),k(B.$$.fragment),st=f(),H=s("p"),ot=i("Scales the denoising model input by "),ae=s("code"),nt=i("(sigma**2 + 1) ** 0.5"),it=i(" to match the K-LMS algorithm."),at=f(),x=s("div"),k(z.$$.fragment),ct=f(),ce=s("p"),dt=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),lt=f(),E=s("div"),k(G.$$.fragment),ft=f(),de=s("p"),ut=i(`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),this.h()},l(t){const m=Vt('[data-svelte="svelte-1phssyn"]',document.head);_=o(m,"META",{name:!0,content:!0}),m.forEach(r),fe=u(t),v=o(t,"H1",{class:!0});var _e=n(v);$=o(_e,"A",{id:!0,class:!0,href:!0});var gt=n($);X=o(gt,"SPAN",{});var _t=n(X);T(F.$$.fragment,_t),_t.forEach(r),gt.forEach(r),Me=u(_e),Y=o(_e,"SPAN",{});var vt=n(Y);xe=a(vt,"Linear multistep scheduler for discrete beta schedules"),vt.forEach(r),_e.forEach(r),ue=u(t),b=o(t,"H2",{class:!0});var ve=n(b);y=o(ve,"A",{id:!0,class:!0,href:!0});var bt=n(y);Z=o(bt,"SPAN",{});var St=n(Z);T(N.$$.fragment,St),St.forEach(r),bt.forEach(r),Ee=u(ve),ee=o(ve,"SPAN",{});var $t=n(ee);ke=a($t,"Overview"),$t.forEach(r),ve.forEach(r),pe=u(t),D=o(t,"P",{});var be=n(D);Te=a(be,"Original implementation can be found "),I=o(be,"A",{href:!0,rel:!0});var yt=n(I);Oe=a(yt,"here"),yt.forEach(r),Pe=a(be,"."),be.forEach(r),he=u(t),S=o(t,"H2",{class:!0});var Se=n(S);L=o(Se,"A",{id:!0,class:!0,href:!0});var Dt=n(L);te=o(Dt,"SPAN",{});var Lt=n(te);T(q.$$.fragment,Lt),Lt.forEach(r),Dt.forEach(r),Ce=u(Se),re=o(Se,"SPAN",{});var wt=n(re);Ae=a(wt,"LMSDiscreteScheduler"),wt.forEach(r),Se.forEach(r),me=u(t),d=o(t,"DIV",{class:!0});var h=n(d);T(K.$$.fragment,h),Fe=u(h),J=o(h,"P",{});var pt=n(J);Ne=a(pt,`Linear Multistep Scheduler for discrete beta schedules. Based on the original k-diffusion implementation by
Katherine Crowson:
`),U=o(pt,"A",{href:!0,rel:!0});var Mt=n(U);Ie=a(Mt,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),Mt.forEach(r),pt.forEach(r),qe=u(h),l=o(h,"P",{});var p=n(l);R=o(p,"A",{href:!0});var xt=n(R);Ke=a(xt,"~ConfigMixin"),xt.forEach(r),Ue=a(p," takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=o(p,"CODE",{});var Et=n(se);Ve=a(Et,"__init__"),Et.forEach(r),Be=a(p,`
function, such as `),oe=o(p,"CODE",{});var kt=n(oe);He=a(kt,"num_train_timesteps"),kt.forEach(r),ze=a(p,". They can be accessed via "),ne=o(p,"CODE",{});var Tt=n(ne);Ge=a(Tt,"scheduler.config.num_train_timesteps"),Tt.forEach(r),Je=a(p,`.
`),W=o(p,"A",{href:!0});var Ot=n(W);Re=a(Ot,"SchedulerMixin"),Ot.forEach(r),We=a(p," provides general loading and saving functionality via the "),j=o(p,"A",{href:!0});var Pt=n(j);je=a(Pt,"SchedulerMixin.save_pretrained()"),Pt.forEach(r),Qe=a(p,` and
`),Q=o(p,"A",{href:!0});var Ct=n(Q);Xe=a(Ct,"from_pretrained()"),Ct.forEach(r),Ye=a(p," functions."),p.forEach(r),Ze=u(h),w=o(h,"DIV",{class:!0});var $e=n(w);T(V.$$.fragment,$e),et=u($e),ie=o($e,"P",{});var At=n(ie);tt=a(At,"Compute a linear multistep coefficient."),At.forEach(r),$e.forEach(r),rt=u(h),M=o(h,"DIV",{class:!0});var ye=n(M);T(B.$$.fragment,ye),st=u(ye),H=o(ye,"P",{});var De=n(H);ot=a(De,"Scales the denoising model input by "),ae=o(De,"CODE",{});var Ft=n(ae);nt=a(Ft,"(sigma**2 + 1) ** 0.5"),Ft.forEach(r),it=a(De," to match the K-LMS algorithm."),De.forEach(r),ye.forEach(r),at=u(h),x=o(h,"DIV",{class:!0});var Le=n(x);T(z.$$.fragment,Le),ct=u(Le),ce=o(Le,"P",{});var Nt=n(ce);dt=a(Nt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Nt.forEach(r),Le.forEach(r),lt=u(h),E=o(h,"DIV",{class:!0});var we=n(E);T(G.$$.fragment,we),ft=u(we),de=o(we,"P",{});var It=n(de);ut=a(It,`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),It.forEach(r),we.forEach(r),h.forEach(r),this.h()},h(){c(_,"name","hf:doc:metadata"),c(_,"content",JSON.stringify(Gt)),c($,"id","linear-multistep-scheduler-for-discrete-beta-schedules"),c($,"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"),c($,"href","#linear-multistep-scheduler-for-discrete-beta-schedules"),c(v,"class","relative group"),c(y,"id","overview"),c(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"),c(y,"href","#overview"),c(b,"class","relative group"),c(I,"href","https://arxiv.org/abs/2206.00364"),c(I,"rel","nofollow"),c(L,"id","diffusers.LMSDiscreteScheduler"),c(L,"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"),c(L,"href","#diffusers.LMSDiscreteScheduler"),c(S,"class","relative group"),c(U,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),c(U,"rel","nofollow"),c(R,"href","/docs/diffusers/v0.17.0/en/api/configuration#diffusers.ConfigMixin"),c(W,"href","/docs/diffusers/v0.17.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),c(j,"href","/docs/diffusers/v0.17.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),c(Q,"href","/docs/diffusers/v0.17.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),c(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(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,m){e(document.head,_),g(t,fe,m),g(t,v,m),e(v,$),e($,X),O(F,X,null),e(v,Me),e(v,Y),e(Y,xe),g(t,ue,m),g(t,b,m),e(b,y),e(y,Z),O(N,Z,null),e(b,Ee),e(b,ee),e(ee,ke),g(t,pe,m),g(t,D,m),e(D,Te),e(D,I),e(I,Oe),e(D,Pe),g(t,he,m),g(t,S,m),e(S,L),e(L,te),O(q,te,null),e(S,Ce),e(S,re),e(re,Ae),g(t,me,m),g(t,d,m),O(K,d,null),e(d,Fe),e(d,J),e(J,Ne),e(J,U),e(U,Ie),e(d,qe),e(d,l),e(l,R),e(R,Ke),e(l,Ue),e(l,se),e(se,Ve),e(l,Be),e(l,oe),e(oe,He),e(l,ze),e(l,ne),e(ne,Ge),e(l,Je),e(l,W),e(W,Re),e(l,We),e(l,j),e(j,je),e(l,Qe),e(l,Q),e(Q,Xe),e(l,Ye),e(d,Ze),e(d,w),O(V,w,null),e(w,et),e(w,ie),e(ie,tt),e(d,rt),e(d,M),O(B,M,null),e(M,st),e(M,H),e(H,ot),e(H,ae),e(ae,nt),e(H,it),e(d,at),e(d,x),O(z,x,null),e(x,ct),e(x,ce),e(ce,dt),e(d,lt),e(d,E),O(G,E,null),e(E,ft),e(E,de),e(de,ut),ge=!0},p:Bt,i(t){ge||(P(F.$$.fragment,t),P(N.$$.fragment,t),P(q.$$.fragment,t),P(K.$$.fragment,t),P(V.$$.fragment,t),P(B.$$.fragment,t),P(z.$$.fragment,t),P(G.$$.fragment,t),ge=!0)},o(t){C(F.$$.fragment,t),C(N.$$.fragment,t),C(q.$$.fragment,t),C(K.$$.fragment,t),C(V.$$.fragment,t),C(B.$$.fragment,t),C(z.$$.fragment,t),C(G.$$.fragment,t),ge=!1},d(t){r(_),t&&r(fe),t&&r(v),A(F),t&&r(ue),t&&r(b),A(N),t&&r(pe),t&&r(D),t&&r(he),t&&r(S),A(q),t&&r(me),t&&r(d),A(K),A(V),A(B),A(z),A(G)}}}const Gt={local:"linear-multistep-scheduler-for-discrete-beta-schedules",sections:[{local:"overview",title:"Overview"},{local:"diffusers.LMSDiscreteScheduler",title:"LMSDiscreteScheduler"}],title:"Linear multistep scheduler for discrete beta schedules"};function Jt(mt){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qt extends qt{constructor(_){super();Kt(this,_,Jt,zt,Ut,{})}}export{Qt as default,Gt as metadata};
