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