import{s as Il,o as Xl,n as Pt}from"../chunks/scheduler.53228c21.js";import{S as Ll,i as Vl,e as o,s as a,c as u,h as Hl,a as p,d as l,b as n,f as Rl,g as d,j as c,k as x,l as Ql,m as s,n as h,t as b,o as y,p as M}from"../chunks/index.100fac89.js";import{C as Yl}from"../chunks/CopyLLMTxtMenu.b0ff86f3.js";import{C as U}from"../chunks/CodeBlock.d30a6509.js";import{H as G,E as Fl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";import{H as Nl,a as At}from"../chunks/HfOption.fad27e59.js";function zl(_){let m,j="bfloat16 is similar to float16 but it is more robust to numerical errors. Hardware support for bfloat16 varies, but most modern GPUs are capable of supporting bfloat16.",T,f,J;return f=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrJTIyJTBBcGlwZWxpbmUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDMwKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>
pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){m=o("p"),m.textContent=j,T=a(),u(f.$$.fragment)},l(r){m=p(r,"P",{"data-svelte-h":!0}),c(m)!=="svelte-kz0em0"&&(m.textContent=j),T=n(r),d(f.$$.fragment,r)},m(r,i){s(r,m,i),s(r,T,i),h(f,r,i),J=!0},p:Pt,i(r){J||(b(f.$$.fragment,r),J=!0)},o(r){y(f.$$.fragment,r),J=!1},d(r){r&&(l(m),l(T)),M(f,r)}}}function El(_){let m,j="float16 is similar to bfloat16 but may be more prone to numerical errors.",T,f,J;return f=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGslMjIlMEFwaXBlbGluZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMzApLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>
pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){m=o("p"),m.textContent=j,T=a(),u(f.$$.fragment)},l(r){m=p(r,"P",{"data-svelte-h":!0}),c(m)!=="svelte-nzm7ns"&&(m.textContent=j),T=n(r),d(f.$$.fragment,r)},m(r,i){s(r,m,i),s(r,T,i),h(f,r,i),J=!0},p:Pt,i(r){J||(b(f.$$.fragment,r),J=!0)},o(r){y(f.$$.fragment,r),J=!1},d(r){r&&(l(m),l(T)),M(f,r)}}}function Sl(_){let m,j='<a href="https://blogs.nvidia.com/blog/2020/05/14/tensorfloat-32-precision-format/" rel="nofollow">TensorFloat-32 (tf32)</a> mode is supported on NVIDIA Ampere GPUs and it computes the convolution and matrix multiplication operations in tf32. Storage and other operations are kept in float32. This enables significantly faster computations when combined with bfloat16 or float16.',T,f,J="PyTorch only enables tf32 mode for convolutions by default and you’ll need to explicitly enable it for matrix multiplications.",r,i,g,$,k='Refer to the <a href="https://huggingface.co/docs/transformers/en/perf_train_gpu_one#mixed-precision" rel="nofollow">mixed precision training</a> docs for more details.',Z;return i=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXRvcmNoLmJhY2tlbmRzLmN1ZGEubWF0bXVsLmFsbG93X3RmMzIlMjAlM0QlMjBUcnVlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGslMjIlMEFwaXBlbGluZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMzApLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

torch.backends.cuda.matmul.allow_tf32 = <span class="hljs-literal">True</span>

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>
pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){m=o("p"),m.innerHTML=j,T=a(),f=o("p"),f.textContent=J,r=a(),u(i.$$.fragment),g=a(),$=o("p"),$.innerHTML=k},l(w){m=p(w,"P",{"data-svelte-h":!0}),c(m)!=="svelte-1sdg1x4"&&(m.innerHTML=j),T=n(w),f=p(w,"P",{"data-svelte-h":!0}),c(f)!=="svelte-13cgegp"&&(f.textContent=J),r=n(w),d(i.$$.fragment,w),g=n(w),$=p(w,"P",{"data-svelte-h":!0}),c($)!=="svelte-uy7wpj"&&($.innerHTML=k)},m(w,W){s(w,m,W),s(w,T,W),s(w,f,W),s(w,r,W),h(i,w,W),s(w,g,W),s(w,$,W),Z=!0},p:Pt,i(w){Z||(b(i.$$.fragment,w),Z=!0)},o(w){y(i.$$.fragment,w),Z=!1},d(w){w&&(l(m),l(T),l(f),l(r),l(g),l($)),M(i,w)}}}function ql(_){let m,j,T,f,J,r;return m=new At({props:{id:"dtypes",option:"bfloat16",$$slots:{default:[zl]},$$scope:{ctx:_}}}),T=new At({props:{id:"dtypes",option:"float16",$$slots:{default:[El]},$$scope:{ctx:_}}}),J=new At({props:{id:"dtypes",option:"TensorFloat-32",$$slots:{default:[Sl]},$$scope:{ctx:_}}}),{c(){u(m.$$.fragment),j=a(),u(T.$$.fragment),f=a(),u(J.$$.fragment)},l(i){d(m.$$.fragment,i),j=n(i),d(T.$$.fragment,i),f=n(i),d(J.$$.fragment,i)},m(i,g){h(m,i,g),s(i,j,g),h(T,i,g),s(i,f,g),h(J,i,g),r=!0},p(i,g){const $={};g&2&&($.$$scope={dirty:g,ctx:i}),m.$set($);const k={};g&2&&(k.$$scope={dirty:g,ctx:i}),T.$set(k);const Z={};g&2&&(Z.$$scope={dirty:g,ctx:i}),J.$set(Z)},i(i){r||(b(m.$$.fragment,i),b(T.$$.fragment,i),b(J.$$.fragment,i),r=!0)},o(i){y(m.$$.fragment,i),y(T.$$.fragment,i),y(J.$$.fragment,i),r=!1},d(i){i&&(l(j),l(f)),M(m,i),M(T,i),M(J,i)}}}function Al(_){let m,j,T,f,J,r,i,g,$,k='Diffusion models are slow at inference because generation is an iterative process where noise is gradually refined into an image or video over a certain number of “steps”. To speedup this process, you can try experimenting with different <a href="../api/schedulers/overview">schedulers</a>, reduce the precision of the model weights for faster computations, use more memory-efficient attention mechanisms, and more.',Z,w,W="Combine and use these techniques together to make inference faster than using any single technique on its own.",He,H,Dt="This guide will go over how to accelerate inference.",Qe,Q,Ye,Y,Kt="The precision and data type of the model weights affect inference speed because a higher precision requires more memory to load and more time to perform the computations. PyTorch loads model weights in float32 or full precision by default, so changing the data type is a simple way to quickly get faster inference.",Fe,v,Ne,F,ze,B,Ot='<p>Memory-efficient attention optimizes for inference speed <em>and</em> <a href="./memory#memory-efficient-attention">memory usage</a>!</p>',Ee,N,el='<a href="https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html" rel="nofollow">Scaled dot product attention (SDPA)</a> implements several attention backends, <a href="https://github.com/Dao-AILab/flash-attention" rel="nofollow">FlashAttention</a>, <a href="https://github.com/facebookresearch/xformers" rel="nofollow">xFormers</a>, and a native C++ implementation. It automatically selects the most optimal backend for your hardware.',Se,z,tl='SDPA is enabled by default if you’re using PyTorch &gt;= 2.0 and no additional changes are required to your code. You could try experimenting with other attention backends though if you’d like to choose your own. The example below uses the <a href="https://pytorch.org/docs/stable/generated/torch.nn.attention.sdpa_kernel.html" rel="nofollow">torch.nn.attention.sdpa_kernel</a> context manager to enable efficient attention.',qe,E,Ae,S,Pe,q,ll='<a href="https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html" rel="nofollow">torch.compile</a> accelerates inference by compiling PyTorch code and operations into optimized kernels. Diffusers typically compiles the more compute-intensive models like the UNet, transformer, or VAE.',De,A,sl='Enable the following compiler settings for maximum speed (refer to the <a href="https://github.com/pytorch/pytorch/blob/main/torch/_inductor/config.py" rel="nofollow">full list</a> for more options).',Ke,P,Oe,D,al="Load and compile the UNet and VAE. There are several different modes you can choose from, but <code>&quot;max-autotune&quot;</code> optimizes for the fastest speed by compiling to a CUDA graph. CUDA graphs effectively reduces the overhead by launching multiple GPU operations through a single CPU operation.",et,C,nl='<p>With PyTorch 2.3.1, you can control the caching behavior of torch.compile. This is particularly beneficial for compilation modes like <code>&quot;max-autotune&quot;</code> which performs a grid-search over several compilation flags to find the optimal configuration. Learn more in the <a href="https://pytorch.org/tutorials/recipes/torch_compile_caching_tutorial.html" rel="nofollow">Compile Time Caching in torch.compile</a> tutorial.</p>',tt,K,il='Changing the memory layout to <a href="./memory#torchchannels_last">channels_last</a> also optimizes memory and inference speed.',lt,O,st,ee,ol="Compilation is slow the first time, but once compiled, it is significantly faster. Try to only use the compiled pipeline on the same type of inference operations. Calling the compiled pipeline on a different image size retriggers compilation which is slow and inefficient.",at,te,nt,R,pl="<p>Make sure to always use the nightly version of PyTorch for better support.</p>",it,le,rl="<code>torch.compile</code> keeps track of input shapes and conditions, and if these are different, it recompiles the model. For example, if a model is compiled on a 1024x1024 resolution image and used on an image with a different resolution, it triggers recompilation.",ot,se,cl="To avoid recompilation, add <code>dynamic=True</code> to try and generate a more dynamic kernel to avoid recompilation when conditions change.",pt,ae,rt,ne,ml='Specifying <code>use_duck_shape=False</code> instructs the compiler if it should use the same symbolic variable to represent input sizes that are the same. For more details, check out this <a href="https://github.com/huggingface/diffusers/pull/11327#discussion_r2047659790" rel="nofollow">comment</a>.',ct,ie,fl='Not all models may benefit from dynamic compilation out of the box and may require changes. Refer to this <a href="https://github.com/huggingface/diffusers/pull/11297/" rel="nofollow">PR</a> that improved the <a href="/docs/diffusers/main/en/api/pipelines/aura_flow#diffusers.AuraFlowPipeline">AuraFlowPipeline</a> implementation to benefit from dynamic compilation.',mt,oe,ul="Feel free to open an issue if dynamic compilation doesn’t work as expected for a Diffusers model.",ft,pe,ut,re,dl=`<a href="https://docs.pytorch.org/tutorials/recipes/regional_compilation.html" rel="nofollow">Regional compilation</a> trims cold-start latency by only compiling the <em>small and frequently-repeated block(s)</em> of a model - typically a transformer layer - and enables reusing compiled artifacts for every subsequent occurrence.
For many diffusion architectures, this delivers the same runtime speedups as full-graph compilation and reduces compile time by 8–10x.`,dt,ce,hl='Use the <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.compile_repeated_blocks">compile_repeated_blocks()</a> method, a helper that wraps <code>torch.compile</code>, on any component such as the transformer model as shown below.',ht,me,bt,fe,bl="To enable regional compilation for a new model, add a <code>_repeated_blocks</code> attribute to a model class containing the class names (as strings) of the blocks you want to compile.",yt,ue,Mt,I,yl='<p>For more regional compilation examples, see the reference <a href="https://github.com/huggingface/diffusers/pull/11705" rel="nofollow">PR</a>.</p>',wt,de,Ml='There is also a <a href="https://github.com/huggingface/accelerate/blob/273799c85d849a1954a4f2e65767216eb37fa089/src/accelerate/utils/other.py#L78" rel="nofollow">compile_regions</a> method in <a href="https://huggingface.co/docs/accelerate/index" rel="nofollow">Accelerate</a> that automatically selects candidate blocks in a model to compile. The remaining graph is compiled separately. This is useful for quick experiments because there aren’t as many options for you to set which blocks to compile or adjust compilation flags.',Tt,he,Jt,be,wl='<a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.compile_repeated_blocks">compile_repeated_blocks()</a> is intentionally explicit. List the blocks to repeat in <code>_repeated_blocks</code> and the helper only compiles those blocks. It offers predictable behavior and easy reasoning about cache reuse in one line of code.',gt,ye,jt,Me,Tl="It is important to specify <code>fullgraph=True</code> in torch.compile to ensure there are no graph breaks in the underlying model. This allows you to take advantage of torch.compile without any performance degradation. For the UNet and VAE, this changes how you access the return variables.",$t,we,Ut,Te,Zt,Je,Jl='The <code>step()</code> function is <a href="https://github.com/huggingface/diffusers/blob/1d686bac8146037e97f3fd8c56e4063230f71751/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py#L1228" rel="nofollow">called</a> on the scheduler each time after the denoiser makes a prediction, and the <code>sigmas</code> variable is <a href="https://github.com/huggingface/diffusers/blob/1d686bac8146037e97f3fd8c56e4063230f71751/src/diffusers/schedulers/scheduling_euler_discrete.py#L476" rel="nofollow">indexed</a>. When placed on the GPU, it introduces latency because of the communication sync between the CPU and GPU. It becomes more evident when the denoiser has already been compiled.',Gt,ge,gl='In general, the <code>sigmas</code> should <a href="https://github.com/huggingface/diffusers/blob/35a969d297cba69110d175ee79c59312b9f49e1e/src/diffusers/schedulers/scheduling_euler_discrete.py#L240" rel="nofollow">stay on the CPU</a> to avoid the communication sync and latency.',_t,X,jl='<p>Refer to the <a href="https://pytorch.org/blog/torch-compile-and-diffusers-a-hands-on-guide-to-peak-performance/" rel="nofollow">torch.compile and Diffusers: A Hands-On Guide to Peak Performance</a> blog post for maximizing performance with <code>torch.compile</code> for diffusion models.</p>',Wt,je,xt,$e,$l='Refer to the <a href="https://huggingface.co/datasets/diffusers/benchmarks" rel="nofollow">diffusers/benchmarks</a> dataset to see inference latency and memory usage data for compiled pipelines.',kt,Ue,Ul='The <a href="https://github.com/sayakpaul/diffusers-torchao#benchmarking-results" rel="nofollow">diffusers-torchao</a> repository also contains benchmarking results for compiled versions of Flux and CogVideoX.',vt,Ze,Bt,Ge,Zl='<a href="https://pytorch.org/tutorials/recipes/recipes/dynamic_quantization.html" rel="nofollow">Dynamic quantization</a> improves inference speed by reducing precision to enable faster math operations. This particular type of quantization determines how to scale the activations based on the data at runtime rather than using a fixed scaling factor. As a result, the scaling factor is more accurately aligned with the data.',Ct,_e,Gl='The example below applies <a href="https://pytorch.org/tutorials/recipes/recipes/dynamic_quantization.html" rel="nofollow">dynamic int8 quantization</a> to the UNet and VAE with the <a href="../quantization/torchao">torchao</a> library.',Rt,L,_l='<p>Refer to our <a href="../quantization/torchao">torchao</a> docs to learn more about how to use the Diffusers torchao integration.</p>',It,We,Wl="Configure the compiler tags for maximum speed.",Xt,xe,Lt,ke,xl='Filter out some linear layers in the UNet and VAE which don’t benefit from dynamic quantization with the <a href="https://github.com/huggingface/diffusion-fast/blob/0f169640b1db106fe6a479f78c1ed3bfaeba3386/utils/pipeline_utils.py#L16" rel="nofollow">dynamic_quant_filter_fn</a>.',Vt,ve,Ht,Be,Qt,V,kl='<p>The <a href="https://github.com/huggingface/diffusers/blob/58431f102cf39c3c8a569f32d71b2ea8caa461e1/src/diffusers/pipelines/pipeline_utils.py#L2034" rel="nofollow">fuse_qkv_projections</a> method is experimental and support is limited to mostly Stable Diffusion pipelines. Take a look at this <a href="https://github.com/huggingface/diffusers/pull/6179" rel="nofollow">PR</a> to learn more about how to enable it for other pipelines</p>',Yt,Ce,vl="An input is projected into three subspaces, represented by the projection matrices Q, K, and V, in an attention block. These projections are typically calculated separately, but you can horizontally combine these into a single matrix and perform the projection in a single step. It increases the size of the matrix multiplications of the input projections and also improves the impact of quantization.",Ft,Re,Nt,Ie,zt,Xe,Bl=`<li><p>Read the <a href="https://pytorch.org/blog/presenting-flux-fast-making-flux-go-brrr-on-h100s/" rel="nofollow">Presenting Flux Fast: Making Flux go brrr on H100s</a> blog post to learn more about how you can combine all of these optimizations with <a href="https://docs.pytorch.org/docs/stable/torch.compiler.html" rel="nofollow">TorchInductor</a> and <a href="https://docs.pytorch.org/docs/stable/torch.compiler_aot_inductor.html" rel="nofollow">AOTInductor</a> for a ~2.5x speedup using recipes from <a href="https://github.com/huggingface/flux-fast" rel="nofollow">flux-fast</a>.</p> <p>These recipes support AMD hardware and <a href="https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev" rel="nofollow">Flux.1 Kontext Dev</a>.</p></li> <li><p>Read the <a href="https://pytorch.org/blog/torch-compile-and-diffusers-a-hands-on-guide-to-peak-performance/" rel="nofollow">torch.compile and Diffusers: A Hands-On Guide to Peak Performance</a> blog post
to maximize performance when using <code>torch.compile</code>.</p></li>`,Et,Le,St,Ve,qt;return J=new Yl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),i=new G({props:{title:"Accelerate inference",local:"accelerate-inference",headingTag:"h1"}}),Q=new G({props:{title:"Model data type",local:"model-data-type",headingTag:"h2"}}),v=new Nl({props:{id:"dtypes",options:["bfloat16","float16","TensorFloat-32"],$$slots:{default:[ql]},$$scope:{ctx:_}}}),F=new G({props:{title:"Scaled dot product attention",local:"scaled-dot-product-attention",headingTag:"h2"}}),E=new U({props:{code:"ZnJvbSUyMHRvcmNoLm5uLmF0dGVudGlvbiUyMGltcG9ydCUyMFNEUEJhY2tlbmQlMkMlMjBzZHBhX2tlcm5lbCUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQXN0cm9uYXV0JTIwaW4lMjBhJTIwanVuZ2xlJTJDJTIwY29sZCUyMGNvbG9yJTIwcGFsZXR0ZSUyQyUyMG11dGVkJTIwY29sb3JzJTJDJTIwZGV0YWlsZWQlMkMlMjA4ayUyMiUwQSUwQXdpdGglMjBzZHBhX2tlcm5lbChTRFBCYWNrZW5kLkVGRklDSUVOVF9BVFRFTlRJT04pJTNBJTBBJTIwJTIwaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMzApLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> torch.nn.attention <span class="hljs-keyword">import</span> SDPBackend, sdpa_kernel
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>

<span class="hljs-keyword">with</span> sdpa_kernel(SDPBackend.EFFICIENT_ATTENTION):
  image = pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),S=new G({props:{title:"torch.compile",local:"torchcompile",headingTag:"h2"}}),P=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXRvcmNoLl9pbmR1Y3Rvci5jb25maWcuY29udl8xeDFfYXNfbW0lMjAlM0QlMjBUcnVlJTBBdG9yY2guX2luZHVjdG9yLmNvbmZpZy5jb29yZGluYXRlX2Rlc2NlbnRfdHVuaW5nJTIwJTNEJTIwVHJ1ZSUwQXRvcmNoLl9pbmR1Y3Rvci5jb25maWcuZXBpbG9ndWVfZnVzaW9uJTIwJTNEJTIwRmFsc2UlMEF0b3JjaC5faW5kdWN0b3IuY29uZmlnLmNvb3JkaW5hdGVfZGVzY2VudF9jaGVja19hbGxfZGlyZWN0aW9ucyUyMCUzRCUyMFRydWU=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

torch._inductor.config.conv_1x1_as_mm = <span class="hljs-literal">True</span>
torch._inductor.config.coordinate_descent_tuning = <span class="hljs-literal">True</span>
torch._inductor.config.epilogue_fusion = <span class="hljs-literal">False</span>
torch._inductor.config.coordinate_descent_check_all_directions = <span class="hljs-literal">True</span>`,wrap:!1}}),O=new U({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUudW5ldC50byhtZW1vcnlfZm9ybWF0JTNEdG9yY2guY2hhbm5lbHNfbGFzdCklMEFwaXBlbGluZS52YWUudG8obWVtb3J5X2Zvcm1hdCUzRHRvcmNoLmNoYW5uZWxzX2xhc3QpJTBBcGlwZWxpbmUudW5ldCUyMCUzRCUyMHRvcmNoLmNvbXBpbGUoJTBBJTIwJTIwJTIwJTIwcGlwZWxpbmUudW5ldCUyQyUyMG1vZGUlM0QlMjJtYXgtYXV0b3R1bmUlMjIlMkMlMjBmdWxsZ3JhcGglM0RUcnVlJTBBKSUwQXBpcGVsaW5lLnZhZS5kZWNvZGUlMjAlM0QlMjB0b3JjaC5jb21waWxlKCUwQSUyMCUyMCUyMCUyMHBpcGVsaW5lLnZhZS5kZWNvZGUlMkMlMEElMjAlMjAlMjAlMjBtb2RlJTNEJTIybWF4LWF1dG90dW5lJTIyJTJDJTBBJTIwJTIwJTIwJTIwZnVsbGdyYXBoJTNEVHJ1ZSUwQSklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrJTIyJTBBcGlwZWxpbmUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDMwKS5pbWFnZXMlNUIwJTVE",highlighted:`pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.unet.to(memory_format=torch.channels_last)
pipeline.vae.to(memory_format=torch.channels_last)
pipeline.unet = torch.<span class="hljs-built_in">compile</span>(
    pipeline.unet, mode=<span class="hljs-string">&quot;max-autotune&quot;</span>, fullgraph=<span class="hljs-literal">True</span>
)
pipeline.vae.decode = torch.<span class="hljs-built_in">compile</span>(
    pipeline.vae.decode,
    mode=<span class="hljs-string">&quot;max-autotune&quot;</span>,
    fullgraph=<span class="hljs-literal">True</span>
)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>
pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),te=new G({props:{title:"Dynamic shape compilation",local:"dynamic-shape-compilation",headingTag:"h3"}}),ae=new U({props:{code:"JTJCJTIwdG9yY2guZnguZXhwZXJpbWVudGFsLl9jb25maWcudXNlX2R1Y2tfc2hhcGUlMjAlM0QlMjBGYWxzZSUwQSUyQiUyMHBpcGVsaW5lLnVuZXQlMjAlM0QlMjB0b3JjaC5jb21waWxlKCUwQSUyMCUyMCUyMCUyMHBpcGVsaW5lLnVuZXQlMkMlMjBmdWxsZ3JhcGglM0RUcnVlJTJDJTIwZHluYW1pYyUzRFRydWUlMEEp",highlighted:`<span class="hljs-addition">+ torch.fx.experimental._config.use_duck_shape = False</span>
<span class="hljs-addition">+ pipeline.unet = torch.compile(</span>
    pipeline.unet, fullgraph=True, dynamic=True
)`,wrap:!1}}),pe=new G({props:{title:"Regional compilation",local:"regional-compilation",headingTag:"h3"}}),me=new U({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMC1VJTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMGNvbXBpbGUlMjBvbmx5JTIwdGhlJTIwcmVwZWF0ZWQlMjB0cmFuc2Zvcm1lciUyMGxheWVycyUyMGluc2lkZSUyMHRoZSUyMFVOZXQlMEFwaXBlbGluZS51bmV0LmNvbXBpbGVfcmVwZWF0ZWRfYmxvY2tzKGZ1bGxncmFwaCUzRFRydWUp",highlighted:`<span class="hljs-comment"># pip install -U diffusers</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># compile only the repeated transformer layers inside the UNet</span>
pipeline.unet.compile_repeated_blocks(fullgraph=<span class="hljs-literal">True</span>)`,wrap:!1}}),ue=new U({props:{code:"Y2xhc3MlMjBNeVVOZXQoTW9kZWxNaXhpbiklM0ElMEElMjAlMjAlMjAlMjBfcmVwZWF0ZWRfYmxvY2tzJTIwJTNEJTIwKCUyMlRyYW5zZm9ybWVyMkRNb2RlbCUyMiUyQyklMjAlMjAlMjMlMjAlRTIlODYlOTAlMjBjb21waWxlZCUyMGJ5JTIwZGVmYXVsdA==",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyUNet</span>(<span class="hljs-title class_ inherited__">ModelMixin</span>):
    _repeated_blocks = (<span class="hljs-string">&quot;Transformer2DModel&quot;</span>,)  <span class="hljs-comment"># ← compiled by default</span>`,wrap:!1}}),he=new U({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMC1VJTIwYWNjZWxlcmF0ZSUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUlMEFmcm9tJTIwYWNjZWxlcmF0ZS51dGlscyUyMGltcG9ydCUyMGNvbXBpbGVfcmVnaW9ucyUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLnVuZXQlMjAlM0QlMjBjb21waWxlX3JlZ2lvbnMocGlwZWxpbmUudW5ldCUyQyUyMG1vZGUlM0QlMjJyZWR1Y2Utb3ZlcmhlYWQlMjIlMkMlMjBmdWxsZ3JhcGglM0RUcnVlKQ==",highlighted:`<span class="hljs-comment"># pip install -U accelerate</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline
<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> compile_regions

pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.unet = compile_regions(pipeline.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)`,wrap:!1}}),ye=new G({props:{title:"Graph breaks",local:"graph-breaks",headingTag:"h3"}}),we=new U({props:{code:"LSUyMGxhdGVudHMlMjAlM0QlMjB1bmV0KCUwQS0lMjAlMjAlMjBsYXRlbnRzJTJDJTIwdGltZXN0ZXAlM0R0aW1lc3RlcCUyQyUyMGVuY29kZXJfaGlkZGVuX3N0YXRlcyUzRHByb21wdF9lbWJlZHMlMEEtKS5zYW1wbGUlMEElMEElMkIlMjBsYXRlbnRzJTIwJTNEJTIwdW5ldCglMEElMkIlMjAlMjAlMjBsYXRlbnRzJTJDJTIwdGltZXN0ZXAlM0R0aW1lc3RlcCUyQyUyMGVuY29kZXJfaGlkZGVuX3N0YXRlcyUzRHByb21wdF9lbWJlZHMlMkMlMjByZXR1cm5fZGljdCUzREZhbHNlJTBBJTJCKSU1QjAlNUQ=",highlighted:`<span class="hljs-deletion">- latents = unet(</span>
<span class="hljs-deletion">-   latents, timestep=timestep, encoder_hidden_states=prompt_embeds</span>
<span class="hljs-deletion">-).sample</span>

<span class="hljs-addition">+ latents = unet(</span>
<span class="hljs-addition">+   latents, timestep=timestep, encoder_hidden_states=prompt_embeds, return_dict=False</span>
<span class="hljs-addition">+)[0]</span>`,wrap:!1}}),Te=new G({props:{title:"GPU sync",local:"gpu-sync",headingTag:"h3"}}),je=new G({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h3"}}),Ze=new G({props:{title:"Dynamic quantization",local:"dynamic-quantization",headingTag:"h2"}}),xe=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdG9yY2hhbyUyMGltcG9ydCUyMGFwcGx5X2R5bmFtaWNfcXVhbnQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQSUwQXRvcmNoLl9pbmR1Y3Rvci5jb25maWcuY29udl8xeDFfYXNfbW0lMjAlM0QlMjBUcnVlJTBBdG9yY2guX2luZHVjdG9yLmNvbmZpZy5jb29yZGluYXRlX2Rlc2NlbnRfdHVuaW5nJTIwJTNEJTIwVHJ1ZSUwQXRvcmNoLl9pbmR1Y3Rvci5jb25maWcuZXBpbG9ndWVfZnVzaW9uJTIwJTNEJTIwRmFsc2UlMEF0b3JjaC5faW5kdWN0b3IuY29uZmlnLmNvb3JkaW5hdGVfZGVzY2VudF9jaGVja19hbGxfZGlyZWN0aW9ucyUyMCUzRCUyMFRydWUlMEF0b3JjaC5faW5kdWN0b3IuY29uZmlnLmZvcmNlX2Z1c2VfaW50X21tX3dpdGhfbXVsJTIwJTNEJTIwVHJ1ZSUwQXRvcmNoLl9pbmR1Y3Rvci5jb25maWcudXNlX21peGVkX21tJTIwJTNEJTIwVHJ1ZQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> torchao <span class="hljs-keyword">import</span> apply_dynamic_quant
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline

torch._inductor.config.conv_1x1_as_mm = <span class="hljs-literal">True</span>
torch._inductor.config.coordinate_descent_tuning = <span class="hljs-literal">True</span>
torch._inductor.config.epilogue_fusion = <span class="hljs-literal">False</span>
torch._inductor.config.coordinate_descent_check_all_directions = <span class="hljs-literal">True</span>
torch._inductor.config.force_fuse_int_mm_with_mul = <span class="hljs-literal">True</span>
torch._inductor.config.use_mixed_mm = <span class="hljs-literal">True</span>`,wrap:!1}}),ve=new U({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWFwcGx5X2R5bmFtaWNfcXVhbnQocGlwZWxpbmUudW5ldCUyQyUyMGR5bmFtaWNfcXVhbnRfZmlsdGVyX2ZuKSUwQWFwcGx5X2R5bmFtaWNfcXVhbnQocGlwZWxpbmUudmFlJTJDJTIwZHluYW1pY19xdWFudF9maWx0ZXJfZm4pJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQXN0cm9uYXV0JTIwaW4lMjBhJTIwanVuZ2xlJTJDJTIwY29sZCUyMGNvbG9yJTIwcGFsZXR0ZSUyQyUyMG11dGVkJTIwY29sb3JzJTJDJTIwZGV0YWlsZWQlMkMlMjA4ayUyMiUwQXBpcGVsaW5lKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QzMCkuaW1hZ2VzJTVCMCU1RA==",highlighted:`pipeline = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

apply_dynamic_quant(pipeline.unet, dynamic_quant_filter_fn)
apply_dynamic_quant(pipeline.vae, dynamic_quant_filter_fn)

prompt = <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k&quot;</span>
pipeline(prompt, num_inference_steps=<span class="hljs-number">30</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),Be=new G({props:{title:"Fused projection matrices",local:"fused-projection-matrices",headingTag:"h2"}}),Re=new U({props:{code:"cGlwZWxpbmUuZnVzZV9xa3ZfcHJvamVjdGlvbnMoKQ==",highlighted:"pipeline.fuse_qkv_projections()",wrap:!1}}),Ie=new G({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Le=new Fl({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/fp16.md"}}),{c(){m=o("meta"),j=a(),T=o("p"),f=a(),u(J.$$.fragment),r=a(),u(i.$$.fragment),g=a(),$=o("p"),$.innerHTML=k,Z=a(),w=o("p"),w.textContent=W,He=a(),H=o("p"),H.textContent=Dt,Qe=a(),u(Q.$$.fragment),Ye=a(),Y=o("p"),Y.textContent=Kt,Fe=a(),u(v.$$.fragment),Ne=a(),u(F.$$.fragment),ze=a(),B=o("blockquote"),B.innerHTML=Ot,Ee=a(),N=o("p"),N.innerHTML=el,Se=a(),z=o("p"),z.innerHTML=tl,qe=a(),u(E.$$.fragment),Ae=a(),u(S.$$.fragment),Pe=a(),q=o("p"),q.innerHTML=ll,De=a(),A=o("p"),A.innerHTML=sl,Ke=a(),u(P.$$.fragment),Oe=a(),D=o("p"),D.innerHTML=al,et=a(),C=o("blockquote"),C.innerHTML=nl,tt=a(),K=o("p"),K.innerHTML=il,lt=a(),u(O.$$.fragment),st=a(),ee=o("p"),ee.textContent=ol,at=a(),u(te.$$.fragment),nt=a(),R=o("blockquote"),R.innerHTML=pl,it=a(),le=o("p"),le.innerHTML=rl,ot=a(),se=o("p"),se.innerHTML=cl,pt=a(),u(ae.$$.fragment),rt=a(),ne=o("p"),ne.innerHTML=ml,ct=a(),ie=o("p"),ie.innerHTML=fl,mt=a(),oe=o("p"),oe.textContent=ul,ft=a(),u(pe.$$.fragment),ut=a(),re=o("p"),re.innerHTML=dl,dt=a(),ce=o("p"),ce.innerHTML=hl,ht=a(),u(me.$$.fragment),bt=a(),fe=o("p"),fe.innerHTML=bl,yt=a(),u(ue.$$.fragment),Mt=a(),I=o("blockquote"),I.innerHTML=yl,wt=a(),de=o("p"),de.innerHTML=Ml,Tt=a(),u(he.$$.fragment),Jt=a(),be=o("p"),be.innerHTML=wl,gt=a(),u(ye.$$.fragment),jt=a(),Me=o("p"),Me.innerHTML=Tl,$t=a(),u(we.$$.fragment),Ut=a(),u(Te.$$.fragment),Zt=a(),Je=o("p"),Je.innerHTML=Jl,Gt=a(),ge=o("p"),ge.innerHTML=gl,_t=a(),X=o("blockquote"),X.innerHTML=jl,Wt=a(),u(je.$$.fragment),xt=a(),$e=o("p"),$e.innerHTML=$l,kt=a(),Ue=o("p"),Ue.innerHTML=Ul,vt=a(),u(Ze.$$.fragment),Bt=a(),Ge=o("p"),Ge.innerHTML=Zl,Ct=a(),_e=o("p"),_e.innerHTML=Gl,Rt=a(),L=o("blockquote"),L.innerHTML=_l,It=a(),We=o("p"),We.textContent=Wl,Xt=a(),u(xe.$$.fragment),Lt=a(),ke=o("p"),ke.innerHTML=xl,Vt=a(),u(ve.$$.fragment),Ht=a(),u(Be.$$.fragment),Qt=a(),V=o("blockquote"),V.innerHTML=kl,Yt=a(),Ce=o("p"),Ce.textContent=vl,Ft=a(),u(Re.$$.fragment),Nt=a(),u(Ie.$$.fragment),zt=a(),Xe=o("ul"),Xe.innerHTML=Bl,Et=a(),u(Le.$$.fragment),St=a(),Ve=o("p"),this.h()},l(e){const t=Hl("svelte-u9bgzb",document.head);m=p(t,"META",{name:!0,content:!0}),t.forEach(l),j=n(e),T=p(e,"P",{}),Rl(T).forEach(l),f=n(e),d(J.$$.fragment,e),r=n(e),d(i.$$.fragment,e),g=n(e),$=p(e,"P",{"data-svelte-h":!0}),c($)!=="svelte-1m782be"&&($.innerHTML=k),Z=n(e),w=p(e,"P",{"data-svelte-h":!0}),c(w)!=="svelte-wa2eaw"&&(w.textContent=W),He=n(e),H=p(e,"P",{"data-svelte-h":!0}),c(H)!=="svelte-1cgitz1"&&(H.textContent=Dt),Qe=n(e),d(Q.$$.fragment,e),Ye=n(e),Y=p(e,"P",{"data-svelte-h":!0}),c(Y)!=="svelte-18445ux"&&(Y.textContent=Kt),Fe=n(e),d(v.$$.fragment,e),Ne=n(e),d(F.$$.fragment,e),ze=n(e),B=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(B)!=="svelte-geybdo"&&(B.innerHTML=Ot),Ee=n(e),N=p(e,"P",{"data-svelte-h":!0}),c(N)!=="svelte-zmbjuq"&&(N.innerHTML=el),Se=n(e),z=p(e,"P",{"data-svelte-h":!0}),c(z)!=="svelte-5i9w75"&&(z.innerHTML=tl),qe=n(e),d(E.$$.fragment,e),Ae=n(e),d(S.$$.fragment,e),Pe=n(e),q=p(e,"P",{"data-svelte-h":!0}),c(q)!=="svelte-nqxvwk"&&(q.innerHTML=ll),De=n(e),A=p(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-17o6ivw"&&(A.innerHTML=sl),Ke=n(e),d(P.$$.fragment,e),Oe=n(e),D=p(e,"P",{"data-svelte-h":!0}),c(D)!=="svelte-dwk3fl"&&(D.innerHTML=al),et=n(e),C=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(C)!=="svelte-qtk1m4"&&(C.innerHTML=nl),tt=n(e),K=p(e,"P",{"data-svelte-h":!0}),c(K)!=="svelte-lm2asr"&&(K.innerHTML=il),lt=n(e),d(O.$$.fragment,e),st=n(e),ee=p(e,"P",{"data-svelte-h":!0}),c(ee)!=="svelte-1jdqgot"&&(ee.textContent=ol),at=n(e),d(te.$$.fragment,e),nt=n(e),R=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(R)!=="svelte-td9ph9"&&(R.innerHTML=pl),it=n(e),le=p(e,"P",{"data-svelte-h":!0}),c(le)!=="svelte-qjj81o"&&(le.innerHTML=rl),ot=n(e),se=p(e,"P",{"data-svelte-h":!0}),c(se)!=="svelte-8dx0b8"&&(se.innerHTML=cl),pt=n(e),d(ae.$$.fragment,e),rt=n(e),ne=p(e,"P",{"data-svelte-h":!0}),c(ne)!=="svelte-1xsy0lm"&&(ne.innerHTML=ml),ct=n(e),ie=p(e,"P",{"data-svelte-h":!0}),c(ie)!=="svelte-8qzwwy"&&(ie.innerHTML=fl),mt=n(e),oe=p(e,"P",{"data-svelte-h":!0}),c(oe)!=="svelte-ebyy21"&&(oe.textContent=ul),ft=n(e),d(pe.$$.fragment,e),ut=n(e),re=p(e,"P",{"data-svelte-h":!0}),c(re)!=="svelte-kgvk4x"&&(re.innerHTML=dl),dt=n(e),ce=p(e,"P",{"data-svelte-h":!0}),c(ce)!=="svelte-8tagli"&&(ce.innerHTML=hl),ht=n(e),d(me.$$.fragment,e),bt=n(e),fe=p(e,"P",{"data-svelte-h":!0}),c(fe)!=="svelte-tp0nc4"&&(fe.innerHTML=bl),yt=n(e),d(ue.$$.fragment,e),Mt=n(e),I=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(I)!=="svelte-1um04qv"&&(I.innerHTML=yl),wt=n(e),de=p(e,"P",{"data-svelte-h":!0}),c(de)!=="svelte-1fu8q94"&&(de.innerHTML=Ml),Tt=n(e),d(he.$$.fragment,e),Jt=n(e),be=p(e,"P",{"data-svelte-h":!0}),c(be)!=="svelte-12g5e7u"&&(be.innerHTML=wl),gt=n(e),d(ye.$$.fragment,e),jt=n(e),Me=p(e,"P",{"data-svelte-h":!0}),c(Me)!=="svelte-12tqltr"&&(Me.innerHTML=Tl),$t=n(e),d(we.$$.fragment,e),Ut=n(e),d(Te.$$.fragment,e),Zt=n(e),Je=p(e,"P",{"data-svelte-h":!0}),c(Je)!=="svelte-1gyzgx0"&&(Je.innerHTML=Jl),Gt=n(e),ge=p(e,"P",{"data-svelte-h":!0}),c(ge)!=="svelte-13ty8ou"&&(ge.innerHTML=gl),_t=n(e),X=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(X)!=="svelte-1o84mka"&&(X.innerHTML=jl),Wt=n(e),d(je.$$.fragment,e),xt=n(e),$e=p(e,"P",{"data-svelte-h":!0}),c($e)!=="svelte-10dnlua"&&($e.innerHTML=$l),kt=n(e),Ue=p(e,"P",{"data-svelte-h":!0}),c(Ue)!=="svelte-1kb6ks2"&&(Ue.innerHTML=Ul),vt=n(e),d(Ze.$$.fragment,e),Bt=n(e),Ge=p(e,"P",{"data-svelte-h":!0}),c(Ge)!=="svelte-13773d2"&&(Ge.innerHTML=Zl),Ct=n(e),_e=p(e,"P",{"data-svelte-h":!0}),c(_e)!=="svelte-1wm8cfw"&&(_e.innerHTML=Gl),Rt=n(e),L=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(L)!=="svelte-141sjm"&&(L.innerHTML=_l),It=n(e),We=p(e,"P",{"data-svelte-h":!0}),c(We)!=="svelte-1rguzol"&&(We.textContent=Wl),Xt=n(e),d(xe.$$.fragment,e),Lt=n(e),ke=p(e,"P",{"data-svelte-h":!0}),c(ke)!=="svelte-applj5"&&(ke.innerHTML=xl),Vt=n(e),d(ve.$$.fragment,e),Ht=n(e),d(Be.$$.fragment,e),Qt=n(e),V=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(V)!=="svelte-dqcyt"&&(V.innerHTML=kl),Yt=n(e),Ce=p(e,"P",{"data-svelte-h":!0}),c(Ce)!=="svelte-1h88cib"&&(Ce.textContent=vl),Ft=n(e),d(Re.$$.fragment,e),Nt=n(e),d(Ie.$$.fragment,e),zt=n(e),Xe=p(e,"UL",{"data-svelte-h":!0}),c(Xe)!=="svelte-19g4t6g"&&(Xe.innerHTML=Bl),Et=n(e),d(Le.$$.fragment,e),St=n(e),Ve=p(e,"P",{}),Rl(Ve).forEach(l),this.h()},h(){x(m,"name","hf:doc:metadata"),x(m,"content",Pl),x(B,"class","tip"),x(C,"class","tip"),x(R,"class","tip"),x(I,"class","tip"),x(X,"class","tip"),x(L,"class","tip"),x(V,"class","warning")},m(e,t){Ql(document.head,m),s(e,j,t),s(e,T,t),s(e,f,t),h(J,e,t),s(e,r,t),h(i,e,t),s(e,g,t),s(e,$,t),s(e,Z,t),s(e,w,t),s(e,He,t),s(e,H,t),s(e,Qe,t),h(Q,e,t),s(e,Ye,t),s(e,Y,t),s(e,Fe,t),h(v,e,t),s(e,Ne,t),h(F,e,t),s(e,ze,t),s(e,B,t),s(e,Ee,t),s(e,N,t),s(e,Se,t),s(e,z,t),s(e,qe,t),h(E,e,t),s(e,Ae,t),h(S,e,t),s(e,Pe,t),s(e,q,t),s(e,De,t),s(e,A,t),s(e,Ke,t),h(P,e,t),s(e,Oe,t),s(e,D,t),s(e,et,t),s(e,C,t),s(e,tt,t),s(e,K,t),s(e,lt,t),h(O,e,t),s(e,st,t),s(e,ee,t),s(e,at,t),h(te,e,t),s(e,nt,t),s(e,R,t),s(e,it,t),s(e,le,t),s(e,ot,t),s(e,se,t),s(e,pt,t),h(ae,e,t),s(e,rt,t),s(e,ne,t),s(e,ct,t),s(e,ie,t),s(e,mt,t),s(e,oe,t),s(e,ft,t),h(pe,e,t),s(e,ut,t),s(e,re,t),s(e,dt,t),s(e,ce,t),s(e,ht,t),h(me,e,t),s(e,bt,t),s(e,fe,t),s(e,yt,t),h(ue,e,t),s(e,Mt,t),s(e,I,t),s(e,wt,t),s(e,de,t),s(e,Tt,t),h(he,e,t),s(e,Jt,t),s(e,be,t),s(e,gt,t),h(ye,e,t),s(e,jt,t),s(e,Me,t),s(e,$t,t),h(we,e,t),s(e,Ut,t),h(Te,e,t),s(e,Zt,t),s(e,Je,t),s(e,Gt,t),s(e,ge,t),s(e,_t,t),s(e,X,t),s(e,Wt,t),h(je,e,t),s(e,xt,t),s(e,$e,t),s(e,kt,t),s(e,Ue,t),s(e,vt,t),h(Ze,e,t),s(e,Bt,t),s(e,Ge,t),s(e,Ct,t),s(e,_e,t),s(e,Rt,t),s(e,L,t),s(e,It,t),s(e,We,t),s(e,Xt,t),h(xe,e,t),s(e,Lt,t),s(e,ke,t),s(e,Vt,t),h(ve,e,t),s(e,Ht,t),h(Be,e,t),s(e,Qt,t),s(e,V,t),s(e,Yt,t),s(e,Ce,t),s(e,Ft,t),h(Re,e,t),s(e,Nt,t),h(Ie,e,t),s(e,zt,t),s(e,Xe,t),s(e,Et,t),h(Le,e,t),s(e,St,t),s(e,Ve,t),qt=!0},p(e,[t]){const Cl={};t&2&&(Cl.$$scope={dirty:t,ctx:e}),v.$set(Cl)},i(e){qt||(b(J.$$.fragment,e),b(i.$$.fragment,e),b(Q.$$.fragment,e),b(v.$$.fragment,e),b(F.$$.fragment,e),b(E.$$.fragment,e),b(S.$$.fragment,e),b(P.$$.fragment,e),b(O.$$.fragment,e),b(te.$$.fragment,e),b(ae.$$.fragment,e),b(pe.$$.fragment,e),b(me.$$.fragment,e),b(ue.$$.fragment,e),b(he.$$.fragment,e),b(ye.$$.fragment,e),b(we.$$.fragment,e),b(Te.$$.fragment,e),b(je.$$.fragment,e),b(Ze.$$.fragment,e),b(xe.$$.fragment,e),b(ve.$$.fragment,e),b(Be.$$.fragment,e),b(Re.$$.fragment,e),b(Ie.$$.fragment,e),b(Le.$$.fragment,e),qt=!0)},o(e){y(J.$$.fragment,e),y(i.$$.fragment,e),y(Q.$$.fragment,e),y(v.$$.fragment,e),y(F.$$.fragment,e),y(E.$$.fragment,e),y(S.$$.fragment,e),y(P.$$.fragment,e),y(O.$$.fragment,e),y(te.$$.fragment,e),y(ae.$$.fragment,e),y(pe.$$.fragment,e),y(me.$$.fragment,e),y(ue.$$.fragment,e),y(he.$$.fragment,e),y(ye.$$.fragment,e),y(we.$$.fragment,e),y(Te.$$.fragment,e),y(je.$$.fragment,e),y(Ze.$$.fragment,e),y(xe.$$.fragment,e),y(ve.$$.fragment,e),y(Be.$$.fragment,e),y(Re.$$.fragment,e),y(Ie.$$.fragment,e),y(Le.$$.fragment,e),qt=!1},d(e){e&&(l(j),l(T),l(f),l(r),l(g),l($),l(Z),l(w),l(He),l(H),l(Qe),l(Ye),l(Y),l(Fe),l(Ne),l(ze),l(B),l(Ee),l(N),l(Se),l(z),l(qe),l(Ae),l(Pe),l(q),l(De),l(A),l(Ke),l(Oe),l(D),l(et),l(C),l(tt),l(K),l(lt),l(st),l(ee),l(at),l(nt),l(R),l(it),l(le),l(ot),l(se),l(pt),l(rt),l(ne),l(ct),l(ie),l(mt),l(oe),l(ft),l(ut),l(re),l(dt),l(ce),l(ht),l(bt),l(fe),l(yt),l(Mt),l(I),l(wt),l(de),l(Tt),l(Jt),l(be),l(gt),l(jt),l(Me),l($t),l(Ut),l(Zt),l(Je),l(Gt),l(ge),l(_t),l(X),l(Wt),l(xt),l($e),l(kt),l(Ue),l(vt),l(Bt),l(Ge),l(Ct),l(_e),l(Rt),l(L),l(It),l(We),l(Xt),l(Lt),l(ke),l(Vt),l(Ht),l(Qt),l(V),l(Yt),l(Ce),l(Ft),l(Nt),l(zt),l(Xe),l(Et),l(St),l(Ve)),l(m),M(J,e),M(i,e),M(Q,e),M(v,e),M(F,e),M(E,e),M(S,e),M(P,e),M(O,e),M(te,e),M(ae,e),M(pe,e),M(me,e),M(ue,e),M(he,e),M(ye,e),M(we,e),M(Te,e),M(je,e),M(Ze,e),M(xe,e),M(ve,e),M(Be,e),M(Re,e),M(Ie,e),M(Le,e)}}}const Pl='{"title":"Accelerate inference","local":"accelerate-inference","sections":[{"title":"Model data type","local":"model-data-type","sections":[],"depth":2},{"title":"Scaled dot product attention","local":"scaled-dot-product-attention","sections":[],"depth":2},{"title":"torch.compile","local":"torchcompile","sections":[{"title":"Dynamic shape compilation","local":"dynamic-shape-compilation","sections":[],"depth":3},{"title":"Regional compilation","local":"regional-compilation","sections":[],"depth":3},{"title":"Graph breaks","local":"graph-breaks","sections":[],"depth":3},{"title":"GPU sync","local":"gpu-sync","sections":[],"depth":3},{"title":"Benchmarks","local":"benchmarks","sections":[],"depth":3}],"depth":2},{"title":"Dynamic quantization","local":"dynamic-quantization","sections":[],"depth":2},{"title":"Fused projection matrices","local":"fused-projection-matrices","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}';function Dl(_){return Xl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class as extends Ll{constructor(m){super(),Vl(this,m,Dl,Al,Il,{})}}export{as as component};
