Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"CacheDiT","local":"cachedit","sections":[],"depth":2}"> | |
| <link href="/docs/diffusers/pr_12249/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/entry/start.d78ccb7e.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/scheduler.53228c21.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/singletons.7109d99c.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/index.e93d0901.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/paths.85ae17be.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/entry/app.cd68c46f.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/preload-helper.20fd9bc3.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/index.100fac89.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/nodes/0.78828106.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/nodes/277.c747d174.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/CodeBlock.d30a6509.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/IconCopy.38cf8f56.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.d8195636.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12249/en/_app/immutable/chunks/HfOption.fad27e59.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"CacheDiT","local":"cachedit","sections":[],"depth":2}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h2 class="relative group"><a id="cachedit" 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="#cachedit"><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>CacheDiT</span></h2> <p data-svelte-h="svelte-a4m664">CacheDiT is a unified, flexible, and training-free cache acceleration framework designed to support nearly all Diffusers’ DiT-based pipelines. It provides a unified cache API that supports automatic block adapter, DBCache, and more.</p> <p data-svelte-h="svelte-53qxzg">To learn more, refer to the <a href="https://github.com/vipshop/cache-dit" rel="nofollow">CacheDiT</a> repository.</p> <p data-svelte-h="svelte-1g5mtjo">Install a stable release of CacheDiT from PyPI or you can install the latest version from GitHub.</p> <div class="flex space-x-2 items-center my-1.5 mr-8 h-7 !pl-0 -mx-3 md:mx-0"><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd border-gray-800 bg-black dark:bg-gray-700 text-white">PyPI </div><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm">source </div></div> <div class="language-select"><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 -->pip3 install -U cache-dit<!-- HTML_TAG_END --></pre></div> </div> <p data-svelte-h="svelte-17xusda">Run the command below to view supported DiT pipelines.</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-meta">>>> </span><span class="hljs-keyword">import</span> cache_dit | |
| <span class="hljs-meta">>>> </span>cache_dit.supported_pipelines() | |
| (<span class="hljs-number">30</span>, [<span class="hljs-string">'Flux*'</span>, <span class="hljs-string">'Mochi*'</span>, <span class="hljs-string">'CogVideoX*'</span>, <span class="hljs-string">'Wan*'</span>, <span class="hljs-string">'HunyuanVideo*'</span>, <span class="hljs-string">'QwenImage*'</span>, <span class="hljs-string">'LTX*'</span>, <span class="hljs-string">'Allegro*'</span>, | |
| <span class="hljs-string">'CogView3Plus*'</span>, <span class="hljs-string">'CogView4*'</span>, <span class="hljs-string">'Cosmos*'</span>, <span class="hljs-string">'EasyAnimate*'</span>, <span class="hljs-string">'SkyReelsV2*'</span>, <span class="hljs-string">'StableDiffusion3*'</span>, | |
| <span class="hljs-string">'ConsisID*'</span>, <span class="hljs-string">'DiT*'</span>, <span class="hljs-string">'Amused*'</span>, <span class="hljs-string">'Bria*'</span>, <span class="hljs-string">'Lumina*'</span>, <span class="hljs-string">'OmniGen*'</span>, <span class="hljs-string">'PixArt*'</span>, <span class="hljs-string">'Sana*'</span>, <span class="hljs-string">'StableAudio*'</span>, | |
| <span class="hljs-string">'VisualCloze*'</span>, <span class="hljs-string">'AuraFlow*'</span>, <span class="hljs-string">'Chroma*'</span>, <span class="hljs-string">'ShapE*'</span>, <span class="hljs-string">'HiDream*'</span>, <span class="hljs-string">'HunyuanDiT*'</span>, <span class="hljs-string">'HunyuanDiTPAG*'</span>])<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-2ejiue">For a complete benchmark, please refer to <a href="https://github.com/vipshop/cache-dit/blob/main/bench/" rel="nofollow">Benchmarks</a>.</p> <h2 class="relative group"><a id="unified-cache-api" 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="#unified-cache-api"><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>Unified Cache API</span></h2> <p data-svelte-h="svelte-h5weta">CacheDiT works by matching specific input/output patterns as shown below.</p> <p data-svelte-h="svelte-1n4p4jc"><img src="https://github.com/vipshop/cache-dit/raw/main/assets/patterns-v1.png"></p> <p data-svelte-h="svelte-2jtqkt">Call the <code>enable_cache()</code> function on a pipeline to enable cache acceleration. This function is the entry point to many of CacheDiT’s features.</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> cache_dit | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| <CopyLLMTxtMenu containerStyle=<span class="hljs-string">"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"</span>></CopyLLMTxtMenu> | |
| <span class="hljs-comment"># Can be any diffusion pipeline</span> | |
| pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">"Qwen/Qwen-Image"</span>) | |
| <span class="hljs-comment"># One-line code with default cache options.</span> | |
| cache_dit.enable_cache(pipe) | |
| <span class="hljs-comment"># Just call the pipe as normal.</span> | |
| output = pipe(...) | |
| <span class="hljs-comment"># Disable cache and run original pipe.</span> | |
| cache_dit.disable_cache(pipe)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="automatic-block-adapter" 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="#automatic-block-adapter"><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>Automatic Block Adapter</span></h2> <p data-svelte-h="svelte-12jmp7v">For custom or modified pipelines or transformers not included in Diffusers, use the <code>BlockAdapter</code> in <code>auto</code> mode or via manual configuration. Please check the <a href="https://github.com/vipshop/cache-dit/blob/main/docs/User_Guide.md#automatic-block-adapter" rel="nofollow">BlockAdapter</a> docs for more details. Refer to <a href="https://github.com/vipshop/cache-dit/blob/main/examples/adapter/run_qwen_image_adapter.py" rel="nofollow">Qwen-Image w/ BlockAdapter</a> as an example.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> cache_dit <span class="hljs-keyword">import</span> ForwardPattern, BlockAdapter | |
| <span class="hljs-comment"># Use 🔥BlockAdapter with `auto` mode.</span> | |
| cache_dit.enable_cache( | |
| BlockAdapter( | |
| <span class="hljs-comment"># Any DiffusionPipeline, Qwen-Image, etc. </span> | |
| pipe=pipe, auto=<span class="hljs-literal">True</span>, | |
| <span class="hljs-comment"># Check `📚Forward Pattern Matching` documentation and hack the code of</span> | |
| <span class="hljs-comment"># of Qwen-Image, you will find that it has satisfied `FORWARD_PATTERN_1`.</span> | |
| forward_pattern=ForwardPattern.Pattern_1, | |
| ), | |
| ) | |
| <span class="hljs-comment"># Or, manually setup transformer configurations.</span> | |
| cache_dit.enable_cache( | |
| BlockAdapter( | |
| pipe=pipe, <span class="hljs-comment"># Qwen-Image, etc.</span> | |
| transformer=pipe.transformer, | |
| blocks=pipe.transformer.transformer_blocks, | |
| forward_pattern=ForwardPattern.Pattern_1, | |
| ), | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-2e9gr4">Sometimes, a Transformer class will contain more than one transformer <code>blocks</code>. For example, FLUX.1 (HiDream, Chroma, etc) contains <code>transformer_blocks</code> and <code>single_transformer_blocks</code> (with different forward patterns). The BlockAdapter is able to detect this hybrid pattern type as well. | |
| Refer to <a href="https://github.com/vipshop/cache-dit/blob/main/examples/adapter/run_flux_adapter.py" rel="nofollow">FLUX.1</a> as an example.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># For diffusers <= 0.34.0, FLUX.1 transformer_blocks and </span> | |
| <span class="hljs-comment"># single_transformer_blocks have different forward patterns.</span> | |
| cache_dit.enable_cache( | |
| BlockAdapter( | |
| pipe=pipe, <span class="hljs-comment"># FLUX.1, etc.</span> | |
| transformer=pipe.transformer, | |
| blocks=[ | |
| pipe.transformer.transformer_blocks, | |
| pipe.transformer.single_transformer_blocks, | |
| ], | |
| forward_pattern=[ | |
| ForwardPattern.Pattern_1, | |
| ForwardPattern.Pattern_3, | |
| ], | |
| ), | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1cf72u">This also works if there is more than one transformer (namely <code>transformer</code> and <code>transformer_2</code>) in its structure. Refer to <a href="https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_wan_2.2.py" rel="nofollow">Wan 2.2 MoE</a> as an example.</p> <h2 class="relative group"><a id="patch-functor" 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="#patch-functor"><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>Patch Functor</span></h2> <p data-svelte-h="svelte-1lpsu24">For any pattern not included in CacheDiT, use the Patch Functor to convert the pattern into a known pattern. You need to subclass the Patch Functor and may also need to fuse the operations within the blocks for loop into block <code>forward</code>. After implementing a Patch Functor, set the <code>patch_functor</code> property in <code>BlockAdapter</code>.</p> <p data-svelte-h="svelte-13fck4t"><img src="https://github.com/vipshop/cache-dit/raw/main/assets/patch-functor.png"></p> <p data-svelte-h="svelte-1pjr02p">Some Patch Functors are already provided in CacheDiT, <a href="https://github.com/vipshop/cache-dit/blob/main/src/cache_dit/cache_factory/patch_functors/functor_hidream.py" rel="nofollow">HiDreamPatchFunctor</a>, <a href="https://github.com/vipshop/cache-dit/blob/main/src/cache_dit/cache_factory/patch_functors/functor_chroma.py" rel="nofollow">ChromaPatchFunctor</a>, etc.</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-meta">@BlockAdapterRegistry.register(<span class="hljs-params"><span class="hljs-string">"HiDream"</span></span>)</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">hidream_adapter</span>(<span class="hljs-params">pipe, **kwargs</span>) -> BlockAdapter: | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HiDreamImageTransformer2DModel | |
| <span class="hljs-keyword">from</span> cache_dit.cache_factory.patch_functors <span class="hljs-keyword">import</span> HiDreamPatchFunctor | |
| <span class="hljs-keyword">assert</span> <span class="hljs-built_in">isinstance</span>(pipe.transformer, HiDreamImageTransformer2DModel) | |
| <span class="hljs-keyword">return</span> BlockAdapter( | |
| pipe=pipe, | |
| transformer=pipe.transformer, | |
| blocks=[ | |
| pipe.transformer.double_stream_blocks, | |
| pipe.transformer.single_stream_blocks, | |
| ], | |
| forward_pattern=[ | |
| ForwardPattern.Pattern_0, | |
| ForwardPattern.Pattern_3, | |
| ], | |
| <span class="hljs-comment"># <span class="hljs-doctag">NOTE:</span> Setup your custom patch functor here.</span> | |
| patch_functor=HiDreamPatchFunctor(), | |
| **kwargs, | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-oldsw1">Finally, you can call the <code>cache_dit.summary()</code> function on a pipeline after its completed inference to get the cache acceleration details.</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 -->stats = cache_dit.summary(pipe)<!-- HTML_TAG_END --></pre></div> <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 -->⚡️Cache Steps <span class="hljs-keyword">and</span> Residual Diffs Statistics: QwenImagePipeline | |
| | Cache Steps | Diffs Min | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Max | | |
| |-------------|-----------|-----------|-----------|-----------|-----------|-----------| | |
| | <span class="hljs-number">23</span> | <span class="hljs-number">0.045</span> | <span class="hljs-number">0.084</span> | <span class="hljs-number">0.114</span> | <span class="hljs-number">0.147</span> | <span class="hljs-number">0.241</span> | <span class="hljs-number">0.297</span> |<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="dbcache-dual-block-cache" 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="#dbcache-dual-block-cache"><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>DBCache: Dual Block Cache</span></h2> <p data-svelte-h="svelte-1b446h5"><img src="https://github.com/vipshop/cache-dit/raw/main/assets/dbcache-v1.png"></p> <p data-svelte-h="svelte-1s3papx">DBCache (Dual Block Caching) supports different configurations of compute blocks (F8B12, etc.) to enable a balanced trade-off between performance and precision.</p> <ul data-svelte-h="svelte-2bd58k"><li>Fn_compute_blocks: Specifies that DBCache uses the <strong>first n</strong> Transformer blocks to fit the information at time step t, enabling the calculation of a more stable L1 diff and delivering more accurate information to subsequent blocks.</li> <li>Bn_compute_blocks: Further fuses approximate information in the <strong>last n</strong> Transformer blocks to enhance prediction accuracy. These blocks act as an auto-scaler for approximate hidden states that use residual cache.</li></ul> <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> cache_dit | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FluxPipeline | |
| pipe_or_adapter = FluxPipeline.from_pretrained( | |
| <span class="hljs-string">"black-forest-labs/FLUX.1-dev"</span>, | |
| torch_dtype=torch.bfloat16, | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-comment"># Default options, F8B0, 8 warmup steps, and unlimited cached </span> | |
| <span class="hljs-comment"># steps for good balance between performance and precision</span> | |
| cache_dit.enable_cache(pipe_or_adapter) | |
| <span class="hljs-comment"># Custom options, F8B8, higher precision</span> | |
| <span class="hljs-keyword">from</span> cache_dit <span class="hljs-keyword">import</span> BasicCacheConfig | |
| cache_dit.enable_cache( | |
| pipe_or_adapter, | |
| cache_config=BasicCacheConfig( | |
| max_warmup_steps=<span class="hljs-number">8</span>, <span class="hljs-comment"># steps do not cache</span> | |
| max_cached_steps=-<span class="hljs-number">1</span>, <span class="hljs-comment"># -1 means no limit</span> | |
| Fn_compute_blocks=<span class="hljs-number">8</span>, <span class="hljs-comment"># Fn, F8, etc.</span> | |
| Bn_compute_blocks=<span class="hljs-number">8</span>, <span class="hljs-comment"># Bn, B8, etc.</span> | |
| residual_diff_threshold=<span class="hljs-number">0.12</span>, | |
| ), | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1scjn5v">Check the <a href="https://github.com/vipshop/cache-dit/blob/main/docs/DBCache.md" rel="nofollow">DBCache</a> and <a href="https://github.com/vipshop/cache-dit/blob/main/docs/User_Guide.md#dbcache" rel="nofollow">User Guide</a> docs for more design details.</p> <h2 class="relative group"><a id="taylorseer-calibrator" 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="#taylorseer-calibrator"><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>TaylorSeer Calibrator</span></h2> <p data-svelte-h="svelte-134vs1n">The <a href="https://huggingface.co/papers/2503.06923" rel="nofollow">TaylorSeers</a> algorithm further improves the precision of DBCache in cases where the cached steps are large (Hybrid TaylorSeer + DBCache). At timesteps with significant intervals, the feature similarity in diffusion models decreases substantially, significantly harming the generation quality.</p> <p data-svelte-h="svelte-vf09xa">TaylorSeer employs a differential method to approximate the higher-order derivatives of features and predict features in future timesteps with Taylor series expansion. The TaylorSeer implemented in CacheDiT supports both hidden states and residual cache types. F_pred can be a residual cache or a hidden-state cache.</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">from</span> cache_dit <span class="hljs-keyword">import</span> BasicCacheConfig, TaylorSeerCalibratorConfig | |
| cache_dit.enable_cache( | |
| pipe_or_adapter, | |
| <span class="hljs-comment"># Basic DBCache w/ FnBn configurations</span> | |
| cache_config=BasicCacheConfig( | |
| max_warmup_steps=<span class="hljs-number">8</span>, <span class="hljs-comment"># steps do not cache</span> | |
| max_cached_steps=-<span class="hljs-number">1</span>, <span class="hljs-comment"># -1 means no limit</span> | |
| Fn_compute_blocks=<span class="hljs-number">8</span>, <span class="hljs-comment"># Fn, F8, etc.</span> | |
| Bn_compute_blocks=<span class="hljs-number">8</span>, <span class="hljs-comment"># Bn, B8, etc.</span> | |
| residual_diff_threshold=<span class="hljs-number">0.12</span>, | |
| ), | |
| <span class="hljs-comment"># Then, you can use the TaylorSeer Calibrator to approximate </span> | |
| <span class="hljs-comment"># the values in cached steps, taylorseer_order default is 1.</span> | |
| calibrator_config=TaylorSeerCalibratorConfig( | |
| taylorseer_order=<span class="hljs-number">1</span>, | |
| ), | |
| )<!-- HTML_TAG_END --></pre></div> <blockquote class="tip" data-svelte-h="svelte-12qv3of"><p><br> | |
| The <code>Bn_compute_blocks</code> parameter of DBCache can be set to <code>0</code> if you use TaylorSeer as the calibrator for approximate hidden states. DBCache’s <code>Bn_compute_blocks</code> also acts as a calibrator, so you can choose either <code>Bn_compute_blocks</code> > 0 or TaylorSeer. We recommend using the configuration scheme of TaylorSeer + DBCache FnB0.</p></blockquote> <h2 class="relative group"><a id="hybrid-cache-cfg" 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="#hybrid-cache-cfg"><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>Hybrid Cache CFG</span></h2> <p data-svelte-h="svelte-bpk9jb">CacheDiT supports caching for CFG (classifier-free guidance). For models that fuse CFG and non-CFG into a single forward step, or models that do not include CFG in the forward step, please set <code>enable_separate_cfg</code> parameter to <code>False (default, None)</code>. Otherwise, set it to <code>True</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">from</span> cache_dit <span class="hljs-keyword">import</span> BasicCacheConfig | |
| cache_dit.enable_cache( | |
| pipe_or_adapter, | |
| cache_config=BasicCacheConfig( | |
| ..., | |
| <span class="hljs-comment"># For example, set it as True for Wan 2.1, Qwen-Image </span> | |
| <span class="hljs-comment"># and set it as False for FLUX.1, HunyuanVideo, etc.</span> | |
| enable_separate_cfg=<span class="hljs-literal">True</span>, | |
| ), | |
| )<!-- 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> <p data-svelte-h="svelte-1m7dmpb">CacheDiT is designed to work with torch.compile for even better performance. Call <code>torch.compile</code> after enabling the cache.</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 -->cache_dit.enable_cache(pipe) | |
| <span class="hljs-comment"># Compile the Transformer module</span> | |
| pipe.transformer = torch.<span class="hljs-built_in">compile</span>(pipe.transformer)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1kanb2y">If you’re using CacheDiT with dynamic input shapes, consider increasing the <code>recompile_limit</code> of <code>torch._dynamo</code>. Otherwise, the <code>recompile_limit</code> error may be triggered, causing the module to fall back to eager mode.</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 -->torch._dynamo.config.recompile_limit = <span class="hljs-number">96</span> <span class="hljs-comment"># default is 8</span> | |
| torch._dynamo.config.accumulated_recompile_limit = <span class="hljs-number">2048</span> <span class="hljs-comment"># default is 256</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-8nl96h">Please check <a href="https://github.com/vipshop/cache-dit/blob/main/bench/perf.py" rel="nofollow">perf.py</a> for more details.</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/en/optimization/cache_dit.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_15arw4w = { | |
| assets: "/docs/diffusers/pr_12249/en", | |
| base: "/docs/diffusers/pr_12249/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/diffusers/pr_12249/en/_app/immutable/entry/start.d78ccb7e.js"), | |
| import("/docs/diffusers/pr_12249/en/_app/immutable/entry/app.cd68c46f.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 277], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 45.4 kB
- Xet hash:
- 441ff9f03210f0694721a01876d67bfd236d2169935c9a819a922aa6b44d118b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.