import{S as xn,i as Jn,s as In,e as s,k as r,w as D,t as o,M as kn,c as i,d as t,m as d,a as n,x as E,h as l,b as p,G as e,g as c,y as T,q as $,o as M,B as S,v as Gn,L as Cn}from"../../../chunks/vendor-hf-doc-builder.js";import{T as Sn}from"../../../chunks/Tip-hf-doc-builder.js";import{D as he}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Un}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Yt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Zn}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function jn(te){let _,v,w,m,y,b,x,L,ge,R,P,J,F,k,W,q,ae,G,C;return{c(){_=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.
`),v=s("p"),w=o("The two parameters to play with are "),m=s("code"),y=o("parallel"),b=o(" (batch size) and "),x=s("code"),L=o("tolerance"),ge=o("."),R=r(),P=s("ul"),J=s("li"),F=o(`If it fits in memory, for 1000-step DDPM you can aim for a batch size of around 100
(e.g. 8 GPUs and batch_per_device=12 to get parallel=96). Higher batch size
may not fit in memory, and lower batch size gives less parallelism.`),k=r(),W=s("li"),q=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 (e.g. 0.001).`),ae=r(),G=s("p"),C=o(`For 1000-step DDPM on 8 A100 GPUs, you can expect around a 3x speedup by StableDiffusionParadigmsPipeline instead of StableDiffusionPipeline
by setting parallel=80 and tolerance=0.1.`)},l(g){_=l(g,`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.
`),v=i(g,"P",{});var U=n(v);w=l(U,"The two parameters to play with are "),m=i(U,"CODE",{});var qe=n(m);y=l(qe,"parallel"),qe.forEach(t),b=l(U," (batch size) and "),x=i(U,"CODE",{});var be=n(x);L=l(be,"tolerance"),be.forEach(t),ge=l(U,"."),U.forEach(t),R=d(g),P=i(g,"UL",{});var Z=n(P);J=i(Z,"LI",{});var ze=n(J);F=l(ze,`If it fits in memory, for 1000-step DDPM you can aim for a batch size of around 100
(e.g. 8 GPUs and batch_per_device=12 to get parallel=96). Higher batch size
may not fit in memory, and lower batch size gives less parallelism.`),ze.forEach(t),k=d(Z),W=i(Z,"LI",{});var _e=n(W);q=l(_e,`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 (e.g. 0.001).`),_e.forEach(t),Z.forEach(t),ae=d(g),G=i(g,"P",{});var z=n(G);C=l(z,`For 1000-step DDPM on 8 A100 GPUs, you can expect around a 3x speedup by StableDiffusionParadigmsPipeline instead of StableDiffusionPipeline
by setting parallel=80 and tolerance=0.1.`),z.forEach(t)},m(g,U){c(g,_,U),c(g,v,U),e(v,w),e(v,m),e(m,y),e(v,b),e(v,x),e(x,L),e(v,ge),c(g,R,U),c(g,P,U),e(P,J),e(J,F),e(P,k),e(P,W),e(W,q),c(g,ae,U),c(g,G,U),e(G,C)},d(g){g&&t(_),g&&t(v),g&&t(R),g&&t(P),g&&t(ae),g&&t(G)}}}function Nn(te){let _,v,w;return{c(){_=o(`Diffusers also offers distributed inference support for generating multiple prompts
in parallel on multiple GPUs. Check out the docs [here](https://huggingface.co/docs/diffusers/main/en/training/distributed_inference).
`),v=s("p"),w=o("In contrast, this pipeline is designed for speeding up sampling of a single prompt (by using multiple GPUs).")},l(m){_=l(m,`Diffusers also offers distributed inference support for generating multiple prompts
in parallel on multiple GPUs. Check out the docs [here](https://huggingface.co/docs/diffusers/main/en/training/distributed_inference).
`),v=i(m,"P",{});var y=n(v);w=l(y,"In contrast, this pipeline is designed for speeding up sampling of a single prompt (by using multiple GPUs)."),y.forEach(t)},m(m,y){c(m,_,y),c(m,v,y),e(v,w)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IwbWFycyUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBwYXJhbGxlbCUzRG5ncHUlMjAqJTIwYmF0Y2hfcGVyX2RldmljZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAwKS5pbWFnZXMlNUIwJTVE",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-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tcHQlMkMlMjBwYXJhbGxlbCUzRG5ncHUlMjAqJTIwYmF0Y2hfcGVyX2RldmljZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAwKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDPMParallelScheduler
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionParadigmsPipeline

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>)

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

ngpu, batch_per_device = torch.cuda.device_count(), <span class="hljs-number">5</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)])

prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</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>]`}}),le=new Sn({props:{$$slots:{default:[jn]},$$scope:{ctx:te}}}),re=new Sn({props:{$$slots:{default:[Nn]},$$scope:{ctx:te}}}),Me=new Yt({}),Se=new he({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/v0.18.2/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> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.18.2/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.18.2/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/v0.18.2/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.18.2/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.18.2/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 details.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L62"}}),Ze=new he({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 the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#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 self.unet.config.sample_size * self.vae_scale_factor) &#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 also can 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/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;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,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 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.__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;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/v0.18.2/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,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;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</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 will ge 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, <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.__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, <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.__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 generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.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/v0.18.2/en/api/pipelines/stable_diffusion/overview#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 will be called every <code>callback_steps</code> steps during inference. The function will be
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 will be called. If not specified, the callback will be
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 under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/cross_attention.py" rel="nofollow">diffusers.cross_attention</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, torch.cumsum is evaluated using the CPU.`,name:"debug"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L521",returnDescription:`
<p><a
  href="/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),pe=new Zn({props:{anchor:"diffusers.StableDiffusionParadigmsPipeline.__call__.example",$$slots:{default:[An]},$$scope:{ctx:te}}}),je=new he({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionParadigmsPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L160"}}),Ae=new he({props:{name:"disable_vae_tiling",anchor:"diffusers.StableDiffusionParadigmsPipeline.disable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L178"}}),Ve=new he({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/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L212"}}),Le=new he({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L186"}}),Re=new he({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L150"}}),Fe=new he({props:{name:"enable_vae_tiling",anchor:"diffusers.StableDiffusionParadigmsPipeline.enable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py#L168"}}),{c(){_=s("meta"),v=r(),w=s("h1"),m=s("a"),y=s("span"),D(b.$$.fragment),x=r(),L=s("span"),ge=o("Parallel Sampling of Diffusion Models (ParaDiGMS)"),R=r(),P=s("h2"),J=s("a"),F=s("span"),D(k.$$.fragment),W=r(),q=s("span"),ae=o("Overview"),G=r(),C=s("p"),g=s("a"),U=o("Parallel Sampling of Diffusion Models"),qe=o(" by Andy Shih, Suneel Belkhale, Stefano Ermon, Dorsa Sadigh, Nima Anari."),be=r(),Z=s("p"),ze=o("The abstract of the paper is the following:"),_e=r(),z=s("p"),ft=s("em"),Ma=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."),Qt=r(),Oe=s("p"),Sa=o("Resources:"),Xt=r(),se=s("ul"),He=s("li"),ve=s("a"),Ua=o("Paper"),xa=o("."),Ja=r(),Ye=s("li"),we=s("a"),Ia=o("Original Code"),ka=o("."),Kt=r(),O=s("h2"),ie=s("a"),ct=s("span"),D(ye.$$.fragment),Ga=r(),ut=s("span"),Ca=o("Available Pipelines:"),ea=r(),ne=s("table"),mt=s("thead"),H=s("tr"),ht=s("th"),Za=o("Pipeline"),ja=r(),gt=s("th"),Na=o("Tasks"),Aa=r(),Qe=s("th"),Ba=o("Demo"),Va=r(),bt=s("tbody"),Y=s("tr"),_t=s("td"),Pe=s("a"),La=o("StableDiffusionParadigmsPipeline"),Ra=r(),vt=s("td"),wt=s("em"),Fa=o("Faster Text-to-Image Generation"),Wa=r(),yt=s("td"),ta=r(),j=s("p"),qa=o("This pipeline was contributed by "),De=s("a"),Pt=s("code"),za=o("AndyShih12"),Oa=o(" in this "),Ee=s("a"),Ha=o("PR"),Ya=o("."),aa=r(),Q=s("h2"),oe=s("a"),Dt=s("span"),D(Te.$$.fragment),Qa=r(),Et=s("span"),Xa=o("Usage example"),sa=r(),D($e.$$.fragment),ia=r(),D(le.$$.fragment),na=r(),D(re.$$.fragment),oa=r(),X=s("h2"),de=s("a"),Tt=s("span"),D(Me.$$.fragment),Ka=r(),$t=s("span"),es=o("StableDiffusionParadigmsPipeline"),la=r(),u=s("div"),D(Se.$$.fragment),ts=r(),Ue=s("p"),as=o("Parallelized version of StableDiffusionPipeline, based on the paper "),xe=s("a"),ss=o("https://arxiv.org/abs/2305.16317"),is=o(` This pipeline
parallelizes the denoising steps to generate a single image faster (more akin to model parallelism).`),ns=r(),Mt=s("p"),os=o("Pipeline for text-to-image generation using Stable Diffusion."),ls=r(),Je=s("p"),rs=o("This model inherits from "),Xe=s("a"),ds=o("DiffusionPipeline"),ps=o(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),fs=r(),St=s("p"),cs=o("In addition the pipeline inherits the following loading methods:"),us=r(),K=s("ul"),Ie=s("li"),Ut=s("em"),ms=o("Textual-Inversion"),hs=o(": "),Ke=s("a"),gs=o("loaders.TextualInversionLoaderMixin.load_textual_inversion()"),bs=r(),ke=s("li"),xt=s("em"),_s=o("LoRA"),vs=o(": "),et=s("a"),ws=o("loaders.LoraLoaderMixin.load_lora_weights()"),ys=r(),Ge=s("li"),Jt=s("em"),Ps=o("Ckpt"),Ds=o(": "),tt=s("a"),Es=o("loaders.FromSingleFileMixin.from_single_file()"),Ts=r(),It=s("p"),$s=o("as well as the following saving methods:"),Ms=r(),kt=s("ul"),Ce=s("li"),Gt=s("em"),Ss=o("LoRA"),Us=o(": "),at=s("a"),xs=o("loaders.LoraLoaderMixin.save_lora_weights()"),Js=r(),N=s("div"),D(Ze.$$.fragment),Is=r(),Ct=s("p"),ks=o("Function invoked when calling the pipeline for generation."),Gs=r(),D(pe.$$.fragment),Cs=r(),fe=s("div"),D(je.$$.fragment),Zs=r(),Ne=s("p"),js=o("Disable sliced VAE decoding. If "),Zt=s("code"),Ns=o("enable_vae_slicing"),As=o(` was previously invoked, this method will go back to
computing decoding in one step.`),Bs=r(),ce=s("div"),D(Ae.$$.fragment),Vs=r(),Be=s("p"),Ls=o("Disable tiled VAE decoding. If "),jt=s("code"),Rs=o("enable_vae_tiling"),Fs=o(` was previously invoked, this method will go back to
computing decoding in one step.`),Ws=r(),ue=s("div"),D(Ve.$$.fragment),qs=r(),I=s("p"),zs=o(`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Nt=s("code"),Os=o("enable_sequential_cpu_offload"),Hs=o(", this method moves one whole model at a time to the GPU when its "),At=s("code"),Ys=o("forward"),Qs=o(`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Bt=s("code"),Xs=o("enable_sequential_cpu_offload"),Ks=o(", but performance is much better due to the iterative execution of the "),Vt=s("code"),ei=o("unet"),ti=o("."),ai=r(),me=s("div"),D(Le.$$.fragment),si=r(),ee=s("p"),ii=o(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Lt=s("code"),ni=o("torch.device('meta') and loaded to GPU only when their specific submodule has its "),oi=o("forward"),Rt=s("code"),li=o("method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),ri=o("enable_model_cpu_offload`, but performance is lower."),di=r(),A=s("div"),D(Re.$$.fragment),pi=r(),Ft=s("p"),fi=o("Enable sliced VAE decoding."),ci=r(),Wt=s("p"),ui=o(`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.`),mi=r(),B=s("div"),D(Fe.$$.fragment),hi=r(),qt=s("p"),gi=o("Enable tiled VAE decoding."),bi=r(),zt=s("p"),_i=o(`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 to save a large amount of memory and to allow the processing of larger images.`),this.h()},l(a){const f=kn('[data-svelte="svelte-1phssyn"]',document.head);_=i(f,"META",{name:!0,content:!0}),f.forEach(t),v=d(a),w=i(a,"H1",{class:!0});var We=n(w);m=i(We,"A",{id:!0,class:!0,href:!0});var Ot=n(m);y=i(Ot,"SPAN",{});var Ht=n(y);E(b.$$.fragment,Ht),Ht.forEach(t),Ot.forEach(t),x=d(We),L=i(We,"SPAN",{});var Pi=n(L);ge=l(Pi,"Parallel Sampling of Diffusion Models (ParaDiGMS)"),Pi.forEach(t),We.forEach(t),R=d(a),P=i(a,"H2",{class:!0});var da=n(P);J=i(da,"A",{id:!0,class:!0,href:!0});var Di=n(J);F=i(Di,"SPAN",{});var Ei=n(F);E(k.$$.fragment,Ei),Ei.forEach(t),Di.forEach(t),W=d(da),q=i(da,"SPAN",{});var Ti=n(q);ae=l(Ti,"Overview"),Ti.forEach(t),da.forEach(t),G=d(a),C=i(a,"P",{});var vi=n(C);g=i(vi,"A",{href:!0,rel:!0});var $i=n(g);U=l($i,"Parallel Sampling of Diffusion Models"),$i.forEach(t),qe=l(vi," by Andy Shih, Suneel Belkhale, Stefano Ermon, Dorsa Sadigh, Nima Anari."),vi.forEach(t),be=d(a),Z=i(a,"P",{});var Mi=n(Z);ze=l(Mi,"The abstract of the paper is the following:"),Mi.forEach(t),_e=d(a),z=i(a,"P",{});var Si=n(z);ft=i(Si,"EM",{});var Ui=n(ft);Ma=l(Ui,"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."),Ui.forEach(t),Si.forEach(t),Qt=d(a),Oe=i(a,"P",{});var xi=n(Oe);Sa=l(xi,"Resources:"),xi.forEach(t),Xt=d(a),se=i(a,"UL",{});var pa=n(se);He=i(pa,"LI",{});var wi=n(He);ve=i(wi,"A",{href:!0,rel:!0});var Ji=n(ve);Ua=l(Ji,"Paper"),Ji.forEach(t),xa=l(wi,"."),wi.forEach(t),Ja=d(pa),Ye=i(pa,"LI",{});var yi=n(Ye);we=i(yi,"A",{href:!0,rel:!0});var Ii=n(we);Ia=l(Ii,"Original Code"),Ii.forEach(t),ka=l(yi,"."),yi.forEach(t),pa.forEach(t),Kt=d(a),O=i(a,"H2",{class:!0});var fa=n(O);ie=i(fa,"A",{id:!0,class:!0,href:!0});var ki=n(ie);ct=i(ki,"SPAN",{});var Gi=n(ct);E(ye.$$.fragment,Gi),Gi.forEach(t),ki.forEach(t),Ga=d(fa),ut=i(fa,"SPAN",{});var Ci=n(ut);Ca=l(Ci,"Available Pipelines:"),Ci.forEach(t),fa.forEach(t),ea=d(a),ne=i(a,"TABLE",{});var ca=n(ne);mt=i(ca,"THEAD",{});var Zi=n(mt);H=i(Zi,"TR",{});var st=n(H);ht=i(st,"TH",{});var ji=n(ht);Za=l(ji,"Pipeline"),ji.forEach(t),ja=d(st),gt=i(st,"TH",{});var Ni=n(gt);Na=l(Ni,"Tasks"),Ni.forEach(t),Aa=d(st),Qe=i(st,"TH",{align:!0});var Ai=n(Qe);Ba=l(Ai,"Demo"),Ai.forEach(t),st.forEach(t),Zi.forEach(t),Va=d(ca),bt=i(ca,"TBODY",{});var Bi=n(bt);Y=i(Bi,"TR",{});var it=n(Y);_t=i(it,"TD",{});var Vi=n(_t);Pe=i(Vi,"A",{href:!0,rel:!0});var Li=n(Pe);La=l(Li,"StableDiffusionParadigmsPipeline"),Li.forEach(t),Vi.forEach(t),Ra=d(it),vt=i(it,"TD",{});var Ri=n(vt);wt=i(Ri,"EM",{});var Fi=n(wt);Fa=l(Fi,"Faster Text-to-Image Generation"),Fi.forEach(t),Ri.forEach(t),Wa=d(it),yt=i(it,"TD",{align:!0}),n(yt).forEach(t),it.forEach(t),Bi.forEach(t),ca.forEach(t),ta=d(a),j=i(a,"P",{});var nt=n(j);qa=l(nt,"This pipeline was contributed by "),De=i(nt,"A",{href:!0,rel:!0});var Wi=n(De);Pt=i(Wi,"CODE",{});var qi=n(Pt);za=l(qi,"AndyShih12"),qi.forEach(t),Wi.forEach(t),Oa=l(nt," in this "),Ee=i(nt,"A",{href:!0,rel:!0});var zi=n(Ee);Ha=l(zi,"PR"),zi.forEach(t),Ya=l(nt,"."),nt.forEach(t),aa=d(a),Q=i(a,"H2",{class:!0});var ua=n(Q);oe=i(ua,"A",{id:!0,class:!0,href:!0});var Oi=n(oe);Dt=i(Oi,"SPAN",{});var Hi=n(Dt);E(Te.$$.fragment,Hi),Hi.forEach(t),Oi.forEach(t),Qa=d(ua),Et=i(ua,"SPAN",{});var Yi=n(Et);Xa=l(Yi,"Usage example"),Yi.forEach(t),ua.forEach(t),sa=d(a),E($e.$$.fragment,a),ia=d(a),E(le.$$.fragment,a),na=d(a),E(re.$$.fragment,a),oa=d(a),X=i(a,"H2",{class:!0});var ma=n(X);de=i(ma,"A",{id:!0,class:!0,href:!0});var Qi=n(de);Tt=i(Qi,"SPAN",{});var Xi=n(Tt);E(Me.$$.fragment,Xi),Xi.forEach(t),Qi.forEach(t),Ka=d(ma),$t=i(ma,"SPAN",{});var Ki=n($t);es=l(Ki,"StableDiffusionParadigmsPipeline"),Ki.forEach(t),ma.forEach(t),la=d(a),u=i(a,"DIV",{class:!0});var h=n(u);E(Se.$$.fragment,h),ts=d(h),Ue=i(h,"P",{});var ha=n(Ue);as=l(ha,"Parallelized version of StableDiffusionPipeline, based on the paper "),xe=i(ha,"A",{href:!0,rel:!0});var en=n(xe);ss=l(en,"https://arxiv.org/abs/2305.16317"),en.forEach(t),is=l(ha,` This pipeline
parallelizes the denoising steps to generate a single image faster (more akin to model parallelism).`),ha.forEach(t),ns=d(h),Mt=i(h,"P",{});var tn=n(Mt);os=l(tn,"Pipeline for text-to-image generation using Stable Diffusion."),tn.forEach(t),ls=d(h),Je=i(h,"P",{});var ga=n(Je);rs=l(ga,"This model inherits from "),Xe=i(ga,"A",{href:!0});var an=n(Xe);ds=l(an,"DiffusionPipeline"),an.forEach(t),ps=l(ga,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),ga.forEach(t),fs=d(h),St=i(h,"P",{});var sn=n(St);cs=l(sn,"In addition the pipeline inherits the following loading methods:"),sn.forEach(t),us=d(h),K=i(h,"UL",{});var ot=n(K);Ie=i(ot,"LI",{});var ba=n(Ie);Ut=i(ba,"EM",{});var nn=n(Ut);ms=l(nn,"Textual-Inversion"),nn.forEach(t),hs=l(ba,": "),Ke=i(ba,"A",{href:!0});var on=n(Ke);gs=l(on,"loaders.TextualInversionLoaderMixin.load_textual_inversion()"),on.forEach(t),ba.forEach(t),bs=d(ot),ke=i(ot,"LI",{});var _a=n(ke);xt=i(_a,"EM",{});var ln=n(xt);_s=l(ln,"LoRA"),ln.forEach(t),vs=l(_a,": "),et=i(_a,"A",{href:!0});var rn=n(et);ws=l(rn,"loaders.LoraLoaderMixin.load_lora_weights()"),rn.forEach(t),_a.forEach(t),ys=d(ot),Ge=i(ot,"LI",{});var va=n(Ge);Jt=i(va,"EM",{});var dn=n(Jt);Ps=l(dn,"Ckpt"),dn.forEach(t),Ds=l(va,": "),tt=i(va,"A",{href:!0});var pn=n(tt);Es=l(pn,"loaders.FromSingleFileMixin.from_single_file()"),pn.forEach(t),va.forEach(t),ot.forEach(t),Ts=d(h),It=i(h,"P",{});var fn=n(It);$s=l(fn,"as well as the following saving methods:"),fn.forEach(t),Ms=d(h),kt=i(h,"UL",{});var cn=n(kt);Ce=i(cn,"LI",{});var wa=n(Ce);Gt=i(wa,"EM",{});var un=n(Gt);Ss=l(un,"LoRA"),un.forEach(t),Us=l(wa,": "),at=i(wa,"A",{href:!0});var mn=n(at);xs=l(mn,"loaders.LoraLoaderMixin.save_lora_weights()"),mn.forEach(t),wa.forEach(t),cn.forEach(t),Js=d(h),N=i(h,"DIV",{class:!0});var lt=n(N);E(Ze.$$.fragment,lt),Is=d(lt),Ct=i(lt,"P",{});var hn=n(Ct);ks=l(hn,"Function invoked when calling the pipeline for generation."),hn.forEach(t),Gs=d(lt),E(pe.$$.fragment,lt),lt.forEach(t),Cs=d(h),fe=i(h,"DIV",{class:!0});var ya=n(fe);E(je.$$.fragment,ya),Zs=d(ya),Ne=i(ya,"P",{});var Pa=n(Ne);js=l(Pa,"Disable sliced VAE decoding. If "),Zt=i(Pa,"CODE",{});var gn=n(Zt);Ns=l(gn,"enable_vae_slicing"),gn.forEach(t),As=l(Pa,` was previously invoked, this method will go back to
computing decoding in one step.`),Pa.forEach(t),ya.forEach(t),Bs=d(h),ce=i(h,"DIV",{class:!0});var Da=n(ce);E(Ae.$$.fragment,Da),Vs=d(Da),Be=i(Da,"P",{});var Ea=n(Be);Ls=l(Ea,"Disable tiled VAE decoding. If "),jt=i(Ea,"CODE",{});var bn=n(jt);Rs=l(bn,"enable_vae_tiling"),bn.forEach(t),Fs=l(Ea,` was previously invoked, this method will go back to
computing decoding in one step.`),Ea.forEach(t),Da.forEach(t),Ws=d(h),ue=i(h,"DIV",{class:!0});var Ta=n(ue);E(Ve.$$.fragment,Ta),qs=d(Ta),I=i(Ta,"P",{});var V=n(I);zs=l(V,`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Nt=i(V,"CODE",{});var _n=n(Nt);Os=l(_n,"enable_sequential_cpu_offload"),_n.forEach(t),Hs=l(V,", this method moves one whole model at a time to the GPU when its "),At=i(V,"CODE",{});var vn=n(At);Ys=l(vn,"forward"),vn.forEach(t),Qs=l(V,`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Bt=i(V,"CODE",{});var wn=n(Bt);Xs=l(wn,"enable_sequential_cpu_offload"),wn.forEach(t),Ks=l(V,", but performance is much better due to the iterative execution of the "),Vt=i(V,"CODE",{});var yn=n(Vt);ei=l(yn,"unet"),yn.forEach(t),ti=l(V,"."),V.forEach(t),Ta.forEach(t),ai=d(h),me=i(h,"DIV",{class:!0});var $a=n(me);E(Le.$$.fragment,$a),si=d($a),ee=i($a,"P",{});var rt=n(ee);ii=l(rt,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Lt=i(rt,"CODE",{});var Pn=n(Lt);ni=l(Pn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Pn.forEach(t),oi=l(rt,"forward"),Rt=i(rt,"CODE",{});var Dn=n(Rt);li=l(Dn,"method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),Dn.forEach(t),ri=l(rt,"enable_model_cpu_offload`, but performance is lower."),rt.forEach(t),$a.forEach(t),di=d(h),A=i(h,"DIV",{class:!0});var dt=n(A);E(Re.$$.fragment,dt),pi=d(dt),Ft=i(dt,"P",{});var En=n(Ft);fi=l(En,"Enable sliced VAE decoding."),En.forEach(t),ci=d(dt),Wt=i(dt,"P",{});var Tn=n(Wt);ui=l(Tn,`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.`),Tn.forEach(t),dt.forEach(t),mi=d(h),B=i(h,"DIV",{class:!0});var pt=n(B);E(Fe.$$.fragment,pt),hi=d(pt),qt=i(pt,"P",{});var $n=n(qt);gi=l($n,"Enable tiled VAE decoding."),$n.forEach(t),bi=d(pt),zt=i(pt,"P",{});var Mn=n(zt);_i=l(Mn,`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 to save a large amount of memory and to allow the processing of larger images.`),Mn.forEach(t),pt.forEach(t),h.forEach(t),this.h()},h(){p(_,"name","hf:doc:metadata"),p(_,"content",JSON.stringify(Vn)),p(m,"id","parallel-sampling-of-diffusion-models-paradigms"),p(m,"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(m,"href","#parallel-sampling-of-diffusion-models-paradigms"),p(w,"class","relative group"),p(J,"id","overview"),p(J,"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(J,"href","#overview"),p(P,"class","relative group"),p(g,"href","https://arxiv.org/abs/2305.16317"),p(g,"rel","nofollow"),p(ve,"href","https://arxiv.org/abs/2305.16317"),p(ve,"rel","nofollow"),p(we,"href","https://github.com/AndyShih12/paradigms"),p(we,"rel","nofollow"),p(ie,"id","available-pipelines"),p(ie,"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(ie,"href","#available-pipelines"),p(O,"class","relative group"),p(Qe,"align","center"),p(Pe,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py"),p(Pe,"rel","nofollow"),p(yt,"align","center"),p(De,"href","https://github.com/AndyShih12"),p(De,"rel","nofollow"),p(Ee,"href","https://github.com/huggingface/diffusers/pull/3716/"),p(Ee,"rel","nofollow"),p(oe,"id","usage-example"),p(oe,"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(oe,"href","#usage-example"),p(Q,"class","relative group"),p(de,"id","diffusers.StableDiffusionParadigmsPipeline"),p(de,"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(de,"href","#diffusers.StableDiffusionParadigmsPipeline"),p(X,"class","relative group"),p(xe,"href","https://arxiv.org/abs/2305.16317"),p(xe,"rel","nofollow"),p(Xe,"href","/docs/diffusers/v0.18.2/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(Ke,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_textual_inversion"),p(et,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(tt,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.from_single_file"),p(at,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.save_lora_weights"),p(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(B,"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")},m(a,f){e(document.head,_),c(a,v,f),c(a,w,f),e(w,m),e(m,y),T(b,y,null),e(w,x),e(w,L),e(L,ge),c(a,R,f),c(a,P,f),e(P,J),e(J,F),T(k,F,null),e(P,W),e(P,q),e(q,ae),c(a,G,f),c(a,C,f),e(C,g),e(g,U),e(C,qe),c(a,be,f),c(a,Z,f),e(Z,ze),c(a,_e,f),c(a,z,f),e(z,ft),e(ft,Ma),c(a,Qt,f),c(a,Oe,f),e(Oe,Sa),c(a,Xt,f),c(a,se,f),e(se,He),e(He,ve),e(ve,Ua),e(He,xa),e(se,Ja),e(se,Ye),e(Ye,we),e(we,Ia),e(Ye,ka),c(a,Kt,f),c(a,O,f),e(O,ie),e(ie,ct),T(ye,ct,null),e(O,Ga),e(O,ut),e(ut,Ca),c(a,ea,f),c(a,ne,f),e(ne,mt),e(mt,H),e(H,ht),e(ht,Za),e(H,ja),e(H,gt),e(gt,Na),e(H,Aa),e(H,Qe),e(Qe,Ba),e(ne,Va),e(ne,bt),e(bt,Y),e(Y,_t),e(_t,Pe),e(Pe,La),e(Y,Ra),e(Y,vt),e(vt,wt),e(wt,Fa),e(Y,Wa),e(Y,yt),c(a,ta,f),c(a,j,f),e(j,qa),e(j,De),e(De,Pt),e(Pt,za),e(j,Oa),e(j,Ee),e(Ee,Ha),e(j,Ya),c(a,aa,f),c(a,Q,f),e(Q,oe),e(oe,Dt),T(Te,Dt,null),e(Q,Qa),e(Q,Et),e(Et,Xa),c(a,sa,f),T($e,a,f),c(a,ia,f),T(le,a,f),c(a,na,f),T(re,a,f),c(a,oa,f),c(a,X,f),e(X,de),e(de,Tt),T(Me,Tt,null),e(X,Ka),e(X,$t),e($t,es),c(a,la,f),c(a,u,f),T(Se,u,null),e(u,ts),e(u,Ue),e(Ue,as),e(Ue,xe),e(xe,ss),e(Ue,is),e(u,ns),e(u,Mt),e(Mt,os),e(u,ls),e(u,Je),e(Je,rs),e(Je,Xe),e(Xe,ds),e(Je,ps),e(u,fs),e(u,St),e(St,cs),e(u,us),e(u,K),e(K,Ie),e(Ie,Ut),e(Ut,ms),e(Ie,hs),e(Ie,Ke),e(Ke,gs),e(K,bs),e(K,ke),e(ke,xt),e(xt,_s),e(ke,vs),e(ke,et),e(et,ws),e(K,ys),e(K,Ge),e(Ge,Jt),e(Jt,Ps),e(Ge,Ds),e(Ge,tt),e(tt,Es),e(u,Ts),e(u,It),e(It,$s),e(u,Ms),e(u,kt),e(kt,Ce),e(Ce,Gt),e(Gt,Ss),e(Ce,Us),e(Ce,at),e(at,xs),e(u,Js),e(u,N),T(Ze,N,null),e(N,Is),e(N,Ct),e(Ct,ks),e(N,Gs),T(pe,N,null),e(u,Cs),e(u,fe),T(je,fe,null),e(fe,Zs),e(fe,Ne),e(Ne,js),e(Ne,Zt),e(Zt,Ns),e(Ne,As),e(u,Bs),e(u,ce),T(Ae,ce,null),e(ce,Vs),e(ce,Be),e(Be,Ls),e(Be,jt),e(jt,Rs),e(Be,Fs),e(u,Ws),e(u,ue),T(Ve,ue,null),e(ue,qs),e(ue,I),e(I,zs),e(I,Nt),e(Nt,Os),e(I,Hs),e(I,At),e(At,Ys),e(I,Qs),e(I,Bt),e(Bt,Xs),e(I,Ks),e(I,Vt),e(Vt,ei),e(I,ti),e(u,ai),e(u,me),T(Le,me,null),e(me,si),e(me,ee),e(ee,ii),e(ee,Lt),e(Lt,ni),e(ee,oi),e(ee,Rt),e(Rt,li),e(ee,ri),e(u,di),e(u,A),T(Re,A,null),e(A,pi),e(A,Ft),e(Ft,fi),e(A,ci),e(A,Wt),e(Wt,ui),e(u,mi),e(u,B),T(Fe,B,null),e(B,hi),e(B,qt),e(qt,gi),e(B,bi),e(B,zt),e(zt,_i),ra=!0},p(a,[f]){const We={};f&2&&(We.$$scope={dirty:f,ctx:a}),le.$set(We);const Ot={};f&2&&(Ot.$$scope={dirty:f,ctx:a}),re.$set(Ot);const Ht={};f&2&&(Ht.$$scope={dirty:f,ctx:a}),pe.$set(Ht)},i(a){ra||($(b.$$.fragment,a),$(k.$$.fragment,a),$(ye.$$.fragment,a),$(Te.$$.fragment,a),$($e.$$.fragment,a),$(le.$$.fragment,a),$(re.$$.fragment,a),$(Me.$$.fragment,a),$(Se.$$.fragment,a),$(Ze.$$.fragment,a),$(pe.$$.fragment,a),$(je.$$.fragment,a),$(Ae.$$.fragment,a),$(Ve.$$.fragment,a),$(Le.$$.fragment,a),$(Re.$$.fragment,a),$(Fe.$$.fragment,a),ra=!0)},o(a){M(b.$$.fragment,a),M(k.$$.fragment,a),M(ye.$$.fragment,a),M(Te.$$.fragment,a),M($e.$$.fragment,a),M(le.$$.fragment,a),M(re.$$.fragment,a),M(Me.$$.fragment,a),M(Se.$$.fragment,a),M(Ze.$$.fragment,a),M(pe.$$.fragment,a),M(je.$$.fragment,a),M(Ae.$$.fragment,a),M(Ve.$$.fragment,a),M(Le.$$.fragment,a),M(Re.$$.fragment,a),M(Fe.$$.fragment,a),ra=!1},d(a){t(_),a&&t(v),a&&t(w),S(b),a&&t(R),a&&t(P),S(k),a&&t(G),a&&t(C),a&&t(be),a&&t(Z),a&&t(_e),a&&t(z),a&&t(Qt),a&&t(Oe),a&&t(Xt),a&&t(se),a&&t(Kt),a&&t(O),S(ye),a&&t(ea),a&&t(ne),a&&t(ta),a&&t(j),a&&t(aa),a&&t(Q),S(Te),a&&t(sa),S($e,a),a&&t(ia),S(le,a),a&&t(na),S(re,a),a&&t(oa),a&&t(X),S(Me),a&&t(la),a&&t(u),S(Se),S(Ze),S(pe),S(je),S(Ae),S(Ve),S(Le),S(Re),S(Fe)}}}const Vn={local:"parallel-sampling-of-diffusion-models-paradigms",sections:[{local:"overview",title:"Overview"},{local:"available-pipelines",title:"Available Pipelines:"},{local:"usage-example",title:"Usage example"},{local:"diffusers.StableDiffusionParadigmsPipeline",title:"StableDiffusionParadigmsPipeline"}],title:"Parallel Sampling of Diffusion Models (ParaDiGMS)"};function Ln(te){return Gn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Hn extends xn{constructor(_){super();Jn(this,_,Ln,Bn,In,{})}}export{Hn as default,Vn as metadata};
