Buckets:

rtrm's picture
download
raw
82.6 kB
<meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{&quot;local&quot;:&quot;accelerated-pytorch-20-support-in-diffusers&quot;,&quot;sections&quot;:[{&quot;local&quot;:&quot;installation&quot;,&quot;title&quot;:&quot;Installation&quot;},{&quot;local&quot;:&quot;using-accelerated-transformers-and-torchcompile&quot;,&quot;title&quot;:&quot;Using accelerated transformers and `torch.compile`.&quot;},{&quot;local&quot;:&quot;benchmark&quot;,&quot;sections&quot;:[{&quot;local&quot;:&quot;benchmarking-code&quot;,&quot;sections&quot;:[{&quot;local&quot;:&quot;stable-diffusion-texttoimage&quot;,&quot;title&quot;:&quot;Stable Diffusion text-to-image &quot;},{&quot;local&quot;:&quot;stable-diffusion-imagetoimage&quot;,&quot;title&quot;:&quot;Stable Diffusion image-to-image &quot;},{&quot;local&quot;:&quot;stable-diffusion-inpainting&quot;,&quot;title&quot;:&quot;Stable Diffusion - inpainting&quot;},{&quot;local&quot;:&quot;controlnet&quot;,&quot;title&quot;:&quot;ControlNet &quot;},{&quot;local&quot;:&quot;if-texttoimage-upscaling&quot;,&quot;title&quot;:&quot;IF text-to-image + upscaling&quot;}],&quot;title&quot;:&quot;Benchmarking code &quot;},{&quot;local&quot;:&quot;a100-batch-size-1&quot;,&quot;title&quot;:&quot;A100 (batch size: 1)&quot;},{&quot;local&quot;:&quot;a100-batch-size-4&quot;,&quot;title&quot;:&quot;A100 (batch size: 4)&quot;},{&quot;local&quot;:&quot;a100-batch-size-16&quot;,&quot;title&quot;:&quot;A100 (batch size: 16)&quot;},{&quot;local&quot;:&quot;v100-batch-size-1&quot;,&quot;title&quot;:&quot;V100 (batch size: 1)&quot;},{&quot;local&quot;:&quot;v100-batch-size-4&quot;,&quot;title&quot;:&quot;V100 (batch size: 4)&quot;},{&quot;local&quot;:&quot;v100-batch-size-16&quot;,&quot;title&quot;:&quot;V100 (batch size: 16)&quot;},{&quot;local&quot;:&quot;t4-batch-size-1&quot;,&quot;title&quot;:&quot;T4 (batch size: 1)&quot;},{&quot;local&quot;:&quot;t4-batch-size-4&quot;,&quot;title&quot;:&quot;T4 (batch size: 4)&quot;},{&quot;local&quot;:&quot;t4-batch-size-16&quot;,&quot;title&quot;:&quot;T4 (batch size: 16)&quot;},{&quot;local&quot;:&quot;rtx-3090-batch-size-1&quot;,&quot;title&quot;:&quot;RTX 3090 (batch size: 1)&quot;},{&quot;local&quot;:&quot;rtx-3090-batch-size-4&quot;,&quot;title&quot;:&quot;RTX 3090 (batch size: 4)&quot;},{&quot;local&quot;:&quot;rtx-3090-batch-size-16&quot;,&quot;title&quot;:&quot;RTX 3090 (batch size: 16)&quot;},{&quot;local&quot;:&quot;rtx-4090-batch-size-1&quot;,&quot;title&quot;:&quot;RTX 4090 (batch size: 1)&quot;},{&quot;local&quot;:&quot;rtx-4090-batch-size-4&quot;,&quot;title&quot;:&quot;RTX 4090 (batch size: 4)&quot;},{&quot;local&quot;:&quot;rtx-4090-batch-size-16&quot;,&quot;title&quot;:&quot;RTX 4090 (batch size: 16)&quot;}],&quot;title&quot;:&quot;Benchmark&quot;},{&quot;local&quot;:&quot;notes&quot;,&quot;title&quot;:&quot;Notes &quot;}],&quot;title&quot;:&quot;Accelerated PyTorch 2.0 support in Diffusers&quot;}" data-svelte="svelte-1phssyn">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/assets/pages/__layout.svelte-hf-doc-builder.css">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/start-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/chunks/vendor-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/chunks/paths-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/pages/__layout.svelte-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/pages/optimization/torch2.0.mdx-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/chunks/IconCopyLink-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/diffusers/v0.18.2/en/_app/chunks/CodeBlock-hf-doc-builder.js">
<h1 class="relative group"><a id="accelerated-pytorch-20-support-in-diffusers" 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" href="#accelerated-pytorch-20-support-in-diffusers"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Accelerated PyTorch 2.0 support in Diffusers
</span></h1>
<p>Starting from version <code>0.13.0</code>, Diffusers supports the latest optimization from <a href="https://pytorch.org/get-started/pytorch-2.0/" rel="nofollow">PyTorch 2.0</a>. These include:</p>
<ol><li>Support for accelerated transformers implementation with memory-efficient attention – no extra dependencies (such as <code>xformers</code>) required.</li>
<li><a href="https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html" rel="nofollow">torch.compile</a> support for extra performance boost when individual models are compiled.</li></ol>
<h2 class="relative group"><a id="installation" 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" href="#installation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Installation
</span></h2>
<p>To benefit from the accelerated attention implementation and <code>torch.compile()</code>, you just need to install the latest versions of PyTorch 2.0 from pip, and make sure you are on diffusers 0.13.0 or later. As explained below, diffusers automatically uses the optimized attention processor (<a href="https://github.com/huggingface/diffusers/blob/1a5797c6d4491a879ea5285c4efc377664e0332d/src/diffusers/models/attention_processor.py#L798" rel="nofollow"><code>AttnProcessor2_0</code></a>) (but not <code>torch.compile()</code>)
when PyTorch 2.0 is available.</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->pip install --upgrade torch diffusers<!-- HTML_TAG_END --></pre></div>
<h2 class="relative group"><a id="using-accelerated-transformers-and-torchcompile" 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" href="#using-accelerated-transformers-and-torchcompile"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Using accelerated transformers and <code>torch.compile</code>.
</span></h2>
<ol><li><p><strong>Accelerated Transformers implementation</strong></p>
<p>PyTorch 2.0 includes an optimized and memory-efficient attention implementation through the <a href="https://pytorch.org/docs/master/generated/torch.nn.functional.scaled_dot_product_attention" rel="nofollow"><code>torch.nn.functional.scaled_dot_product_attention</code></a> function, which automatically enables several optimizations depending on the inputs and the GPU type. This is similar to the <code>memory_efficient_attention</code> from <a href="https://github.com/facebookresearch/xformers" rel="nofollow">xFormers</a>, but built natively into PyTorch. </p>
<p>These optimizations will be enabled by default in Diffusers if PyTorch 2.0 is installed and if <code>torch.nn.functional.scaled_dot_product_attention</code> is available. To use it, just install <code>torch 2.0</code> as suggested above and simply use the pipeline. For example:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
image = pipe(prompt).images[<span class="hljs-number">0</span>]<!-- HTML_TAG_END --></pre></div>
<p>If you want to enable it explicitly (which is not required), you can do so as shown below.</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->import torch
from diffusers import DiffusionPipeline
<span class="hljs-addition">+ from diffusers.models.attention_processor import AttnProcessor2_0</span>
pipe = DiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;, torch_dtype=torch.float16).to(&quot;cuda&quot;)
<span class="hljs-addition">+ pipe.unet.set_attn_processor(AttnProcessor2_0())</span>
prompt = &quot;a photo of an astronaut riding a horse on mars&quot;
image = pipe(prompt).images[0]<!-- HTML_TAG_END --></pre></div>
<p>This should be as fast and memory efficient as <code>xFormers</code>. More details <a href="#benchmark">in our benchmark</a>.</p>
<p>It is possible to revert to the vanilla attention processor (<a href="https://github.com/huggingface/diffusers/blob/1a5797c6d4491a879ea5285c4efc377664e0332d/src/diffusers/models/attention_processor.py#L402" rel="nofollow"><code>AttnProcessor</code></a>), which can be helpful to make the pipeline more deterministic, or if you need to convert a fine-tuned model to other formats such as <a href="https://huggingface.co/docs/diffusers/v0.16.0/en/optimization/coreml#how-to-run-stable-diffusion-with-core-ml" rel="nofollow">Core ML</a>. To use the normal attention processor you can use the <a href="/docs/diffusers/v0.18.2/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel.set_default_attn_processor">set_default_attn_processor()</a> function:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> diffusers.models.attention_processor <span class="hljs-keyword">import</span> AttnProcessor
pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.set_default_attn_processor()
prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
image = pipe(prompt).images[<span class="hljs-number">0</span>]<!-- HTML_TAG_END --></pre></div></li>
<li><p><strong>torch.compile</strong></p>
<p>To get an additional speedup, we can use the new <code>torch.compile</code> feature. Since the UNet of the pipeline is usually the most computationally expensive, we wrap the <code>unet</code> with <code>torch.compile</code> leaving rest of the sub-models (text encoder and VAE) as is. For more information and different options, refer to the
<a href="https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html" rel="nofollow">torch compile docs</a>.</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
images = pipe(prompt, num_inference_steps=steps, num_images_per_prompt=batch_size).images<!-- HTML_TAG_END --></pre></div>
<p>Depending on the type of GPU, <code>compile()</code> can yield between <strong>5% - 300%</strong> of <em>additional speed-up</em> over the accelerated transformer optimizations. Note, however, that compilation is able to squeeze more performance improvements in more recent GPU architectures such as Ampere (A100, 3090), Ada (4090) and Hopper (H100).</p>
<p>Compilation takes some time to complete, so it is best suited for situations where you need to prepare your pipeline once and then perform the same type of inference operations multiple times. Calling the compiled pipeline on a different image size will re-trigger compilation which can be expensive.</p></li></ol>
<h2 class="relative group"><a id="benchmark" 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" href="#benchmark"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Benchmark
</span></h2>
<p>We conducted a comprehensive benchmark with PyTorch 2.0’s efficient attention implementation and <code>torch.compile</code> across different GPUs and batch sizes for five of our most used pipelines. We used <code>diffusers 0.17.0.dev0</code>, which <a href="https://github.com/huggingface/diffusers/pull/3313" rel="nofollow">makes sure <code>torch.compile()</code> is leveraged optimally</a>.</p>
<h3 class="relative group"><a id="benchmarking-code" 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" href="#benchmarking-code"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Benchmarking code
</span></h3>
<h4 class="relative group"><a id="stable-diffusion-texttoimage" 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" href="#stable-diffusion-texttoimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Stable Diffusion text-to-image
</span></h4>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch
path = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
run_compile = <span class="hljs-literal">True</span> <span class="hljs-comment"># Set True / False</span>
pipe = DiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.to(memory_format=torch.channels_last)
<span class="hljs-keyword">if</span> run_compile:
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Run torch compile&quot;</span>)
pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;ghibli style, a fantasy landscape with castles&quot;</span>
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
images = pipe(prompt=prompt).images<!-- HTML_TAG_END --></pre></div>
<h4 class="relative group"><a id="stable-diffusion-imagetoimage" 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" href="#stable-diffusion-imagetoimage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Stable Diffusion image-to-image
</span></h4>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionImg2ImgPipeline
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image = init_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
path = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
run_compile = <span class="hljs-literal">True</span> <span class="hljs-comment"># Set True / False</span>
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(path, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.to(memory_format=torch.channels_last)
<span class="hljs-keyword">if</span> run_compile:
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Run torch compile&quot;</span>)
pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;ghibli style, a fantasy landscape with castles&quot;</span>
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
image = pipe(prompt=prompt, image=init_image).images[<span class="hljs-number">0</span>]<!-- HTML_TAG_END --></pre></div>
<h4 class="relative group"><a id="stable-diffusion-inpainting" 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" href="#stable-diffusion-inpainting"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Stable Diffusion - inpainting
</span></h4>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInpaintPipeline
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
response = requests.get(url)
<span class="hljs-keyword">return</span> Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png&quot;</span>
init_image = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
mask_image = download_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
path = <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>
run_compile = <span class="hljs-literal">True</span> <span class="hljs-comment"># Set True / False</span>
pipe = StableDiffusionInpaintPipeline.from_pretrained(path, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.to(memory_format=torch.channels_last)
<span class="hljs-keyword">if</span> run_compile:
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Run torch compile&quot;</span>)
pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;ghibli style, a fantasy landscape with castles&quot;</span>
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]<!-- HTML_TAG_END --></pre></div>
<h4 class="relative group"><a id="controlnet" 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" href="#controlnet"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>ControlNet
</span></h4>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image = init_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
path = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
run_compile = <span class="hljs-literal">True</span> <span class="hljs-comment"># Set True / False</span>
controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">&quot;lllyasviel/sd-controlnet-canny&quot;</span>, torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
path, controlnet=controlnet, torch_dtype=torch.float16
)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.to(memory_format=torch.channels_last)
pipe.controlnet.to(memory_format=torch.channels_last)
<span class="hljs-keyword">if</span> run_compile:
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Run torch compile&quot;</span>)
pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
pipe.controlnet = torch.<span class="hljs-built_in">compile</span>(pipe.controlnet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;ghibli style, a fantasy landscape with castles&quot;</span>
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
image = pipe(prompt=prompt, image=init_image).images[<span class="hljs-number">0</span>]<!-- HTML_TAG_END --></pre></div>
<h4 class="relative group"><a id="if-texttoimage-upscaling" 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" href="#if-texttoimage-upscaling"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>IF text-to-image + upscaling
</span></h4>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch
run_compile = <span class="hljs-literal">True</span> <span class="hljs-comment"># Set True / False</span>
pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;DeepFloyd/IF-I-M-v1.0&quot;</span>, variant=<span class="hljs-string">&quot;fp16&quot;</span>, text_encoder=<span class="hljs-literal">None</span>, torch_dtype=torch.float16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe_2 = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;DeepFloyd/IF-II-M-v1.0&quot;</span>, variant=<span class="hljs-string">&quot;fp16&quot;</span>, text_encoder=<span class="hljs-literal">None</span>, torch_dtype=torch.float16)
pipe_2.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe_3 = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-x4-upscaler&quot;</span>, torch_dtype=torch.float16)
pipe_3.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.to(memory_format=torch.channels_last)
pipe_2.unet.to(memory_format=torch.channels_last)
pipe_3.unet.to(memory_format=torch.channels_last)
<span class="hljs-keyword">if</span> run_compile:
pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
pipe_2.unet = torch.<span class="hljs-built_in">compile</span>(pipe_2.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
pipe_3.unet = torch.<span class="hljs-built_in">compile</span>(pipe_3.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;the blue hulk&quot;</span>
prompt_embeds = torch.randn((<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">4096</span>), dtype=torch.float16)
neg_prompt_embeds = torch.randn((<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">4096</span>), dtype=torch.float16)
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
image = pipe(prompt_embeds=prompt_embeds, negative_prompt_embeds=neg_prompt_embeds, output_type=<span class="hljs-string">&quot;pt&quot;</span>).images
image_2 = pipe_2(image=image, prompt_embeds=prompt_embeds, negative_prompt_embeds=neg_prompt_embeds, output_type=<span class="hljs-string">&quot;pt&quot;</span>).images
image_3 = pipe_3(prompt=prompt, image=image, noise_level=<span class="hljs-number">100</span>).images<!-- HTML_TAG_END --></pre></div>
<p>To give you a pictorial overview of the possible speed-ups that can be obtained with PyTorch 2.0 and <code>torch.compile()</code>,
here is a plot that shows relative speed-ups for the <a href="StableDiffusionPipeline">Stable Diffusion text-to-image pipeline</a> across five
different GPU families (with a batch size of 4):</p>
<p><img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/pt2_benchmarks/t2i_speedup.png" alt="t2i_speedup"></p>
<p>To give you an even better idea of how this speed-up holds for the other pipelines presented above, consider the following
plot that shows the benchmarking numbers from an A100 across three different batch sizes
(with PyTorch 2.0 nightly and <code>torch.compile()</code>):</p>
<p><img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/pt2_benchmarks/a100_numbers.png" alt="a100_numbers"></p>
<p><em>(Our benchmarking metric for the plots above is <strong>number of iterations/second</strong>)</em></p>
<p>But we reveal all the benchmarking numbers in the interest of transparency! </p>
<p>In the following tables, we report our findings in terms of the number of <strong><em>iterations processed per second</em></strong>. </p>
<h3 class="relative group"><a id="a100-batch-size-1" 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" href="#a100-batch-size-1"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>A100 (batch size: 1)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">21.66</td>
<td align="center">23.13</td>
<td align="center">44.03</td>
<td align="center">49.74</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">21.81</td>
<td align="center">22.40</td>
<td align="center">43.92</td>
<td align="center">46.32</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">22.24</td>
<td align="center">23.23</td>
<td align="center">43.76</td>
<td align="center">49.25</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">15.02</td>
<td align="center">15.82</td>
<td align="center">32.13</td>
<td align="center">36.08</td></tr>
<tr><td align="center">IF</td>
<td align="center">20.21 / <br>13.84 / <br>24.00</td>
<td align="center">20.12 / <br>13.70 / <br>24.03</td>
<td align="center"></td>
<td align="center">97.34 / <br>27.23 / <br>111.66</td></tr></tbody></table>
<h3 class="relative group"><a id="a100-batch-size-4" 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" href="#a100-batch-size-4"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>A100 (batch size: 4)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">11.6</td>
<td align="center">13.12</td>
<td align="center">14.62</td>
<td align="center">17.27</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">11.47</td>
<td align="center">13.06</td>
<td align="center">14.66</td>
<td align="center">17.25</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">11.67</td>
<td align="center">13.31</td>
<td align="center">14.88</td>
<td align="center">17.48</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">8.28</td>
<td align="center">9.38</td>
<td align="center">10.51</td>
<td align="center">12.41</td></tr>
<tr><td align="center">IF</td>
<td align="center">25.02</td>
<td align="center">18.04</td>
<td align="center"></td>
<td align="center">48.47</td></tr></tbody></table>
<h3 class="relative group"><a id="a100-batch-size-16" 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" href="#a100-batch-size-16"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>A100 (batch size: 16)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">3.04</td>
<td align="center">3.6</td>
<td align="center">3.83</td>
<td align="center">4.68</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">2.98</td>
<td align="center">3.58</td>
<td align="center">3.83</td>
<td align="center">4.67</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">3.04</td>
<td align="center">3.66</td>
<td align="center">3.9</td>
<td align="center">4.76</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">2.15</td>
<td align="center">2.58</td>
<td align="center">2.74</td>
<td align="center">3.35</td></tr>
<tr><td align="center">IF</td>
<td align="center">8.78</td>
<td align="center">9.82</td>
<td align="center"></td>
<td align="center">16.77</td></tr></tbody></table>
<h3 class="relative group"><a id="v100-batch-size-1" 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" href="#v100-batch-size-1"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>V100 (batch size: 1)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">18.99</td>
<td align="center">19.14</td>
<td align="center">20.95</td>
<td align="center">22.17</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">18.56</td>
<td align="center">19.18</td>
<td align="center">20.95</td>
<td align="center">22.11</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">19.14</td>
<td align="center">19.06</td>
<td align="center">21.08</td>
<td align="center">22.20</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">13.48</td>
<td align="center">13.93</td>
<td align="center">15.18</td>
<td align="center">15.88</td></tr>
<tr><td align="center">IF</td>
<td align="center">20.01 / <br>9.08 / <br>23.34</td>
<td align="center">19.79 / <br>8.98 / <br>24.10</td>
<td align="center"></td>
<td align="center">55.75 / <br>11.57 / <br>57.67</td></tr></tbody></table>
<h3 class="relative group"><a id="v100-batch-size-4" 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" href="#v100-batch-size-4"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>V100 (batch size: 4)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">5.96</td>
<td align="center">5.89</td>
<td align="center">6.83</td>
<td align="center">6.86</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">5.90</td>
<td align="center">5.91</td>
<td align="center">6.81</td>
<td align="center">6.82</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">5.99</td>
<td align="center">6.03</td>
<td align="center">6.93</td>
<td align="center">6.95</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">4.26</td>
<td align="center">4.29</td>
<td align="center">4.92</td>
<td align="center">4.93</td></tr>
<tr><td align="center">IF</td>
<td align="center">15.41</td>
<td align="center">14.76</td>
<td align="center"></td>
<td align="center">22.95</td></tr></tbody></table>
<h3 class="relative group"><a id="v100-batch-size-16" 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" href="#v100-batch-size-16"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>V100 (batch size: 16)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">1.66</td>
<td align="center">1.66</td>
<td align="center">1.92</td>
<td align="center">1.90</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">1.65</td>
<td align="center">1.65</td>
<td align="center">1.91</td>
<td align="center">1.89</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">1.69</td>
<td align="center">1.69</td>
<td align="center">1.95</td>
<td align="center">1.93</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">1.19</td>
<td align="center">1.19</td>
<td align="center">OOM after warmup</td>
<td align="center">1.36</td></tr>
<tr><td align="center">IF</td>
<td align="center">5.43</td>
<td align="center">5.29</td>
<td align="center"></td>
<td align="center">7.06</td></tr></tbody></table>
<h3 class="relative group"><a id="t4-batch-size-1" 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" href="#t4-batch-size-1"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>T4 (batch size: 1)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">6.9</td>
<td align="center">6.95</td>
<td align="center">7.3</td>
<td align="center">7.56</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">6.84</td>
<td align="center">6.99</td>
<td align="center">7.04</td>
<td align="center">7.55</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">6.91</td>
<td align="center">6.7</td>
<td align="center">7.01</td>
<td align="center">7.37</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">4.89</td>
<td align="center">4.86</td>
<td align="center">5.35</td>
<td align="center">5.48</td></tr>
<tr><td align="center">IF</td>
<td align="center">17.42 / <br>2.47 / <br>18.52</td>
<td align="center">16.96 / <br>2.45 / <br>18.69</td>
<td align="center"></td>
<td align="center">24.63 / <br>2.47 / <br>23.39</td></tr></tbody></table>
<h3 class="relative group"><a id="t4-batch-size-4" 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" href="#t4-batch-size-4"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>T4 (batch size: 4)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">1.79</td>
<td align="center">1.79</td>
<td align="center">2.03</td>
<td align="center">1.99</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">1.77</td>
<td align="center">1.77</td>
<td align="center">2.05</td>
<td align="center">2.04</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">1.81</td>
<td align="center">1.82</td>
<td align="center">2.09</td>
<td align="center">2.09</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">1.34</td>
<td align="center">1.27</td>
<td align="center">1.47</td>
<td align="center">1.46</td></tr>
<tr><td align="center">IF</td>
<td align="center">5.79</td>
<td align="center">5.61</td>
<td align="center"></td>
<td align="center">7.39</td></tr></tbody></table>
<h3 class="relative group"><a id="t4-batch-size-16" 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" href="#t4-batch-size-16"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>T4 (batch size: 16)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">2.34s</td>
<td align="center">2.30s</td>
<td align="center">OOM after 2nd iteration</td>
<td align="center">1.99s</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">2.35s</td>
<td align="center">2.31s</td>
<td align="center">OOM after warmup</td>
<td align="center">2.00s</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">2.30s</td>
<td align="center">2.26s</td>
<td align="center">OOM after 2nd iteration</td>
<td align="center">1.95s</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">OOM after 2nd iteration</td>
<td align="center">OOM after 2nd iteration</td>
<td align="center">OOM after warmup</td>
<td align="center">OOM after warmup</td></tr>
<tr><td align="center">IF *</td>
<td align="center">1.44</td>
<td align="center">1.44</td>
<td align="center"></td>
<td align="center">1.94</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-3090-batch-size-1" 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" href="#rtx-3090-batch-size-1"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 3090 (batch size: 1)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">22.56</td>
<td align="center">22.84</td>
<td align="center">23.84</td>
<td align="center">25.69</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">22.25</td>
<td align="center">22.61</td>
<td align="center">24.1</td>
<td align="center">25.83</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">22.22</td>
<td align="center">22.54</td>
<td align="center">24.26</td>
<td align="center">26.02</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">16.03</td>
<td align="center">16.33</td>
<td align="center">17.38</td>
<td align="center">18.56</td></tr>
<tr><td align="center">IF</td>
<td align="center">27.08 / <br>9.07 / <br>31.23</td>
<td align="center">26.75 / <br>8.92 / <br>31.47</td>
<td align="center"></td>
<td align="center">68.08 / <br>11.16 / <br>65.29</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-3090-batch-size-4" 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" href="#rtx-3090-batch-size-4"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 3090 (batch size: 4)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">6.46</td>
<td align="center">6.35</td>
<td align="center">7.29</td>
<td align="center">7.3</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">6.33</td>
<td align="center">6.27</td>
<td align="center">7.31</td>
<td align="center">7.26</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">6.47</td>
<td align="center">6.4</td>
<td align="center">7.44</td>
<td align="center">7.39</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">4.59</td>
<td align="center">4.54</td>
<td align="center">5.27</td>
<td align="center">5.26</td></tr>
<tr><td align="center">IF</td>
<td align="center">16.81</td>
<td align="center">16.62</td>
<td align="center"></td>
<td align="center">21.57</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-3090-batch-size-16" 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" href="#rtx-3090-batch-size-16"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 3090 (batch size: 16)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">1.7</td>
<td align="center">1.69</td>
<td align="center">1.93</td>
<td align="center">1.91</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">1.68</td>
<td align="center">1.67</td>
<td align="center">1.93</td>
<td align="center">1.9</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">1.72</td>
<td align="center">1.71</td>
<td align="center">1.97</td>
<td align="center">1.94</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">1.23</td>
<td align="center">1.22</td>
<td align="center">1.4</td>
<td align="center">1.38</td></tr>
<tr><td align="center">IF</td>
<td align="center">5.01</td>
<td align="center">5.00</td>
<td align="center"></td>
<td align="center">6.33</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-4090-batch-size-1" 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" href="#rtx-4090-batch-size-1"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 4090 (batch size: 1)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">40.5</td>
<td align="center">41.89</td>
<td align="center">44.65</td>
<td align="center">49.81</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">40.39</td>
<td align="center">41.95</td>
<td align="center">44.46</td>
<td align="center">49.8</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">40.51</td>
<td align="center">41.88</td>
<td align="center">44.58</td>
<td align="center">49.72</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">29.27</td>
<td align="center">30.29</td>
<td align="center">32.26</td>
<td align="center">36.03</td></tr>
<tr><td align="center">IF</td>
<td align="center">69.71 / <br>18.78 / <br>85.49</td>
<td align="center">69.13 / <br>18.80 / <br>85.56</td>
<td align="center"></td>
<td align="center">124.60 / <br>26.37 / <br>138.79</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-4090-batch-size-4" 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" href="#rtx-4090-batch-size-4"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 4090 (batch size: 4)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">12.62</td>
<td align="center">12.84</td>
<td align="center">15.32</td>
<td align="center">15.59</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">12.61</td>
<td align="center">12,.79</td>
<td align="center">15.35</td>
<td align="center">15.66</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">12.65</td>
<td align="center">12.81</td>
<td align="center">15.3</td>
<td align="center">15.58</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">9.1</td>
<td align="center">9.25</td>
<td align="center">11.03</td>
<td align="center">11.22</td></tr>
<tr><td align="center">IF</td>
<td align="center">31.88</td>
<td align="center">31.14</td>
<td align="center"></td>
<td align="center">43.92</td></tr></tbody></table>
<h3 class="relative group"><a id="rtx-4090-batch-size-16" 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" href="#rtx-4090-batch-size-16"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>RTX 4090 (batch size: 16)
</span></h3>
<table><thead><tr><th align="center"><strong>Pipeline</strong></th>
<th align="center"><strong>torch 2.0 - <br>no compile</strong></th>
<th align="center"><strong>torch nightly - <br>no compile</strong></th>
<th align="center"><strong>torch 2.0 - <br>compile</strong></th>
<th align="center"><strong>torch nightly - <br>compile</strong></th></tr></thead>
<tbody><tr><td align="center">SD - txt2img</td>
<td align="center">3.17</td>
<td align="center">3.2</td>
<td align="center">3.84</td>
<td align="center">3.85</td></tr>
<tr><td align="center">SD - img2img</td>
<td align="center">3.16</td>
<td align="center">3.2</td>
<td align="center">3.84</td>
<td align="center">3.85</td></tr>
<tr><td align="center">SD - inpaint</td>
<td align="center">3.17</td>
<td align="center">3.2</td>
<td align="center">3.85</td>
<td align="center">3.85</td></tr>
<tr><td align="center">SD - controlnet</td>
<td align="center">2.23</td>
<td align="center">2.3</td>
<td align="center">2.7</td>
<td align="center">2.75</td></tr>
<tr><td align="center">IF</td>
<td align="center">9.26</td>
<td align="center">9.2</td>
<td align="center"></td>
<td align="center">13.31</td></tr></tbody></table>
<h2 class="relative group"><a id="notes" 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" href="#notes"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Notes
</span></h2>
<ul><li>Follow <a href="https://github.com/huggingface/diffusers/pull/3313" rel="nofollow">this PR</a> for more details on the environment used for conducting the benchmarks. </li>
<li>For the IF pipeline and batch sizes &gt; 1, we only used a batch size of &gt;1 in the first IF pipeline for text-to-image generation and NOT for upscaling. So, that means the two upscaling pipelines received a batch size of 1. </li></ul>
<p><em>Thanks to <a href="https://github.com/Chillee" rel="nofollow">Horace He</a> from the PyTorch team for their support in improving our support of <code>torch.compile()</code> in Diffusers.</em></p>
<script type="module" data-hydrate="16rzfq4">
import { start } from "/docs/diffusers/v0.18.2/en/_app/start-hf-doc-builder.js";
start({
target: document.querySelector('[data-hydrate="16rzfq4"]').parentNode,
paths: {"base":"/docs/diffusers/v0.18.2/en","assets":"/docs/diffusers/v0.18.2/en"},
session: {},
route: false,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/docs/diffusers/v0.18.2/en/_app/pages/__layout.svelte-hf-doc-builder.js"),
import("/docs/diffusers/v0.18.2/en/_app/pages/optimization/torch2.0.mdx-hf-doc-builder.js")
],
params: {}
}
});
</script>

Xet Storage Details

Size:
82.6 kB
·
Xet hash:
5c535e3c9a0260c713c442666d930ad19ad0cf07a0503956327cd0e49e0a8d82

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.