Buckets:

download
raw
91.2 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Diffusers에서의 PyTorch 2.0 가속화 지원&quot;,&quot;local&quot;:&quot;diffusers에서의-pytorch-20-가속화-지원&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;설치&quot;,&quot;local&quot;:&quot;설치&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;가속화된 트랜스포머와 torch.compile 사용하기.&quot;,&quot;local&quot;:&quot;가속화된-트랜스포머와-torchcompile-사용하기&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;벤치마크&quot;,&quot;local&quot;:&quot;벤치마크&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;벤치마킹 코드&quot;,&quot;local&quot;:&quot;벤치마킹-코드&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Stable Diffusion text-to-image&quot;,&quot;local&quot;:&quot;stable-diffusion-text-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Stable Diffusion image-to-image&quot;,&quot;local&quot;:&quot;stable-diffusion-image-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Stable Diffusion - inpainting&quot;,&quot;local&quot;:&quot;stable-diffusion---inpainting&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;ControlNet&quot;,&quot;local&quot;:&quot;controlnet&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;IF text-to-image + upscaling&quot;,&quot;local&quot;:&quot;if-text-to-image--upscaling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4}],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 1)&quot;,&quot;local&quot;:&quot;a100-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 4)&quot;,&quot;local&quot;:&quot;a100-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 16)&quot;,&quot;local&quot;:&quot;a100-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 1)&quot;,&quot;local&quot;:&quot;v100-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 4)&quot;,&quot;local&quot;:&quot;v100-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 16)&quot;,&quot;local&quot;:&quot;v100-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 1)&quot;,&quot;local&quot;:&quot;t4-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 4)&quot;,&quot;local&quot;:&quot;t4-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 16)&quot;,&quot;local&quot;:&quot;t4-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 1)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 4)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 16)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 1)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 4)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 16)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;참고&quot;,&quot;local&quot;:&quot;참고&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/diffusers/pr_11452/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/entry/start.475318ac.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/scheduler.94020406.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/singletons.7249ad28.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/index.8b553f6b.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/paths.36fb8dff.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/entry/app.42775c8f.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/index.a08c8d92.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/nodes/0.0d510dbd.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/nodes/17.78e00196.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/CodeBlock.f1fae7de.js">
<link rel="modulepreload" href="/docs/diffusers/pr_11452/ko/_app/immutable/chunks/getInferenceSnippets.58cd4b84.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Diffusers에서의 PyTorch 2.0 가속화 지원&quot;,&quot;local&quot;:&quot;diffusers에서의-pytorch-20-가속화-지원&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;설치&quot;,&quot;local&quot;:&quot;설치&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;가속화된 트랜스포머와 torch.compile 사용하기.&quot;,&quot;local&quot;:&quot;가속화된-트랜스포머와-torchcompile-사용하기&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;벤치마크&quot;,&quot;local&quot;:&quot;벤치마크&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;벤치마킹 코드&quot;,&quot;local&quot;:&quot;벤치마킹-코드&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Stable Diffusion text-to-image&quot;,&quot;local&quot;:&quot;stable-diffusion-text-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Stable Diffusion image-to-image&quot;,&quot;local&quot;:&quot;stable-diffusion-image-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Stable Diffusion - inpainting&quot;,&quot;local&quot;:&quot;stable-diffusion---inpainting&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;ControlNet&quot;,&quot;local&quot;:&quot;controlnet&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;IF text-to-image + upscaling&quot;,&quot;local&quot;:&quot;if-text-to-image--upscaling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4}],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 1)&quot;,&quot;local&quot;:&quot;a100-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 4)&quot;,&quot;local&quot;:&quot;a100-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;A100 (batch size: 16)&quot;,&quot;local&quot;:&quot;a100-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 1)&quot;,&quot;local&quot;:&quot;v100-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 4)&quot;,&quot;local&quot;:&quot;v100-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100 (batch size: 16)&quot;,&quot;local&quot;:&quot;v100-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 1)&quot;,&quot;local&quot;:&quot;t4-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 4)&quot;,&quot;local&quot;:&quot;t4-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;T4 (batch size: 16)&quot;,&quot;local&quot;:&quot;t4-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 1)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 4)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 3090 (batch size: 16)&quot;,&quot;local&quot;:&quot;rtx-3090-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 1)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-1&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 4)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-4&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;RTX 4090 (batch size: 16)&quot;,&quot;local&quot;:&quot;rtx-4090-batch-size-16&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;참고&quot;,&quot;local&quot;:&quot;참고&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="diffusers에서의-pytorch-20-가속화-지원" 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="#diffusers에서의-pytorch-20-가속화-지원"><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>Diffusers에서의 PyTorch 2.0 가속화 지원</span></h1> <p data-svelte-h="svelte-ygcqou"><code>0.13.0</code> 버전부터 Diffusers는 <a href="https://pytorch.org/get-started/pytorch-2.0/" rel="nofollow">PyTorch 2.0</a>에서의 최신 최적화를 지원합니다. 이는 다음을 포함됩니다.</p> <ol data-svelte-h="svelte-1dkijqo"><li>momory-efficient attention을 사용한 가속화된 트랜스포머 지원 - <code>xformers</code>같은 추가적인 dependencies 필요 없음</li> <li>추가 성능 향상을 위한 개별 모델에 대한 컴파일 기능 <a href="https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html" rel="nofollow">torch.compile</a> 지원</li></ol> <h2 class="relative group"><a id="설치" 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="#설치"><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>설치</span></h2> <p data-svelte-h="svelte-1i7y0my">가속화된 어텐션 구현과 및 <code>torch.compile()</code>을 사용하기 위해, pip에서 최신 버전의 PyTorch 2.0을 설치되어 있고 diffusers 0.13.0. 버전 이상인지 확인하세요. 아래 설명된 바와 같이, PyTorch 2.0이 활성화되어 있을 때 diffusers는 최적화된 어텐션 프로세서(<a href="https://github.com/huggingface/diffusers/blob/1a5797c6d4491a879ea5285c4efc377664e0332d/src/diffusers/models/attention_processor.py#L798" rel="nofollow"><code>AttnProcessor2_0</code></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 class=""><!-- HTML_TAG_START -->pip install --upgrade torch diffusers<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="가속화된-트랜스포머와-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="#가속화된-트랜스포머와-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>가속화된 트랜스포머와 torch.compile 사용하기.</span></h2> <ol><li><p data-svelte-h="svelte-csjjs8"><strong>가속화된 트랜스포머 구현</strong></p> <p data-svelte-h="svelte-ptbosd">PyTorch 2.0에는 <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> 함수를 통해 최적화된 memory-efficient attention의 구현이 포함되어 있습니다. 이는 입력 및 GPU 유형에 따라 여러 최적화를 자동으로 활성화합니다. 이는 <a href="https://github.com/facebookresearch/xformers" rel="nofollow">xFormers</a><code>memory_efficient_attention</code>과 유사하지만 기본적으로 PyTorch에 내장되어 있습니다.</p> <p data-svelte-h="svelte-i6ofk3">이러한 최적화는 PyTorch 2.0이 설치되어 있고 <code>torch.nn.functional.scaled_dot_product_attention</code>을 사용할 수 있는 경우 Diffusers에서 기본적으로 활성화됩니다. 이를 사용하려면 <code>torch 2.0</code>을 설치하고 파이프라인을 사용하기만 하면 됩니다. 예를 들어:</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 class=""><!-- 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;stable-diffusion-v1-5/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 data-svelte-h="svelte-14x25cf">이를 명시적으로 활성화하려면(필수는 아님) 아래와 같이 수행할 수 있습니다.</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 class=""><!-- 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;stable-diffusion-v1-5/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 data-svelte-h="svelte-uqlxk7">이 실행 과정은 <code>xFormers</code>만큼 빠르고 메모리적으로 효율적이어야 합니다. 자세한 내용은 <a href="#benchmark">벤치마크</a>에서 확인하세요.</p> <p data-svelte-h="svelte-1artegh">파이프라인을 보다 deterministic으로 만들거나 파인 튜닝된 모델을 <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>과 같은 다른 형식으로 변환해야 하는 경우 바닐라 어텐션 프로세서 (<a href="https://github.com/huggingface/diffusers/blob/1a5797c6d4491a879ea5285c4efc377664e0332d/src/diffusers/models/attention_processor.py#L402" rel="nofollow"><code>AttnProcessor</code></a>)로 되돌릴 수 있습니다. 일반 어텐션 프로세서를 사용하려면 <code>set_default_attn_processor()</code> 함수를 사용할 수 있습니다:</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 class=""><!-- 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;stable-diffusion-v1-5/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 data-svelte-h="svelte-azj1k8"><strong>torch.compile</strong></p> <p data-svelte-h="svelte-1wvf4df">추가적인 속도 향상을 위해 새로운 <code>torch.compile</code> 기능을 사용할 수 있습니다. 파이프라인의 UNet은 일반적으로 계산 비용이 가장 크기 때문에 나머지 하위 모델(텍스트 인코더와 VAE)은 그대로 두고 <code>unet</code><code>torch.compile</code>로 래핑합니다. 자세한 내용과 다른 옵션은 <a href="https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html" rel="nofollow">torch 컴파일 문서</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 class=""><!-- 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 data-svelte-h="svelte-5tr1im">GPU 유형에 따라 <code>compile()</code>은 가속화된 트랜스포머 최적화를 통해 <strong>5% - 300%</strong><em>추가 성능 향상</em>을 얻을 수 있습니다. 그러나 컴파일은 Ampere(A100, 3090), Ada(4090) 및 Hopper(H100)와 같은 최신 GPU 아키텍처에서 더 많은 성능 향상을 가져올 수 있음을 참고하세요.</p> <p data-svelte-h="svelte-ijvl95">컴파일은 완료하는 데 약간의 시간이 걸리므로, 파이프라인을 한 번 준비한 다음 동일한 유형의 추론 작업을 여러 번 수행해야 하는 상황에 가장 적합합니다. 다른 이미지 크기에서 컴파일된 파이프라인을 호출하면 시간적 비용이 많이 들 수 있는 컴파일 작업이 다시 트리거됩니다.</p></li></ol> <h2 class="relative group"><a id="벤치마크" 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="#벤치마크"><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>벤치마크</span></h2> <p data-svelte-h="svelte-1c5iz5d">PyTorch 2.0의 효율적인 어텐션 구현과 <code>torch.compile</code>을 사용하여 가장 많이 사용되는 5개의 파이프라인에 대해 다양한 GPU와 배치 크기에 걸쳐 포괄적인 벤치마크를 수행했습니다. 여기서는 <a href="https://github.com/huggingface/diffusers/pull/3313" rel="nofollow"><code>torch.compile()</code>이 최적으로 활용되도록 하는</a> <code>diffusers 0.17.0.dev0</code>을 사용했습니다.</p> <h3 class="relative group"><a id="벤치마킹-코드" 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="#벤치마킹-코드"><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>벤치마킹 코드</span></h3> <h4 class="relative group"><a id="stable-diffusion-text-to-image" 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-text-to-image"><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 class=""><!-- 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;stable-diffusion-v1-5/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-image-to-image" 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-image-to-image"><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 class=""><!-- 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;stable-diffusion-v1-5/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 class=""><!-- 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 class=""><!-- 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;stable-diffusion-v1-5/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-text-to-image--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-text-to-image--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 class=""><!-- 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 data-svelte-h="svelte-1ujmkc6">PyTorch 2.0 및 <code>torch.compile()</code>로 얻을 수 있는 가능한 속도 향상에 대해, <a href="StableDiffusionPipeline">Stable Diffusion text-to-image pipeline</a>에 대한 상대적인 속도 향상을 보여주는 차트를 5개의 서로 다른 GPU 제품군(배치 크기 4)에 대해 나타냅니다:</p> <p data-svelte-h="svelte-1sjwyaz"><img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/pt2_benchmarks/t2i_speedup.png" alt="t2i_speedup"></p> <p data-svelte-h="svelte-1ph0h0b">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>):
이 속도 향상이 위에 제시된 다른 파이프라인에 대해서도 어떻게 유지되는지 더 잘 이해하기 위해, 세 가지의 다른 배치 크기에 걸쳐 A100의 벤치마킹(PyTorch 2.0 nightly 및 `torch.compile() 사용) 수치를 보여주는 차트를 보입니다:</p> <p data-svelte-h="svelte-19p9vzv"><img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/pt2_benchmarks/a100_numbers.png" alt="a100_numbers"></p> <p data-svelte-h="svelte-1wqu6gn"><em>(위 차트의 벤치마크 메트릭은 <strong>초당 iteration 수(iterations/second)</strong>입니다)</em></p> <p data-svelte-h="svelte-1k8h2j4">그러나 투명성을 위해 모든 벤치마킹 수치를 공개합니다!</p> <p data-svelte-h="svelte-9xhu5s">다음 표들에서는, <strong><em>초당 처리되는 iteration</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 data-svelte-h="svelte-ua6hkm"><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 data-svelte-h="svelte-19p4o4"><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 data-svelte-h="svelte-ghymkz"><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 data-svelte-h="svelte-9j8rj7"><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 data-svelte-h="svelte-1xs3uwi"><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 data-svelte-h="svelte-1elkjwp"><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 data-svelte-h="svelte-15rkrq1"><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 data-svelte-h="svelte-qjzzgd"><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 data-svelte-h="svelte-h3a43b"><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 data-svelte-h="svelte-1hbo08l"><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 data-svelte-h="svelte-abi9u4"><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 data-svelte-h="svelte-11m8i0f"><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 data-svelte-h="svelte-u80fnb"><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 data-svelte-h="svelte-x5owk6"><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 data-svelte-h="svelte-1x66rvc"><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="참고" 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="#참고"><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>참고</span></h2> <ul data-svelte-h="svelte-1llz67b"><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 data-svelte-h="svelte-7zliwv"><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> <ul data-svelte-h="svelte-ppwv8l"><li>벤치마크 수행에 사용된 환경에 대한 자세한 내용은 <a href="https://github.com/huggingface/diffusers/pull/3313" rel="nofollow">이 PR</a>을 참조하세요.</li> <li>IF 파이프라인와 배치 크기 &gt; 1의 경우 첫 번째 IF 파이프라인에서 text-to-image 생성을 위한 배치 크기 &gt; 1만 사용했으며 업스케일링에는 사용하지 않았습니다. 즉, 두 개의 업스케일링 파이프라인이 배치 크기 1임을 의미합니다.</li></ul> <p data-svelte-h="svelte-zzoysd"><em>Diffusers에서 <code>torch.compile()</code> 지원을 개선하는 데 도움을 준 PyTorch 팀의 <a href="https://github.com/Chillee" rel="nofollow">Horace He</a>에게 감사드립니다.</em></p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/diffusers/blob/main/docs/source/ko/optimization/torch2.0.md" target="_blank"><span data-svelte-h="svelte-1kd6by1">&lt;</span> <span data-svelte-h="svelte-x0xyl0">&gt;</span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1q80ugm = {
assets: "/docs/diffusers/pr_11452/ko",
base: "/docs/diffusers/pr_11452/ko",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/diffusers/pr_11452/ko/_app/immutable/entry/start.475318ac.js"),
import("/docs/diffusers/pr_11452/ko/_app/immutable/entry/app.42775c8f.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 17],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
91.2 kB
·
Xet hash:
285bf047df50c043b69ffd9799da6a39842a657e241fdab9b744275d6a01546e

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