import{S as kt,i as Tt,s as At,e as s,k as u,w as L,t as i,M as Ct,c as o,d as r,m as h,a as n,x as U,h as l,b as a,G as e,g as v,y as q,L as Nt,q as V,o as B,B as H,v as Ot}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Se}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ot}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Ft(nt){let _,le,S,y,X,P,be,Z,De,de,b,E,ee,x,ye,te,Ee,ce,g,we,M,$e,Pe,k,xe,Me,pe,T,ke,A,Te,fe,D,w,re,C,Ae,se,Ce,ue,c,N,Ne,R,Oe,O,Fe,Ie,d,z,Ke,Le,oe,Ue,qe,ne,Ve,Be,ae,He,Re,G,ze,Ge,J,Je,We,W,Ye,je,Qe,Y,F,Xe,$,I,Ze,ie,et,tt,j,K,he;return P=new ot({}),x=new ot({}),C=new ot({}),N=new Se({props:{name:"class diffusers.DPMSolverSDEScheduler",anchor:"diffusers.DPMSolverSDEScheduler",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"},{name:"noise_sampler_seed",val:": typing.Optional[int] = None"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.noise_sampler_seed",description:`<strong>noise_sampler_seed</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The random seed to use for the noise sampler. If <code>None</code>, a random seed will be generated.`,name:"noise_sampler_seed"},{anchor:"diffusers.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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_dpmsolver_sde.py#L124"}}),F=new Se({props:{name:"scale_model_input",anchor:"diffusers.DPMSolverSDEScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.19.0/src/diffusers/schedulers/scheduling_dpmsolver_sde.py#L229",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new Se({props:{name:"set_timesteps",anchor:"diffusers.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.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_dpmsolver_sde.py#L249"}}),K=new Se({props:{name:"step",anchor:"diffusers.DPMSolverSDEScheduler.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"},{name:"s_noise",val:": float = 1.0"}],parametersDescription:[{anchor:"diffusers.DPMSolverSDEScheduler.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.DPMSolverSDEScheduler.step.process",description:"<strong>process</strong> from the learned model outputs (most often the predicted noise). &#x2014;",name:"process"},{anchor:"diffusers.DPMSolverSDEScheduler.step.model_output",description:"<strong>model_output</strong> (Union[torch.FloatTensor, np.ndarray]) &#x2014; Direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.DPMSolverSDEScheduler.step.timestep",description:"<strong>timestep</strong> (Union[float, torch.FloatTensor]) &#x2014; Current discrete timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.DPMSolverSDEScheduler.step.sample",description:"<strong>sample</strong> (Union[torch.FloatTensor, np.ndarray]) &#x2014; Current instance of sample being created by diffusion process.",name:"sample"},{anchor:"diffusers.DPMSolverSDEScheduler.step.return_dict",description:"<strong>return_dict</strong> (bool, optional) &#x2014; Option for returning tuple rather than SchedulerOutput class. Defaults to True.",name:"return_dict"},{anchor:"diffusers.DPMSolverSDEScheduler.step.s_noise",description:"<strong>s_noise</strong> (float, optional) &#x2014; Scaling factor for the noise added to the sample. Defaults to 1.0.",name:"s_noise"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/schedulers/scheduling_dpmsolver_sde.py#L378",returnDescription:`
<p><a
  href="/docs/diffusers/v0.19.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.19.0/en/api/schedulers/overview#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),{c(){_=s("meta"),le=u(),S=s("h1"),y=s("a"),X=s("span"),L(P.$$.fragment),be=u(),Z=s("span"),De=i("DPM Stochastic Scheduler inspired by Karras et. al paper"),de=u(),b=s("h2"),E=s("a"),ee=s("span"),L(x.$$.fragment),ye=u(),te=s("span"),Ee=i("Overview"),ce=u(),g=s("p"),we=i("Inspired by Stochastic Sampler from "),M=s("a"),$e=i("Karras et. al"),Pe=i(`.
Scheduler ported from @crowsonkb\u2019s `),k=s("a"),xe=i("https://github.com/crowsonkb/k-diffusion"),Me=i(" library:"),pe=u(),T=s("p"),ke=i("All credit for making this scheduler work goes to "),A=s("a"),Te=i("Katherine Crowson"),fe=u(),D=s("h2"),w=s("a"),re=s("span"),L(C.$$.fragment),Ae=u(),se=s("span"),Ce=i("DPMSolverSDEScheduler"),ue=u(),c=s("div"),L(N.$$.fragment),Ne=u(),R=s("p"),Oe=i(`Implements Stochastic Sampler (Algorithm 2) from Karras et al. (2022). Based on the original k-diffusion
implementation by Katherine Crowson:
`),O=s("a"),Fe=i("https://github.com/crowsonkb/k-diffusion/blob/41b4cb6df0506694a7776af31349acf082bf6091/k_diffusion/sampling.py#L543"),Ie=u(),d=s("p"),z=s("a"),Ke=i("~ConfigMixin"),Le=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=s("code"),Ue=i("__init__"),qe=i(`
function, such as `),ne=s("code"),Ve=i("num_train_timesteps"),Be=i(". They can be accessed via "),ae=s("code"),He=i("scheduler.config.num_train_timesteps"),Re=i(`.
`),G=s("a"),ze=i("SchedulerMixin"),Ge=i(" provides general loading and saving functionality via the "),J=s("a"),Je=i("SchedulerMixin.save_pretrained()"),We=i(` and
`),W=s("a"),Ye=i("from_pretrained()"),je=i(" functions."),Qe=u(),Y=s("div"),L(F.$$.fragment),Xe=u(),$=s("div"),L(I.$$.fragment),Ze=u(),ie=s("p"),et=i("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),tt=u(),j=s("div"),L(K.$$.fragment),this.h()},l(t){const p=Ct('[data-svelte="svelte-1phssyn"]',document.head);_=o(p,"META",{name:!0,content:!0}),p.forEach(r),le=h(t),S=o(t,"H1",{class:!0});var me=n(S);y=o(me,"A",{id:!0,class:!0,href:!0});var at=n(y);X=o(at,"SPAN",{});var it=n(X);U(P.$$.fragment,it),it.forEach(r),at.forEach(r),be=h(me),Z=o(me,"SPAN",{});var lt=n(Z);De=l(lt,"DPM Stochastic Scheduler inspired by Karras et. al paper"),lt.forEach(r),me.forEach(r),de=h(t),b=o(t,"H2",{class:!0});var ve=n(b);E=o(ve,"A",{id:!0,class:!0,href:!0});var dt=n(E);ee=o(dt,"SPAN",{});var ct=n(ee);U(x.$$.fragment,ct),ct.forEach(r),dt.forEach(r),ye=h(ve),te=o(ve,"SPAN",{});var pt=n(te);Ee=l(pt,"Overview"),pt.forEach(r),ve.forEach(r),ce=h(t),g=o(t,"P",{});var Q=n(g);we=l(Q,"Inspired by Stochastic Sampler from "),M=o(Q,"A",{href:!0,rel:!0});var ft=n(M);$e=l(ft,"Karras et. al"),ft.forEach(r),Pe=l(Q,`.
Scheduler ported from @crowsonkb\u2019s `),k=o(Q,"A",{href:!0,rel:!0});var ut=n(k);xe=l(ut,"https://github.com/crowsonkb/k-diffusion"),ut.forEach(r),Me=l(Q," library:"),Q.forEach(r),pe=h(t),T=o(t,"P",{});var rt=n(T);ke=l(rt,"All credit for making this scheduler work goes to "),A=o(rt,"A",{href:!0,rel:!0});var ht=n(A);Te=l(ht,"Katherine Crowson"),ht.forEach(r),rt.forEach(r),fe=h(t),D=o(t,"H2",{class:!0});var ge=n(D);w=o(ge,"A",{id:!0,class:!0,href:!0});var mt=n(w);re=o(mt,"SPAN",{});var vt=n(re);U(C.$$.fragment,vt),vt.forEach(r),mt.forEach(r),Ae=h(ge),se=o(ge,"SPAN",{});var gt=n(se);Ce=l(gt,"DPMSolverSDEScheduler"),gt.forEach(r),ge.forEach(r),ue=h(t),c=o(t,"DIV",{class:!0});var m=n(c);U(N.$$.fragment,m),Ne=h(m),R=o(m,"P",{});var st=n(R);Oe=l(st,`Implements Stochastic Sampler (Algorithm 2) from Karras et al. (2022). Based on the original k-diffusion
implementation by Katherine Crowson:
`),O=o(st,"A",{href:!0,rel:!0});var _t=n(O);Fe=l(_t,"https://github.com/crowsonkb/k-diffusion/blob/41b4cb6df0506694a7776af31349acf082bf6091/k_diffusion/sampling.py#L543"),_t.forEach(r),st.forEach(r),Ie=h(m),d=o(m,"P",{});var f=n(d);z=o(f,"A",{href:!0});var St=n(z);Ke=l(St,"~ConfigMixin"),St.forEach(r),Le=l(f," takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=o(f,"CODE",{});var bt=n(oe);Ue=l(bt,"__init__"),bt.forEach(r),qe=l(f,`
function, such as `),ne=o(f,"CODE",{});var Dt=n(ne);Ve=l(Dt,"num_train_timesteps"),Dt.forEach(r),Be=l(f,". They can be accessed via "),ae=o(f,"CODE",{});var yt=n(ae);He=l(yt,"scheduler.config.num_train_timesteps"),yt.forEach(r),Re=l(f,`.
`),G=o(f,"A",{href:!0});var Et=n(G);ze=l(Et,"SchedulerMixin"),Et.forEach(r),Ge=l(f," provides general loading and saving functionality via the "),J=o(f,"A",{href:!0});var wt=n(J);Je=l(wt,"SchedulerMixin.save_pretrained()"),wt.forEach(r),We=l(f,` and
`),W=o(f,"A",{href:!0});var $t=n(W);Ye=l($t,"from_pretrained()"),$t.forEach(r),je=l(f," functions."),f.forEach(r),Qe=h(m),Y=o(m,"DIV",{class:!0});var Pt=n(Y);U(F.$$.fragment,Pt),Pt.forEach(r),Xe=h(m),$=o(m,"DIV",{class:!0});var _e=n($);U(I.$$.fragment,_e),Ze=h(_e),ie=o(_e,"P",{});var xt=n(ie);et=l(xt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),xt.forEach(r),_e.forEach(r),tt=h(m),j=o(m,"DIV",{class:!0});var Mt=n(j);U(K.$$.fragment,Mt),Mt.forEach(r),m.forEach(r),this.h()},h(){a(_,"name","hf:doc:metadata"),a(_,"content",JSON.stringify(It)),a(y,"id","dpm-stochastic-scheduler-inspired-by-karras-et-al-paper"),a(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"),a(y,"href","#dpm-stochastic-scheduler-inspired-by-karras-et-al-paper"),a(S,"class","relative group"),a(E,"id","overview"),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","#overview"),a(b,"class","relative group"),a(M,"href","https://arxiv.org/abs/2206.00364"),a(M,"rel","nofollow"),a(k,"href","https://github.com/crowsonkb/k-diffusion"),a(k,"rel","nofollow"),a(A,"href","https://github.com/crowsonkb/"),a(A,"rel","nofollow"),a(w,"id","diffusers.DPMSolverSDEScheduler"),a(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"),a(w,"href","#diffusers.DPMSolverSDEScheduler"),a(D,"class","relative group"),a(O,"href","https://github.com/crowsonkb/k-diffusion/blob/41b4cb6df0506694a7776af31349acf082bf6091/k_diffusion/sampling.py#L543"),a(O,"rel","nofollow"),a(z,"href","/docs/diffusers/v0.19.0/en/api/configuration#diffusers.ConfigMixin"),a(G,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),a(J,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),a(W,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),a(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),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(c,"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,p){e(document.head,_),v(t,le,p),v(t,S,p),e(S,y),e(y,X),q(P,X,null),e(S,be),e(S,Z),e(Z,De),v(t,de,p),v(t,b,p),e(b,E),e(E,ee),q(x,ee,null),e(b,ye),e(b,te),e(te,Ee),v(t,ce,p),v(t,g,p),e(g,we),e(g,M),e(M,$e),e(g,Pe),e(g,k),e(k,xe),e(g,Me),v(t,pe,p),v(t,T,p),e(T,ke),e(T,A),e(A,Te),v(t,fe,p),v(t,D,p),e(D,w),e(w,re),q(C,re,null),e(D,Ae),e(D,se),e(se,Ce),v(t,ue,p),v(t,c,p),q(N,c,null),e(c,Ne),e(c,R),e(R,Oe),e(R,O),e(O,Fe),e(c,Ie),e(c,d),e(d,z),e(z,Ke),e(d,Le),e(d,oe),e(oe,Ue),e(d,qe),e(d,ne),e(ne,Ve),e(d,Be),e(d,ae),e(ae,He),e(d,Re),e(d,G),e(G,ze),e(d,Ge),e(d,J),e(J,Je),e(d,We),e(d,W),e(W,Ye),e(d,je),e(c,Qe),e(c,Y),q(F,Y,null),e(c,Xe),e(c,$),q(I,$,null),e($,Ze),e($,ie),e(ie,et),e(c,tt),e(c,j),q(K,j,null),he=!0},p:Nt,i(t){he||(V(P.$$.fragment,t),V(x.$$.fragment,t),V(C.$$.fragment,t),V(N.$$.fragment,t),V(F.$$.fragment,t),V(I.$$.fragment,t),V(K.$$.fragment,t),he=!0)},o(t){B(P.$$.fragment,t),B(x.$$.fragment,t),B(C.$$.fragment,t),B(N.$$.fragment,t),B(F.$$.fragment,t),B(I.$$.fragment,t),B(K.$$.fragment,t),he=!1},d(t){r(_),t&&r(le),t&&r(S),H(P),t&&r(de),t&&r(b),H(x),t&&r(ce),t&&r(g),t&&r(pe),t&&r(T),t&&r(fe),t&&r(D),H(C),t&&r(ue),t&&r(c),H(N),H(F),H(I),H(K)}}}const It={local:"dpm-stochastic-scheduler-inspired-by-karras-et-al-paper",sections:[{local:"overview",title:"Overview"},{local:"diffusers.DPMSolverSDEScheduler",title:"DPMSolverSDEScheduler"}],title:"DPM Stochastic Scheduler inspired by Karras et. al paper"};function Kt(nt){return Ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vt extends kt{constructor(_){super();Tt(this,_,Kt,Ft,At,{})}}export{Vt as default,It as metadata};
