import{S as Ut,i as Vt,s as qt,e as s,k as u,w as k,t as i,M as Kt,c as n,d as r,m as f,a as o,x as T,h as a,b as c,G as e,g,y as O,L as Bt,q as P,o as A,B as C,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 Gt(mt){let _,ue,v,$,X,N,Me,Y,xe,fe,b,y,Z,F,Ee,ee,ke,pe,D,Te,I,Oe,Pe,he,S,L,te,U,Ae,re,Ce,me,d,V,Ne,R,Fe,q,Ie,Ue,l,W,Ve,qe,se,Ke,Be,ne,He,Ge,oe,Je,Re,j,We,je,z,ze,Qe,Q,Xe,Ye,Ze,w,K,et,ie,tt,rt,M,B,st,H,nt,ae,ot,it,at,x,G,ct,ce,dt,lt,E,J,ut,de,ft,ge;return N=new ht({}),F=new ht({}),U=new ht({}),V=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:"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.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_lms_discrete.py#L77"}}),K=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/main/src/diffusers/schedulers/scheduling_lms_discrete.py#L169"}}),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/main/src/diffusers/schedulers/scheduling_lms_discrete.py#L148",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),G=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/main/src/diffusers/schedulers/scheduling_lms_discrete.py#L191"}}),J=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/main/src/diffusers/schedulers/scheduling_lms_discrete.py#L217",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"),ue=u(),v=s("h1"),$=s("a"),X=s("span"),k(N.$$.fragment),Me=u(),Y=s("span"),xe=i("Linear multistep scheduler for discrete beta schedules"),fe=u(),b=s("h2"),y=s("a"),Z=s("span"),k(F.$$.fragment),Ee=u(),ee=s("span"),ke=i("Overview"),pe=u(),D=s("p"),Te=i("Original implementation can be found "),I=s("a"),Oe=i("here"),Pe=i("."),he=u(),S=s("h2"),L=s("a"),te=s("span"),k(U.$$.fragment),Ae=u(),re=s("span"),Ce=i("LMSDiscreteScheduler"),me=u(),d=s("div"),k(V.$$.fragment),Ne=u(),R=s("p"),Fe=i(`Linear Multistep Scheduler for discrete beta schedules. Based on the original k-diffusion implementation by
Katherine Crowson:
`),q=s("a"),Ie=i("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),Ue=u(),l=s("p"),W=s("a"),Ve=i("~ConfigMixin"),qe=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=s("code"),Ke=i("__init__"),Be=i(`
function, such as `),ne=s("code"),He=i("num_train_timesteps"),Ge=i(". They can be accessed via "),oe=s("code"),Je=i("scheduler.config.num_train_timesteps"),Re=i(`.
`),j=s("a"),We=i("SchedulerMixin"),je=i(" provides general loading and saving functionality via the "),z=s("a"),ze=i("SchedulerMixin.save_pretrained()"),Qe=i(` and
`),Q=s("a"),Xe=i("from_pretrained()"),Ye=i(" functions."),Ze=u(),w=s("div"),k(K.$$.fragment),et=u(),ie=s("p"),tt=i("Compute a linear multistep coefficient."),rt=u(),M=s("div"),k(B.$$.fragment),st=u(),H=s("p"),nt=i("Scales the denoising model input by "),ae=s("code"),ot=i("(sigma**2 + 1) ** 0.5"),it=i(" to match the K-LMS algorithm."),at=u(),x=s("div"),k(G.$$.fragment),ct=u(),ce=s("p"),dt=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),lt=u(),E=s("div"),k(J.$$.fragment),ut=u(),de=s("p"),ft=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=Kt('[data-svelte="svelte-1phssyn"]',document.head);_=n(m,"META",{name:!0,content:!0}),m.forEach(r),ue=f(t),v=n(t,"H1",{class:!0});var _e=o(v);$=n(_e,"A",{id:!0,class:!0,href:!0});var gt=o($);X=n(gt,"SPAN",{});var _t=o(X);T(N.$$.fragment,_t),_t.forEach(r),gt.forEach(r),Me=f(_e),Y=n(_e,"SPAN",{});var vt=o(Y);xe=a(vt,"Linear multistep scheduler for discrete beta schedules"),vt.forEach(r),_e.forEach(r),fe=f(t),b=n(t,"H2",{class:!0});var ve=o(b);y=n(ve,"A",{id:!0,class:!0,href:!0});var bt=o(y);Z=n(bt,"SPAN",{});var St=o(Z);T(F.$$.fragment,St),St.forEach(r),bt.forEach(r),Ee=f(ve),ee=n(ve,"SPAN",{});var $t=o(ee);ke=a($t,"Overview"),$t.forEach(r),ve.forEach(r),pe=f(t),D=n(t,"P",{});var be=o(D);Te=a(be,"Original implementation can be found "),I=n(be,"A",{href:!0,rel:!0});var yt=o(I);Oe=a(yt,"here"),yt.forEach(r),Pe=a(be,"."),be.forEach(r),he=f(t),S=n(t,"H2",{class:!0});var Se=o(S);L=n(Se,"A",{id:!0,class:!0,href:!0});var Dt=o(L);te=n(Dt,"SPAN",{});var Lt=o(te);T(U.$$.fragment,Lt),Lt.forEach(r),Dt.forEach(r),Ae=f(Se),re=n(Se,"SPAN",{});var wt=o(re);Ce=a(wt,"LMSDiscreteScheduler"),wt.forEach(r),Se.forEach(r),me=f(t),d=n(t,"DIV",{class:!0});var h=o(d);T(V.$$.fragment,h),Ne=f(h),R=n(h,"P",{});var pt=o(R);Fe=a(pt,`Linear Multistep Scheduler for discrete beta schedules. Based on the original k-diffusion implementation by
Katherine Crowson:
`),q=n(pt,"A",{href:!0,rel:!0});var Mt=o(q);Ie=a(Mt,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),Mt.forEach(r),pt.forEach(r),Ue=f(h),l=n(h,"P",{});var p=o(l);W=n(p,"A",{href:!0});var xt=o(W);Ve=a(xt,"~ConfigMixin"),xt.forEach(r),qe=a(p," takes care of storing all config attributes that are passed in the scheduler\u2019s "),se=n(p,"CODE",{});var Et=o(se);Ke=a(Et,"__init__"),Et.forEach(r),Be=a(p,`
function, such as `),ne=n(p,"CODE",{});var kt=o(ne);He=a(kt,"num_train_timesteps"),kt.forEach(r),Ge=a(p,". They can be accessed via "),oe=n(p,"CODE",{});var Tt=o(oe);Je=a(Tt,"scheduler.config.num_train_timesteps"),Tt.forEach(r),Re=a(p,`.
`),j=n(p,"A",{href:!0});var Ot=o(j);We=a(Ot,"SchedulerMixin"),Ot.forEach(r),je=a(p," provides general loading and saving functionality via the "),z=n(p,"A",{href:!0});var Pt=o(z);ze=a(Pt,"SchedulerMixin.save_pretrained()"),Pt.forEach(r),Qe=a(p,` and
`),Q=n(p,"A",{href:!0});var At=o(Q);Xe=a(At,"from_pretrained()"),At.forEach(r),Ye=a(p," functions."),p.forEach(r),Ze=f(h),w=n(h,"DIV",{class:!0});var $e=o(w);T(K.$$.fragment,$e),et=f($e),ie=n($e,"P",{});var Ct=o(ie);tt=a(Ct,"Compute a linear multistep coefficient."),Ct.forEach(r),$e.forEach(r),rt=f(h),M=n(h,"DIV",{class:!0});var ye=o(M);T(B.$$.fragment,ye),st=f(ye),H=n(ye,"P",{});var De=o(H);nt=a(De,"Scales the denoising model input by "),ae=n(De,"CODE",{});var Nt=o(ae);ot=a(Nt,"(sigma**2 + 1) ** 0.5"),Nt.forEach(r),it=a(De," to match the K-LMS algorithm."),De.forEach(r),ye.forEach(r),at=f(h),x=n(h,"DIV",{class:!0});var Le=o(x);T(G.$$.fragment,Le),ct=f(Le),ce=n(Le,"P",{});var Ft=o(ce);dt=a(Ft,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Ft.forEach(r),Le.forEach(r),lt=f(h),E=n(h,"DIV",{class:!0});var we=o(E);T(J.$$.fragment,we),ut=f(we),de=n(we,"P",{});var It=o(de);ft=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(Jt)),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(q,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181"),c(q,"rel","nofollow"),c(W,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),c(j,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),c(z,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),c(Q,"href","/docs/diffusers/main/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,ue,m),g(t,v,m),e(v,$),e($,X),O(N,X,null),e(v,Me),e(v,Y),e(Y,xe),g(t,fe,m),g(t,b,m),e(b,y),e(y,Z),O(F,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(U,te,null),e(S,Ae),e(S,re),e(re,Ce),g(t,me,m),g(t,d,m),O(V,d,null),e(d,Ne),e(d,R),e(R,Fe),e(R,q),e(q,Ie),e(d,Ue),e(d,l),e(l,W),e(W,Ve),e(l,qe),e(l,se),e(se,Ke),e(l,Be),e(l,ne),e(ne,He),e(l,Ge),e(l,oe),e(oe,Je),e(l,Re),e(l,j),e(j,We),e(l,je),e(l,z),e(z,ze),e(l,Qe),e(l,Q),e(Q,Xe),e(l,Ye),e(d,Ze),e(d,w),O(K,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,nt),e(H,ae),e(ae,ot),e(H,it),e(d,at),e(d,x),O(G,x,null),e(x,ct),e(x,ce),e(ce,dt),e(d,lt),e(d,E),O(J,E,null),e(E,ut),e(E,de),e(de,ft),ge=!0},p:Bt,i(t){ge||(P(N.$$.fragment,t),P(F.$$.fragment,t),P(U.$$.fragment,t),P(V.$$.fragment,t),P(K.$$.fragment,t),P(B.$$.fragment,t),P(G.$$.fragment,t),P(J.$$.fragment,t),ge=!0)},o(t){A(N.$$.fragment,t),A(F.$$.fragment,t),A(U.$$.fragment,t),A(V.$$.fragment,t),A(K.$$.fragment,t),A(B.$$.fragment,t),A(G.$$.fragment,t),A(J.$$.fragment,t),ge=!1},d(t){r(_),t&&r(ue),t&&r(v),C(N),t&&r(fe),t&&r(b),C(F),t&&r(pe),t&&r(D),t&&r(he),t&&r(S),C(U),t&&r(me),t&&r(d),C(V),C(K),C(B),C(G),C(J)}}}const Jt={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 Rt(mt){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qt extends Ut{constructor(_){super();Vt(this,_,Rt,Gt,qt,{})}}export{Qt as default,Jt as metadata};
