import{s as Te,n as we,o as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as Ue,i as Ge,g as s,s as i,r as _,A as Ce,h as o,f as a,c as n,j as Me,u as v,x as r,k as ye,y as He,a as l,v as W,d as I,t as j,w as Z}from"../chunks/index.da70eac4.js";import{C as le}from"../chunks/CodeBlock.00a903b3.js";import{H as ge,E as $e}from"../chunks/EditOnGithub.1e64e623.js";function _e(ie){let u,S,x,L,p,k,d,ne='🤗 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:',E,h,V,f,se="To generate images with Stable Diffusion 1 and 2 on Gaudi, you need to instantiate two instances:",F,m,oe="<li><code>GaudiStableDiffusionPipeline</code>, a pipeline for text-to-image generation.</li> <li><code>GaudiDDIMScheduler</code>, a Gaudi-optimized scheduler.</li>",N,c,re="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>.",z,b,ue='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,pe="Now you can call the pipeline to generate images by batches from one or several prompts:",X,g,Y,T,de='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.',D,w,P,J,he='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.',A,U,fe='For <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">Stable Diffusion v1.5</a> on 512x512 images:',q,G,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">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>',K,C,ce='For <a href="https://huggingface.co/stabilityai/stable-diffusion-2-1" rel="nofollow">Stable Diffusion v2.1</a> on 768x768 images:',O,H,be='<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>',ee,$,te,B,ae;return p=new ge({props:{title:"Habana Gaudi",local:"habana-gaudi",headingTag:"h1"}}),h=new le({props:{code:"cHl0aG9uJTIwLW0lMjBwaXAlMjBpbnN0YWxsJTIwLS11cGdyYWRlLXN0cmF0ZWd5JTIwZWFnZXIlMjBvcHRpbXVtJTVCaGFiYW5hJTVE",highlighted:"python -m pip install --upgrade-strategy eager optimum[habana]",wrap:!1}}),M=new le({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}}),g=new le({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 ge({props:{title:"Benchmark",local:"benchmark",headingTag:"h2"}}),$=new $e({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/habana.md"}}),{c(){u=s("meta"),S=i(),x=s("p"),L=i(),_(p.$$.fragment),k=i(),d=s("p"),d.innerHTML=ne,E=i(),_(h.$$.fragment),V=i(),f=s("p"),f.textContent=se,F=i(),m=s("ul"),m.innerHTML=oe,N=i(),c=s("p"),c.innerHTML=re,z=i(),b=s("p"),b.innerHTML=ue,Q=i(),_(M.$$.fragment),R=i(),y=s("p"),y.textContent=pe,X=i(),_(g.$$.fragment),Y=i(),T=s("p"),T.innerHTML=de,D=i(),_(w.$$.fragment),P=i(),J=s("p"),J.innerHTML=he,A=i(),U=s("p"),U.innerHTML=fe,q=i(),G=s("table"),G.innerHTML=me,K=i(),C=s("p"),C.innerHTML=ce,O=i(),H=s("table"),H.innerHTML=be,ee=i(),_($.$$.fragment),te=i(),B=s("p"),this.h()},l(e){const t=Ce("svelte-u9bgzb",document.head);u=o(t,"META",{name:!0,content:!0}),t.forEach(a),S=n(e),x=o(e,"P",{}),Me(x).forEach(a),L=n(e),v(p.$$.fragment,e),k=n(e),d=o(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-zkz97r"&&(d.innerHTML=ne),E=n(e),v(h.$$.fragment,e),V=n(e),f=o(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-ojl4a9"&&(f.textContent=se),F=n(e),m=o(e,"UL",{"data-svelte-h":!0}),r(m)!=="svelte-1x8zh9o"&&(m.innerHTML=oe),N=n(e),c=o(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-1ncqr39"&&(c.innerHTML=re),z=n(e),b=o(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-orl9jn"&&(b.innerHTML=ue),Q=n(e),v(M.$$.fragment,e),R=n(e),y=o(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-g0h5z1"&&(y.textContent=pe),X=n(e),v(g.$$.fragment,e),Y=n(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-1xk941i"&&(T.innerHTML=de),D=n(e),v(w.$$.fragment,e),P=n(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-whvrtk"&&(J.innerHTML=he),A=n(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-v3u7rq"&&(U.innerHTML=fe),q=n(e),G=o(e,"TABLE",{"data-svelte-h":!0}),r(G)!=="svelte-1d97u7g"&&(G.innerHTML=me),K=n(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1pi2k0u"&&(C.innerHTML=ce),O=n(e),H=o(e,"TABLE",{"data-svelte-h":!0}),r(H)!=="svelte-1uvfcpf"&&(H.innerHTML=be),ee=n(e),v($.$$.fragment,e),te=n(e),B=o(e,"P",{}),Me(B).forEach(a),this.h()},h(){ye(u,"name","hf:doc:metadata"),ye(u,"content",ve)},m(e,t){He(document.head,u),l(e,S,t),l(e,x,t),l(e,L,t),W(p,e,t),l(e,k,t),l(e,d,t),l(e,E,t),W(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,z,t),l(e,b,t),l(e,Q,t),W(M,e,t),l(e,R,t),l(e,y,t),l(e,X,t),W(g,e,t),l(e,Y,t),l(e,T,t),l(e,D,t),W(w,e,t),l(e,P,t),l(e,J,t),l(e,A,t),l(e,U,t),l(e,q,t),l(e,G,t),l(e,K,t),l(e,C,t),l(e,O,t),l(e,H,t),l(e,ee,t),W($,e,t),l(e,te,t),l(e,B,t),ae=!0},p:we,i(e){ae||(I(p.$$.fragment,e),I(h.$$.fragment,e),I(M.$$.fragment,e),I(g.$$.fragment,e),I(w.$$.fragment,e),I($.$$.fragment,e),ae=!0)},o(e){j(p.$$.fragment,e),j(h.$$.fragment,e),j(M.$$.fragment,e),j(g.$$.fragment,e),j(w.$$.fragment,e),j($.$$.fragment,e),ae=!1},d(e){e&&(a(S),a(x),a(L),a(k),a(d),a(E),a(V),a(f),a(F),a(m),a(N),a(c),a(z),a(b),a(Q),a(R),a(y),a(X),a(Y),a(T),a(D),a(P),a(J),a(A),a(U),a(q),a(G),a(K),a(C),a(O),a(H),a(ee),a(te),a(B)),a(u),Z(p,e),Z(h,e),Z(M,e),Z(g,e),Z(w,e),Z($,e)}}}const ve='{"title":"Habana Gaudi","local":"habana-gaudi","sections":[{"title":"Benchmark","local":"benchmark","sections":[],"depth":2}],"depth":1}';function We(ie){return Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends Ue{constructor(u){super(),Ge(this,u,We,_e,Te,{})}}export{Be as component};
