import{s as Ge,o as Re,n as We}from"../chunks/scheduler.182ea377.js";import{S as Ye,i as Be,g as i,s as o,r as h,A as Je,h as a,f as t,c as r,j as b,u as f,x as u,k as y,y as n,a as d,v as g,d as v,t as _,w as S}from"../chunks/index.abf12888.js";import{T as Qe}from"../chunks/Tip.230e2334.js";import{D as K}from"../chunks/Docstring.93f6f462.js";import{H as He}from"../chunks/Heading.16916d63.js";function Xe(se){let p,D="<code>epsilon</code> in the equations for <code>c_skip</code> and <code>c_out</code> is set to <code>sigma_min</code>.";return{c(){p=i("p"),p.innerHTML=D},l(m){p=a(m,"P",{"data-svelte-h":!0}),u(p)!=="svelte-a3ozzd"&&(p.innerHTML=D)},m(m,G){d(m,p,G)},p:We,d(m){m&&t(p)}}}function Ze(se){let p,D,m,G,L,ne,P,Fe='<a href="https://huggingface.co/papers/2303.01469" rel="nofollow">Consistency Models</a> by Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever introduced a multistep and onestep scheduler (Algorithm 1) that is capable of generating good samples in one or a small number of steps.',oe,H,Oe="The abstract from the paper is:",re,F,Ae="<em>Diffusion models have made significant breakthroughs in image, audio, and video generation, but they depend on an iterative generation process that causes slow sampling speed and caps their potential for real-time applications. To overcome this limitation, we propose consistency models, a new family of generative models that achieve high sample quality without adversarial training. They support fast one-step generation by design, while still allowing for few-step sampling to trade compute for sample quality. They also support zero-shot data editing, like image inpainting, colorization, and super-resolution, without requiring explicit training on these tasks. Consistency models can be trained either as a way to distill pre-trained diffusion models, or as standalone generative models. Through extensive experiments, we demonstrate that they outperform existing distillation techniques for diffusion models in one- and few-step generation. For example, we achieve the new state-of-the-art FID of 3.55 on CIFAR-10 and 6.20 on ImageNet 64x64 for one-step generation. When trained as standalone generative models, consistency models also outperform single-step, non-adversarial generative models on standard benchmarks like CIFAR-10, ImageNet 64x64 and LSUN 256x256.</em>",ie,O,Ee='The original codebase can be found at <a href="https://github.com/openai/consistency_models" rel="nofollow">openai/consistency_models</a>.',ae,A,ce,c,E,_e,R,ke="Multistep and onestep sampling for consistency models.",Se,W,Ne=`This model inherits from <a href="/docs/diffusers/v0.22.3/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/v0.22.3/en/api/configuration#diffusers.ConfigMixin">ConfigMixin</a>. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`,$e,$,k,xe,Y,qe=`Gets the scalings used in the consistency model parameterization (from Appendix C of the
<a href="https://huggingface.co/papers/2303.01469" rel="nofollow">paper</a>) to enforce boundary condition.`,be,C,ye,M,N,Ce,B,ze="Scales the consistency model input by <code>(sigma**2 + sigma_data**2) ** 0.5</code>.",Me,T,q,Te,J,Ve="Sets the timesteps used for the diffusion chain (to be run before inference).",Ie,I,z,we,Q,Ue="Gets scaled timesteps from the Karras sigmas for input to the consistency model.",De,w,V,Le,X,je=`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`,de,U,le,x,j,Pe,Z,Ke="Output class for the scheduler’s <code>step</code> function.",pe,te,ue;return L=new He({props:{title:"CMStochasticIterativeScheduler",local:"cmstochasticiterativescheduler",headingTag:"h1"}}),A=new He({props:{title:"CMStochasticIterativeScheduler",local:"diffusers.CMStochasticIterativeScheduler",headingTag:"h2"}}),E=new K({props:{name:"class diffusers.CMStochasticIterativeScheduler",anchor:"diffusers.CMStochasticIterativeScheduler",parameters:[{name:"num_train_timesteps",val:": int = 40"},{name:"sigma_min",val:": float = 0.002"},{name:"sigma_max",val:": float = 80.0"},{name:"sigma_data",val:": float = 0.5"},{name:"s_noise",val:": float = 1.0"},{name:"rho",val:": float = 7.0"},{name:"clip_denoised",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 40) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.CMStochasticIterativeScheduler.sigma_min",description:`<strong>sigma_min</strong> (<code>float</code>, defaults to 0.002) &#x2014;
Minimum noise magnitude in the sigma schedule. Defaults to 0.002 from the original implementation.`,name:"sigma_min"},{anchor:"diffusers.CMStochasticIterativeScheduler.sigma_max",description:`<strong>sigma_max</strong> (<code>float</code>, defaults to 80.0) &#x2014;
Maximum noise magnitude in the sigma schedule. Defaults to 80.0 from the original implementation.`,name:"sigma_max"},{anchor:"diffusers.CMStochasticIterativeScheduler.sigma_data",description:`<strong>sigma_data</strong> (<code>float</code>, defaults to 0.5) &#x2014;
The standard deviation of the data distribution from the EDM
<a href="https://huggingface.co/papers/2206.00364" rel="nofollow">paper</a>. Defaults to 0.5 from the original implementation.`,name:"sigma_data"},{anchor:"diffusers.CMStochasticIterativeScheduler.s_noise",description:`<strong>s_noise</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The amount of additional noise to counteract loss of detail during sampling. A reasonable range is [1.000,
1.011]. Defaults to 1.0 from the original implementation.`,name:"s_noise"},{anchor:"diffusers.CMStochasticIterativeScheduler.rho",description:`<strong>rho</strong> (<code>float</code>, defaults to 7.0) &#x2014;
The parameter for calculating the Karras sigma schedule from the EDM
<a href="https://huggingface.co/papers/2206.00364" rel="nofollow">paper</a>. Defaults to 7.0 from the original implementation.`,name:"rho"},{anchor:"diffusers.CMStochasticIterativeScheduler.clip_denoised",description:`<strong>clip_denoised</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to clip the denoised outputs to <code>(-1, 1)</code>.`,name:"clip_denoised"},{anchor:"diffusers.CMStochasticIterativeScheduler.timesteps",description:`<strong>timesteps</strong> (<code>List</code> or <code>np.ndarray</code> or <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
An explicit timestep schedule that can be optionally specified. The timesteps are expected to be in
increasing order.`,name:"timesteps"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L44"}}),k=new K({props:{name:"get_scalings_for_boundary_condition",anchor:"diffusers.CMStochasticIterativeScheduler.get_scalings_for_boundary_condition",parameters:[{name:"sigma",val:""}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.get_scalings_for_boundary_condition.sigma",description:`<strong>sigma</strong> (<code>torch.FloatTensor</code>) &#x2014;
The current sigma in the Karras sigma schedule.`,name:"sigma"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L254",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A two-element tuple where <code>c_skip</code> (which weights the current sample) is the first element and <code>c_out</code>
(which weights the consistency model output) is the second element.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>tuple</code></p>
`}}),C=new Qe({props:{$$slots:{default:[Xe]},$$scope:{ctx:se}}}),N=new K({props:{name:"scale_model_input",anchor:"diffusers.CMStochasticIterativeScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.CMStochasticIterativeScheduler.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.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L116",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A scaled input sample.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.FloatTensor</code></p>
`}}),q=new K({props:{name:"set_timesteps",anchor:"diffusers.CMStochasticIterativeScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": typing.Optional[int] = None"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"timesteps",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.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.CMStochasticIterativeScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps should be moved to. If <code>None</code>, the timesteps are not moved.`,name:"device"},{anchor:"diffusers.CMStochasticIterativeScheduler.set_timesteps.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps used to support arbitrary spacing between timesteps. If <code>None</code>, then the default
timestep spacing strategy of equal spacing between timesteps is used. If <code>timesteps</code> is passed,
<code>num_inference_steps</code> must be <code>None</code>.`,name:"timesteps"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L162"}}),z=new K({props:{name:"sigma_to_t",anchor:"diffusers.CMStochasticIterativeScheduler.sigma_to_t",parameters:[{name:"sigmas",val:": typing.Union[float, numpy.ndarray]"}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.sigma_to_t.sigmas",description:`<strong>sigmas</strong> (<code>float</code> or <code>np.ndarray</code>) &#x2014;
A single Karras sigma or an array of Karras sigmas.`,name:"sigmas"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L143",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A scaled input timestep or scaled input timestep array.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>float</code> or <code>np.ndarray</code></p>
`}}),V=new K({props:{name:"step",anchor:"diffusers.CMStochasticIterativeScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": FloatTensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CMStochasticIterativeScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from the learned diffusion model.`,name:"model_output"},{anchor:"diffusers.CMStochasticIterativeScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.CMStochasticIterativeScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.CMStochasticIterativeScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.CMStochasticIterativeScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a
<a href="/docs/diffusers/v0.22.3/en/api/schedulers/cm_stochastic_iterative#diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput">CMStochasticIterativeSchedulerOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L299",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>,
<a
  href="/docs/diffusers/v0.22.3/en/api/schedulers/cm_stochastic_iterative#diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput"
>CMStochasticIterativeSchedulerOutput</a> is returned,
otherwise a tuple is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/v0.22.3/en/api/schedulers/cm_stochastic_iterative#diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput"
>CMStochasticIterativeSchedulerOutput</a> or <code>tuple</code></p>
`}}),U=new He({props:{title:"CMStochasticIterativeSchedulerOutput",local:"diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput",headingTag:"h2"}}),j=new K({props:{name:"class diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput",anchor:"diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Computed sample <code>(x_{t-1})</code> of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.3/src/diffusers/schedulers/scheduling_consistency_models.py#L31"}}),{c(){p=i("meta"),D=o(),m=i("p"),G=o(),h(L.$$.fragment),ne=o(),P=i("p"),P.innerHTML=Fe,oe=o(),H=i("p"),H.textContent=Oe,re=o(),F=i("p"),F.innerHTML=Ae,ie=o(),O=i("p"),O.innerHTML=Ee,ae=o(),h(A.$$.fragment),ce=o(),c=i("div"),h(E.$$.fragment),_e=o(),R=i("p"),R.textContent=ke,Se=o(),W=i("p"),W.innerHTML=Ne,$e=o(),$=i("div"),h(k.$$.fragment),xe=o(),Y=i("p"),Y.innerHTML=qe,be=o(),h(C.$$.fragment),ye=o(),M=i("div"),h(N.$$.fragment),Ce=o(),B=i("p"),B.innerHTML=ze,Me=o(),T=i("div"),h(q.$$.fragment),Te=o(),J=i("p"),J.textContent=Ve,Ie=o(),I=i("div"),h(z.$$.fragment),we=o(),Q=i("p"),Q.textContent=Ue,De=o(),w=i("div"),h(V.$$.fragment),Le=o(),X=i("p"),X.textContent=je,de=o(),h(U.$$.fragment),le=o(),x=i("div"),h(j.$$.fragment),Pe=o(),Z=i("p"),Z.innerHTML=Ke,pe=o(),te=i("p"),this.h()},l(e){const s=Je("svelte-u9bgzb",document.head);p=a(s,"META",{name:!0,content:!0}),s.forEach(t),D=r(e),m=a(e,"P",{}),b(m).forEach(t),G=r(e),f(L.$$.fragment,e),ne=r(e),P=a(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-je4cvt"&&(P.innerHTML=Fe),oe=r(e),H=a(e,"P",{"data-svelte-h":!0}),u(H)!=="svelte-1cwsb16"&&(H.textContent=Oe),re=r(e),F=a(e,"P",{"data-svelte-h":!0}),u(F)!=="svelte-ymygwa"&&(F.innerHTML=Ae),ie=r(e),O=a(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-1ci2nab"&&(O.innerHTML=Ee),ae=r(e),f(A.$$.fragment,e),ce=r(e),c=a(e,"DIV",{class:!0});var l=b(c);f(E.$$.fragment,l),_e=r(l),R=a(l,"P",{"data-svelte-h":!0}),u(R)!=="svelte-252n82"&&(R.textContent=ke),Se=r(l),W=a(l,"P",{"data-svelte-h":!0}),u(W)!=="svelte-15k1vx1"&&(W.innerHTML=Ne),$e=r(l),$=a(l,"DIV",{class:!0});var ee=b($);f(k.$$.fragment,ee),xe=r(ee),Y=a(ee,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-1t9pjgt"&&(Y.innerHTML=qe),be=r(ee),f(C.$$.fragment,ee),ee.forEach(t),ye=r(l),M=a(l,"DIV",{class:!0});var me=b(M);f(N.$$.fragment,me),Ce=r(me),B=a(me,"P",{"data-svelte-h":!0}),u(B)!=="svelte-hzru6p"&&(B.innerHTML=ze),me.forEach(t),Me=r(l),T=a(l,"DIV",{class:!0});var he=b(T);f(q.$$.fragment,he),Te=r(he),J=a(he,"P",{"data-svelte-h":!0}),u(J)!=="svelte-qri72b"&&(J.textContent=Ve),he.forEach(t),Ie=r(l),I=a(l,"DIV",{class:!0});var fe=b(I);f(z.$$.fragment,fe),we=r(fe),Q=a(fe,"P",{"data-svelte-h":!0}),u(Q)!=="svelte-1yxdts4"&&(Q.textContent=Ue),fe.forEach(t),De=r(l),w=a(l,"DIV",{class:!0});var ge=b(w);f(V.$$.fragment,ge),Le=r(ge),X=a(ge,"P",{"data-svelte-h":!0}),u(X)!=="svelte-hi84tp"&&(X.textContent=je),ge.forEach(t),l.forEach(t),de=r(e),f(U.$$.fragment,e),le=r(e),x=a(e,"DIV",{class:!0});var ve=b(x);f(j.$$.fragment,ve),Pe=r(ve),Z=a(ve,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-xucjnj"&&(Z.innerHTML=Ke),ve.forEach(t),pe=r(e),te=a(e,"P",{}),b(te).forEach(t),this.h()},h(){y(p,"name","hf:doc:metadata"),y(p,"content",et),y($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,s){n(document.head,p),d(e,D,s),d(e,m,s),d(e,G,s),g(L,e,s),d(e,ne,s),d(e,P,s),d(e,oe,s),d(e,H,s),d(e,re,s),d(e,F,s),d(e,ie,s),d(e,O,s),d(e,ae,s),g(A,e,s),d(e,ce,s),d(e,c,s),g(E,c,null),n(c,_e),n(c,R),n(c,Se),n(c,W),n(c,$e),n(c,$),g(k,$,null),n($,xe),n($,Y),n($,be),g(C,$,null),n(c,ye),n(c,M),g(N,M,null),n(M,Ce),n(M,B),n(c,Me),n(c,T),g(q,T,null),n(T,Te),n(T,J),n(c,Ie),n(c,I),g(z,I,null),n(I,we),n(I,Q),n(c,De),n(c,w),g(V,w,null),n(w,Le),n(w,X),d(e,de,s),g(U,e,s),d(e,le,s),d(e,x,s),g(j,x,null),n(x,Pe),n(x,Z),d(e,pe,s),d(e,te,s),ue=!0},p(e,[s]){const l={};s&2&&(l.$$scope={dirty:s,ctx:e}),C.$set(l)},i(e){ue||(v(L.$$.fragment,e),v(A.$$.fragment,e),v(E.$$.fragment,e),v(k.$$.fragment,e),v(C.$$.fragment,e),v(N.$$.fragment,e),v(q.$$.fragment,e),v(z.$$.fragment,e),v(V.$$.fragment,e),v(U.$$.fragment,e),v(j.$$.fragment,e),ue=!0)},o(e){_(L.$$.fragment,e),_(A.$$.fragment,e),_(E.$$.fragment,e),_(k.$$.fragment,e),_(C.$$.fragment,e),_(N.$$.fragment,e),_(q.$$.fragment,e),_(z.$$.fragment,e),_(V.$$.fragment,e),_(U.$$.fragment,e),_(j.$$.fragment,e),ue=!1},d(e){e&&(t(D),t(m),t(G),t(ne),t(P),t(oe),t(H),t(re),t(F),t(ie),t(O),t(ae),t(ce),t(c),t(de),t(le),t(x),t(pe),t(te)),t(p),S(L,e),S(A,e),S(E),S(k),S(C),S(N),S(q),S(z),S(V),S(U,e),S(j)}}}const et='{"title":"CMStochasticIterativeScheduler","local":"cmstochasticiterativescheduler","sections":[{"title":"CMStochasticIterativeScheduler","local":"diffusers.CMStochasticIterativeScheduler","sections":[],"depth":2},{"title":"CMStochasticIterativeSchedulerOutput","local":"diffusers.schedulers.scheduling_consistency_models.CMStochasticIterativeSchedulerOutput","sections":[],"depth":2}],"depth":1}';function tt(se){return Re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class at extends Ye{constructor(p){super(),Be(this,p,tt,Ze,Ge,{})}}export{at as component};
