import{s as Xl,o as Bl,n as v}from"../chunks/scheduler.8c3d61f6.js";import{S as Cl,i as Vl,g as c,s as a,r as h,A as Ll,h as m,f as l,c as i,j as Rl,u as b,x as u,k as Il,y as Hl,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 Yl}from"../chunks/getInferenceSnippets.28ca3596.js";import{H as Fl,a as qt}from"../chunks/HfOption.6c3b4e77.js";function Ql(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:v,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 Nl(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:v,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 zl(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.',x;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),x=!0},p:v,i(g){x||(w(p.$$.fragment,g),x=!0)},o(g){M(p.$$.fragment,g),x=!1},d(g){g&&(l(n),l(o),l(r),l(f),l(j),l(U)),$(p,g)}}}function Sl(J){let n,d,o,r,T,f;return n=new qt({props:{id:"dtypes",option:"bfloat16",$$slots:{default:[Ql]},$$scope:{ctx:J}}}),o=new qt({props:{id:"dtypes",option:"float16",$$slots:{default:[Nl]},$$scope:{ctx:J}}}),T=new qt({props:{id:"dtypes",option:"TensorFloat-32",$$slots:{default:[zl]},$$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 x={};j&2&&(x.$$scope={dirty:j,ctx:p}),T.$set(x)},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:v,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:v,d(o){o&&l(n)}}}function Pl(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:v,d(o){o&&l(n)}}}function Al(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:v,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:v,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:v,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:v,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,_,x="Combine and use these techniques together to make inference faster than using any single technique on its own.",g,Z,Pt="This guide will go over how to accelerate inference.",He,H,Ye,Y,At="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,k,Qe,F,Ne,R,ze,Q,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.',Se,N,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,z,qe,S,Pe,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.',Ae,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,P,Ke,A,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,I,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,X,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,B,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,C,_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.',xt,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.',vt,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.',Rt,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.',It,V,Xt,_e,Tl="Configure the compiler tags for maximum speed.",Bt,We,Ct,xe,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,ve,Lt,ke,Ht,L,Yt,Re,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.",Ft,Ie,Qt,Xe,Nt,Be,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>`,zt,Ce,St,Le,Et;return T=new W({props:{title:"Accelerate inference",local:"accelerate-inference",headingTag:"h1"}}),H=new W({props:{title:"Model data type",local:"model-data-type",headingTag:"h2"}}),k=new Fl({props:{id:"dtypes",options:["bfloat16","float16","TensorFloat-32"],$$slots:{default:[Sl]},$$scope:{ctx:J}}}),F=new W({props:{title:"Scaled dot product attention",local:"scaled-dot-product-attention",headingTag:"h2"}}),R=new Ve({props:{warning:!1,$$slots:{default:[El]},$$scope:{ctx:J}}}),z=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}}),S=new W({props:{title:"torch.compile",local:"torchcompile",headingTag:"h2"}}),P=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}}),I=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"}}),X=new Ve({props:{warning:!1,$$slots:{default:[Pl]},$$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}}),B=new Ve({props:{warning:!1,$$slots:{default:[Al]},$$scope:{ctx:J}}}),de=new G({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}}),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"}}),C=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}}),ve=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"}}),L=new Ve({props:{warning:!0,$$slots:{default:[Ol]},$$scope:{ctx:J}}}),Ie=new G({props:{code:"cGlwZWxpbmUuZnVzZV9xa3ZfcHJvamVjdGlvbnMoKQ==",highlighted:"pipeline.fuse_qkv_projections()",wrap:!1}}),Xe=new W({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Ce=new Yl({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=x,g=a(),Z=c("p"),Z.textContent=Pt,He=a(),h(H.$$.fragment),Ye=a(),Y=c("p"),Y.textContent=At,Fe=a(),h(k.$$.fragment),Qe=a(),h(F.$$.fragment),Ne=a(),h(R.$$.fragment),ze=a(),Q=c("p"),Q.innerHTML=Dt,Se=a(),N=c("p"),N.innerHTML=Kt,Ee=a(),h(z.$$.fragment),qe=a(),h(S.$$.fragment),Pe=a(),E=c("p"),E.innerHTML=Ot,Ae=a(),q=c("p"),q.innerHTML=el,De=a(),h(P.$$.fragment),Ke=a(),A=c("p"),A.innerHTML=tl,Oe=a(),h(I.$$.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(X.$$.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(B.$$.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(C.$$.fragment),_t=a(),h(ge.$$.fragment),Wt=a(),Je=c("p"),Je.innerHTML=yl,xt=a(),je=c("p"),je.innerHTML=wl,vt=a(),h(Ue.$$.fragment),kt=a(),Ze=c("p"),Ze.innerHTML=Ml,Rt=a(),Ge=c("p"),Ge.innerHTML=$l,It=a(),h(V.$$.fragment),Xt=a(),_e=c("p"),_e.textContent=Tl,Bt=a(),h(We.$$.fragment),Ct=a(),xe=c("p"),xe.innerHTML=gl,Vt=a(),h(ve.$$.fragment),Lt=a(),h(ke.$$.fragment),Ht=a(),h(L.$$.fragment),Yt=a(),Re=c("p"),Re.textContent=Jl,Ft=a(),h(Ie.$$.fragment),Qt=a(),h(Xe.$$.fragment),Nt=a(),Be=c("ul"),Be.innerHTML=jl,zt=a(),h(Ce.$$.fragment),St=a(),Le=c("p"),this.h()},l(e){const t=Ll("svelte-u9bgzb",document.head);n=m(t,"META",{name:!0,content:!0}),t.forEach(l),d=i(e),o=m(e,"P",{}),Rl(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=x),g=i(e),Z=m(e,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-1cgitz1"&&(Z.textContent=Pt),He=i(e),b(H.$$.fragment,e),Ye=i(e),Y=m(e,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-18445ux"&&(Y.textContent=At),Fe=i(e),b(k.$$.fragment,e),Qe=i(e),b(F.$$.fragment,e),Ne=i(e),b(R.$$.fragment,e),ze=i(e),Q=m(e,"P",{"data-svelte-h":!0}),u(Q)!=="svelte-zmbjuq"&&(Q.innerHTML=Dt),Se=i(e),N=m(e,"P",{"data-svelte-h":!0}),u(N)!=="svelte-5i9w75"&&(N.innerHTML=Kt),Ee=i(e),b(z.$$.fragment,e),qe=i(e),b(S.$$.fragment,e),Pe=i(e),E=m(e,"P",{"data-svelte-h":!0}),u(E)!=="svelte-nqxvwk"&&(E.innerHTML=Ot),Ae=i(e),q=m(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-17o6ivw"&&(q.innerHTML=el),De=i(e),b(P.$$.fragment,e),Ke=i(e),A=m(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-dwk3fl"&&(A.innerHTML=tl),Oe=i(e),b(I.$$.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(X.$$.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(B.$$.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(C.$$.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),xt=i(e),je=m(e,"P",{"data-svelte-h":!0}),u(je)!=="svelte-1kb6ks2"&&(je.innerHTML=wl),vt=i(e),b(Ue.$$.fragment,e),kt=i(e),Ze=m(e,"P",{"data-svelte-h":!0}),u(Ze)!=="svelte-13773d2"&&(Ze.innerHTML=Ml),Rt=i(e),Ge=m(e,"P",{"data-svelte-h":!0}),u(Ge)!=="svelte-1wm8cfw"&&(Ge.innerHTML=$l),It=i(e),b(V.$$.fragment,e),Xt=i(e),_e=m(e,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-1rguzol"&&(_e.textContent=Tl),Bt=i(e),b(We.$$.fragment,e),Ct=i(e),xe=m(e,"P",{"data-svelte-h":!0}),u(xe)!=="svelte-applj5"&&(xe.innerHTML=gl),Vt=i(e),b(ve.$$.fragment,e),Lt=i(e),b(ke.$$.fragment,e),Ht=i(e),b(L.$$.fragment,e),Yt=i(e),Re=m(e,"P",{"data-svelte-h":!0}),u(Re)!=="svelte-1h88cib"&&(Re.textContent=Jl),Ft=i(e),b(Ie.$$.fragment,e),Qt=i(e),b(Xe.$$.fragment,e),Nt=i(e),Be=m(e,"UL",{"data-svelte-h":!0}),u(Be)!=="svelte-19g4t6g"&&(Be.innerHTML=jl),zt=i(e),b(Ce.$$.fragment,e),St=i(e),Le=m(e,"P",{}),Rl(Le).forEach(l),this.h()},h(){Il(n,"name","hf:doc:metadata"),Il(n,"content",ts)},m(e,t){Hl(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,He,t),y(H,e,t),s(e,Ye,t),s(e,Y,t),s(e,Fe,t),y(k,e,t),s(e,Qe,t),y(F,e,t),s(e,Ne,t),y(R,e,t),s(e,ze,t),s(e,Q,t),s(e,Se,t),s(e,N,t),s(e,Ee,t),y(z,e,t),s(e,qe,t),y(S,e,t),s(e,Pe,t),s(e,E,t),s(e,Ae,t),s(e,q,t),s(e,De,t),y(P,e,t),s(e,Ke,t),s(e,A,t),s(e,Oe,t),y(I,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(X,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(B,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(C,e,t),s(e,_t,t),y(ge,e,t),s(e,Wt,t),s(e,Je,t),s(e,xt,t),s(e,je,t),s(e,vt,t),y(Ue,e,t),s(e,kt,t),s(e,Ze,t),s(e,Rt,t),s(e,Ge,t),s(e,It,t),y(V,e,t),s(e,Xt,t),s(e,_e,t),s(e,Bt,t),y(We,e,t),s(e,Ct,t),s(e,xe,t),s(e,Vt,t),y(ve,e,t),s(e,Lt,t),y(ke,e,t),s(e,Ht,t),y(L,e,t),s(e,Yt,t),s(e,Re,t),s(e,Ft,t),y(Ie,e,t),s(e,Qt,t),y(Xe,e,t),s(e,Nt,t),s(e,Be,t),s(e,zt,t),y(Ce,e,t),s(e,St,t),s(e,Le,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}),R.$set(Zl);const Gl={};t&2&&(Gl.$$scope={dirty:t,ctx:e}),I.$set(Gl);const _l={};t&2&&(_l.$$scope={dirty:t,ctx:e}),X.$set(_l);const Wl={};t&2&&(Wl.$$scope={dirty:t,ctx:e}),B.$set(Wl);const xl={};t&2&&(xl.$$scope={dirty:t,ctx:e}),C.$set(xl);const vl={};t&2&&(vl.$$scope={dirty:t,ctx:e}),V.$set(vl);const kl={};t&2&&(kl.$$scope={dirty:t,ctx:e}),L.$set(kl)},i(e){Et||(w(T.$$.fragment,e),w(H.$$.fragment,e),w(k.$$.fragment,e),w(F.$$.fragment,e),w(R.$$.fragment,e),w(z.$$.fragment,e),w(S.$$.fragment,e),w(P.$$.fragment,e),w(I.$$.fragment,e),w(K.$$.fragment,e),w(ee.$$.fragment,e),w(X.$$.fragment,e),w(se.$$.fragment,e),w(oe.$$.fragment,e),w(ce.$$.fragment,e),w(fe.$$.fragment,e),w(B.$$.fragment,e),w(de.$$.fragment,e),w(be.$$.fragment,e),w(we.$$.fragment,e),w(Me.$$.fragment,e),w(C.$$.fragment,e),w(ge.$$.fragment,e),w(Ue.$$.fragment,e),w(V.$$.fragment,e),w(We.$$.fragment,e),w(ve.$$.fragment,e),w(ke.$$.fragment,e),w(L.$$.fragment,e),w(Ie.$$.fragment,e),w(Xe.$$.fragment,e),w(Ce.$$.fragment,e),Et=!0)},o(e){M(T.$$.fragment,e),M(H.$$.fragment,e),M(k.$$.fragment,e),M(F.$$.fragment,e),M(R.$$.fragment,e),M(z.$$.fragment,e),M(S.$$.fragment,e),M(P.$$.fragment,e),M(I.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(X.$$.fragment,e),M(se.$$.fragment,e),M(oe.$$.fragment,e),M(ce.$$.fragment,e),M(fe.$$.fragment,e),M(B.$$.fragment,e),M(de.$$.fragment,e),M(be.$$.fragment,e),M(we.$$.fragment,e),M(Me.$$.fragment,e),M(C.$$.fragment,e),M(ge.$$.fragment,e),M(Ue.$$.fragment,e),M(V.$$.fragment,e),M(We.$$.fragment,e),M(ve.$$.fragment,e),M(ke.$$.fragment,e),M(L.$$.fragment,e),M(Ie.$$.fragment,e),M(Xe.$$.fragment,e),M(Ce.$$.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(He),l(Ye),l(Y),l(Fe),l(Qe),l(Ne),l(ze),l(Q),l(Se),l(N),l(Ee),l(qe),l(Pe),l(E),l(Ae),l(q),l(De),l(Ke),l(A),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(xt),l(je),l(vt),l(kt),l(Ze),l(Rt),l(Ge),l(It),l(Xt),l(_e),l(Bt),l(Ct),l(xe),l(Vt),l(Lt),l(Ht),l(Yt),l(Re),l(Ft),l(Qt),l(Nt),l(Be),l(zt),l(St),l(Le)),l(n),$(T,e),$(H,e),$(k,e),$(F,e),$(R,e),$(z,e),$(S,e),$(P,e),$(I,e),$(K,e),$(ee,e),$(X,e),$(se,e),$(oe,e),$(ce,e),$(fe,e),$(B,e),$(de,e),$(be,e),$(we,e),$(Me,e),$(C,e),$(ge,e),$(Ue,e),$(V,e),$(We,e),$(ve,e),$(ke,e),$(L,e),$(Ie,e),$(Xe,e),$(Ce,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 Bl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rs extends Cl{constructor(n){super(),Vl(this,n,ls,es,Xl,{})}}export{rs as component};
