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 C,o as P,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 Rt(mt){let _,fe,v,$,Q,F,Me,X,xe,ue,b,y,Z,N,Ee,ee,ke,pe,D,Te,I,Oe,Ce,he,S,w,te,q,Pe,re,Ae,me,d,K,Fe,G,Ne,U,Ie,qe,l,J,Ke,Ue,se,Ve,Be,oe,He,Re,ne,ze,Ge,W,Je,We,Y,Ye,je,j,Qe,Xe,Ze,L,V,et,ie,tt,rt,M,B,st,H,ot,ae,nt,it,at,x,R,ct,ce,dt,lt,E,z,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'"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],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"},{anchor:"diffusers.LMSDiscreteScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, default <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2. of <a href="https://arxiv.org/abs/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample
Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.LMSDiscreteScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, default <code>0</code>) &#x2014;
an offset added to the inference steps. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_one=False</code>, to make the last step use step 0 for the previous alpha product, as done in
stable diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L92"}}),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.19.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L203"}}),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.19.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L182",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),R=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.19.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L225"}}),z=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.19.0/src/diffusers/schedulers/scheduling_lms_discrete.py#L316",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"),Q=s("span"),k(F.$$.fragment),Me=f(),X=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"),Ce=i("."),he=f(),S=s("h2"),w=s("a"),te=s("span"),k(q.$$.fragment),Pe=f(),re=s("span"),Ae=i("LMSDiscreteScheduler"),me=f(),d=s("div"),k(K.$$.fragment),Fe=f(),G=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"),J=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"),Re=i(". They can be accessed via "),ne=s("code"),ze=i("scheduler.config.num_train_timesteps"),Ge=i(`.
`),W=s("a"),Je=i("SchedulerMixin"),We=i(" provides general loading and saving functionality via the "),Y=s("a"),Ye=i("SchedulerMixin.save_pretrained()"),je=i(` and
`),j=s("a"),Qe=i("from_pretrained()"),Xe=i(" functions."),Ze=f(),L=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(R.$$.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(z.$$.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($);Q=o(gt,"SPAN",{});var _t=n(Q);T(F.$$.fragment,_t),_t.forEach(r),gt.forEach(r),Me=u(_e),X=o(_e,"SPAN",{});var vt=n(X);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),Ce=a(be,"."),be.forEach(r),he=u(t),S=o(t,"H2",{class:!0});var Se=n(S);w=o(Se,"A",{id:!0,class:!0,href:!0});var Dt=n(w);te=o(Dt,"SPAN",{});var wt=n(te);T(q.$$.fragment,wt),wt.forEach(r),Dt.forEach(r),Pe=u(Se),re=o(Se,"SPAN",{});var Lt=n(re);Ae=a(Lt,"LMSDiscreteScheduler"),Lt.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),G=o(h,"P",{});var pt=n(G);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);J=o(p,"A",{href:!0});var xt=n(J);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),Re=a(p,". They can be accessed via "),ne=o(p,"CODE",{});var Tt=n(ne);ze=a(Tt,"scheduler.config.num_train_timesteps"),Tt.forEach(r),Ge=a(p,`.
`),W=o(p,"A",{href:!0});var Ot=n(W);Je=a(Ot,"SchedulerMixin"),Ot.forEach(r),We=a(p," provides general loading and saving functionality via the "),Y=o(p,"A",{href:!0});var Ct=n(Y);Ye=a(Ct,"SchedulerMixin.save_pretrained()"),Ct.forEach(r),je=a(p,` and
`),j=o(p,"A",{href:!0});var Pt=n(j);Qe=a(Pt,"from_pretrained()"),Pt.forEach(r),Xe=a(p," functions."),p.forEach(r),Ze=u(h),L=o(h,"DIV",{class:!0});var $e=n(L);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 we=n(x);T(R.$$.fragment,we),ct=u(we),ce=o(we,"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),we.forEach(r),lt=u(h),E=o(h,"DIV",{class:!0});var Le=n(E);T(z.$$.fragment,Le),ft=u(Le),de=o(Le,"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),Le.forEach(r),h.forEach(r),this.h()},h(){c(_,"name","hf:doc:metadata"),c(_,"content",JSON.stringify(zt)),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(w,"id","diffusers.LMSDiscreteScheduler"),c(w,"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(w,"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(J,"href","/docs/diffusers/v0.19.0/en/api/configuration#diffusers.ConfigMixin"),c(W,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),c(Y,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),c(j,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),c(L,"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($,Q),O(F,Q,null),e(v,Me),e(v,X),e(X,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,Ce),g(t,he,m),g(t,S,m),e(S,w),e(w,te),O(q,te,null),e(S,Pe),e(S,re),e(re,Ae),g(t,me,m),g(t,d,m),O(K,d,null),e(d,Fe),e(d,G),e(G,Ne),e(G,U),e(U,Ie),e(d,qe),e(d,l),e(l,J),e(J,Ke),e(l,Ue),e(l,se),e(se,Ve),e(l,Be),e(l,oe),e(oe,He),e(l,Re),e(l,ne),e(ne,ze),e(l,Ge),e(l,W),e(W,Je),e(l,We),e(l,Y),e(Y,Ye),e(l,je),e(l,j),e(j,Qe),e(l,Xe),e(d,Ze),e(d,L),O(V,L,null),e(L,et),e(L,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(R,x,null),e(x,ct),e(x,ce),e(ce,dt),e(d,lt),e(d,E),O(z,E,null),e(E,ft),e(E,de),e(de,ut),ge=!0},p:Bt,i(t){ge||(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(R.$$.fragment,t),C(z.$$.fragment,t),ge=!0)},o(t){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(R.$$.fragment,t),P(z.$$.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(R),A(z)}}}const zt={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 Gt(mt){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends qt{constructor(_){super();Kt(this,_,Gt,Rt,Ut,{})}}export{jt as default,zt as metadata};
