Buckets:

download
raw
25.9 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Token Merging (토큰 병합)&quot;,&quot;local&quot;:&quot;token-merging-토큰-병합&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;ToMe 사용하기&quot;,&quot;local&quot;:&quot;tome-사용하기&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;StableDiffusionPipeline 으로 tomesd 벤치마킹하기&quot;,&quot;local&quot;:&quot;stablediffusionpipeline-으로-tomesd-벤치마킹하기&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;A100&quot;,&quot;local&quot;:&quot;a100&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100&quot;,&quot;local&quot;:&quot;v100&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_12820/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/entry/start.3d235f8e.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/scheduler.23542ac5.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/singletons.90d76c2a.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/index.7166da64.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/paths.5789b09f.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/entry/app.86e25fc8.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/preload-helper.b51cdadd.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/index.9b1f405b.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/nodes/0.49c759ef.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/nodes/16.2fb74320.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.af5bd6bd.js">
<link rel="modulepreload" href="/docs/diffusers/pr_12820/ko/_app/immutable/chunks/CodeBlock.dc8eaa1c.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Token Merging (토큰 병합)&quot;,&quot;local&quot;:&quot;token-merging-토큰-병합&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;ToMe 사용하기&quot;,&quot;local&quot;:&quot;tome-사용하기&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;StableDiffusionPipeline 으로 tomesd 벤치마킹하기&quot;,&quot;local&quot;:&quot;stablediffusionpipeline-으로-tomesd-벤치마킹하기&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;A100&quot;,&quot;local&quot;:&quot;a100&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;V100&quot;,&quot;local&quot;:&quot;v100&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> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" 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></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="token-merging-토큰-병합" 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="#token-merging-토큰-병합"><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>Token Merging (토큰 병합)</span></h1> <p data-svelte-h="svelte-kzgdnq">Token Merging (introduced in <a href="https://huggingface.co/papers/2210.09461" rel="nofollow">Token Merging: Your ViT But Faster</a>)은 트랜스포머 기반 네트워크의 forward pass에서 중복 토큰이나 패치를 점진적으로 병합하는 방식으로 작동합니다. 이를 통해 기반 네트워크의 추론 지연 시간을 단축할 수 있습니다.</p> <p data-svelte-h="svelte-14ocghf">Token Merging(ToMe)이 출시된 후, 저자들은 <a href="https://huggingface.co/papers/2303.17604" rel="nofollow">Fast Stable Diffusion을 위한 토큰 병합</a>을 발표하여 Stable Diffusion과 더 잘 호환되는 ToMe 버전을 소개했습니다. ToMe를 사용하면 <code>DiffusionPipeline</code>의 추론 지연 시간을 부드럽게 단축할 수 있습니다. 이 문서에서는 ToMe를 <code>StableDiffusionPipeline</code>에 적용하는 방법, 예상되는 속도 향상, <code>StableDiffusionPipeline</code>에서 ToMe를 사용할 때의 질적 측면에 대해 설명합니다.</p> <h2 class="relative group"><a id="tome-사용하기" 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="#tome-사용하기"><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>ToMe 사용하기</span></h2> <p data-svelte-h="svelte-12otzto">ToMe의 저자들은 <a href="https://github.com/dbolya/tomesd" rel="nofollow"><code>tomesd</code></a>라는 편리한 Python 라이브러리를 공개했는데, 이 라이브러리를 이용하면 <code>DiffusionPipeline</code>에 ToMe를 다음과 같이 적용할 수 있습니다:</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 -->from diffusers import StableDiffusionPipeline
import tomesd
pipeline = StableDiffusionPipeline.from_pretrained(
&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;, torch_dtype=torch.float16
).to(&quot;cuda&quot;)
<span class="hljs-addition">+ tomesd.apply_patch(pipeline, ratio=0.5)</span>
image = pipeline(&quot;a photo of an astronaut riding a horse on mars&quot;).images[0]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1k8jadh">이것이 다입니다!</p> <p data-svelte-h="svelte-x6i6j6"><code>tomesd.apply_patch()</code>는 파이프라인 추론 속도와 생성된 토큰의 품질 사이의 균형을 맞출 수 있도록 <a href="https://github.com/dbolya/tomesd#usage" rel="nofollow">여러 개의 인자</a>를 노출합니다. 이러한 인수 중 가장 중요한 것은 <code>ratio(비율)</code>입니다. <code>ratio</code>은 forward pass 중에 병합될 토큰의 수를 제어합니다. <code>tomesd</code>에 대한 자세한 내용은 해당 리포지토리(<a href="https://github.com/dbolya/tomesd" rel="nofollow">https://github.com/dbolya/tomesd</a>) 및 <a href="https://huggingface.co/papers/2303.17604" rel="nofollow">논문</a>을 참고하시기 바랍니다.</p> <h2 class="relative group"><a id="stablediffusionpipeline-으로-tomesd-벤치마킹하기" 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="#stablediffusionpipeline-으로-tomesd-벤치마킹하기"><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>StableDiffusionPipeline 으로 tomesd 벤치마킹하기</span></h2> <p data-svelte-h="svelte-11ikqbb">We benchmarked the impact of using <code>tomesd</code> on <code>StableDiffusionPipeline</code> along with <a href="https://huggingface.co/docs/diffusers/optimization/xformers" rel="nofollow">xformers</a> across different image resolutions. We used A100 and V100 as our test GPU devices with the following development environment (with Python 3.8.5):
다양한 이미지 해상도에서 <a href="https://huggingface.co/docs/diffusers/optimization/xformers" rel="nofollow">xformers</a>를 적용한 상태에서, <code>StableDiffusionPipeline</code><code>tomesd</code>를 사용했을 때의 영향을 벤치마킹했습니다. 테스트 GPU 장치로 A100과 V100을 사용했으며 개발 환경은 다음과 같습니다(Python 3.8.5 사용):</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 -->- `diffusers` version: 0.15.1
- Python version: 3.8.16
- PyTorch version (GPU?): 1.13.1+cu116 (True)
- Huggingface_hub version: 0.13.2
- Transformers version: 4.27.2
- Accelerate version: 0.18.0
- xFormers version: 0.0.16
- tomesd version: 0.1.2<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-7462bd">벤치마킹에는 다음 스크립트를 사용했습니다: <a href="https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335" rel="nofollow">https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335</a>. 결과는 다음과 같습니다:</p> <h3 class="relative group"><a id="a100" 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"><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</span></h3> <table data-svelte-h="svelte-1sq5eqd"><thead><tr><th>해상도</th> <th>배치 크기</th> <th>Vanilla</th> <th>ToMe</th> <th>ToMe + xFormers</th> <th>ToMe 속도 향상 (%)</th> <th>ToMe + xFormers 속도 향상 (%)</th></tr></thead> <tbody><tr><td>512</td> <td>10</td> <td>6.88</td> <td>5.26</td> <td>4.69</td> <td>23.54651163</td> <td>31.83139535</td></tr> <tr><td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td></tr> <tr><td>768</td> <td>10</td> <td>OOM</td> <td>14.71</td> <td>11</td> <td></td> <td></td></tr> <tr><td></td> <td>8</td> <td>OOM</td> <td>11.56</td> <td>8.84</td> <td></td> <td></td></tr> <tr><td></td> <td>4</td> <td>OOM</td> <td>5.98</td> <td>4.66</td> <td></td> <td></td></tr> <tr><td></td> <td>2</td> <td>4.99</td> <td>3.24</td> <td>3.1</td> <td>35.07014028</td> <td>37.8757515</td></tr> <tr><td></td> <td>1</td> <td>3.29</td> <td>2.24</td> <td>2.03</td> <td>31.91489362</td> <td>38.29787234</td></tr> <tr><td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td></tr> <tr><td>1024</td> <td>10</td> <td>OOM</td> <td>OOM</td> <td>OOM</td> <td></td> <td></td></tr> <tr><td></td> <td>8</td> <td>OOM</td> <td>OOM</td> <td>OOM</td> <td></td> <td></td></tr> <tr><td></td> <td>4</td> <td>OOM</td> <td>12.51</td> <td>9.09</td> <td></td> <td></td></tr> <tr><td></td> <td>2</td> <td>OOM</td> <td>6.52</td> <td>4.96</td> <td></td> <td></td></tr> <tr><td></td> <td>1</td> <td>6.4</td> <td>3.61</td> <td>2.81</td> <td>43.59375</td> <td>56.09375</td></tr></tbody></table> <p data-svelte-h="svelte-wj7mc7"><strong><em>결과는 초 단위입니다. 속도 향상은 <code>Vanilla</code>과 비교해 계산됩니다.</em></strong></p> <h3 class="relative group"><a id="v100" 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"><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</span></h3> <table data-svelte-h="svelte-db49ae"><thead><tr><th>해상도</th> <th>배치 크기</th> <th>Vanilla</th> <th>ToMe</th> <th>ToMe + xFormers</th> <th>ToMe 속도 향상 (%)</th> <th>ToMe + xFormers 속도 향상 (%)</th></tr></thead> <tbody><tr><td>512</td> <td>10</td> <td>OOM</td> <td>10.03</td> <td>9.29</td> <td></td> <td></td></tr> <tr><td></td> <td>8</td> <td>OOM</td> <td>8.05</td> <td>7.47</td> <td></td> <td></td></tr> <tr><td></td> <td>4</td> <td>5.7</td> <td>4.3</td> <td>3.98</td> <td>24.56140351</td> <td>30.1754386</td></tr> <tr><td></td> <td>2</td> <td>3.14</td> <td>2.43</td> <td>2.27</td> <td>22.61146497</td> <td>27.70700637</td></tr> <tr><td></td> <td>1</td> <td>1.88</td> <td>1.57</td> <td>1.57</td> <td>16.4893617</td> <td>16.4893617</td></tr> <tr><td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td></tr> <tr><td>768</td> <td>10</td> <td>OOM</td> <td>OOM</td> <td>23.67</td> <td></td> <td></td></tr> <tr><td></td> <td>8</td> <td>OOM</td> <td>OOM</td> <td>18.81</td> <td></td> <td></td></tr> <tr><td></td> <td>4</td> <td>OOM</td> <td>11.81</td> <td>9.7</td> <td></td> <td></td></tr> <tr><td></td> <td>2</td> <td>OOM</td> <td>6.27</td> <td>5.2</td> <td></td> <td></td></tr> <tr><td></td> <td>1</td> <td>5.43</td> <td>3.38</td> <td>2.82</td> <td>37.75322284</td> <td>48.06629834</td></tr> <tr><td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td></tr> <tr><td>1024</td> <td>10</td> <td>OOM</td> <td>OOM</td> <td>OOM</td> <td></td> <td></td></tr> <tr><td></td> <td>8</td> <td>OOM</td> <td>OOM</td> <td>OOM</td> <td></td> <td></td></tr> <tr><td></td> <td>4</td> <td>OOM</td> <td>OOM</td> <td>19.35</td> <td></td> <td></td></tr> <tr><td></td> <td>2</td> <td>OOM</td> <td>13</td> <td>10.78</td> <td></td> <td></td></tr> <tr><td></td> <td>1</td> <td>OOM</td> <td>6.66</td> <td>5.54</td> <td></td> <td></td></tr></tbody></table> <p data-svelte-h="svelte-1g345nk">위의 표에서 볼 수 있듯이, 이미지 해상도가 높을수록 <code>tomesd</code>를 사용한 속도 향상이 더욱 두드러집니다. 또한 <code>tomesd</code>를 사용하면 1024x1024와 같은 더 높은 해상도에서 파이프라인을 실행할 수 있다는 점도 흥미롭습니다.</p> <p data-svelte-h="svelte-130oxzi"><a href="https://huggingface.co/docs/diffusers/optimization/torch2.0" rel="nofollow"><code>torch.compile()</code></a>을 사용하면 추론 속도를 더욱 높일 수 있습니다.</p> <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-twhmc1">As reported in <a href="https://huggingface.co/papers/2303.17604" rel="nofollow">the paper</a>, ToMe can preserve the quality of the generated images to a great extent while speeding up inference. By increasing the <code>ratio</code>, it is possible to further speed up inference, but that might come at the cost of a deterioration in the image quality.</p> <p data-svelte-h="svelte-xb1okv">To test the quality of the generated samples using our setup, we sampled a few prompts from the “Parti Prompts” (introduced in <a href="https://parti.research.google/" rel="nofollow">Parti</a>) and performed inference with the <code>StableDiffusionPipeline</code> in the following settings:</p> <p data-svelte-h="svelte-1bj1bzh"><a href="https://huggingface.co/papers/2303.17604" rel="nofollow">논문</a>에 보고된 바와 같이, ToMe는 생성된 이미지의 품질을 상당 부분 보존하면서 추론 속도를 높일 수 있습니다. <code>ratio</code>을 높이면 추론 속도를 더 높일 수 있지만, 이미지 품질이 저하될 수 있습니다.</p> <p data-svelte-h="svelte-q8pz6p">해당 설정을 사용하여 생성된 샘플의 품질을 테스트하기 위해, “Parti 프롬프트”(<a href="https://parti.research.google/" rel="nofollow">Parti</a>에서 소개)에서 몇 가지 프롬프트를 샘플링하고 다음 설정에서 <code>StableDiffusionPipeline</code>을 사용하여 추론을 수행했습니다:</p> <ul data-svelte-h="svelte-nt18e6"><li>Vanilla <code>StableDiffusionPipeline</code></li> <li><code>StableDiffusionPipeline</code> + ToMe</li> <li><code>StableDiffusionPipeline</code> + ToMe + xformers</li></ul> <p data-svelte-h="svelte-13iqe5c">생성된 샘플의 품질이 크게 저하되는 것을 발견하지 못했습니다. 다음은 샘플입니다:</p> <p data-svelte-h="svelte-121uzx9"><img src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/tome/tome_samples.png" alt="tome-samples"></p> <p data-svelte-h="svelte-4mouq">생성된 샘플은 <a href="https://wandb.ai/sayakpaul/tomesd-results/runs/23j4bj3i?workspace=" rel="nofollow">여기</a>에서 확인할 수 있습니다. 이 실험을 수행하기 위해 <a href="https://gist.github.com/sayakpaul/8cac98d7f22399085a060992f411ecbd" rel="nofollow">이 스크립트</a>를 사용했습니다.</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/tome.md" target="_blank"><svg class="mr-1" 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="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1nna9bv = {
assets: "/docs/diffusers/pr_12820/ko",
base: "/docs/diffusers/pr_12820/ko",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/diffusers/pr_12820/ko/_app/immutable/entry/start.3d235f8e.js"),
import("/docs/diffusers/pr_12820/ko/_app/immutable/entry/app.86e25fc8.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 16],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
25.9 kB
·
Xet hash:
34fc3ae0454673c6fc41512c1f9fddd1e53e7bedf983db500e12110f4f32c19b

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