import{s as ye,n as Te,o as ge}from"../chunks/scheduler.182ea377.js";import{S as we,i as Je,g as s,s as i,r as W,A as Ue,h as o,f as a,c as n,j as ce,u as I,x as r,k as be,y as Ge,a as l,v as j,d as Z,t as $,w as x}from"../chunks/index.abf12888.js";import{C as te}from"../chunks/CodeBlock.57fe6e13.js";import{H as Me}from"../chunks/Heading.16916d63.js";function Ce(ae){let u,B,_,S,p,L,d,le='🤗 Diffusers is compatible with Habana Gaudi through 🤗 <a href="https://huggingface.co/docs/optimum/habana/usage_guides/stable_diffusion" rel="nofollow">Optimum</a>. Follow the <a href="https://docs.habana.ai/en/latest/Installation_Guide/index.html" rel="nofollow">installation</a> guide to install the SynapseAI and Gaudi drivers, and then install Optimum Habana:',k,h,V,f,ie="To generate images with Stable Diffusion 1 and 2 on Gaudi, you need to instantiate two instances:",F,m,ne="<li><code>GaudiStableDiffusionPipeline</code>, a pipeline for text-to-image generation.</li> <li><code>GaudiDDIMScheduler</code>, a Gaudi-optimized scheduler.</li>",N,c,se="When you initialize the pipeline, you have to specify <code>use_habana=True</code> to deploy it on HPUs and to get the fastest possible generation, you should enable <strong>HPU graphs</strong> with <code>use_hpu_graphs=True</code>.",E,b,oe='Finally, specify a <code>GaudiConfig</code> which can be downloaded from the <a href="https://huggingface.co/Habana" rel="nofollow">Habana</a> organization on the Hub.',Q,M,R,y,re="Now you can call the pipeline to generate images by batches from one or several prompts:",z,T,X,g,ue='For more information, check out 🤗 Optimum Habana’s <a href="https://huggingface.co/docs/optimum/habana/usage_guides/stable_diffusion" rel="nofollow">documentation</a> and the <a href="https://github.com/huggingface/optimum-habana/tree/main/examples/stable-diffusion" rel="nofollow">example</a> provided in the official Github repository.',Y,w,D,J,pe='We benchmarked Habana’s first-generation Gaudi and Gaudi2 with the <a href="https://huggingface.co/Habana/stable-diffusion" rel="nofollow">Habana/stable-diffusion</a> and <a href="https://huggingface.co/Habana/stable-diffusion-2" rel="nofollow">Habana/stable-diffusion-2</a> Gaudi configurations (mixed precision bf16/fp32) to demonstrate their performance.',P,U,de='For <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">Stable Diffusion v1.5</a> on 512x512 images:',q,G,he='<thead><tr><th></th> <th align="center">Latency (batch size = 1)</th> <th align="center">Throughput</th></tr></thead> <tbody><tr><td>first-generation Gaudi</td> <td align="center">3.80s</td> <td align="center">0.308 images/s (batch size = 8)</td></tr> <tr><td>Gaudi2</td> <td align="center">1.33s</td> <td align="center">1.081 images/s (batch size = 8)</td></tr></tbody>',A,C,fe='For <a href="https://huggingface.co/stabilityai/stable-diffusion-2-1" rel="nofollow">Stable Diffusion v2.1</a> on 768x768 images:',K,H,me='<thead><tr><th></th> <th align="center">Latency (batch size = 1)</th> <th align="center">Throughput</th></tr></thead> <tbody><tr><td>first-generation Gaudi</td> <td align="center">10.2s</td> <td align="center">0.108 images/s (batch size = 4)</td></tr> <tr><td>Gaudi2</td> <td align="center">3.17s</td> <td align="center">0.379 images/s (batch size = 8)</td></tr></tbody>',O,v,ee;return p=new Me({props:{title:"Habana Gaudi",local:"habana-gaudi",headingTag:"h1"}}),h=new te({props:{code:"cHl0aG9uJTIwLW0lMjBwaXAlMjBpbnN0YWxsJTIwLS11cGdyYWRlLXN0cmF0ZWd5JTIwZWFnZXIlMjBvcHRpbXVtJTVCaGFiYW5hJTVE",highlighted:"python -m pip install --upgrade-strategy eager optimum[habana]",wrap:!1}}),M=new te({props:{code:"ZnJvbSUyMG9wdGltdW0uaGFiYW5hJTIwaW1wb3J0JTIwR2F1ZGlDb25maWclMEFmcm9tJTIwb3B0aW11bS5oYWJhbmEuZGlmZnVzZXJzJTIwaW1wb3J0JTIwR2F1ZGlERElNU2NoZWR1bGVyJTJDJTIwR2F1ZGlTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX25hbWUlMjAlM0QlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24tMi1iYXNlJTIyJTBBc2NoZWR1bGVyJTIwJTNEJTIwR2F1ZGlERElNU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9uYW1lJTJDJTIwc3ViZm9sZGVyJTNEJTIyc2NoZWR1bGVyJTIyKSUwQXBpcGVsaW5lJTIwJTNEJTIwR2F1ZGlTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfbmFtZSUyQyUwQSUyMCUyMCUyMCUyMHNjaGVkdWxlciUzRHNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMHVzZV9oYWJhbmElM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2hwdV9ncmFwaHMlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZ2F1ZGlfY29uZmlnJTNEJTIySGFiYW5hJTJGc3RhYmxlLWRpZmZ1c2lvbi0yJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> optimum.habana <span class="hljs-keyword">import</span> GaudiConfig
<span class="hljs-keyword">from</span> optimum.habana.diffusers <span class="hljs-keyword">import</span> GaudiDDIMScheduler, GaudiStableDiffusionPipeline

model_name = <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-base&quot;</span>
scheduler = GaudiDDIMScheduler.from_pretrained(model_name, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
pipeline = GaudiStableDiffusionPipeline.from_pretrained(
    model_name,
    scheduler=scheduler,
    use_habana=<span class="hljs-literal">True</span>,
    use_hpu_graphs=<span class="hljs-literal">True</span>,
    gaudi_config=<span class="hljs-string">&quot;Habana/stable-diffusion-2&quot;</span>,
)`,wrap:!1}}),T=new te({props:{code:"b3V0cHV0cyUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkhpZ2glMjBxdWFsaXR5JTIwcGhvdG8lMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwaW4lMjBzcGFjZSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkZhY2UlMjBvZiUyMGElMjB5ZWxsb3clMjBjYXQlMkMlMjBoaWdoJTIwcmVzb2x1dGlvbiUyQyUyMHNpdHRpbmclMjBvbiUyMGElMjBwYXJrJTIwYmVuY2glMjIlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0QxMCUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0Q0JTJDJTBBKQ==",highlighted:`outputs = pipeline(
    prompt=[
        <span class="hljs-string">&quot;High quality photo of an astronaut riding a horse in space&quot;</span>,
        <span class="hljs-string">&quot;Face of a yellow cat, high resolution, sitting on a park bench&quot;</span>,
    ],
    num_images_per_prompt=<span class="hljs-number">10</span>,
    batch_size=<span class="hljs-number">4</span>,
)`,wrap:!1}}),w=new Me({props:{title:"Benchmark",local:"benchmark",headingTag:"h2"}}),{c(){u=s("meta"),B=i(),_=s("p"),S=i(),W(p.$$.fragment),L=i(),d=s("p"),d.innerHTML=le,k=i(),W(h.$$.fragment),V=i(),f=s("p"),f.textContent=ie,F=i(),m=s("ul"),m.innerHTML=ne,N=i(),c=s("p"),c.innerHTML=se,E=i(),b=s("p"),b.innerHTML=oe,Q=i(),W(M.$$.fragment),R=i(),y=s("p"),y.textContent=re,z=i(),W(T.$$.fragment),X=i(),g=s("p"),g.innerHTML=ue,Y=i(),W(w.$$.fragment),D=i(),J=s("p"),J.innerHTML=pe,P=i(),U=s("p"),U.innerHTML=de,q=i(),G=s("table"),G.innerHTML=he,A=i(),C=s("p"),C.innerHTML=fe,K=i(),H=s("table"),H.innerHTML=me,O=i(),v=s("p"),this.h()},l(e){const t=Ue("svelte-u9bgzb",document.head);u=o(t,"META",{name:!0,content:!0}),t.forEach(a),B=n(e),_=o(e,"P",{}),ce(_).forEach(a),S=n(e),I(p.$$.fragment,e),L=n(e),d=o(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-zkz97r"&&(d.innerHTML=le),k=n(e),I(h.$$.fragment,e),V=n(e),f=o(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-ojl4a9"&&(f.textContent=ie),F=n(e),m=o(e,"UL",{"data-svelte-h":!0}),r(m)!=="svelte-1x8zh9o"&&(m.innerHTML=ne),N=n(e),c=o(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-1ncqr39"&&(c.innerHTML=se),E=n(e),b=o(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-orl9jn"&&(b.innerHTML=oe),Q=n(e),I(M.$$.fragment,e),R=n(e),y=o(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-g0h5z1"&&(y.textContent=re),z=n(e),I(T.$$.fragment,e),X=n(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-1qf95g6"&&(g.innerHTML=ue),Y=n(e),I(w.$$.fragment,e),D=n(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-whvrtk"&&(J.innerHTML=pe),P=n(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-v3u7rq"&&(U.innerHTML=de),q=n(e),G=o(e,"TABLE",{"data-svelte-h":!0}),r(G)!=="svelte-1d97u7g"&&(G.innerHTML=he),A=n(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1pi2k0u"&&(C.innerHTML=fe),K=n(e),H=o(e,"TABLE",{"data-svelte-h":!0}),r(H)!=="svelte-1uvfcpf"&&(H.innerHTML=me),O=n(e),v=o(e,"P",{}),ce(v).forEach(a),this.h()},h(){be(u,"name","hf:doc:metadata"),be(u,"content",He)},m(e,t){Ge(document.head,u),l(e,B,t),l(e,_,t),l(e,S,t),j(p,e,t),l(e,L,t),l(e,d,t),l(e,k,t),j(h,e,t),l(e,V,t),l(e,f,t),l(e,F,t),l(e,m,t),l(e,N,t),l(e,c,t),l(e,E,t),l(e,b,t),l(e,Q,t),j(M,e,t),l(e,R,t),l(e,y,t),l(e,z,t),j(T,e,t),l(e,X,t),l(e,g,t),l(e,Y,t),j(w,e,t),l(e,D,t),l(e,J,t),l(e,P,t),l(e,U,t),l(e,q,t),l(e,G,t),l(e,A,t),l(e,C,t),l(e,K,t),l(e,H,t),l(e,O,t),l(e,v,t),ee=!0},p:Te,i(e){ee||(Z(p.$$.fragment,e),Z(h.$$.fragment,e),Z(M.$$.fragment,e),Z(T.$$.fragment,e),Z(w.$$.fragment,e),ee=!0)},o(e){$(p.$$.fragment,e),$(h.$$.fragment,e),$(M.$$.fragment,e),$(T.$$.fragment,e),$(w.$$.fragment,e),ee=!1},d(e){e&&(a(B),a(_),a(S),a(L),a(d),a(k),a(V),a(f),a(F),a(m),a(N),a(c),a(E),a(b),a(Q),a(R),a(y),a(z),a(X),a(g),a(Y),a(D),a(J),a(P),a(U),a(q),a(G),a(A),a(C),a(K),a(H),a(O),a(v)),a(u),x(p,e),x(h,e),x(M,e),x(T,e),x(w,e)}}}const He='{"title":"Habana Gaudi","local":"habana-gaudi","sections":[{"title":"Benchmark","local":"benchmark","sections":[],"depth":2}],"depth":1}';function _e(ae){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends we{constructor(u){super(),Je(this,u,_e,Ce,ye,{})}}export{Ze as component};
