import{s as Rl,o as Xl,n as x}from"../chunks/scheduler.8c3d61f6.js";import{S as Il,i as Vl,g as c,s as a,r as h,A as Hl,h as m,f as l,c as i,j as Bl,u as b,x as u,k as Cl,y as Ll,a as s,v as y,d as w,t as M,w as $}from"../chunks/index.da70eac4.js";import{T as Ve}from"../chunks/Tip.1d9b8c37.js";import{C as G}from"../chunks/CodeBlock.a9c4becf.js";import{H as W,E as Fl}from"../chunks/getInferenceSnippets.725ed3d4.js";import{H as Nl,a as qt}from"../chunks/HfOption.6ab18950.js";function zl(J){let n,d="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.",o,r,T;return r=new G({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(){n=c("p"),n.textContent=d,o=a(),h(r.$$.fragment)},l(f){n=m(f,"P",{"data-svelte-h":!0}),u(n)!=="svelte-kz0em0"&&(n.textContent=d),o=i(f),b(r.$$.fragment,f)},m(f,p){s(f,n,p),s(f,o,p),y(r,f,p),T=!0},p:x,i(f){T||(w(r.$$.fragment,f),T=!0)},o(f){M(r.$$.fragment,f),T=!1},d(f){f&&(l(n),l(o)),$(r,f)}}}function Yl(J){let n,d="float16 is similar to bfloat16 but may be more prone to numerical errors.",o,r,T;return r=new G({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(){n=c("p"),n.textContent=d,o=a(),h(r.$$.fragment)},l(f){n=m(f,"P",{"data-svelte-h":!0}),u(n)!=="svelte-nzm7ns"&&(n.textContent=d),o=i(f),b(r.$$.fragment,f)},m(f,p){s(f,n,p),s(f,o,p),y(r,f,p),T=!0},p:x,i(f){T||(w(r.$$.fragment,f),T=!0)},o(f){M(r.$$.fragment,f),T=!1},d(f){f&&(l(n),l(o)),$(r,f)}}}function Sl(J){let n,d='<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.',o,r,T="PyTorch only enables tf32 mode for convolutions by default and you’ll need to explicitly enable it for matrix multiplications.",f,p,j,U,_='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.',v;return p=new G({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(){n=c("p"),n.innerHTML=d,o=a(),r=c("p"),r.textContent=T,f=a(),h(p.$$.fragment),j=a(),U=c("p"),U.innerHTML=_},l(g){n=m(g,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1sdg1x4"&&(n.innerHTML=d),o=i(g),r=m(g,"P",{"data-svelte-h":!0}),u(r)!=="svelte-13cgegp"&&(r.textContent=T),f=i(g),b(p.$$.fragment,g),j=i(g),U=m(g,"P",{"data-svelte-h":!0}),u(U)!=="svelte-uy7wpj"&&(U.innerHTML=_)},m(g,Z){s(g,n,Z),s(g,o,Z),s(g,r,Z),s(g,f,Z),y(p,g,Z),s(g,j,Z),s(g,U,Z),v=!0},p:x,i(g){v||(w(p.$$.fragment,g),v=!0)},o(g){M(p.$$.fragment,g),v=!1},d(g){g&&(l(n),l(o),l(r),l(f),l(j),l(U)),$(p,g)}}}function Ql(J){let n,d,o,r,T,f;return n=new qt({props:{id:"dtypes",option:"bfloat16",$$slots:{default:[zl]},$$scope:{ctx:J}}}),o=new qt({props:{id:"dtypes",option:"float16",$$slots:{default:[Yl]},$$scope:{ctx:J}}}),T=new qt({props:{id:"dtypes",option:"TensorFloat-32",$$slots:{default:[Sl]},$$scope:{ctx:J}}}),{c(){h(n.$$.fragment),d=a(),h(o.$$.fragment),r=a(),h(T.$$.fragment)},l(p){b(n.$$.fragment,p),d=i(p),b(o.$$.fragment,p),r=i(p),b(T.$$.fragment,p)},m(p,j){y(n,p,j),s(p,d,j),y(o,p,j),s(p,r,j),y(T,p,j),f=!0},p(p,j){const U={};j&2&&(U.$$scope={dirty:j,ctx:p}),n.$set(U);const _={};j&2&&(_.$$scope={dirty:j,ctx:p}),o.$set(_);const v={};j&2&&(v.$$scope={dirty:j,ctx:p}),T.$set(v)},i(p){f||(w(n.$$.fragment,p),w(o.$$.fragment,p),w(T.$$.fragment,p),f=!0)},o(p){M(n.$$.fragment,p),M(o.$$.fragment,p),M(T.$$.fragment,p),f=!1},d(p){p&&(l(d),l(r)),$(n,p),$(o,p),$(T,p)}}}function El(J){let n,d='Memory-efficient attention optimizes for inference speed <em>and</em> <a href="./memory#memory-efficient-attention">memory usage</a>!';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-nfsjqr"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function ql(J){let n,d='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.';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1a730av"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function Al(J){let n,d="Make sure to always use the nightly version of PyTorch for better support.";return{c(){n=c("p"),n.textContent=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1nw49au"&&(n.textContent=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function Pl(J){let n,d='For more regional compilation examples, see the reference <a href="https://github.com/huggingface/diffusers/pull/11705" rel="nofollow">PR</a>.';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-kfuh7c"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function Dl(J){let n,d='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.';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-14nq31x"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function Kl(J){let n,d='Refer to our <a href="../quantization/torchao">torchao</a> docs to learn more about how to use the Diffusers torchao integration.';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1h2qhs5"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function Ol(J){let n,d='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';return{c(){n=c("p"),n.innerHTML=d},l(o){n=m(o,"P",{"data-svelte-h":!0}),u(n)!=="svelte-o2jj7j"&&(n.innerHTML=d)},m(o,r){s(o,n,r)},p:x,d(o){o&&l(n)}}}function es(J){let n,d,o,r,T,f,p,j='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.',U,_,v="Combine and use these techniques together to make inference faster than using any single technique on its own.",g,Z,At="This guide will go over how to accelerate inference.",Le,L,Fe,F,Pt="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.",Ne,k,ze,N,Ye,B,Se,z,Dt='<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.',Qe,Y,Kt='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.',Ee,S,qe,Q,Ae,E,Ot='<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.',Pe,q,el='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).',De,A,Ke,P,tl="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.",Oe,C,et,D,ll='Changing the memory layout to <a href="./memory#torchchannels_last">channels_last</a> also optimizes memory and inference speed.',tt,K,lt,O,sl="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.",st,ee,nt,R,at,te,nl="<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.",it,le,al="To avoid recompilation, add <code>dynamic=True</code> to try and generate a more dynamic kernel to avoid recompilation when conditions change.",ot,se,pt,ne,il='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>.',rt,ae,ol='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.',ct,ie,pl="Feel free to open an issue if dynamic compilation doesn’t work as expected for a Diffusers model.",mt,oe,ft,pe,rl=`<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.`,ut,re,cl='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.',dt,ce,ht,me,ml="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.",bt,fe,yt,X,wt,ue,fl='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.',Mt,de,$t,he,ul='<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.',Tt,be,gt,ye,dl="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.",Jt,we,jt,Me,Ut,$e,hl='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.',Zt,Te,bl='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.',Gt,I,_t,ge,Wt,Je,yl='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.',vt,je,wl='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.',xt,Ue,kt,Ze,Ml='<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.',Bt,Ge,$l='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.',Ct,V,Rt,_e,Tl="Configure the compiler tags for maximum speed.",Xt,We,It,ve,gl='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,xe,Ht,ke,Lt,H,Ft,Be,Jl="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.",Nt,Ce,zt,Re,Yt,Xe,jl=`<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>`,St,Ie,Qt,He,Et;return T=new W({props:{title:"Accelerate inference",local:"accelerate-inference",headingTag:"h1"}}),L=new W({props:{title:"Model data type",local:"model-data-type",headingTag:"h2"}}),k=new Nl({props:{id:"dtypes",options:["bfloat16","float16","TensorFloat-32"],$$slots:{default:[Ql]},$$scope:{ctx:J}}}),N=new W({props:{title:"Scaled dot product attention",local:"scaled-dot-product-attention",headingTag:"h2"}}),B=new Ve({props:{warning:!1,$$slots:{default:[El]},$$scope:{ctx:J}}}),S=new G({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}}),Q=new W({props:{title:"torch.compile",local:"torchcompile",headingTag:"h2"}}),A=new G({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}}),C=new Ve({props:{warning:!1,$$slots:{default:[ql]},$$scope:{ctx:J}}}),K=new G({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}}),ee=new W({props:{title:"Dynamic shape compilation",local:"dynamic-shape-compilation",headingTag:"h3"}}),R=new Ve({props:{warning:!1,$$slots:{default:[Al]},$$scope:{ctx:J}}}),se=new G({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}}),oe=new W({props:{title:"Regional compilation",local:"regional-compilation",headingTag:"h3"}}),ce=new G({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}}),fe=new G({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}}),X=new Ve({props:{warning:!1,$$slots:{default:[Pl]},$$scope:{ctx:J}}}),de=new G({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMC1VJTIwYWNjZWxlcmF0ZSUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUlMEFmcm9tJTIwYWNjZWxlcmF0ZS51dGlscyUyMGltcG9ydCUyMGNvbXBpbGUlMjByZWdpb25zJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUudW5ldCUyMCUzRCUyMGNvbXBpbGVfcmVnaW9ucyhwaXBlbGluZS51bmV0JTJDJTIwbW9kZSUzRCUyMnJlZHVjZS1vdmVyaGVhZCUyMiUyQyUyMGZ1bGxncmFwaCUzRFRydWUp",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> <span class="hljs-built_in">compile</span> 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}}),be=new W({props:{title:"Graph breaks",local:"graph-breaks",headingTag:"h3"}}),we=new G({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}}),Me=new W({props:{title:"GPU sync",local:"gpu-sync",headingTag:"h3"}}),I=new Ve({props:{$$slots:{default:[Dl]},$$scope:{ctx:J}}}),ge=new W({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h3"}}),Ue=new W({props:{title:"Dynamic quantization",local:"dynamic-quantization",headingTag:"h2"}}),V=new Ve({props:{warning:!1,$$slots:{default:[Kl]},$$scope:{ctx:J}}}),We=new G({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}}),xe=new G({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}}),ke=new W({props:{title:"Fused projection matrices",local:"fused-projection-matrices",headingTag:"h2"}}),H=new Ve({props:{warning:!0,$$slots:{default:[Ol]},$$scope:{ctx:J}}}),Ce=new G({props:{code:"cGlwZWxpbmUuZnVzZV9xa3ZfcHJvamVjdGlvbnMoKQ==",highlighted:"pipeline.fuse_qkv_projections()",wrap:!1}}),Re=new W({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Ie=new Fl({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/fp16.md"}}),{c(){n=c("meta"),d=a(),o=c("p"),r=a(),h(T.$$.fragment),f=a(),p=c("p"),p.innerHTML=j,U=a(),_=c("p"),_.textContent=v,g=a(),Z=c("p"),Z.textContent=At,Le=a(),h(L.$$.fragment),Fe=a(),F=c("p"),F.textContent=Pt,Ne=a(),h(k.$$.fragment),ze=a(),h(N.$$.fragment),Ye=a(),h(B.$$.fragment),Se=a(),z=c("p"),z.innerHTML=Dt,Qe=a(),Y=c("p"),Y.innerHTML=Kt,Ee=a(),h(S.$$.fragment),qe=a(),h(Q.$$.fragment),Ae=a(),E=c("p"),E.innerHTML=Ot,Pe=a(),q=c("p"),q.innerHTML=el,De=a(),h(A.$$.fragment),Ke=a(),P=c("p"),P.innerHTML=tl,Oe=a(),h(C.$$.fragment),et=a(),D=c("p"),D.innerHTML=ll,tt=a(),h(K.$$.fragment),lt=a(),O=c("p"),O.textContent=sl,st=a(),h(ee.$$.fragment),nt=a(),h(R.$$.fragment),at=a(),te=c("p"),te.innerHTML=nl,it=a(),le=c("p"),le.innerHTML=al,ot=a(),h(se.$$.fragment),pt=a(),ne=c("p"),ne.innerHTML=il,rt=a(),ae=c("p"),ae.innerHTML=ol,ct=a(),ie=c("p"),ie.textContent=pl,mt=a(),h(oe.$$.fragment),ft=a(),pe=c("p"),pe.innerHTML=rl,ut=a(),re=c("p"),re.innerHTML=cl,dt=a(),h(ce.$$.fragment),ht=a(),me=c("p"),me.innerHTML=ml,bt=a(),h(fe.$$.fragment),yt=a(),h(X.$$.fragment),wt=a(),ue=c("p"),ue.innerHTML=fl,Mt=a(),h(de.$$.fragment),$t=a(),he=c("p"),he.innerHTML=ul,Tt=a(),h(be.$$.fragment),gt=a(),ye=c("p"),ye.innerHTML=dl,Jt=a(),h(we.$$.fragment),jt=a(),h(Me.$$.fragment),Ut=a(),$e=c("p"),$e.innerHTML=hl,Zt=a(),Te=c("p"),Te.innerHTML=bl,Gt=a(),h(I.$$.fragment),_t=a(),h(ge.$$.fragment),Wt=a(),Je=c("p"),Je.innerHTML=yl,vt=a(),je=c("p"),je.innerHTML=wl,xt=a(),h(Ue.$$.fragment),kt=a(),Ze=c("p"),Ze.innerHTML=Ml,Bt=a(),Ge=c("p"),Ge.innerHTML=$l,Ct=a(),h(V.$$.fragment),Rt=a(),_e=c("p"),_e.textContent=Tl,Xt=a(),h(We.$$.fragment),It=a(),ve=c("p"),ve.innerHTML=gl,Vt=a(),h(xe.$$.fragment),Ht=a(),h(ke.$$.fragment),Lt=a(),h(H.$$.fragment),Ft=a(),Be=c("p"),Be.textContent=Jl,Nt=a(),h(Ce.$$.fragment),zt=a(),h(Re.$$.fragment),Yt=a(),Xe=c("ul"),Xe.innerHTML=jl,St=a(),h(Ie.$$.fragment),Qt=a(),He=c("p"),this.h()},l(e){const t=Hl("svelte-u9bgzb",document.head);n=m(t,"META",{name:!0,content:!0}),t.forEach(l),d=i(e),o=m(e,"P",{}),Bl(o).forEach(l),r=i(e),b(T.$$.fragment,e),f=i(e),p=m(e,"P",{"data-svelte-h":!0}),u(p)!=="svelte-1m782be"&&(p.innerHTML=j),U=i(e),_=m(e,"P",{"data-svelte-h":!0}),u(_)!=="svelte-wa2eaw"&&(_.textContent=v),g=i(e),Z=m(e,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-1cgitz1"&&(Z.textContent=At),Le=i(e),b(L.$$.fragment,e),Fe=i(e),F=m(e,"P",{"data-svelte-h":!0}),u(F)!=="svelte-18445ux"&&(F.textContent=Pt),Ne=i(e),b(k.$$.fragment,e),ze=i(e),b(N.$$.fragment,e),Ye=i(e),b(B.$$.fragment,e),Se=i(e),z=m(e,"P",{"data-svelte-h":!0}),u(z)!=="svelte-zmbjuq"&&(z.innerHTML=Dt),Qe=i(e),Y=m(e,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-5i9w75"&&(Y.innerHTML=Kt),Ee=i(e),b(S.$$.fragment,e),qe=i(e),b(Q.$$.fragment,e),Ae=i(e),E=m(e,"P",{"data-svelte-h":!0}),u(E)!=="svelte-nqxvwk"&&(E.innerHTML=Ot),Pe=i(e),q=m(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-17o6ivw"&&(q.innerHTML=el),De=i(e),b(A.$$.fragment,e),Ke=i(e),P=m(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-dwk3fl"&&(P.innerHTML=tl),Oe=i(e),b(C.$$.fragment,e),et=i(e),D=m(e,"P",{"data-svelte-h":!0}),u(D)!=="svelte-lm2asr"&&(D.innerHTML=ll),tt=i(e),b(K.$$.fragment,e),lt=i(e),O=m(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-1jdqgot"&&(O.textContent=sl),st=i(e),b(ee.$$.fragment,e),nt=i(e),b(R.$$.fragment,e),at=i(e),te=m(e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-qjj81o"&&(te.innerHTML=nl),it=i(e),le=m(e,"P",{"data-svelte-h":!0}),u(le)!=="svelte-8dx0b8"&&(le.innerHTML=al),ot=i(e),b(se.$$.fragment,e),pt=i(e),ne=m(e,"P",{"data-svelte-h":!0}),u(ne)!=="svelte-1xsy0lm"&&(ne.innerHTML=il),rt=i(e),ae=m(e,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-8qzwwy"&&(ae.innerHTML=ol),ct=i(e),ie=m(e,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-ebyy21"&&(ie.textContent=pl),mt=i(e),b(oe.$$.fragment,e),ft=i(e),pe=m(e,"P",{"data-svelte-h":!0}),u(pe)!=="svelte-kgvk4x"&&(pe.innerHTML=rl),ut=i(e),re=m(e,"P",{"data-svelte-h":!0}),u(re)!=="svelte-8tagli"&&(re.innerHTML=cl),dt=i(e),b(ce.$$.fragment,e),ht=i(e),me=m(e,"P",{"data-svelte-h":!0}),u(me)!=="svelte-tp0nc4"&&(me.innerHTML=ml),bt=i(e),b(fe.$$.fragment,e),yt=i(e),b(X.$$.fragment,e),wt=i(e),ue=m(e,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-1fu8q94"&&(ue.innerHTML=fl),Mt=i(e),b(de.$$.fragment,e),$t=i(e),he=m(e,"P",{"data-svelte-h":!0}),u(he)!=="svelte-12g5e7u"&&(he.innerHTML=ul),Tt=i(e),b(be.$$.fragment,e),gt=i(e),ye=m(e,"P",{"data-svelte-h":!0}),u(ye)!=="svelte-12tqltr"&&(ye.innerHTML=dl),Jt=i(e),b(we.$$.fragment,e),jt=i(e),b(Me.$$.fragment,e),Ut=i(e),$e=m(e,"P",{"data-svelte-h":!0}),u($e)!=="svelte-1gyzgx0"&&($e.innerHTML=hl),Zt=i(e),Te=m(e,"P",{"data-svelte-h":!0}),u(Te)!=="svelte-13ty8ou"&&(Te.innerHTML=bl),Gt=i(e),b(I.$$.fragment,e),_t=i(e),b(ge.$$.fragment,e),Wt=i(e),Je=m(e,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-10dnlua"&&(Je.innerHTML=yl),vt=i(e),je=m(e,"P",{"data-svelte-h":!0}),u(je)!=="svelte-1kb6ks2"&&(je.innerHTML=wl),xt=i(e),b(Ue.$$.fragment,e),kt=i(e),Ze=m(e,"P",{"data-svelte-h":!0}),u(Ze)!=="svelte-13773d2"&&(Ze.innerHTML=Ml),Bt=i(e),Ge=m(e,"P",{"data-svelte-h":!0}),u(Ge)!=="svelte-1wm8cfw"&&(Ge.innerHTML=$l),Ct=i(e),b(V.$$.fragment,e),Rt=i(e),_e=m(e,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-1rguzol"&&(_e.textContent=Tl),Xt=i(e),b(We.$$.fragment,e),It=i(e),ve=m(e,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-applj5"&&(ve.innerHTML=gl),Vt=i(e),b(xe.$$.fragment,e),Ht=i(e),b(ke.$$.fragment,e),Lt=i(e),b(H.$$.fragment,e),Ft=i(e),Be=m(e,"P",{"data-svelte-h":!0}),u(Be)!=="svelte-1h88cib"&&(Be.textContent=Jl),Nt=i(e),b(Ce.$$.fragment,e),zt=i(e),b(Re.$$.fragment,e),Yt=i(e),Xe=m(e,"UL",{"data-svelte-h":!0}),u(Xe)!=="svelte-19g4t6g"&&(Xe.innerHTML=jl),St=i(e),b(Ie.$$.fragment,e),Qt=i(e),He=m(e,"P",{}),Bl(He).forEach(l),this.h()},h(){Cl(n,"name","hf:doc:metadata"),Cl(n,"content",ts)},m(e,t){Ll(document.head,n),s(e,d,t),s(e,o,t),s(e,r,t),y(T,e,t),s(e,f,t),s(e,p,t),s(e,U,t),s(e,_,t),s(e,g,t),s(e,Z,t),s(e,Le,t),y(L,e,t),s(e,Fe,t),s(e,F,t),s(e,Ne,t),y(k,e,t),s(e,ze,t),y(N,e,t),s(e,Ye,t),y(B,e,t),s(e,Se,t),s(e,z,t),s(e,Qe,t),s(e,Y,t),s(e,Ee,t),y(S,e,t),s(e,qe,t),y(Q,e,t),s(e,Ae,t),s(e,E,t),s(e,Pe,t),s(e,q,t),s(e,De,t),y(A,e,t),s(e,Ke,t),s(e,P,t),s(e,Oe,t),y(C,e,t),s(e,et,t),s(e,D,t),s(e,tt,t),y(K,e,t),s(e,lt,t),s(e,O,t),s(e,st,t),y(ee,e,t),s(e,nt,t),y(R,e,t),s(e,at,t),s(e,te,t),s(e,it,t),s(e,le,t),s(e,ot,t),y(se,e,t),s(e,pt,t),s(e,ne,t),s(e,rt,t),s(e,ae,t),s(e,ct,t),s(e,ie,t),s(e,mt,t),y(oe,e,t),s(e,ft,t),s(e,pe,t),s(e,ut,t),s(e,re,t),s(e,dt,t),y(ce,e,t),s(e,ht,t),s(e,me,t),s(e,bt,t),y(fe,e,t),s(e,yt,t),y(X,e,t),s(e,wt,t),s(e,ue,t),s(e,Mt,t),y(de,e,t),s(e,$t,t),s(e,he,t),s(e,Tt,t),y(be,e,t),s(e,gt,t),s(e,ye,t),s(e,Jt,t),y(we,e,t),s(e,jt,t),y(Me,e,t),s(e,Ut,t),s(e,$e,t),s(e,Zt,t),s(e,Te,t),s(e,Gt,t),y(I,e,t),s(e,_t,t),y(ge,e,t),s(e,Wt,t),s(e,Je,t),s(e,vt,t),s(e,je,t),s(e,xt,t),y(Ue,e,t),s(e,kt,t),s(e,Ze,t),s(e,Bt,t),s(e,Ge,t),s(e,Ct,t),y(V,e,t),s(e,Rt,t),s(e,_e,t),s(e,Xt,t),y(We,e,t),s(e,It,t),s(e,ve,t),s(e,Vt,t),y(xe,e,t),s(e,Ht,t),y(ke,e,t),s(e,Lt,t),y(H,e,t),s(e,Ft,t),s(e,Be,t),s(e,Nt,t),y(Ce,e,t),s(e,zt,t),y(Re,e,t),s(e,Yt,t),s(e,Xe,t),s(e,St,t),y(Ie,e,t),s(e,Qt,t),s(e,He,t),Et=!0},p(e,[t]){const Ul={};t&2&&(Ul.$$scope={dirty:t,ctx:e}),k.$set(Ul);const Zl={};t&2&&(Zl.$$scope={dirty:t,ctx:e}),B.$set(Zl);const Gl={};t&2&&(Gl.$$scope={dirty:t,ctx:e}),C.$set(Gl);const _l={};t&2&&(_l.$$scope={dirty:t,ctx:e}),R.$set(_l);const Wl={};t&2&&(Wl.$$scope={dirty:t,ctx:e}),X.$set(Wl);const vl={};t&2&&(vl.$$scope={dirty:t,ctx:e}),I.$set(vl);const xl={};t&2&&(xl.$$scope={dirty:t,ctx:e}),V.$set(xl);const kl={};t&2&&(kl.$$scope={dirty:t,ctx:e}),H.$set(kl)},i(e){Et||(w(T.$$.fragment,e),w(L.$$.fragment,e),w(k.$$.fragment,e),w(N.$$.fragment,e),w(B.$$.fragment,e),w(S.$$.fragment,e),w(Q.$$.fragment,e),w(A.$$.fragment,e),w(C.$$.fragment,e),w(K.$$.fragment,e),w(ee.$$.fragment,e),w(R.$$.fragment,e),w(se.$$.fragment,e),w(oe.$$.fragment,e),w(ce.$$.fragment,e),w(fe.$$.fragment,e),w(X.$$.fragment,e),w(de.$$.fragment,e),w(be.$$.fragment,e),w(we.$$.fragment,e),w(Me.$$.fragment,e),w(I.$$.fragment,e),w(ge.$$.fragment,e),w(Ue.$$.fragment,e),w(V.$$.fragment,e),w(We.$$.fragment,e),w(xe.$$.fragment,e),w(ke.$$.fragment,e),w(H.$$.fragment,e),w(Ce.$$.fragment,e),w(Re.$$.fragment,e),w(Ie.$$.fragment,e),Et=!0)},o(e){M(T.$$.fragment,e),M(L.$$.fragment,e),M(k.$$.fragment,e),M(N.$$.fragment,e),M(B.$$.fragment,e),M(S.$$.fragment,e),M(Q.$$.fragment,e),M(A.$$.fragment,e),M(C.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(R.$$.fragment,e),M(se.$$.fragment,e),M(oe.$$.fragment,e),M(ce.$$.fragment,e),M(fe.$$.fragment,e),M(X.$$.fragment,e),M(de.$$.fragment,e),M(be.$$.fragment,e),M(we.$$.fragment,e),M(Me.$$.fragment,e),M(I.$$.fragment,e),M(ge.$$.fragment,e),M(Ue.$$.fragment,e),M(V.$$.fragment,e),M(We.$$.fragment,e),M(xe.$$.fragment,e),M(ke.$$.fragment,e),M(H.$$.fragment,e),M(Ce.$$.fragment,e),M(Re.$$.fragment,e),M(Ie.$$.fragment,e),Et=!1},d(e){e&&(l(d),l(o),l(r),l(f),l(p),l(U),l(_),l(g),l(Z),l(Le),l(Fe),l(F),l(Ne),l(ze),l(Ye),l(Se),l(z),l(Qe),l(Y),l(Ee),l(qe),l(Ae),l(E),l(Pe),l(q),l(De),l(Ke),l(P),l(Oe),l(et),l(D),l(tt),l(lt),l(O),l(st),l(nt),l(at),l(te),l(it),l(le),l(ot),l(pt),l(ne),l(rt),l(ae),l(ct),l(ie),l(mt),l(ft),l(pe),l(ut),l(re),l(dt),l(ht),l(me),l(bt),l(yt),l(wt),l(ue),l(Mt),l($t),l(he),l(Tt),l(gt),l(ye),l(Jt),l(jt),l(Ut),l($e),l(Zt),l(Te),l(Gt),l(_t),l(Wt),l(Je),l(vt),l(je),l(xt),l(kt),l(Ze),l(Bt),l(Ge),l(Ct),l(Rt),l(_e),l(Xt),l(It),l(ve),l(Vt),l(Ht),l(Lt),l(Ft),l(Be),l(Nt),l(zt),l(Yt),l(Xe),l(St),l(Qt),l(He)),l(n),$(T,e),$(L,e),$(k,e),$(N,e),$(B,e),$(S,e),$(Q,e),$(A,e),$(C,e),$(K,e),$(ee,e),$(R,e),$(se,e),$(oe,e),$(ce,e),$(fe,e),$(X,e),$(de,e),$(be,e),$(we,e),$(Me,e),$(I,e),$(ge,e),$(Ue,e),$(V,e),$(We,e),$(xe,e),$(ke,e),$(H,e),$(Ce,e),$(Re,e),$(Ie,e)}}}const ts='{"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 ls(J){return Xl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rs extends Il{constructor(n){super(),Vl(this,n,ls,es,Rl,{})}}export{rs as component};
