import{s as wt,o as mt,n as lt}from"../chunks/scheduler.53228c21.js";import{S as ft,i as Jt,e as m,s as o,c as J,h as ut,a as f,d as a,b as c,f as ot,g as u,j as b,k as ct,l as yt,m as i,n as y,t as h,o as U,p as j}from"../chunks/index.100fac89.js";import{C as ht}from"../chunks/CopyLLMTxtMenu.494046bd.js";import{C as D}from"../chunks/CodeBlock.d30a6509.js";import{H as Tt,E as Ut}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8999c127.js";import{H as jt,a as et}from"../chunks/HfOption.fad27e59.js";function bt(I){let l,T="Accelerate <code>PixArtAlphaPipeline</code> with T-GATE:",d,n,M;return n=new D({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwUGl4QXJ0QWxwaGFQaXBlbGluZSUwQWZyb20lMjB0Z2F0ZSUyMGltcG9ydCUyMFRnYXRlUGl4QXJ0TG9hZGVyJTBBJTBBcGlwZSUyMCUzRCUyMFBpeEFydEFscGhhUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMlBpeEFydC1hbHBoYSUyRlBpeEFydC1YTC0yLTEwMjQtTVMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBZ2F0ZV9zdGVwJTIwJTNEJTIwOCUwQWluZmVyZW5jZV9zdGVwJTIwJTNEJTIwMjUlMEFwaXBlJTIwJTNEJTIwVGdhdGVQaXhBcnRMb2FkZXIoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwcGlwZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUyQyUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUudGdhdGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyQW4lMjBhbHBhY2ElMjBtYWRlJTIwb2YlMjBjb2xvcmZ1bCUyMGJ1aWxkaW5nJTIwYmxvY2tzJTJDJTIwY3liZXJwdW5rLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> PixArtAlphaPipeline
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgatePixArtLoader

pipe = PixArtAlphaPipeline.from_pretrained(<span class="hljs-string">&quot;PixArt-alpha/PixArt-XL-2-1024-MS&quot;</span>, torch_dtype=torch.float16)

gate_step = <span class="hljs-number">8</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgatePixArtLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;An alpaca made of colorful building blocks, cyberpunk.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=m("p"),l.innerHTML=T,d=o(),J(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),b(l)!=="svelte-10eb54u"&&(l.innerHTML=T),d=c(e),u(n.$$.fragment,e)},m(e,r){i(e,l,r),i(e,d,r),y(n,e,r),M=!0},p:lt,i(e){M||(h(n.$$.fragment,e),M=!0)},o(e){U(n.$$.fragment,e),M=!1},d(e){e&&(a(l),a(d)),j(n,e)}}}function It(I){let l,T="Accelerate <code>StableDiffusionXLPipeline</code> with T-GATE:",d,n,M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0ZXAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEaW5mZXJlbmNlX3N0ZXAlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlLnRnYXRlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGsuJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwZ2F0ZV9zdGVwJTNEZ2F0ZV9zdGVwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRGluZmVyZW5jZV9zdGVwJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<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> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLLoader

pipe = StableDiffusionXLPipeline.from_pretrained(
            <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
            torch_dtype=torch.float16,
            variant=<span class="hljs-string">&quot;fp16&quot;</span>,
            use_safetensors=<span class="hljs-literal">True</span>,
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">10</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgateSDXLLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=m("p"),l.innerHTML=T,d=o(),J(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),b(l)!=="svelte-iys01i"&&(l.innerHTML=T),d=c(e),u(n.$$.fragment,e)},m(e,r){i(e,l,r),i(e,d,r),y(n,e,r),M=!0},p:lt,i(e){M||(h(n.$$.fragment,e),M=!0)},o(e){U(n.$$.fragment,e),M=!1},d(e){e&&(a(l),a(d)),j(n,e)}}}function Ct(I){let l,T='Accelerate <code>StableDiffusionXLPipeline</code> with <a href="https://github.com/horseee/DeepCache" rel="nofollow">DeepCache</a> and T-GATE:',d,n,M;return n=new D({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEFmcm9tJTIwdGdhdGUlMjBpbXBvcnQlMjBUZ2F0ZVNEWExEZWVwQ2FjaGVMb2FkZXIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTJDJTBBKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyklMEElMEFnYXRlX3N0ZXAlMjAlM0QlMjAxMCUwQWluZmVyZW5jZV9zdGVwJTIwJTNEJTIwMjUlMEFwaXBlJTIwJTNEJTIwVGdhdGVTRFhMRGVlcENhY2hlTG9hZGVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMHBpcGUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBjYWNoZV9pbnRlcnZhbCUzRDMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBjYWNoZV9icmFuY2hfaWQlM0QwJTJDJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<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> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLDeepCacheLoader

pipe = StableDiffusionXLPipeline.from_pretrained(
            <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
            torch_dtype=torch.float16,
            variant=<span class="hljs-string">&quot;fp16&quot;</span>,
            use_safetensors=<span class="hljs-literal">True</span>,
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">10</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgateSDXLDeepCacheLoader(
       pipe,
       cache_interval=<span class="hljs-number">3</span>,
       cache_branch_id=<span class="hljs-number">0</span>,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=m("p"),l.innerHTML=T,d=o(),J(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),b(l)!=="svelte-tcx4pu"&&(l.innerHTML=T),d=c(e),u(n.$$.fragment,e)},m(e,r){i(e,l,r),i(e,d,r),y(n,e,r),M=!0},p:lt,i(e){M||(h(n.$$.fragment,e),M=!0)},o(e){U(n.$$.fragment,e),M=!1},d(e){e&&(a(l),a(d)),j(n,e)}}}function Zt(I){let l,T="Accelerate <code>latent-consistency/lcm-sdxl</code> with T-GATE:",d,n,M;return n=new D({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBVTmV0MkRDb25kaXRpb25Nb2RlbCUyQyUyMExDTVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY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NlX3N0ZXAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBsY20lM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<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> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel, LCMScheduler
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLLoader

unet = UNet2DConditionModel.from_pretrained(
    <span class="hljs-string">&quot;latent-consistency/lcm-sdxl&quot;</span>,
    torch_dtype=torch.float16,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipe = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    unet=unet,
    torch_dtype=torch.float16,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">1</span>
inference_step = <span class="hljs-number">4</span>
pipe = TgateSDXLLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
       lcm=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=m("p"),l.innerHTML=T,d=o(),J(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),b(l)!=="svelte-13iqzli"&&(l.innerHTML=T),d=c(e),u(n.$$.fragment,e)},m(e,r){i(e,l,r),i(e,d,r),y(n,e,r),M=!0},p:lt,i(e){M||(h(n.$$.fragment,e),M=!0)},o(e){U(n.$$.fragment,e),M=!1},d(e){e&&(a(l),a(d)),j(n,e)}}}function Gt(I){let l,T,d,n,M,e,r,Z;return l=new et({props:{id:"pipelines",option:"PixArt",$$slots:{default:[bt]},$$scope:{ctx:I}}}),d=new et({props:{id:"pipelines",option:"Stable Diffusion XL",$$slots:{default:[It]},$$scope:{ctx:I}}}),M=new et({props:{id:"pipelines",option:"StableDiffusionXL with DeepCache",$$slots:{default:[Ct]},$$scope:{ctx:I}}}),r=new et({props:{id:"pipelines",option:"Latent Consistency Model",$$slots:{default:[Zt]},$$scope:{ctx:I}}}),{c(){J(l.$$.fragment),T=o(),J(d.$$.fragment),n=o(),J(M.$$.fragment),e=o(),J(r.$$.fragment)},l(s){u(l.$$.fragment,s),T=c(s),u(d.$$.fragment,s),n=c(s),u(M.$$.fragment,s),e=c(s),u(r.$$.fragment,s)},m(s,w){y(l,s,w),i(s,T,w),y(d,s,w),i(s,n,w),y(M,s,w),i(s,e,w),y(r,s,w),Z=!0},p(s,w){const B={};w&2&&(B.$$scope={dirty:w,ctx:s}),l.$set(B);const C={};w&2&&(C.$$scope={dirty:w,ctx:s}),d.$set(C);const L={};w&2&&(L.$$scope={dirty:w,ctx:s}),M.$set(L);const A={};w&2&&(A.$$scope={dirty:w,ctx:s}),r.$set(A)},i(s){Z||(h(l.$$.fragment,s),h(d.$$.fragment,s),h(M.$$.fragment,s),h(r.$$.fragment,s),Z=!0)},o(s){U(l.$$.fragment,s),U(d.$$.fragment,s),U(M.$$.fragment,s),U(r.$$.fragment,s),Z=!1},d(s){s&&(a(T),a(n),a(e)),j(l,s),j(d,s),j(M,s),j(r,s)}}}function Bt(I){let l,T,d,n,M,e,r,Z,s,w='<a href="https://github.com/HaozheLiu-ST/T-GATE/tree/main" rel="nofollow">T-GATE</a> accelerates inference for <a href="../api/pipelines/stable_diffusion/overview">Stable Diffusion</a>, <a href="../api/pipelines/pixart">PixArt</a>, and <a href="../api/pipelines/latent_consistency_models.md">Latency Consistency Model</a> pipelines by skipping the cross-attention calculation once it converges. This method doesn’t require any additional training and it can speed up inference from 10-50%. T-GATE is also compatible with other optimization methods like <a href="./deepcache">DeepCache</a>.',B,C,L="Before you begin, make sure you install T-GATE.",A,$,Q,V,st="To use T-GATE with a pipeline, you need to use its corresponding loader.",Y,E,at="<thead><tr><th>Pipeline</th> <th>T-GATE Loader</th></tr></thead> <tbody><tr><td>PixArt</td> <td>TgatePixArtLoader</td></tr> <tr><td>Stable Diffusion XL</td> <td>TgateSDXLLoader</td></tr> <tr><td>Stable Diffusion XL + DeepCache</td> <td>TgateSDXLDeepCacheLoader</td></tr> <tr><td>Stable Diffusion</td> <td>TgateSDLoader</td></tr> <tr><td>Stable Diffusion + DeepCache</td> <td>TgateSDDeepCacheLoader</td></tr></tbody>",N,X,nt="Next, create a <code>TgateLoader</code> with a pipeline, the gate step (the time step to stop calculating the cross attention), and the number of inference steps. Then call the <code>tgate</code> method on the pipeline with a prompt, gate step, and the number of inference steps.",F,g,pt="Let’s see how to enable this for several different pipelines.",v,G,z,R,it='T-GATE also supports <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> and <a href="https://hf.co/PixArt-alpha/PixArt-LCM-XL-2-1024-MS" rel="nofollow">PixArt-alpha/PixArt-LCM-XL-2-1024-MS</a>.',P,S,H,W,Mt="<thead><tr><th>Model</th> <th>MACs</th> <th>Param</th> <th>Latency</th> <th>Zero-shot 10K-FID on MS-COCO</th></tr></thead> <tbody><tr><td>SD-1.5</td> <td>16.938T</td> <td>859.520M</td> <td>7.032s</td> <td>23.927</td></tr> <tr><td>SD-1.5 w/ T-GATE</td> <td>9.875T</td> <td>815.557M</td> <td>4.313s</td> <td>20.789</td></tr> <tr><td>SD-2.1</td> <td>38.041T</td> <td>865.785M</td> <td>16.121s</td> <td>22.609</td></tr> <tr><td>SD-2.1 w/ T-GATE</td> <td>22.208T</td> <td>815.433 M</td> <td>9.878s</td> <td>19.940</td></tr> <tr><td>SD-XL</td> <td>149.438T</td> <td>2.570B</td> <td>53.187s</td> <td>24.628</td></tr> <tr><td>SD-XL w/ T-GATE</td> <td>84.438T</td> <td>2.024B</td> <td>27.932s</td> <td>22.738</td></tr> <tr><td>Pixart-Alpha</td> <td>107.031T</td> <td>611.350M</td> <td>61.502s</td> <td>38.669</td></tr> <tr><td>Pixart-Alpha w/ T-GATE</td> <td>65.318T</td> <td>462.585M</td> <td>37.867s</td> <td>35.825</td></tr> <tr><td>DeepCache (SD-XL)</td> <td>57.888T</td> <td>-</td> <td>19.931s</td> <td>23.755</td></tr> <tr><td>DeepCache w/ T-GATE</td> <td>43.868T</td> <td>-</td> <td>14.666s</td> <td>23.999</td></tr> <tr><td>LCM (SD-XL)</td> <td>11.955T</td> <td>2.570B</td> <td>3.805s</td> <td>25.044</td></tr> <tr><td>LCM w/ T-GATE</td> <td>11.171T</td> <td>2.024B</td> <td>3.533s</td> <td>25.028</td></tr> <tr><td>LCM (Pixart-Alpha)</td> <td>8.563T</td> <td>611.350M</td> <td>4.733s</td> <td>36.086</td></tr> <tr><td>LCM w/ T-GATE</td> <td>7.623T</td> <td>462.585M</td> <td>4.543s</td> <td>37.048</td></tr></tbody>",q,_,dt='The latency is tested on an NVIDIA 1080TI, MACs and Params are calculated with <a href="https://github.com/MrYxJ/calculate-flops.pytorch" rel="nofollow">calflops</a>, and the FID is calculated with <a href="https://github.com/mseitzer/pytorch-fid" rel="nofollow">PytorchFID</a>.',K,k,O,x,tt;return M=new ht({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),r=new Tt({props:{title:"T-GATE",local:"t-gate",headingTag:"h1"}}),$=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRnYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC1VJTIwdG9yY2glMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBhY2NlbGVyYXRlJTIwRGVlcENhY2hl",highlighted:`pip install tgate
pip install -U torch diffusers transformers accelerate DeepCache`,wrap:!1}}),G=new jt({props:{id:"pipelines",options:["PixArt","Stable Diffusion XL","StableDiffusionXL with DeepCache","Latent Consistency Model"],$$slots:{default:[Gt]},$$scope:{ctx:I}}}),S=new Tt({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h2"}}),k=new Ut({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/tgate.md"}}),{c(){l=m("meta"),T=o(),d=m("p"),n=o(),J(M.$$.fragment),e=o(),J(r.$$.fragment),Z=o(),s=m("p"),s.innerHTML=w,B=o(),C=m("p"),C.textContent=L,A=o(),J($.$$.fragment),Q=o(),V=m("p"),V.textContent=st,Y=o(),E=m("table"),E.innerHTML=at,N=o(),X=m("p"),X.innerHTML=nt,F=o(),g=m("p"),g.textContent=pt,v=o(),J(G.$$.fragment),z=o(),R=m("p"),R.innerHTML=it,P=o(),J(S.$$.fragment),H=o(),W=m("table"),W.innerHTML=Mt,q=o(),_=m("p"),_.innerHTML=dt,K=o(),J(k.$$.fragment),O=o(),x=m("p"),this.h()},l(t){const p=ut("svelte-u9bgzb",document.head);l=f(p,"META",{name:!0,content:!0}),p.forEach(a),T=c(t),d=f(t,"P",{}),ot(d).forEach(a),n=c(t),u(M.$$.fragment,t),e=c(t),u(r.$$.fragment,t),Z=c(t),s=f(t,"P",{"data-svelte-h":!0}),b(s)!=="svelte-1qox7gi"&&(s.innerHTML=w),B=c(t),C=f(t,"P",{"data-svelte-h":!0}),b(C)!=="svelte-rx8j02"&&(C.textContent=L),A=c(t),u($.$$.fragment,t),Q=c(t),V=f(t,"P",{"data-svelte-h":!0}),b(V)!=="svelte-113mmog"&&(V.textContent=st),Y=c(t),E=f(t,"TABLE",{"data-svelte-h":!0}),b(E)!=="svelte-17jk9ut"&&(E.innerHTML=at),N=c(t),X=f(t,"P",{"data-svelte-h":!0}),b(X)!=="svelte-1uere4x"&&(X.innerHTML=nt),F=c(t),g=f(t,"P",{"data-svelte-h":!0}),b(g)!=="svelte-1tyd5nl"&&(g.textContent=pt),v=c(t),u(G.$$.fragment,t),z=c(t),R=f(t,"P",{"data-svelte-h":!0}),b(R)!=="svelte-1prc9kg"&&(R.innerHTML=it),P=c(t),u(S.$$.fragment,t),H=c(t),W=f(t,"TABLE",{"data-svelte-h":!0}),b(W)!=="svelte-7mhhwa"&&(W.innerHTML=Mt),q=c(t),_=f(t,"P",{"data-svelte-h":!0}),b(_)!=="svelte-17hd8in"&&(_.innerHTML=dt),K=c(t),u(k.$$.fragment,t),O=c(t),x=f(t,"P",{}),ot(x).forEach(a),this.h()},h(){ct(l,"name","hf:doc:metadata"),ct(l,"content",At)},m(t,p){yt(document.head,l),i(t,T,p),i(t,d,p),i(t,n,p),y(M,t,p),i(t,e,p),y(r,t,p),i(t,Z,p),i(t,s,p),i(t,B,p),i(t,C,p),i(t,A,p),y($,t,p),i(t,Q,p),i(t,V,p),i(t,Y,p),i(t,E,p),i(t,N,p),i(t,X,p),i(t,F,p),i(t,g,p),i(t,v,p),y(G,t,p),i(t,z,p),i(t,R,p),i(t,P,p),y(S,t,p),i(t,H,p),i(t,W,p),i(t,q,p),i(t,_,p),i(t,K,p),y(k,t,p),i(t,O,p),i(t,x,p),tt=!0},p(t,[p]){const rt={};p&2&&(rt.$$scope={dirty:p,ctx:t}),G.$set(rt)},i(t){tt||(h(M.$$.fragment,t),h(r.$$.fragment,t),h($.$$.fragment,t),h(G.$$.fragment,t),h(S.$$.fragment,t),h(k.$$.fragment,t),tt=!0)},o(t){U(M.$$.fragment,t),U(r.$$.fragment,t),U($.$$.fragment,t),U(G.$$.fragment,t),U(S.$$.fragment,t),U(k.$$.fragment,t),tt=!1},d(t){t&&(a(T),a(d),a(n),a(e),a(Z),a(s),a(B),a(C),a(A),a(Q),a(V),a(Y),a(E),a(N),a(X),a(F),a(g),a(v),a(z),a(R),a(P),a(H),a(W),a(q),a(_),a(K),a(O),a(x)),a(l),j(M,t),j(r,t),j($,t),j(G,t),j(S,t),j(k,t)}}}const At='{"title":"T-GATE","local":"t-gate","sections":[{"title":"Benchmarks","local":"benchmarks","sections":[],"depth":2}],"depth":1}';function $t(I){return mt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wt extends ft{constructor(l){super(),Jt(this,l,$t,Bt,wt,{})}}export{Wt as component};
