import{S as Za,i as Fa,s as za,e as n,k as l,w as v,t as o,M as Ra,c as a,d as i,m as d,a as s,x as P,h as r,b as p,G as e,g as c,y as w,q as y,o as D,B as S,v as Wa,L as Ha}from"../../../chunks/vendor-hf-doc-builder.js";import{T as Ya}from"../../../chunks/Tip-hf-doc-builder.js";import{D as z}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Qa}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Kt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Xa}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ka(xe){let g,I,_,b,$,m,E,O;return{c(){g=n("p"),I=o("Make sure to check out the Schedulers "),_=n("a"),b=o("guide"),$=o(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=n("a"),E=o("reuse components across pipelines"),O=o(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(V){g=a(V,"P",{});var T=s(g);I=r(T,"Make sure to check out the Schedulers "),_=a(T,"A",{href:!0});var U=s(_);b=r(U,"guide"),U.forEach(i),$=r(T," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=a(T,"A",{href:!0});var A=s(m);E=r(A,"reuse components across pipelines"),A.forEach(i),O=r(T," section to learn how to efficiently load the same components into multiple pipelines."),T.forEach(i),this.h()},h(){p(_,"href","/using-diffusers/schedulers"),p(m,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(V,T){c(V,g,T),e(g,I),e(g,_),e(_,b),e(g,$),e(g,m),e(m,E),e(g,O)},d(V){V&&i(g)}}}function es(xe){let g,I,_,b,$;return b=new Qa({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRERQTVBhcmFsbGVsU2NoZWR1bGVyJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBhcmFkaWdtc1BpcGVsaW5lJTBBJTBBc2NoZWR1bGVyJTIwJTNEJTIwRERQTVBhcmFsbGVsU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGFyYWRpZ21zUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTIwc2NoZWR1bGVyJTNEc2NoZWR1bGVyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBbmdwdSUyQyUyMGJhdGNoX3Blcl9kZXZpY2UlMjAlM0QlMjB0b3JjaC5jdWRhLmRldmljZV9jb3VudCgpJTJDJTIwNSUwQXBpcGUud3JhcHBlZF91bmV0JTIwJTNEJTIwdG9yY2gubm4uRGF0YVBhcmFsbGVsKHBpcGUudW5ldCUyQyUyMGRldmljZV9pZHMlM0QlNUJkJTIwZm9yJTIwZCUyMGluJTIwcmFuZ2UobmdwdSklNUQpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyYSUyMHBob3RvJTIwb2YlMjBhbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMG9uJTIwbWFycyUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBwYXJhbGxlbCUzRG5ncHUlMjAqJTIwYmF0Y2hfcGVyX2RldmljZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAwKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDPMParallelScheduler
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionParadigmsPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>scheduler = DDPMParallelScheduler.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionParadigmsPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, scheduler=scheduler, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>ngpu, batch_per_device = torch.cuda.device_count(), <span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.wrapped_unet = torch.nn.DataParallel(pipe.unet, device_ids=[d <span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(ngpu)])

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt, parallel=ngpu * batch_per_device, num_inference_steps=<span class="hljs-number">1000</span>).images[<span class="hljs-number">0</span>]`}}),{c(){g=n("p"),I=o("Examples:"),_=l(),v(b.$$.fragment)},l(m){g=a(m,"P",{});var E=s(g);I=r(E,"Examples:"),E.forEach(i),_=d(m),P(b.$$.fragment,m)},m(m,E){c(m,g,E),e(g,I),c(m,_,E),w(b,m,E),$=!0},p:Ha,i(m){$||(y(b.$$.fragment,m),$=!0)},o(m){D(b.$$.fragment,m),$=!1},d(m){m&&i(g),m&&i(_),S(b,m)}}}function ts(xe){let g,I,_,b,$,m,E,O,V,T,U,A,ei,ti,Dt,Te,ii,St,Ie,We,ni,$t,C,ai,le,si,oi,de,ri,li,Et,j,R,He,pe,di,Ye,pi,xt,ke,fi,Tt,G,ci,Qe,mi,ui,Xe,gi,hi,It,W,q,_i,Ke,bi,vi,et,Pi,wi,yi,fe,Di,tt,Si,$i,kt,x,Ei,Me,xi,Ti,Ue,Ii,ki,it,Mi,Ui,nt,Ai,Ci,Mt,J,Gi,Ae,Ji,Li,Ce,Ni,Oi,Ut,H,At,B,Y,at,ce,Vi,st,ji,Ct,u,me,qi,ot,Bi,Zi,ue,Fi,Ge,zi,Ri,Wi,rt,Hi,Yi,k,Je,Le,Qi,Xi,Ki,Ne,Oe,en,tn,nn,Ve,je,an,sn,on,Q,qe,rn,ln,lt,dn,pn,fn,L,ge,cn,dt,mn,un,X,gn,K,he,hn,_e,_n,pt,bn,vn,Pn,ee,be,wn,ve,yn,ft,Dn,Sn,$n,te,Pe,En,M,xn,ct,Tn,In,mt,kn,Mn,ut,Un,An,Cn,ie,we,Gn,gt,Jn,Ln,ne,ye,Nn,ht,On,Vn,ae,De,jn,_t,qn,Gt,Z,se,bt,Se,Bn,vt,Zn,Jt,F,$e,Fn,Pt,zn,Lt;return m=new Kt({}),pe=new Kt({}),H=new Ya({props:{$$slots:{default:[Ka]},$$scope:{ctx:xe}}}),ce=new Kt({}),me=new z({props:{name:"class diffusers.StableDiffusionParadigmsPipeline",anchor:"diffusers.StableDiffusionParadigmsPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionParadigmsPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIPTextModel</a>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for more details
about a model&#x2019;s potential harms.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor" rel="nofollow">CLIPImageProcessor</a>) &#x2014;
A <code>CLIPImageProcessor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L63"}}),ge=new z({props:{name:"__call__",anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"parallel",val:": int = 10"},{name:"tolerance",val:": float = 0.1"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"debug",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide image generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.parallel",description:`<strong>parallel</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
The batch size to use when doing parallel sampling. More parallelism may lead to faster inference but
requires higher memory usage and can also require more total FLOPs.`,name:"parallel"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.tolerance",description:`<strong>tolerance</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The error tolerance for determining when to slide the batch window forward for parallel sampling. Lower
tolerance usually leads to less or no degradation. Higher tolerance is faster but can risk degradation
of sample quality. The tolerance is specified as a ratio of the scheduler&#x2019;s noise magnitude.`,name:"tolerance"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.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/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function is called. If not specified, the callback is called at
every step.`,name:"callback_steps"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.debug",description:`<strong>debug</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to run in debug mode. In debug mode, <code>torch.cumsum</code> is evaluated using the CPU.`,name:"debug"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L501",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),X=new Xa({props:{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.example",$$slots:{default:[es]},$$scope:{ctx:xe}}}),he=new z({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionParadigmsPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L153"}}),be=new z({props:{name:"disable_vae_tiling",anchor:"diffusers.StableDiffusionParadigmsPipeline.disable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L170"}}),Pe=new z({props:{name:"enable_model_cpu_offload",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L178"}}),we=new z({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L145"}}),ye=new z({props:{name:"enable_vae_tiling",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L161"}}),De=new z({props:{name:"encode_prompt",anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt",parameters:[{name:"prompt",val:""},{name:"device",val:""},{name:"num_images_per_prompt",val:""},{name:"do_classifier_free_guidance",val:""},{name:"negative_prompt",val:" = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"lora_scale",val:": typing.Optional[float] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded
device &#x2014; (<code>torch.device</code>):
torch device`,name:"prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) &#x2014;
number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>) &#x2014;
whether to use classifier free guidance or not`,name:"do_classifier_free_guidance"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.encode_prompt.lora_scale",description:`<strong>lora_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded.`,name:"lora_scale"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L238"}}),Se=new Kt({}),$e=new z({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){g=n("meta"),I=l(),_=n("h1"),b=n("a"),$=n("span"),v(m.$$.fragment),E=l(),O=n("span"),V=o("Parallel Sampling of Diffusion Models"),T=l(),U=n("p"),A=n("a"),ei=o("Parallel Sampling of Diffusion Models"),ti=o(" is by Andy Shih, Suneel Belkhale, Stefano Ermon, Dorsa Sadigh, Nima Anari."),Dt=l(),Te=n("p"),ii=o("The abstract from the paper is:"),St=l(),Ie=n("p"),We=n("em"),ni=o("Diffusion models are powerful generative models but suffer from slow sampling, often taking 1000 sequential denoising steps for one sample. As a result, considerable efforts have been directed toward reducing the number of denoising steps, but these methods hurt sample quality. Instead of reducing the number of denoising steps (trading quality for speed), in this paper we explore an orthogonal approach: can we run the denoising steps in parallel (trading compute for speed)? In spite of the sequential nature of the denoising steps, we show that surprisingly it is possible to parallelize sampling via Picard iterations, by guessing the solution of future denoising steps and iteratively refining until convergence. With this insight, we present ParaDiGMS, a novel method to accelerate the sampling of pretrained diffusion models by denoising multiple steps in parallel. ParaDiGMS is the first diffusion sampling method that enables trading compute for speed and is even compatible with existing fast sampling techniques such as DDIM and DPMSolver. Using ParaDiGMS, we improve sampling speed by 2-4x across a range of robotics and image generation models, giving state-of-the-art sampling speeds of 0.2s on 100-step DiffusionPolicy and 16s on 1000-step StableDiffusion-v2 with no measurable degradation of task reward, FID score, or CLIP score."),$t=l(),C=n("p"),ai=o("The original codebase can be found at "),le=n("a"),si=o("AndyShih12/paradigms"),oi=o(", and the pipeline was contributed by "),de=n("a"),ri=o("AndyShih12"),li=o(". \u2764\uFE0F"),Et=l(),j=n("h2"),R=n("a"),He=n("span"),v(pe.$$.fragment),di=l(),Ye=n("span"),pi=o("Tips"),xt=l(),ke=n("p"),fi=o(`This pipeline improves sampling speed by running denoising steps in parallel, at the cost of increased total FLOPs.
Therefore, it is better to call this pipeline when running on multiple GPUs. Otherwise, without enough GPU bandwidth
sampling may be even slower than sequential sampling.`),Tt=l(),G=n("p"),ci=o("The two parameters to play with are "),Qe=n("code"),mi=o("parallel"),ui=o(" (batch size) and "),Xe=n("code"),gi=o("tolerance"),hi=o("."),It=l(),W=n("ul"),q=n("li"),_i=o(`If it fits in memory, for a 1000-step DDPM you can aim for a batch size of around 100
(for example, 8 GPUs and `),Ke=n("code"),bi=o("batch_per_device=12"),vi=o(" to get "),et=n("code"),Pi=o("parallel=96"),wi=o(`). A higher batch size
may not fit in memory, and lower batch size gives less parallelism.`),yi=l(),fe=n("li"),Di=o(`For tolerance, using a higher tolerance may get better speedups but can risk sample quality degradation.
If there is quality degradation with the default tolerance, then use a lower tolerance like `),tt=n("code"),Si=o("0.001"),$i=o("."),kt=l(),x=n("p"),Ei=o("For a 1000-step DDPM on 8 A100 GPUs, you can expect around a 3x speedup from "),Me=n("a"),xi=o("StableDiffusionParadigmsPipeline"),Ti=o(" compared to the "),Ue=n("a"),Ii=o("StableDiffusionPipeline"),ki=o(`
by setting `),it=n("code"),Mi=o("parallel=80"),Ui=o(" and "),nt=n("code"),Ai=o("tolerance=0.1"),Ci=o("."),Mt=l(),J=n("p"),Gi=o("\u{1F917} Diffusers offers "),Ae=n("a"),Ji=o("distributed inference support"),Li=o(` for generating multiple prompts
in parallel on multiple GPUs. But `),Ce=n("a"),Ni=o("StableDiffusionParadigmsPipeline"),Oi=o(" is designed for speeding up sampling of a single prompt by using multiple GPUs."),Ut=l(),v(H.$$.fragment),At=l(),B=n("h2"),Y=n("a"),at=n("span"),v(ce.$$.fragment),Vi=l(),st=n("span"),ji=o("StableDiffusionParadigmsPipeline"),Ct=l(),u=n("div"),v(me.$$.fragment),qi=l(),ot=n("p"),Bi=o("Pipeline for text-to-image generation using a parallelized version of Stable Diffusion."),Zi=l(),ue=n("p"),Fi=o("This model inherits from "),Ge=n("a"),zi=o("DiffusionPipeline"),Ri=o(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Wi=l(),rt=n("p"),Hi=o("The pipeline also inherits the following loading methods:"),Yi=l(),k=n("ul"),Je=n("li"),Le=n("a"),Qi=o("load_textual_inversion()"),Xi=o(" for loading textual inversion embeddings"),Ki=l(),Ne=n("li"),Oe=n("a"),en=o("load_lora_weights()"),tn=o(" for loading LoRA weights"),nn=l(),Ve=n("li"),je=n("a"),an=o("save_lora_weights()"),sn=o(" for saving LoRA weights"),on=l(),Q=n("li"),qe=n("a"),rn=o("from_single_file()"),ln=o(" for loading "),lt=n("code"),dn=o(".ckpt"),pn=o(" files"),fn=l(),L=n("div"),v(ge.$$.fragment),cn=l(),dt=n("p"),mn=o("The call function to the pipeline for generation."),un=l(),v(X.$$.fragment),gn=l(),K=n("div"),v(he.$$.fragment),hn=l(),_e=n("p"),_n=o("Disable sliced VAE decoding. If "),pt=n("code"),bn=o("enable_vae_slicing"),vn=o(` was previously enabled, this method will go back to
computing decoding in one step.`),Pn=l(),ee=n("div"),v(be.$$.fragment),wn=l(),ve=n("p"),yn=o("Disable tiled VAE decoding. If "),ft=n("code"),Dn=o("enable_vae_tiling"),Sn=o(` was previously enabled, this method will go back to
computing decoding in one step.`),$n=l(),te=n("div"),v(Pe.$$.fragment),En=l(),M=n("p"),xn=o(`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ct=n("code"),Tn=o("forward"),In=o(` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),mt=n("code"),kn=o("enable_sequential_cpu_offload"),Mn=o(`, but performance is much better due to the
iterative execution of the `),ut=n("code"),Un=o("unet"),An=o("."),Cn=l(),ie=n("div"),v(we.$$.fragment),Gn=l(),gt=n("p"),Jn=o(`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),Ln=l(),ne=n("div"),v(ye.$$.fragment),Nn=l(),ht=n("p"),On=o(`Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
processing larger images.`),Vn=l(),ae=n("div"),v(De.$$.fragment),jn=l(),_t=n("p"),qn=o("Encodes the prompt into text encoder hidden states."),Gt=l(),Z=n("h2"),se=n("a"),bt=n("span"),v(Se.$$.fragment),Bn=l(),vt=n("span"),Zn=o("StableDiffusionPipelineOutput"),Jt=l(),F=n("div"),v($e.$$.fragment),Fn=l(),Pt=n("p"),zn=o("Output class for Stable Diffusion pipelines."),this.h()},l(t){const f=Ra('[data-svelte="svelte-1phssyn"]',document.head);g=a(f,"META",{name:!0,content:!0}),f.forEach(i),I=d(t),_=a(t,"H1",{class:!0});var Ee=s(_);b=a(Ee,"A",{id:!0,class:!0,href:!0});var wt=s(b);$=a(wt,"SPAN",{});var Qn=s($);P(m.$$.fragment,Qn),Qn.forEach(i),wt.forEach(i),E=d(Ee),O=a(Ee,"SPAN",{});var Xn=s(O);V=r(Xn,"Parallel Sampling of Diffusion Models"),Xn.forEach(i),Ee.forEach(i),T=d(t),U=a(t,"P",{});var Rn=s(U);A=a(Rn,"A",{href:!0,rel:!0});var Kn=s(A);ei=r(Kn,"Parallel Sampling of Diffusion Models"),Kn.forEach(i),ti=r(Rn," is by Andy Shih, Suneel Belkhale, Stefano Ermon, Dorsa Sadigh, Nima Anari."),Rn.forEach(i),Dt=d(t),Te=a(t,"P",{});var ea=s(Te);ii=r(ea,"The abstract from the paper is:"),ea.forEach(i),St=d(t),Ie=a(t,"P",{});var ta=s(Ie);We=a(ta,"EM",{});var ia=s(We);ni=r(ia,"Diffusion models are powerful generative models but suffer from slow sampling, often taking 1000 sequential denoising steps for one sample. As a result, considerable efforts have been directed toward reducing the number of denoising steps, but these methods hurt sample quality. Instead of reducing the number of denoising steps (trading quality for speed), in this paper we explore an orthogonal approach: can we run the denoising steps in parallel (trading compute for speed)? In spite of the sequential nature of the denoising steps, we show that surprisingly it is possible to parallelize sampling via Picard iterations, by guessing the solution of future denoising steps and iteratively refining until convergence. With this insight, we present ParaDiGMS, a novel method to accelerate the sampling of pretrained diffusion models by denoising multiple steps in parallel. ParaDiGMS is the first diffusion sampling method that enables trading compute for speed and is even compatible with existing fast sampling techniques such as DDIM and DPMSolver. Using ParaDiGMS, we improve sampling speed by 2-4x across a range of robotics and image generation models, giving state-of-the-art sampling speeds of 0.2s on 100-step DiffusionPolicy and 16s on 1000-step StableDiffusion-v2 with no measurable degradation of task reward, FID score, or CLIP score."),ia.forEach(i),ta.forEach(i),$t=d(t),C=a(t,"P",{});var Be=s(C);ai=r(Be,"The original codebase can be found at "),le=a(Be,"A",{href:!0,rel:!0});var na=s(le);si=r(na,"AndyShih12/paradigms"),na.forEach(i),oi=r(Be,", and the pipeline was contributed by "),de=a(Be,"A",{href:!0,rel:!0});var aa=s(de);ri=r(aa,"AndyShih12"),aa.forEach(i),li=r(Be,". \u2764\uFE0F"),Be.forEach(i),Et=d(t),j=a(t,"H2",{class:!0});var Nt=s(j);R=a(Nt,"A",{id:!0,class:!0,href:!0});var sa=s(R);He=a(sa,"SPAN",{});var oa=s(He);P(pe.$$.fragment,oa),oa.forEach(i),sa.forEach(i),di=d(Nt),Ye=a(Nt,"SPAN",{});var ra=s(Ye);pi=r(ra,"Tips"),ra.forEach(i),Nt.forEach(i),xt=d(t),ke=a(t,"P",{});var la=s(ke);fi=r(la,`This pipeline improves sampling speed by running denoising steps in parallel, at the cost of increased total FLOPs.
Therefore, it is better to call this pipeline when running on multiple GPUs. Otherwise, without enough GPU bandwidth
sampling may be even slower than sequential sampling.`),la.forEach(i),Tt=d(t),G=a(t,"P",{});var Ze=s(G);ci=r(Ze,"The two parameters to play with are "),Qe=a(Ze,"CODE",{});var da=s(Qe);mi=r(da,"parallel"),da.forEach(i),ui=r(Ze," (batch size) and "),Xe=a(Ze,"CODE",{});var pa=s(Xe);gi=r(pa,"tolerance"),pa.forEach(i),hi=r(Ze,"."),Ze.forEach(i),It=d(t),W=a(t,"UL",{});var Ot=s(W);q=a(Ot,"LI",{});var Fe=s(q);_i=r(Fe,`If it fits in memory, for a 1000-step DDPM you can aim for a batch size of around 100
(for example, 8 GPUs and `),Ke=a(Fe,"CODE",{});var fa=s(Ke);bi=r(fa,"batch_per_device=12"),fa.forEach(i),vi=r(Fe," to get "),et=a(Fe,"CODE",{});var ca=s(et);Pi=r(ca,"parallel=96"),ca.forEach(i),wi=r(Fe,`). A higher batch size
may not fit in memory, and lower batch size gives less parallelism.`),Fe.forEach(i),yi=d(Ot),fe=a(Ot,"LI",{});var Vt=s(fe);Di=r(Vt,`For tolerance, using a higher tolerance may get better speedups but can risk sample quality degradation.
If there is quality degradation with the default tolerance, then use a lower tolerance like `),tt=a(Vt,"CODE",{});var ma=s(tt);Si=r(ma,"0.001"),ma.forEach(i),$i=r(Vt,"."),Vt.forEach(i),Ot.forEach(i),kt=d(t),x=a(t,"P",{});var N=s(x);Ei=r(N,"For a 1000-step DDPM on 8 A100 GPUs, you can expect around a 3x speedup from "),Me=a(N,"A",{href:!0});var ua=s(Me);xi=r(ua,"StableDiffusionParadigmsPipeline"),ua.forEach(i),Ti=r(N," compared to the "),Ue=a(N,"A",{href:!0});var ga=s(Ue);Ii=r(ga,"StableDiffusionPipeline"),ga.forEach(i),ki=r(N,`
by setting `),it=a(N,"CODE",{});var ha=s(it);Mi=r(ha,"parallel=80"),ha.forEach(i),Ui=r(N," and "),nt=a(N,"CODE",{});var _a=s(nt);Ai=r(_a,"tolerance=0.1"),_a.forEach(i),Ci=r(N,"."),N.forEach(i),Mt=d(t),J=a(t,"P",{});var ze=s(J);Gi=r(ze,"\u{1F917} Diffusers offers "),Ae=a(ze,"A",{href:!0});var ba=s(Ae);Ji=r(ba,"distributed inference support"),ba.forEach(i),Li=r(ze,` for generating multiple prompts
in parallel on multiple GPUs. But `),Ce=a(ze,"A",{href:!0});var va=s(Ce);Ni=r(va,"StableDiffusionParadigmsPipeline"),va.forEach(i),Oi=r(ze," is designed for speeding up sampling of a single prompt by using multiple GPUs."),ze.forEach(i),Ut=d(t),P(H.$$.fragment,t),At=d(t),B=a(t,"H2",{class:!0});var jt=s(B);Y=a(jt,"A",{id:!0,class:!0,href:!0});var Pa=s(Y);at=a(Pa,"SPAN",{});var wa=s(at);P(ce.$$.fragment,wa),wa.forEach(i),Pa.forEach(i),Vi=d(jt),st=a(jt,"SPAN",{});var ya=s(st);ji=r(ya,"StableDiffusionParadigmsPipeline"),ya.forEach(i),jt.forEach(i),Ct=d(t),u=a(t,"DIV",{class:!0});var h=s(u);P(me.$$.fragment,h),qi=d(h),ot=a(h,"P",{});var Da=s(ot);Bi=r(Da,"Pipeline for text-to-image generation using a parallelized version of Stable Diffusion."),Da.forEach(i),Zi=d(h),ue=a(h,"P",{});var qt=s(ue);Fi=r(qt,"This model inherits from "),Ge=a(qt,"A",{href:!0});var Sa=s(Ge);zi=r(Sa,"DiffusionPipeline"),Sa.forEach(i),Ri=r(qt,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),qt.forEach(i),Wi=d(h),rt=a(h,"P",{});var $a=s(rt);Hi=r($a,"The pipeline also inherits the following loading methods:"),$a.forEach(i),Yi=d(h),k=a(h,"UL",{});var oe=s(k);Je=a(oe,"LI",{});var Wn=s(Je);Le=a(Wn,"A",{href:!0});var Ea=s(Le);Qi=r(Ea,"load_textual_inversion()"),Ea.forEach(i),Xi=r(Wn," for loading textual inversion embeddings"),Wn.forEach(i),Ki=d(oe),Ne=a(oe,"LI",{});var Hn=s(Ne);Oe=a(Hn,"A",{href:!0});var xa=s(Oe);en=r(xa,"load_lora_weights()"),xa.forEach(i),tn=r(Hn," for loading LoRA weights"),Hn.forEach(i),nn=d(oe),Ve=a(oe,"LI",{});var Yn=s(Ve);je=a(Yn,"A",{href:!0});var Ta=s(je);an=r(Ta,"save_lora_weights()"),Ta.forEach(i),sn=r(Yn," for saving LoRA weights"),Yn.forEach(i),on=d(oe),Q=a(oe,"LI",{});var yt=s(Q);qe=a(yt,"A",{href:!0});var Ia=s(qe);rn=r(Ia,"from_single_file()"),Ia.forEach(i),ln=r(yt," for loading "),lt=a(yt,"CODE",{});var ka=s(lt);dn=r(ka,".ckpt"),ka.forEach(i),pn=r(yt," files"),yt.forEach(i),oe.forEach(i),fn=d(h),L=a(h,"DIV",{class:!0});var Re=s(L);P(ge.$$.fragment,Re),cn=d(Re),dt=a(Re,"P",{});var Ma=s(dt);mn=r(Ma,"The call function to the pipeline for generation."),Ma.forEach(i),un=d(Re),P(X.$$.fragment,Re),Re.forEach(i),gn=d(h),K=a(h,"DIV",{class:!0});var Bt=s(K);P(he.$$.fragment,Bt),hn=d(Bt),_e=a(Bt,"P",{});var Zt=s(_e);_n=r(Zt,"Disable sliced VAE decoding. If "),pt=a(Zt,"CODE",{});var Ua=s(pt);bn=r(Ua,"enable_vae_slicing"),Ua.forEach(i),vn=r(Zt,` was previously enabled, this method will go back to
computing decoding in one step.`),Zt.forEach(i),Bt.forEach(i),Pn=d(h),ee=a(h,"DIV",{class:!0});var Ft=s(ee);P(be.$$.fragment,Ft),wn=d(Ft),ve=a(Ft,"P",{});var zt=s(ve);yn=r(zt,"Disable tiled VAE decoding. If "),ft=a(zt,"CODE",{});var Aa=s(ft);Dn=r(Aa,"enable_vae_tiling"),Aa.forEach(i),Sn=r(zt,` was previously enabled, this method will go back to
computing decoding in one step.`),zt.forEach(i),Ft.forEach(i),$n=d(h),te=a(h,"DIV",{class:!0});var Rt=s(te);P(Pe.$$.fragment,Rt),En=d(Rt),M=a(Rt,"P",{});var re=s(M);xn=r(re,`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ct=a(re,"CODE",{});var Ca=s(ct);Tn=r(Ca,"forward"),Ca.forEach(i),In=r(re,` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),mt=a(re,"CODE",{});var Ga=s(mt);kn=r(Ga,"enable_sequential_cpu_offload"),Ga.forEach(i),Mn=r(re,`, but performance is much better due to the
iterative execution of the `),ut=a(re,"CODE",{});var Ja=s(ut);Un=r(Ja,"unet"),Ja.forEach(i),An=r(re,"."),re.forEach(i),Rt.forEach(i),Cn=d(h),ie=a(h,"DIV",{class:!0});var Wt=s(ie);P(we.$$.fragment,Wt),Gn=d(Wt),gt=a(Wt,"P",{});var La=s(gt);Jn=r(La,`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),La.forEach(i),Wt.forEach(i),Ln=d(h),ne=a(h,"DIV",{class:!0});var Ht=s(ne);P(ye.$$.fragment,Ht),Nn=d(Ht),ht=a(Ht,"P",{});var Na=s(ht);On=r(Na,`Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
processing larger images.`),Na.forEach(i),Ht.forEach(i),Vn=d(h),ae=a(h,"DIV",{class:!0});var Yt=s(ae);P(De.$$.fragment,Yt),jn=d(Yt),_t=a(Yt,"P",{});var Oa=s(_t);qn=r(Oa,"Encodes the prompt into text encoder hidden states."),Oa.forEach(i),Yt.forEach(i),h.forEach(i),Gt=d(t),Z=a(t,"H2",{class:!0});var Qt=s(Z);se=a(Qt,"A",{id:!0,class:!0,href:!0});var Va=s(se);bt=a(Va,"SPAN",{});var ja=s(bt);P(Se.$$.fragment,ja),ja.forEach(i),Va.forEach(i),Bn=d(Qt),vt=a(Qt,"SPAN",{});var qa=s(vt);Zn=r(qa,"StableDiffusionPipelineOutput"),qa.forEach(i),Qt.forEach(i),Jt=d(t),F=a(t,"DIV",{class:!0});var Xt=s(F);P($e.$$.fragment,Xt),Fn=d(Xt),Pt=a(Xt,"P",{});var Ba=s(Pt);zn=r(Ba,"Output class for Stable Diffusion pipelines."),Ba.forEach(i),Xt.forEach(i),this.h()},h(){p(g,"name","hf:doc:metadata"),p(g,"content",JSON.stringify(is)),p(b,"id","parallel-sampling-of-diffusion-models"),p(b,"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"),p(b,"href","#parallel-sampling-of-diffusion-models"),p(_,"class","relative group"),p(A,"href","https://huggingface.co/papers/2305.16317"),p(A,"rel","nofollow"),p(le,"href","https://github.com/AndyShih12/paradigms"),p(le,"rel","nofollow"),p(de,"href","https://github.com/AndyShih12"),p(de,"rel","nofollow"),p(R,"id","tips"),p(R,"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"),p(R,"href","#tips"),p(j,"class","relative group"),p(Me,"href","/docs/diffusers/main/en/api/pipelines/paradigms#diffusers.StableDiffusionParadigmsPipeline"),p(Ue,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(Ae,"href","../training/distributed_inference"),p(Ce,"href","/docs/diffusers/main/en/api/pipelines/paradigms#diffusers.StableDiffusionParadigmsPipeline"),p(Y,"id","diffusers.StableDiffusionParadigmsPipeline"),p(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"),p(Y,"href","#diffusers.StableDiffusionParadigmsPipeline"),p(B,"class","relative group"),p(Ge,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(Le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion"),p(Oe,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(je,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights"),p(qe,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.from_single_file"),p(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(se,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(se,"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"),p(se,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(Z,"class","relative group"),p(F,"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,f){e(document.head,g),c(t,I,f),c(t,_,f),e(_,b),e(b,$),w(m,$,null),e(_,E),e(_,O),e(O,V),c(t,T,f),c(t,U,f),e(U,A),e(A,ei),e(U,ti),c(t,Dt,f),c(t,Te,f),e(Te,ii),c(t,St,f),c(t,Ie,f),e(Ie,We),e(We,ni),c(t,$t,f),c(t,C,f),e(C,ai),e(C,le),e(le,si),e(C,oi),e(C,de),e(de,ri),e(C,li),c(t,Et,f),c(t,j,f),e(j,R),e(R,He),w(pe,He,null),e(j,di),e(j,Ye),e(Ye,pi),c(t,xt,f),c(t,ke,f),e(ke,fi),c(t,Tt,f),c(t,G,f),e(G,ci),e(G,Qe),e(Qe,mi),e(G,ui),e(G,Xe),e(Xe,gi),e(G,hi),c(t,It,f),c(t,W,f),e(W,q),e(q,_i),e(q,Ke),e(Ke,bi),e(q,vi),e(q,et),e(et,Pi),e(q,wi),e(W,yi),e(W,fe),e(fe,Di),e(fe,tt),e(tt,Si),e(fe,$i),c(t,kt,f),c(t,x,f),e(x,Ei),e(x,Me),e(Me,xi),e(x,Ti),e(x,Ue),e(Ue,Ii),e(x,ki),e(x,it),e(it,Mi),e(x,Ui),e(x,nt),e(nt,Ai),e(x,Ci),c(t,Mt,f),c(t,J,f),e(J,Gi),e(J,Ae),e(Ae,Ji),e(J,Li),e(J,Ce),e(Ce,Ni),e(J,Oi),c(t,Ut,f),w(H,t,f),c(t,At,f),c(t,B,f),e(B,Y),e(Y,at),w(ce,at,null),e(B,Vi),e(B,st),e(st,ji),c(t,Ct,f),c(t,u,f),w(me,u,null),e(u,qi),e(u,ot),e(ot,Bi),e(u,Zi),e(u,ue),e(ue,Fi),e(ue,Ge),e(Ge,zi),e(ue,Ri),e(u,Wi),e(u,rt),e(rt,Hi),e(u,Yi),e(u,k),e(k,Je),e(Je,Le),e(Le,Qi),e(Je,Xi),e(k,Ki),e(k,Ne),e(Ne,Oe),e(Oe,en),e(Ne,tn),e(k,nn),e(k,Ve),e(Ve,je),e(je,an),e(Ve,sn),e(k,on),e(k,Q),e(Q,qe),e(qe,rn),e(Q,ln),e(Q,lt),e(lt,dn),e(Q,pn),e(u,fn),e(u,L),w(ge,L,null),e(L,cn),e(L,dt),e(dt,mn),e(L,un),w(X,L,null),e(u,gn),e(u,K),w(he,K,null),e(K,hn),e(K,_e),e(_e,_n),e(_e,pt),e(pt,bn),e(_e,vn),e(u,Pn),e(u,ee),w(be,ee,null),e(ee,wn),e(ee,ve),e(ve,yn),e(ve,ft),e(ft,Dn),e(ve,Sn),e(u,$n),e(u,te),w(Pe,te,null),e(te,En),e(te,M),e(M,xn),e(M,ct),e(ct,Tn),e(M,In),e(M,mt),e(mt,kn),e(M,Mn),e(M,ut),e(ut,Un),e(M,An),e(u,Cn),e(u,ie),w(we,ie,null),e(ie,Gn),e(ie,gt),e(gt,Jn),e(u,Ln),e(u,ne),w(ye,ne,null),e(ne,Nn),e(ne,ht),e(ht,On),e(u,Vn),e(u,ae),w(De,ae,null),e(ae,jn),e(ae,_t),e(_t,qn),c(t,Gt,f),c(t,Z,f),e(Z,se),e(se,bt),w(Se,bt,null),e(Z,Bn),e(Z,vt),e(vt,Zn),c(t,Jt,f),c(t,F,f),w($e,F,null),e(F,Fn),e(F,Pt),e(Pt,zn),Lt=!0},p(t,[f]){const Ee={};f&2&&(Ee.$$scope={dirty:f,ctx:t}),H.$set(Ee);const wt={};f&2&&(wt.$$scope={dirty:f,ctx:t}),X.$set(wt)},i(t){Lt||(y(m.$$.fragment,t),y(pe.$$.fragment,t),y(H.$$.fragment,t),y(ce.$$.fragment,t),y(me.$$.fragment,t),y(ge.$$.fragment,t),y(X.$$.fragment,t),y(he.$$.fragment,t),y(be.$$.fragment,t),y(Pe.$$.fragment,t),y(we.$$.fragment,t),y(ye.$$.fragment,t),y(De.$$.fragment,t),y(Se.$$.fragment,t),y($e.$$.fragment,t),Lt=!0)},o(t){D(m.$$.fragment,t),D(pe.$$.fragment,t),D(H.$$.fragment,t),D(ce.$$.fragment,t),D(me.$$.fragment,t),D(ge.$$.fragment,t),D(X.$$.fragment,t),D(he.$$.fragment,t),D(be.$$.fragment,t),D(Pe.$$.fragment,t),D(we.$$.fragment,t),D(ye.$$.fragment,t),D(De.$$.fragment,t),D(Se.$$.fragment,t),D($e.$$.fragment,t),Lt=!1},d(t){i(g),t&&i(I),t&&i(_),S(m),t&&i(T),t&&i(U),t&&i(Dt),t&&i(Te),t&&i(St),t&&i(Ie),t&&i($t),t&&i(C),t&&i(Et),t&&i(j),S(pe),t&&i(xt),t&&i(ke),t&&i(Tt),t&&i(G),t&&i(It),t&&i(W),t&&i(kt),t&&i(x),t&&i(Mt),t&&i(J),t&&i(Ut),S(H,t),t&&i(At),t&&i(B),S(ce),t&&i(Ct),t&&i(u),S(me),S(ge),S(X),S(he),S(be),S(Pe),S(we),S(ye),S(De),t&&i(Gt),t&&i(Z),S(Se),t&&i(Jt),t&&i(F),S($e)}}}const is={local:"parallel-sampling-of-diffusion-models",sections:[{local:"tips",title:"Tips"},{local:"diffusers.StableDiffusionParadigmsPipeline",title:"StableDiffusionParadigmsPipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"Parallel Sampling of Diffusion Models"};function ns(xe){return Wa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ps extends Za{constructor(g){super();Fa(this,g,ns,ts,za,{})}}export{ps as default,is as metadata};
