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GFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTJCJTIwdG9tZXNkLmFwcGx5X3BhdGNoKHBpcGVsaW5lJTJDJTIwcmF0aW8lM0QwLjUpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMjJhJTIwcGhvdG8lMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwb24lMjBtYXJzJTIyKS5pbWFnZXMlNUIwJTVE",highlighted:`from diffusers import StableDiffusionPipeline
import tomesd

pipeline = StableDiffusionPipeline.from_pretrained(
      &quot;runwayml/stable-diffusion-v1-5&quot;, torch_dtype=torch.float16
).to(&quot;cuda&quot;)
<span class="hljs-addition">+ tomesd.apply_patch(pipeline, ratio=0.5)</span>

image = pipeline(&quot;a photo of an astronaut riding a horse on mars&quot;).images[0]`}}),De=new el({}),Me=new Uu({props:{code:"LSUyMCU2MGRpZmZ1c2VycyU2MCUyMHZlcnNpb24lM0ElMjAwLjE1LjElMEEtJTIwUHl0aG9uJTIwdmVyc2lvbiUzQSUyMDMuOC4xNiUwQS0lMjBQeVRvcmNoJTIwdmVyc2lvbiUyMChHUFUlM0YpJTNBJTIwMS4xMy4xJTJCY3UxMTYlMjAoVHJ1ZSklMEEtJTIwSHVnZ2luZ2ZhY2VfaHViJTIwdmVyc2lvbiUzQSUyMDAuMTMuMiUwQS0lMjBUcmFuc2Zvcm1lcnMlMjB2ZXJzaW9uJTNBJTIwNC4yNy4yJTBBLSUyMEFjY2VsZXJhdGUlMjB2ZXJzaW9uJTNBJTIwMC4xOC4wJTBBLSUyMHhGb3JtZXJzJTIwdmVyc2lvbiUzQSUyMDAuMC4xNiUwQS0lMjB0b21lc2QlMjB2ZXJzaW9uJTNBJTIwMC4xLjI=",highlighted:`- \`diffusers\` version: 0.15.1
- Python version: 3.8.16
- PyTorch version (GPU?): 1.13.1+cu116 (True)
- Huggingface_hub version: 0.13.2
- Transformers version: 4.27.2
- Accelerate version: 0.18.0
- xFormers version: 0.0.16
- tomesd version: 0.1.2`}}),we=new el({}),Oe=new el({}),ke=new el({}),{c(){Zt=l("meta"),na=a(),Ht=l("h1"),Wt=l("a"),ll=l("span"),oe(ie.$$.fragment),gs=a(),rl=l("span"),Os=s("Token Merging"),ia=a(),jt=l("p"),ys=s("Token Merging (introduced in "),he=l("a"),ks=s("Token Merging: Your ViT But Faster"),Ps=s(") works by merging the redundant tokens / patches progressively in the forward pass of a Transformer-based network. It can speed up the inference latency of the underlying network."),ha=a(),z=l("p"),As=s("After Token Merging (ToMe) was released, the authors released "),ce=l("a"),Ss=s("Token Merging for Fast Stable Diffusion"),$s=s(", which introduced a version of ToMe which is more compatible with Stable Diffusion. We can use ToMe to gracefully speed up the inference latency of a "),Je=l("a"),Js=s("DiffusionPipeline"),xs=s(". This doc discusses how to apply ToMe to the "),xe=l("a"),Bs=s("StableDiffusionPipeline"),Rs=s(", the expected speedups, and the qualitative aspects of using ToMe on the "),Be=l("a"),Us=s("StableDiffusionPipeline"),Is=s("."),ca=a(),Nt=l("h2"),qt=l("a"),ol=l("span"),oe(pe.$$.fragment),Zs=a(),al=l("span"),Hs=s("Using ToMe"),pa=a(),$t=l("p"),Ns=s("The authors of ToMe released a convenient Python library called "),Te=l("a"),dl=l("code"),Vs=s("tomesd"),Gs=s(" that lets us apply ToMe to a "),Re=l("a"),Cs=s("DiffusionPipeline"),Fs=s(" like so:"),Ta=a(),oe(Ee.$$.fragment),Ea=a(),Ue=l("p"),Ws=s("And that\u2019s it!"),ua=a(),v=l("p"),sl=l("code"),js=s("tomesd.apply_patch()"),qs=s(" exposes "),ue=l("a"),Ls=s("a number of arguments"),Ys=s(" to let us strike a balance between the pipeline inference speed and the quality of the generated tokens. Amongst those arguments, the most important one is "),fl=l("code"),Xs=s("ratio"),zs=s(". "),nl=l("code"),Qs=s("ratio"),Ks=s(" controls the number of tokens that will be merged during the forward pass. For more details on "),il=l("code"),tf=s("tomesd"),ef=s(", please refer to the original repository "),ve=l("a"),lf=s("https://github.com/dbolya/tomesd"),rf=s(" and "),_e=l("a"),of=s("the paper"),af=s("."),va=a(),Vt=l("h2"),Lt=l("a"),hl=l("span"),oe(De.$$.fragment),df=a(),Yt=l("span"),sf=s("Benchmarking "),cl=l("code"),ff=s("tomesd"),nf=s(" with "),pl=l("code"),hf=s("StableDiffusionPipeline"),_a=a(),St=l("p"),cf=s("We benchmarked the impact of using "),Tl=l("code"),pf=s("tomesd"),Tf=s(" on "),Ie=l("a"),Ef=s("StableDiffusionPipeline"),uf=s(" along with "),me=l("a"),vf=s("xformers"),_f=s(" across different image resolutions. We used A100 and V100 as our test GPU devices with the following development environment (with Python 3.8.5):"),Da=a(),oe(Me.$$.fragment),ma=a(),Xt=l("p"),Df=s("We used this script for benchmarking: "),be=l("a"),mf=s("https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),Mf=s(". Following are our findings:"),Ma=a(),Gt=l("h3"),zt=l("a"),El=l("span"),oe(we.$$.fragment),bf=a(),ul=l("span"),wf=s("A100"),ba=a(),Qt=l("table"),vl=l("thead"),_=l("tr"),_l=l("th"),gf=s("Resolution"),Of=a(),Dl=l("th"),yf=s("Batch size"),kf=a(),ml=l("th"),Pf=s("Vanilla"),Af=a(),Ml=l("th"),Sf=s("ToMe"),$f=a(),bl=l("th"),Jf=s("ToMe + xFormers"),xf=a(),wl=l("th"),Bf=s("ToMe speedup (%)"),Rf=a(),gl=l("th"),Uf=s("ToMe + xFormers speedup (%)"),If=a(),E=l("tbody"),D=l("tr"),Ol=l("td"),Zf=s("512"),Hf=a(),yl=l("td"),Nf=s("10"),Vf=a(),kl=l("td"),Gf=s("6.88"),Cf=a(),Pl=l("td"),Ff=s("5.26"),Wf=a(),Al=l("td"),jf=s("4.69"),qf=a(),Sl=l("td"),Lf=s("23.54651163"),Yf=a(),$l=l("td"),Xf=s("31.83139535"),zf=a(),m=l("tr"),wa=l("td"),Qf=a(),ga=l("td"),Kf=a(),Oa=l("td"),t1=a(),ya=l("td"),e1=a(),ka=l("td"),l1=a(),Pa=l("td"),r1=a(),Aa=l("td"),o1=a(),M=l("tr"),Jl=l("td"),a1=s("768"),d1=a(),xl=l("td"),s1=s("10"),f1=a(),Bl=l("td"),n1=s("OOM"),i1=a(),Rl=l("td"),h1=s("14.71"),c1=a(),Ul=l("td"),p1=s("11"),T1=a(),Sa=l("td"),E1=a(),$a=l("td"),u1=a(),b=l("tr"),Ja=l("td"),v1=a(),Il=l("td"),_1=s("8"),D1=a(),Zl=l("td"),m1=s("OOM"),M1=a(),Hl=l("td"),b1=s("11.56"),w1=a(),Nl=l("td"),g1=s("8.84"),O1=a(),xa=l("td"),y1=a(),Ba=l("td"),k1=a(),w=l("tr"),Ra=l("td"),P1=a(),Vl=l("td"),A1=s("4"),S1=a(),Gl=l("td"),$1=s("OOM"),J1=a(),Cl=l("td"),x1=s("5.98"),B1=a(),Fl=l("td"),R1=s("4.66"),U1=a(),Ua=l("td"),I1=a(),Ia=l("td"),Z1=a(),g=l("tr"),Za=l("td"),H1=a(),Wl=l("td"),N1=s("2"),V1=a(),jl=l("td"),G1=s("4.99"),C1=a(),ql=l("td"),F1=s("3.24"),W1=a(),Ll=l("td"),j1=s("3.1"),q1=a(),Yl=l("td"),L1=s("35.07014028"),Y1=a(),Xl=l("td"),X1=s("37.8757515"),z1=a(),O=l("tr"),Ha=l("td"),Q1=a(),zl=l("td"),K1=s("1"),tn=a(),Ql=l("td"),en=s("3.29"),ln=a(),Kl=l("td"),rn=s("2.24"),on=a(),tr=l("td"),an=s("2.03"),dn=a(),er=l("td"),sn=s("31.91489362"),fn=a(),lr=l("td"),nn=s("38.29787234"),hn=a(),y=l("tr"),Na=l("td"),cn=a(),Va=l("td"),pn=a(),Ga=l("td"),Tn=a(),Ca=l("td"),En=a(),Fa=l("td"),un=a(),Wa=l("td"),vn=a(),ja=l("td"),_n=a(),k=l("tr"),rr=l("td"),Dn=s("1024"),mn=a(),or=l("td"),Mn=s("10"),bn=a(),ar=l("td"),wn=s("OOM"),gn=a(),dr=l("td"),On=s("OOM"),yn=a(),sr=l("td"),kn=s("OOM"),Pn=a(),qa=l("td"),An=a(),La=l("td"),Sn=a(),P=l("tr"),Ya=l("td"),$n=a(),fr=l("td"),Jn=s("8"),xn=a(),nr=l("td"),Bn=s("OOM"),Rn=a(),ir=l("td"),Un=s("OOM"),In=a(),hr=l("td"),Zn=s("OOM"),Hn=a(),Xa=l("td"),Nn=a(),za=l("td"),Vn=a(),A=l("tr"),Qa=l("td"),Gn=a(),cr=l("td"),Cn=s("4"),Fn=a(),pr=l("td"),Wn=s("OOM"),jn=a(),Tr=l("td"),qn=s("12.51"),Ln=a(),Er=l("td"),Yn=s("9.09"),Xn=a(),Ka=l("td"),zn=a(),td=l("td"),Qn=a(),S=l("tr"),ed=l("td"),Kn=a(),ur=l("td"),ti=s("2"),ei=a(),vr=l("td"),li=s("OOM"),ri=a(),_r=l("td"),oi=s("6.52"),ai=a(),Dr=l("td"),di=s("4.96"),si=a(),ld=l("td"),fi=a(),rd=l("td"),ni=a(),$=l("tr"),od=l("td"),ii=a(),mr=l("td"),hi=s("1"),ci=a(),Mr=l("td"),pi=s("6.4"),Ti=a(),br=l("td"),Ei=s("3.61"),ui=a(),wr=l("td"),vi=s("2.81"),_i=a(),gr=l("td"),Di=s("43.59375"),mi=a(),Or=l("td"),Mi=s("56.09375"),ad=a(),Ze=l("p"),yr=l("strong"),ge=l("em"),bi=s("The timings reported here are in seconds. Speedups are calculated over the "),kr=l("code"),wi=s("Vanilla"),gi=s(" timings."),dd=a(),Ct=l("h3"),Kt=l("a"),Pr=l("span"),oe(Oe.$$.fragment),Oi=a(),Ar=l("span"),yi=s("V100"),sd=a(),te=l("table"),Sr=l("thead"),J=l("tr"),$r=l("th"),ki=s("Resolution"),Pi=a(),Jr=l("th"),Ai=s("Batch size"),Si=a(),xr=l("th"),$i=s("Vanilla"),Ji=a(),Br=l("th"),xi=s("ToMe"),Bi=a(),Rr=l("th"),Ri=s("ToMe + xFormers"),Ui=a(),Ur=l("th"),Ii=s("ToMe speedup (%)"),Zi=a(),Ir=l("th"),Hi=s("ToMe + xFormers speedup (%)"),Ni=a(),p=l("tbody"),x=l("tr"),Zr=l("td"),Vi=s("512"),Gi=a(),Hr=l("td"),Ci=s("10"),Fi=a(),Nr=l("td"),Wi=s("OOM"),ji=a(),Vr=l("td"),qi=s("10.03"),Li=a(),Gr=l("td"),Yi=s("9.29"),Xi=a(),fd=l("td"),zi=a(),nd=l("td"),Qi=a(),B=l("tr"),id=l("td"),Ki=a(),Cr=l("td"),th=s("8"),eh=a(),Fr=l("td"),lh=s("OOM"),rh=a(),Wr=l("td"),oh=s("8.05"),ah=a(),jr=l("td"),dh=s("7.47"),sh=a(),hd=l("td"),fh=a(),cd=l("td"),nh=a(),R=l("tr"),pd=l("td"),ih=a(),qr=l("td"),hh=s("4"),ch=a(),Lr=l("td"),ph=s("5.7"),Th=a(),Yr=l("td"),Eh=s("4.3"),uh=a(),Xr=l("td"),vh=s("3.98"),_h=a(),zr=l("td"),Dh=s("24.56140351"),mh=a(),Qr=l("td"),Mh=s("30.1754386"),bh=a(),U=l("tr"),Td=l("td"),wh=a(),Kr=l("td"),gh=s("2"),Oh=a(),to=l("td"),yh=s("3.14"),kh=a(),eo=l("td"),Ph=s("2.43"),Ah=a(),lo=l("td"),Sh=s("2.27"),$h=a(),ro=l("td"),Jh=s("22.61146497"),xh=a(),oo=l("td"),Bh=s("27.70700637"),Rh=a(),I=l("tr"),Ed=l("td"),Uh=a(),ao=l("td"),Ih=s("1"),Zh=a(),so=l("td"),Hh=s("1.88"),Nh=a(),fo=l("td"),Vh=s("1.57"),Gh=a(),no=l("td"),Ch=s("1.57"),Fh=a(),io=l("td"),Wh=s("16.4893617"),jh=a(),ho=l("td"),qh=s("16.4893617"),Lh=a(),Z=l("tr"),ud=l("td"),Yh=a(),vd=l("td"),Xh=a(),_d=l("td"),zh=a(),Dd=l("td"),Qh=a(),md=l("td"),Kh=a(),Md=l("td"),tc=a(),bd=l("td"),ec=a(),H=l("tr"),co=l("td"),lc=s("768"),rc=a(),po=l("td"),oc=s("10"),ac=a(),To=l("td"),dc=s("OOM"),sc=a(),Eo=l("td"),fc=s("OOM"),nc=a(),uo=l("td"),ic=s("23.67"),hc=a(),wd=l("td"),cc=a(),gd=l("td"),pc=a(),N=l("tr"),Od=l("td"),Tc=a(),vo=l("td"),Ec=s("8"),uc=a(),_o=l("td"),vc=s("OOM"),_c=a(),Do=l("td"),Dc=s("OOM"),mc=a(),mo=l("td"),Mc=s("18.81"),bc=a(),yd=l("td"),wc=a(),kd=l("td"),gc=a(),V=l("tr"),Pd=l("td"),Oc=a(),Mo=l("td"),yc=s("4"),kc=a(),bo=l("td"),Pc=s("OOM"),Ac=a(),wo=l("td"),Sc=s("11.81"),$c=a(),go=l("td"),Jc=s("9.7"),xc=a(),Ad=l("td"),Bc=a(),Sd=l("td"),Rc=a(),G=l("tr"),$d=l("td"),Uc=a(),Oo=l("td"),Ic=s("2"),Zc=a(),yo=l("td"),Hc=s("OOM"),Nc=a(),ko=l("td"),Vc=s("6.27"),Gc=a(),Po=l("td"),Cc=s("5.2"),Fc=a(),Jd=l("td"),Wc=a(),xd=l("td"),jc=a(),C=l("tr"),Bd=l("td"),qc=a(),Ao=l("td"),Lc=s("1"),Yc=a(),So=l("td"),Xc=s("5.43"),zc=a(),$o=l("td"),Qc=s("3.38"),Kc=a(),Jo=l("td"),t2=s("2.82"),e2=a(),xo=l("td"),l2=s("37.75322284"),r2=a(),Bo=l("td"),o2=s("48.06629834"),a2=a(),F=l("tr"),Rd=l("td"),d2=a(),Ud=l("td"),s2=a(),Id=l("td"),f2=a(),Zd=l("td"),n2=a(),Hd=l("td"),i2=a(),Nd=l("td"),h2=a(),Vd=l("td"),c2=a(),W=l("tr"),Ro=l("td"),p2=s("1024"),T2=a(),Uo=l("td"),E2=s("10"),u2=a(),Io=l("td"),v2=s("OOM"),_2=a(),Zo=l("td"),D2=s("OOM"),m2=a(),Ho=l("td"),M2=s("OOM"),b2=a(),Gd=l("td"),w2=a(),Cd=l("td"),g2=a(),j=l("tr"),Fd=l("td"),O2=a(),No=l("td"),y2=s("8"),k2=a(),Vo=l("td"),P2=s("OOM"),A2=a(),Go=l("td"),S2=s("OOM"),$2=a(),Co=l("td"),J2=s("OOM"),x2=a(),Wd=l("td"),B2=a(),jd=l("td"),R2=a(),q=l("tr"),qd=l("td"),U2=a(),Fo=l("td"),I2=s("4"),Z2=a(),Wo=l("td"),H2=s("OOM"),N2=a(),jo=l("td"),V2=s("OOM"),G2=a(),qo=l("td"),C2=s("19.35"),F2=a(),Ld=l("td"),W2=a(),Yd=l("td"),j2=a(),L=l("tr"),Xd=l("td"),q2=a(),Lo=l("td"),L2=s("2"),Y2=a(),Yo=l("td"),X2=s("OOM"),z2=a(),Xo=l("td"),Q2=s("13"),K2=a(),zo=l("td"),tp=s("10.78"),ep=a(),zd=l("td"),lp=a(),Qd=l("td"),rp=a(),Y=l("tr"),Kd=l("td"),op=a(),Qo=l("td"),ap=s("1"),dp=a(),Ko=l("td"),sp=s("OOM"),fp=a(),ta=l("td"),np=s("6.66"),ip=a(),ea=l("td"),hp=s("5.54"),cp=a(),ts=l("td"),pp=a(),es=l("td"),ls=a(),Jt=l("p"),Tp=s("As seen in the tables above, the speedup with "),la=l("code"),Ep=s("tomesd"),up=s(" becomes more pronounced for larger image resolutions. It is also interesting to note that with "),ra=l("code"),vp=s("tomesd"),_p=s(", it becomes possible to run the pipeline on a higher resolution, like 1024x1024."),rs=a(),ee=l("p"),Dp=s("It might be possible to speed up inference even further with "),ye=l("a"),oa=l("code"),mp=s("torch.compile()"),Mp=s("."),os=a(),Ft=l("h2"),le=l("a"),aa=l("span"),oe(ke.$$.fragment),bp=a(),da=l("span"),wp=s("Quality"),as=a(),xt=l("p"),gp=s("As reported in "),Pe=l("a"),Op=s("the paper"),yp=s(", ToMe can preserve the quality of the generated images to a great extent while speeding up inference. By increasing the "),sa=l("code"),kp=s("ratio"),Pp=s(", it is possible to further speed up inference, but that might come at the cost of a deterioration in the image quality."),ds=a(),Bt=l("p"),Ap=s("To test the quality of the generated samples using our setup, we sampled a few prompts from the \u201CParti Prompts\u201D (introduced in "),Ae=l("a"),Sp=s("Parti"),$p=s(") and performed inference with the "),He=l("a"),Jp=s("StableDiffusionPipeline"),xp=s(" in the following settings:"),ss=a(),Rt=l("ul"),Ne=l("li"),Bp=s("Vanilla "),Ve=l("a"),Rp=s("StableDiffusionPipeline"),Up=a(),Ge=l("li"),Ce=l("a"),Ip=s("StableDiffusionPipeline"),Zp=s(" + ToMe"),Hp=a(),Fe=l("li"),We=l("a"),Np=s("StableDiffusionPipeline"),Vp=s(" + ToMe + xformers"),fs=a(),je=l("p"),Gp=s("We didn\u2019t notice any significant decrease in the quality of the generated samples. Here are samples:"),ns=a(),qe=l("p"),Le=l("img"),is=a(),Ut=l("p"),Cp=s("You can check out the generated samples "),Se=l("a"),Fp=s("here"),Wp=s(". We used "),$e=l("a"),jp=s("this script"),qp=s(" for conducting this experiment."),this.h()},l(n){const h=Nu('[data-svelte="svelte-1phssyn"]',document.head);Zt=r(h,"META",{name:!0,content:!0}),h.forEach(e),na=d(n),Ht=r(n,"H1",{class:!0});var cs=o(Ht);Wt=r(cs,"A",{id:!0,class:!0,href:!0});var Kp=o(Wt);ll=r(Kp,"SPAN",{});var t3=o(ll);ae(ie.$$.fragment,t3),t3.forEach(e),Kp.forEach(e),gs=d(cs),rl=r(cs,"SPAN",{});var e3=o(rl);Os=f(e3,"Token Merging"),e3.forEach(e),cs.forEach(e),ia=d(n),jt=r(n,"P",{});var ps=o(jt);ys=f(ps,"Token Merging (introduced in "),he=r(ps,"A",{href:!0,rel:!0});var l3=o(he);ks=f(l3,"Token Merging: Your ViT But Faster"),l3.forEach(e),Ps=f(ps,") works by merging the redundant tokens / patches progressively in the forward pass of a Transformer-based network. It can speed up the inference latency of the underlying network."),ps.forEach(e),ha=d(n),z=r(n,"P",{});var It=o(z);As=f(It,"After Token Merging (ToMe) was released, the authors released "),ce=r(It,"A",{href:!0,rel:!0});var r3=o(ce);Ss=f(r3,"Token Merging for Fast Stable Diffusion"),r3.forEach(e),$s=f(It,", which introduced a version of ToMe which is more compatible with Stable Diffusion. We can use ToMe to gracefully speed up the inference latency of a "),Je=r(It,"A",{href:!0});var o3=o(Je);Js=f(o3,"DiffusionPipeline"),o3.forEach(e),xs=f(It,". This doc discusses how to apply ToMe to the "),xe=r(It,"A",{href:!0});var a3=o(xe);Bs=f(a3,"StableDiffusionPipeline"),a3.forEach(e),Rs=f(It,", the expected speedups, and the qualitative aspects of using ToMe on the "),Be=r(It,"A",{href:!0});var d3=o(Be);Us=f(d3,"StableDiffusionPipeline"),d3.forEach(e),Is=f(It,"."),It.forEach(e),ca=d(n),Nt=r(n,"H2",{class:!0});var Ts=o(Nt);qt=r(Ts,"A",{id:!0,class:!0,href:!0});var s3=o(qt);ol=r(s3,"SPAN",{});var f3=o(ol);ae(pe.$$.fragment,f3),f3.forEach(e),s3.forEach(e),Zs=d(Ts),al=r(Ts,"SPAN",{});var n3=o(al);Hs=f(n3,"Using ToMe"),n3.forEach(e),Ts.forEach(e),pa=d(n),$t=r(n,"P",{});var Ye=o($t);Ns=f(Ye,"The authors of ToMe released a convenient Python library called "),Te=r(Ye,"A",{href:!0,rel:!0});var i3=o(Te);dl=r(i3,"CODE",{});var h3=o(dl);Vs=f(h3,"tomesd"),h3.forEach(e),i3.forEach(e),Gs=f(Ye," that lets us apply ToMe to a "),Re=r(Ye,"A",{href:!0});var c3=o(Re);Cs=f(c3,"DiffusionPipeline"),c3.forEach(e),Fs=f(Ye," like so:"),Ye.forEach(e),Ta=d(n),ae(Ee.$$.fragment,n),Ea=d(n),Ue=r(n,"P",{});var p3=o(Ue);Ws=f(p3,"And that\u2019s it!"),p3.forEach(e),ua=d(n),v=r(n,"P",{});var X=o(v);sl=r(X,"CODE",{});var T3=o(sl);js=f(T3,"tomesd.apply_patch()"),T3.forEach(e),qs=f(X," exposes "),ue=r(X,"A",{href:!0,rel:!0});var E3=o(ue);Ls=f(E3,"a number of arguments"),E3.forEach(e),Ys=f(X," to let us strike a balance between the pipeline inference speed and the quality of the generated tokens. Amongst those arguments, the most important one is "),fl=r(X,"CODE",{});var u3=o(fl);Xs=f(u3,"ratio"),u3.forEach(e),zs=f(X,". "),nl=r(X,"CODE",{});var v3=o(nl);Qs=f(v3,"ratio"),v3.forEach(e),Ks=f(X," controls the number of tokens that will be merged during the forward pass. For more details on "),il=r(X,"CODE",{});var _3=o(il);tf=f(_3,"tomesd"),_3.forEach(e),ef=f(X,", please refer to the original repository "),ve=r(X,"A",{href:!0,rel:!0});var D3=o(ve);lf=f(D3,"https://github.com/dbolya/tomesd"),D3.forEach(e),rf=f(X," and "),_e=r(X,"A",{href:!0,rel:!0});var m3=o(_e);of=f(m3,"the paper"),m3.forEach(e),af=f(X,"."),X.forEach(e),va=d(n),Vt=r(n,"H2",{class:!0});var Es=o(Vt);Lt=r(Es,"A",{id:!0,class:!0,href:!0});var M3=o(Lt);hl=r(M3,"SPAN",{});var b3=o(hl);ae(De.$$.fragment,b3),b3.forEach(e),M3.forEach(e),df=d(Es),Yt=r(Es,"SPAN",{});var fa=o(Yt);sf=f(fa,"Benchmarking "),cl=r(fa,"CODE",{});var w3=o(cl);ff=f(w3,"tomesd"),w3.forEach(e),nf=f(fa," with "),pl=r(fa,"CODE",{});var g3=o(pl);hf=f(g3,"StableDiffusionPipeline"),g3.forEach(e),fa.forEach(e),Es.forEach(e),_a=d(n),St=r(n,"P",{});var re=o(St);cf=f(re,"We benchmarked the impact of using "),Tl=r(re,"CODE",{});var O3=o(Tl);pf=f(O3,"tomesd"),O3.forEach(e),Tf=f(re," on "),Ie=r(re,"A",{href:!0});var y3=o(Ie);Ef=f(y3,"StableDiffusionPipeline"),y3.forEach(e),uf=f(re," along with "),me=r(re,"A",{href:!0,rel:!0});var k3=o(me);vf=f(k3,"xformers"),k3.forEach(e),_f=f(re," across different image resolutions. We used A100 and V100 as our test GPU devices with the following development environment (with Python 3.8.5):"),re.forEach(e),Da=d(n),ae(Me.$$.fragment,n),ma=d(n),Xt=r(n,"P",{});var us=o(Xt);Df=f(us,"We used this script for benchmarking: "),be=r(us,"A",{href:!0,rel:!0});var P3=o(be);mf=f(P3,"https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),P3.forEach(e),Mf=f(us,". Following are our findings:"),us.forEach(e),Ma=d(n),Gt=r(n,"H3",{class:!0});var vs=o(Gt);zt=r(vs,"A",{id:!0,class:!0,href:!0});var A3=o(zt);El=r(A3,"SPAN",{});var S3=o(El);ae(we.$$.fragment,S3),S3.forEach(e),A3.forEach(e),bf=d(vs),ul=r(vs,"SPAN",{});var $3=o(ul);wf=f($3,"A100"),$3.forEach(e),vs.forEach(e),ba=d(n),Qt=r(n,"TABLE",{});var _s=o(Qt);vl=r(_s,"THEAD",{});var J3=o(vl);_=r(J3,"TR",{});var Q=o(_);_l=r(Q,"TH",{});var x3=o(_l);gf=f(x3,"Resolution"),x3.forEach(e),Of=d(Q),Dl=r(Q,"TH",{});var B3=o(Dl);yf=f(B3,"Batch size"),B3.forEach(e),kf=d(Q),ml=r(Q,"TH",{});var R3=o(ml);Pf=f(R3,"Vanilla"),R3.forEach(e),Af=d(Q),Ml=r(Q,"TH",{});var U3=o(Ml);Sf=f(U3,"ToMe"),U3.forEach(e),$f=d(Q),bl=r(Q,"TH",{});var I3=o(bl);Jf=f(I3,"ToMe + xFormers"),I3.forEach(e),xf=d(Q),wl=r(Q,"TH",{});var Z3=o(wl);Bf=f(Z3,"ToMe speedup (%)"),Z3.forEach(e),Rf=d(Q),gl=r(Q,"TH",{});var H3=o(gl);Uf=f(H3,"ToMe + xFormers speedup (%)"),H3.forEach(e),Q.forEach(e),J3.forEach(e),If=d(_s),E=r(_s,"TBODY",{});var u=o(E);D=r(u,"TR",{});var K=o(D);Ol=r(K,"TD",{});var N3=o(Ol);Zf=f(N3,"512"),N3.forEach(e),Hf=d(K),yl=r(K,"TD",{});var V3=o(yl);Nf=f(V3,"10"),V3.forEach(e),Vf=d(K),kl=r(K,"TD",{});var G3=o(kl);Gf=f(G3,"6.88"),G3.forEach(e),Cf=d(K),Pl=r(K,"TD",{});var C3=o(Pl);Ff=f(C3,"5.26"),C3.forEach(e),Wf=d(K),Al=r(K,"TD",{});var F3=o(Al);jf=f(F3,"4.69"),F3.forEach(e),qf=d(K),Sl=r(K,"TD",{});var W3=o(Sl);Lf=f(W3,"23.54651163"),W3.forEach(e),Yf=d(K),$l=r(K,"TD",{});var j3=o($l);Xf=f(j3,"31.83139535"),j3.forEach(e),K.forEach(e),zf=d(u),m=r(u,"TR",{});var tt=o(m);wa=r(tt,"TD",{}),o(wa).forEach(e),Qf=d(tt),ga=r(tt,"TD",{}),o(ga).forEach(e),Kf=d(tt),Oa=r(tt,"TD",{}),o(Oa).forEach(e),t1=d(tt),ya=r(tt,"TD",{}),o(ya).forEach(e),e1=d(tt),ka=r(tt,"TD",{}),o(ka).forEach(e),l1=d(tt),Pa=r(tt,"TD",{}),o(Pa).forEach(e),r1=d(tt),Aa=r(tt,"TD",{}),o(Aa).forEach(e),tt.forEach(e),o1=d(u),M=r(u,"TR",{});var et=o(M);Jl=r(et,"TD",{});var q3=o(Jl);a1=f(q3,"768"),q3.forEach(e),d1=d(et),xl=r(et,"TD",{});var L3=o(xl);s1=f(L3,"10"),L3.forEach(e),f1=d(et),Bl=r(et,"TD",{});var Y3=o(Bl);n1=f(Y3,"OOM"),Y3.forEach(e),i1=d(et),Rl=r(et,"TD",{});var X3=o(Rl);h1=f(X3,"14.71"),X3.forEach(e),c1=d(et),Ul=r(et,"TD",{});var z3=o(Ul);p1=f(z3,"11"),z3.forEach(e),T1=d(et),Sa=r(et,"TD",{}),o(Sa).forEach(e),E1=d(et),$a=r(et,"TD",{}),o($a).forEach(e),et.forEach(e),u1=d(u),b=r(u,"TR",{});var lt=o(b);Ja=r(lt,"TD",{}),o(Ja).forEach(e),v1=d(lt),Il=r(lt,"TD",{});var Q3=o(Il);_1=f(Q3,"8"),Q3.forEach(e),D1=d(lt),Zl=r(lt,"TD",{});var K3=o(Zl);m1=f(K3,"OOM"),K3.forEach(e),M1=d(lt),Hl=r(lt,"TD",{});var tT=o(Hl);b1=f(tT,"11.56"),tT.forEach(e),w1=d(lt),Nl=r(lt,"TD",{});var eT=o(Nl);g1=f(eT,"8.84"),eT.forEach(e),O1=d(lt),xa=r(lt,"TD",{}),o(xa).forEach(e),y1=d(lt),Ba=r(lt,"TD",{}),o(Ba).forEach(e),lt.forEach(e),k1=d(u),w=r(u,"TR",{});var rt=o(w);Ra=r(rt,"TD",{}),o(Ra).forEach(e),P1=d(rt),Vl=r(rt,"TD",{});var lT=o(Vl);A1=f(lT,"4"),lT.forEach(e),S1=d(rt),Gl=r(rt,"TD",{});var rT=o(Gl);$1=f(rT,"OOM"),rT.forEach(e),J1=d(rt),Cl=r(rt,"TD",{});var oT=o(Cl);x1=f(oT,"5.98"),oT.forEach(e),B1=d(rt),Fl=r(rt,"TD",{});var aT=o(Fl);R1=f(aT,"4.66"),aT.forEach(e),U1=d(rt),Ua=r(rt,"TD",{}),o(Ua).forEach(e),I1=d(rt),Ia=r(rt,"TD",{}),o(Ia).forEach(e),rt.forEach(e),Z1=d(u),g=r(u,"TR",{});var ot=o(g);Za=r(ot,"TD",{}),o(Za).forEach(e),H1=d(ot),Wl=r(ot,"TD",{});var dT=o(Wl);N1=f(dT,"2"),dT.forEach(e),V1=d(ot),jl=r(ot,"TD",{});var sT=o(jl);G1=f(sT,"4.99"),sT.forEach(e),C1=d(ot),ql=r(ot,"TD",{});var fT=o(ql);F1=f(fT,"3.24"),fT.forEach(e),W1=d(ot),Ll=r(ot,"TD",{});var nT=o(Ll);j1=f(nT,"3.1"),nT.forEach(e),q1=d(ot),Yl=r(ot,"TD",{});var iT=o(Yl);L1=f(iT,"35.07014028"),iT.forEach(e),Y1=d(ot),Xl=r(ot,"TD",{});var hT=o(Xl);X1=f(hT,"37.8757515"),hT.forEach(e),ot.forEach(e),z1=d(u),O=r(u,"TR",{});var at=o(O);Ha=r(at,"TD",{}),o(Ha).forEach(e),Q1=d(at),zl=r(at,"TD",{});var cT=o(zl);K1=f(cT,"1"),cT.forEach(e),tn=d(at),Ql=r(at,"TD",{});var pT=o(Ql);en=f(pT,"3.29"),pT.forEach(e),ln=d(at),Kl=r(at,"TD",{});var TT=o(Kl);rn=f(TT,"2.24"),TT.forEach(e),on=d(at),tr=r(at,"TD",{});var ET=o(tr);an=f(ET,"2.03"),ET.forEach(e),dn=d(at),er=r(at,"TD",{});var uT=o(er);sn=f(uT,"31.91489362"),uT.forEach(e),fn=d(at),lr=r(at,"TD",{});var vT=o(lr);nn=f(vT,"38.29787234"),vT.forEach(e),at.forEach(e),hn=d(u),y=r(u,"TR",{});var dt=o(y);Na=r(dt,"TD",{}),o(Na).forEach(e),cn=d(dt),Va=r(dt,"TD",{}),o(Va).forEach(e),pn=d(dt),Ga=r(dt,"TD",{}),o(Ga).forEach(e),Tn=d(dt),Ca=r(dt,"TD",{}),o(Ca).forEach(e),En=d(dt),Fa=r(dt,"TD",{}),o(Fa).forEach(e),un=d(dt),Wa=r(dt,"TD",{}),o(Wa).forEach(e),vn=d(dt),ja=r(dt,"TD",{}),o(ja).forEach(e),dt.forEach(e),_n=d(u),k=r(u,"TR",{});var st=o(k);rr=r(st,"TD",{});var _T=o(rr);Dn=f(_T,"1024"),_T.forEach(e),mn=d(st),or=r(st,"TD",{});var DT=o(or);Mn=f(DT,"10"),DT.forEach(e),bn=d(st),ar=r(st,"TD",{});var mT=o(ar);wn=f(mT,"OOM"),mT.forEach(e),gn=d(st),dr=r(st,"TD",{});var MT=o(dr);On=f(MT,"OOM"),MT.forEach(e),yn=d(st),sr=r(st,"TD",{});var bT=o(sr);kn=f(bT,"OOM"),bT.forEach(e),Pn=d(st),qa=r(st,"TD",{}),o(qa).forEach(e),An=d(st),La=r(st,"TD",{}),o(La).forEach(e),st.forEach(e),Sn=d(u),P=r(u,"TR",{});var ft=o(P);Ya=r(ft,"TD",{}),o(Ya).forEach(e),$n=d(ft),fr=r(ft,"TD",{});var wT=o(fr);Jn=f(wT,"8"),wT.forEach(e),xn=d(ft),nr=r(ft,"TD",{});var gT=o(nr);Bn=f(gT,"OOM"),gT.forEach(e),Rn=d(ft),ir=r(ft,"TD",{});var OT=o(ir);Un=f(OT,"OOM"),OT.forEach(e),In=d(ft),hr=r(ft,"TD",{});var yT=o(hr);Zn=f(yT,"OOM"),yT.forEach(e),Hn=d(ft),Xa=r(ft,"TD",{}),o(Xa).forEach(e),Nn=d(ft),za=r(ft,"TD",{}),o(za).forEach(e),ft.forEach(e),Vn=d(u),A=r(u,"TR",{});var nt=o(A);Qa=r(nt,"TD",{}),o(Qa).forEach(e),Gn=d(nt),cr=r(nt,"TD",{});var kT=o(cr);Cn=f(kT,"4"),kT.forEach(e),Fn=d(nt),pr=r(nt,"TD",{});var PT=o(pr);Wn=f(PT,"OOM"),PT.forEach(e),jn=d(nt),Tr=r(nt,"TD",{});var AT=o(Tr);qn=f(AT,"12.51"),AT.forEach(e),Ln=d(nt),Er=r(nt,"TD",{});var ST=o(Er);Yn=f(ST,"9.09"),ST.forEach(e),Xn=d(nt),Ka=r(nt,"TD",{}),o(Ka).forEach(e),zn=d(nt),td=r(nt,"TD",{}),o(td).forEach(e),nt.forEach(e),Qn=d(u),S=r(u,"TR",{});var it=o(S);ed=r(it,"TD",{}),o(ed).forEach(e),Kn=d(it),ur=r(it,"TD",{});var $T=o(ur);ti=f($T,"2"),$T.forEach(e),ei=d(it),vr=r(it,"TD",{});var JT=o(vr);li=f(JT,"OOM"),JT.forEach(e),ri=d(it),_r=r(it,"TD",{});var xT=o(_r);oi=f(xT,"6.52"),xT.forEach(e),ai=d(it),Dr=r(it,"TD",{});var BT=o(Dr);di=f(BT,"4.96"),BT.forEach(e),si=d(it),ld=r(it,"TD",{}),o(ld).forEach(e),fi=d(it),rd=r(it,"TD",{}),o(rd).forEach(e),it.forEach(e),ni=d(u),$=r(u,"TR",{});var ht=o($);od=r(ht,"TD",{}),o(od).forEach(e),ii=d(ht),mr=r(ht,"TD",{});var RT=o(mr);hi=f(RT,"1"),RT.forEach(e),ci=d(ht),Mr=r(ht,"TD",{});var UT=o(Mr);pi=f(UT,"6.4"),UT.forEach(e),Ti=d(ht),br=r(ht,"TD",{});var IT=o(br);Ei=f(IT,"3.61"),IT.forEach(e),ui=d(ht),wr=r(ht,"TD",{});var ZT=o(wr);vi=f(ZT,"2.81"),ZT.forEach(e),_i=d(ht),gr=r(ht,"TD",{});var HT=o(gr);Di=f(HT,"43.59375"),HT.forEach(e),mi=d(ht),Or=r(ht,"TD",{});var NT=o(Or);Mi=f(NT,"56.09375"),NT.forEach(e),ht.forEach(e),u.forEach(e),_s.forEach(e),ad=d(n),Ze=r(n,"P",{});var VT=o(Ze);yr=r(VT,"STRONG",{});var GT=o(yr);ge=r(GT,"EM",{});var Ds=o(ge);bi=f(Ds,"The timings reported here are in seconds. Speedups are calculated over the "),kr=r(Ds,"CODE",{});var CT=o(kr);wi=f(CT,"Vanilla"),CT.forEach(e),gi=f(Ds," timings."),Ds.forEach(e),GT.forEach(e),VT.forEach(e),dd=d(n),Ct=r(n,"H3",{class:!0});var ms=o(Ct);Kt=r(ms,"A",{id:!0,class:!0,href:!0});var FT=o(Kt);Pr=r(FT,"SPAN",{});var WT=o(Pr);ae(Oe.$$.fragment,WT),WT.forEach(e),FT.forEach(e),Oi=d(ms),Ar=r(ms,"SPAN",{});var jT=o(Ar);yi=f(jT,"V100"),jT.forEach(e),ms.forEach(e),sd=d(n),te=r(n,"TABLE",{});var Ms=o(te);Sr=r(Ms,"THEAD",{});var qT=o(Sr);J=r(qT,"TR",{});var ct=o(J);$r=r(ct,"TH",{});var LT=o($r);ki=f(LT,"Resolution"),LT.forEach(e),Pi=d(ct),Jr=r(ct,"TH",{});var YT=o(Jr);Ai=f(YT,"Batch size"),YT.forEach(e),Si=d(ct),xr=r(ct,"TH",{});var XT=o(xr);$i=f(XT,"Vanilla"),XT.forEach(e),Ji=d(ct),Br=r(ct,"TH",{});var zT=o(Br);xi=f(zT,"ToMe"),zT.forEach(e),Bi=d(ct),Rr=r(ct,"TH",{});var QT=o(Rr);Ri=f(QT,"ToMe + xFormers"),QT.forEach(e),Ui=d(ct),Ur=r(ct,"TH",{});var KT=o(Ur);Ii=f(KT,"ToMe speedup (%)"),KT.forEach(e),Zi=d(ct),Ir=r(ct,"TH",{});var tE=o(Ir);Hi=f(tE,"ToMe + xFormers speedup (%)"),tE.forEach(e),ct.forEach(e),qT.forEach(e),Ni=d(Ms),p=r(Ms,"TBODY",{});var T=o(p);x=r(T,"TR",{});var pt=o(x);Zr=r(pt,"TD",{});var eE=o(Zr);Vi=f(eE,"512"),eE.forEach(e),Gi=d(pt),Hr=r(pt,"TD",{});var lE=o(Hr);Ci=f(lE,"10"),lE.forEach(e),Fi=d(pt),Nr=r(pt,"TD",{});var rE=o(Nr);Wi=f(rE,"OOM"),rE.forEach(e),ji=d(pt),Vr=r(pt,"TD",{});var oE=o(Vr);qi=f(oE,"10.03"),oE.forEach(e),Li=d(pt),Gr=r(pt,"TD",{});var aE=o(Gr);Yi=f(aE,"9.29"),aE.forEach(e),Xi=d(pt),fd=r(pt,"TD",{}),o(fd).forEach(e),zi=d(pt),nd=r(pt,"TD",{}),o(nd).forEach(e),pt.forEach(e),Qi=d(T),B=r(T,"TR",{});var Tt=o(B);id=r(Tt,"TD",{}),o(id).forEach(e),Ki=d(Tt),Cr=r(Tt,"TD",{});var dE=o(Cr);th=f(dE,"8"),dE.forEach(e),eh=d(Tt),Fr=r(Tt,"TD",{});var sE=o(Fr);lh=f(sE,"OOM"),sE.forEach(e),rh=d(Tt),Wr=r(Tt,"TD",{});var fE=o(Wr);oh=f(fE,"8.05"),fE.forEach(e),ah=d(Tt),jr=r(Tt,"TD",{});var nE=o(jr);dh=f(nE,"7.47"),nE.forEach(e),sh=d(Tt),hd=r(Tt,"TD",{}),o(hd).forEach(e),fh=d(Tt),cd=r(Tt,"TD",{}),o(cd).forEach(e),Tt.forEach(e),nh=d(T),R=r(T,"TR",{});var Et=o(R);pd=r(Et,"TD",{}),o(pd).forEach(e),ih=d(Et),qr=r(Et,"TD",{});var iE=o(qr);hh=f(iE,"4"),iE.forEach(e),ch=d(Et),Lr=r(Et,"TD",{});var hE=o(Lr);ph=f(hE,"5.7"),hE.forEach(e),Th=d(Et),Yr=r(Et,"TD",{});var cE=o(Yr);Eh=f(cE,"4.3"),cE.forEach(e),uh=d(Et),Xr=r(Et,"TD",{});var pE=o(Xr);vh=f(pE,"3.98"),pE.forEach(e),_h=d(Et),zr=r(Et,"TD",{});var TE=o(zr);Dh=f(TE,"24.56140351"),TE.forEach(e),mh=d(Et),Qr=r(Et,"TD",{});var EE=o(Qr);Mh=f(EE,"30.1754386"),EE.forEach(e),Et.forEach(e),bh=d(T),U=r(T,"TR",{});var ut=o(U);Td=r(ut,"TD",{}),o(Td).forEach(e),wh=d(ut),Kr=r(ut,"TD",{});var uE=o(Kr);gh=f(uE,"2"),uE.forEach(e),Oh=d(ut),to=r(ut,"TD",{});var vE=o(to);yh=f(vE,"3.14"),vE.forEach(e),kh=d(ut),eo=r(ut,"TD",{});var _E=o(eo);Ph=f(_E,"2.43"),_E.forEach(e),Ah=d(ut),lo=r(ut,"TD",{});var DE=o(lo);Sh=f(DE,"2.27"),DE.forEach(e),$h=d(ut),ro=r(ut,"TD",{});var mE=o(ro);Jh=f(mE,"22.61146497"),mE.forEach(e),xh=d(ut),oo=r(ut,"TD",{});var ME=o(oo);Bh=f(ME,"27.70700637"),ME.forEach(e),ut.forEach(e),Rh=d(T),I=r(T,"TR",{});var vt=o(I);Ed=r(vt,"TD",{}),o(Ed).forEach(e),Uh=d(vt),ao=r(vt,"TD",{});var bE=o(ao);Ih=f(bE,"1"),bE.forEach(e),Zh=d(vt),so=r(vt,"TD",{});var wE=o(so);Hh=f(wE,"1.88"),wE.forEach(e),Nh=d(vt),fo=r(vt,"TD",{});var gE=o(fo);Vh=f(gE,"1.57"),gE.forEach(e),Gh=d(vt),no=r(vt,"TD",{});var OE=o(no);Ch=f(OE,"1.57"),OE.forEach(e),Fh=d(vt),io=r(vt,"TD",{});var yE=o(io);Wh=f(yE,"16.4893617"),yE.forEach(e),jh=d(vt),ho=r(vt,"TD",{});var kE=o(ho);qh=f(kE,"16.4893617"),kE.forEach(e),vt.forEach(e),Lh=d(T),Z=r(T,"TR",{});var _t=o(Z);ud=r(_t,"TD",{}),o(ud).forEach(e),Yh=d(_t),vd=r(_t,"TD",{}),o(vd).forEach(e),Xh=d(_t),_d=r(_t,"TD",{}),o(_d).forEach(e),zh=d(_t),Dd=r(_t,"TD",{}),o(Dd).forEach(e),Qh=d(_t),md=r(_t,"TD",{}),o(md).forEach(e),Kh=d(_t),Md=r(_t,"TD",{}),o(Md).forEach(e),tc=d(_t),bd=r(_t,"TD",{}),o(bd).forEach(e),_t.forEach(e),ec=d(T),H=r(T,"TR",{});var Dt=o(H);co=r(Dt,"TD",{});var PE=o(co);lc=f(PE,"768"),PE.forEach(e),rc=d(Dt),po=r(Dt,"TD",{});var AE=o(po);oc=f(AE,"10"),AE.forEach(e),ac=d(Dt),To=r(Dt,"TD",{});var SE=o(To);dc=f(SE,"OOM"),SE.forEach(e),sc=d(Dt),Eo=r(Dt,"TD",{});var $E=o(Eo);fc=f($E,"OOM"),$E.forEach(e),nc=d(Dt),uo=r(Dt,"TD",{});var JE=o(uo);ic=f(JE,"23.67"),JE.forEach(e),hc=d(Dt),wd=r(Dt,"TD",{}),o(wd).forEach(e),cc=d(Dt),gd=r(Dt,"TD",{}),o(gd).forEach(e),Dt.forEach(e),pc=d(T),N=r(T,"TR",{});var mt=o(N);Od=r(mt,"TD",{}),o(Od).forEach(e),Tc=d(mt),vo=r(mt,"TD",{});var xE=o(vo);Ec=f(xE,"8"),xE.forEach(e),uc=d(mt),_o=r(mt,"TD",{});var BE=o(_o);vc=f(BE,"OOM"),BE.forEach(e),_c=d(mt),Do=r(mt,"TD",{});var RE=o(Do);Dc=f(RE,"OOM"),RE.forEach(e),mc=d(mt),mo=r(mt,"TD",{});var UE=o(mo);Mc=f(UE,"18.81"),UE.forEach(e),bc=d(mt),yd=r(mt,"TD",{}),o(yd).forEach(e),wc=d(mt),kd=r(mt,"TD",{}),o(kd).forEach(e),mt.forEach(e),gc=d(T),V=r(T,"TR",{});var Mt=o(V);Pd=r(Mt,"TD",{}),o(Pd).forEach(e),Oc=d(Mt),Mo=r(Mt,"TD",{});var IE=o(Mo);yc=f(IE,"4"),IE.forEach(e),kc=d(Mt),bo=r(Mt,"TD",{});var ZE=o(bo);Pc=f(ZE,"OOM"),ZE.forEach(e),Ac=d(Mt),wo=r(Mt,"TD",{});var HE=o(wo);Sc=f(HE,"11.81"),HE.forEach(e),$c=d(Mt),go=r(Mt,"TD",{});var NE=o(go);Jc=f(NE,"9.7"),NE.forEach(e),xc=d(Mt),Ad=r(Mt,"TD",{}),o(Ad).forEach(e),Bc=d(Mt),Sd=r(Mt,"TD",{}),o(Sd).forEach(e),Mt.forEach(e),Rc=d(T),G=r(T,"TR",{});var bt=o(G);$d=r(bt,"TD",{}),o($d).forEach(e),Uc=d(bt),Oo=r(bt,"TD",{});var VE=o(Oo);Ic=f(VE,"2"),VE.forEach(e),Zc=d(bt),yo=r(bt,"TD",{});var GE=o(yo);Hc=f(GE,"OOM"),GE.forEach(e),Nc=d(bt),ko=r(bt,"TD",{});var CE=o(ko);Vc=f(CE,"6.27"),CE.forEach(e),Gc=d(bt),Po=r(bt,"TD",{});var FE=o(Po);Cc=f(FE,"5.2"),FE.forEach(e),Fc=d(bt),Jd=r(bt,"TD",{}),o(Jd).forEach(e),Wc=d(bt),xd=r(bt,"TD",{}),o(xd).forEach(e),bt.forEach(e),jc=d(T),C=r(T,"TR",{});var wt=o(C);Bd=r(wt,"TD",{}),o(Bd).forEach(e),qc=d(wt),Ao=r(wt,"TD",{});var WE=o(Ao);Lc=f(WE,"1"),WE.forEach(e),Yc=d(wt),So=r(wt,"TD",{});var jE=o(So);Xc=f(jE,"5.43"),jE.forEach(e),zc=d(wt),$o=r(wt,"TD",{});var qE=o($o);Qc=f(qE,"3.38"),qE.forEach(e),Kc=d(wt),Jo=r(wt,"TD",{});var LE=o(Jo);t2=f(LE,"2.82"),LE.forEach(e),e2=d(wt),xo=r(wt,"TD",{});var YE=o(xo);l2=f(YE,"37.75322284"),YE.forEach(e),r2=d(wt),Bo=r(wt,"TD",{});var XE=o(Bo);o2=f(XE,"48.06629834"),XE.forEach(e),wt.forEach(e),a2=d(T),F=r(T,"TR",{});var gt=o(F);Rd=r(gt,"TD",{}),o(Rd).forEach(e),d2=d(gt),Ud=r(gt,"TD",{}),o(Ud).forEach(e),s2=d(gt),Id=r(gt,"TD",{}),o(Id).forEach(e),f2=d(gt),Zd=r(gt,"TD",{}),o(Zd).forEach(e),n2=d(gt),Hd=r(gt,"TD",{}),o(Hd).forEach(e),i2=d(gt),Nd=r(gt,"TD",{}),o(Nd).forEach(e),h2=d(gt),Vd=r(gt,"TD",{}),o(Vd).forEach(e),gt.forEach(e),c2=d(T),W=r(T,"TR",{});var Ot=o(W);Ro=r(Ot,"TD",{});var zE=o(Ro);p2=f(zE,"1024"),zE.forEach(e),T2=d(Ot),Uo=r(Ot,"TD",{});var QE=o(Uo);E2=f(QE,"10"),QE.forEach(e),u2=d(Ot),Io=r(Ot,"TD",{});var KE=o(Io);v2=f(KE,"OOM"),KE.forEach(e),_2=d(Ot),Zo=r(Ot,"TD",{});var tu=o(Zo);D2=f(tu,"OOM"),tu.forEach(e),m2=d(Ot),Ho=r(Ot,"TD",{});var eu=o(Ho);M2=f(eu,"OOM"),eu.forEach(e),b2=d(Ot),Gd=r(Ot,"TD",{}),o(Gd).forEach(e),w2=d(Ot),Cd=r(Ot,"TD",{}),o(Cd).forEach(e),Ot.forEach(e),g2=d(T),j=r(T,"TR",{});var yt=o(j);Fd=r(yt,"TD",{}),o(Fd).forEach(e),O2=d(yt),No=r(yt,"TD",{});var lu=o(No);y2=f(lu,"8"),lu.forEach(e),k2=d(yt),Vo=r(yt,"TD",{});var ru=o(Vo);P2=f(ru,"OOM"),ru.forEach(e),A2=d(yt),Go=r(yt,"TD",{});var ou=o(Go);S2=f(ou,"OOM"),ou.forEach(e),$2=d(yt),Co=r(yt,"TD",{});var au=o(Co);J2=f(au,"OOM"),au.forEach(e),x2=d(yt),Wd=r(yt,"TD",{}),o(Wd).forEach(e),B2=d(yt),jd=r(yt,"TD",{}),o(jd).forEach(e),yt.forEach(e),R2=d(T),q=r(T,"TR",{});var kt=o(q);qd=r(kt,"TD",{}),o(qd).forEach(e),U2=d(kt),Fo=r(kt,"TD",{});var du=o(Fo);I2=f(du,"4"),du.forEach(e),Z2=d(kt),Wo=r(kt,"TD",{});var su=o(Wo);H2=f(su,"OOM"),su.forEach(e),N2=d(kt),jo=r(kt,"TD",{});var fu=o(jo);V2=f(fu,"OOM"),fu.forEach(e),G2=d(kt),qo=r(kt,"TD",{});var nu=o(qo);C2=f(nu,"19.35"),nu.forEach(e),F2=d(kt),Ld=r(kt,"TD",{}),o(Ld).forEach(e),W2=d(kt),Yd=r(kt,"TD",{}),o(Yd).forEach(e),kt.forEach(e),j2=d(T),L=r(T,"TR",{});var Pt=o(L);Xd=r(Pt,"TD",{}),o(Xd).forEach(e),q2=d(Pt),Lo=r(Pt,"TD",{});var iu=o(Lo);L2=f(iu,"2"),iu.forEach(e),Y2=d(Pt),Yo=r(Pt,"TD",{});var hu=o(Yo);X2=f(hu,"OOM"),hu.forEach(e),z2=d(Pt),Xo=r(Pt,"TD",{});var cu=o(Xo);Q2=f(cu,"13"),cu.forEach(e),K2=d(Pt),zo=r(Pt,"TD",{});var pu=o(zo);tp=f(pu,"10.78"),pu.forEach(e),ep=d(Pt),zd=r(Pt,"TD",{}),o(zd).forEach(e),lp=d(Pt),Qd=r(Pt,"TD",{}),o(Qd).forEach(e),Pt.forEach(e),rp=d(T),Y=r(T,"TR",{});var At=o(Y);Kd=r(At,"TD",{}),o(Kd).forEach(e),op=d(At),Qo=r(At,"TD",{});var Tu=o(Qo);ap=f(Tu,"1"),Tu.forEach(e),dp=d(At),Ko=r(At,"TD",{});var Eu=o(Ko);sp=f(Eu,"OOM"),Eu.forEach(e),fp=d(At),ta=r(At,"TD",{});var uu=o(ta);np=f(uu,"6.66"),uu.forEach(e),ip=d(At),ea=r(At,"TD",{});var vu=o(ea);hp=f(vu,"5.54"),vu.forEach(e),cp=d(At),ts=r(At,"TD",{}),o(ts).forEach(e),pp=d(At),es=r(At,"TD",{}),o(es).forEach(e),At.forEach(e),T.forEach(e),Ms.forEach(e),ls=d(n),Jt=r(n,"P",{});var Xe=o(Jt);Tp=f(Xe,"As seen in the tables above, the speedup with "),la=r(Xe,"CODE",{});var _u=o(la);Ep=f(_u,"tomesd"),_u.forEach(e),up=f(Xe," becomes more pronounced for larger image resolutions. It is also interesting to note that with "),ra=r(Xe,"CODE",{});var Du=o(ra);vp=f(Du,"tomesd"),Du.forEach(e),_p=f(Xe,", it becomes possible to run the pipeline on a higher resolution, like 1024x1024."),Xe.forEach(e),rs=d(n),ee=r(n,"P",{});var bs=o(ee);Dp=f(bs,"It might be possible to speed up inference even further with "),ye=r(bs,"A",{href:!0,rel:!0});var mu=o(ye);oa=r(mu,"CODE",{});var Mu=o(oa);mp=f(Mu,"torch.compile()"),Mu.forEach(e),mu.forEach(e),Mp=f(bs,"."),bs.forEach(e),os=d(n),Ft=r(n,"H2",{class:!0});var ws=o(Ft);le=r(ws,"A",{id:!0,class:!0,href:!0});var bu=o(le);aa=r(bu,"SPAN",{});var wu=o(aa);ae(ke.$$.fragment,wu),wu.forEach(e),bu.forEach(e),bp=d(ws),da=r(ws,"SPAN",{});var gu=o(da);wp=f(gu,"Quality"),gu.forEach(e),ws.forEach(e),as=d(n),xt=r(n,"P",{});var ze=o(xt);gp=f(ze,"As reported in "),Pe=r(ze,"A",{href:!0,rel:!0});var Ou=o(Pe);Op=f(Ou,"the paper"),Ou.forEach(e),yp=f(ze,", ToMe can preserve the quality of the generated images to a great extent while speeding up inference. By increasing the "),sa=r(ze,"CODE",{});var yu=o(sa);kp=f(yu,"ratio"),yu.forEach(e),Pp=f(ze,", it is possible to further speed up inference, but that might come at the cost of a deterioration in the image quality."),ze.forEach(e),ds=d(n),Bt=r(n,"P",{});var Qe=o(Bt);Ap=f(Qe,"To test the quality of the generated samples using our setup, we sampled a few prompts from the \u201CParti Prompts\u201D (introduced in "),Ae=r(Qe,"A",{href:!0,rel:!0});var ku=o(Ae);Sp=f(ku,"Parti"),ku.forEach(e),$p=f(Qe,") and performed inference with the "),He=r(Qe,"A",{href:!0});var Pu=o(He);Jp=f(Pu,"StableDiffusionPipeline"),Pu.forEach(e),xp=f(Qe," in the following settings:"),Qe.forEach(e),ss=d(n),Rt=r(n,"UL",{});var Ke=o(Rt);Ne=r(Ke,"LI",{});var Lp=o(Ne);Bp=f(Lp,"Vanilla "),Ve=r(Lp,"A",{href:!0});var Au=o(Ve);Rp=f(Au,"StableDiffusionPipeline"),Au.forEach(e),Lp.forEach(e),Up=d(Ke),Ge=r(Ke,"LI",{});var Yp=o(Ge);Ce=r(Yp,"A",{href:!0});var Su=o(Ce);Ip=f(Su,"StableDiffusionPipeline"),Su.forEach(e),Zp=f(Yp," + ToMe"),Yp.forEach(e),Hp=d(Ke),Fe=r(Ke,"LI",{});var Xp=o(Fe);We=r(Xp,"A",{href:!0});var $u=o(We);Np=f($u,"StableDiffusionPipeline"),$u.forEach(e),Vp=f(Xp," + ToMe + xformers"),Xp.forEach(e),Ke.forEach(e),fs=d(n),je=r(n,"P",{});var Ju=o(je);Gp=f(Ju,"We didn\u2019t notice any significant decrease in the quality of the generated samples. Here are samples:"),Ju.forEach(e),ns=d(n),qe=r(n,"P",{});var xu=o(qe);Le=r(xu,"IMG",{src:!0,alt:!0}),xu.forEach(e),is=d(n),Ut=r(n,"P",{});var tl=o(Ut);Cp=f(tl,"You can check out the generated samples "),Se=r(tl,"A",{href:!0,rel:!0});var Bu=o(Se);Fp=f(Bu,"here"),Bu.forEach(e),Wp=f(tl,". We used "),$e=r(tl,"A",{href:!0,rel:!0});var Ru=o($e);jp=f(Ru,"this script"),Ru.forEach(e),qp=f(tl," for conducting this experiment."),tl.forEach(e),this.h()},h(){i(Zt,"name","hf:doc:metadata"),i(Zt,"content",JSON.stringify(Wu)),i(Wt,"id","token-merging"),i(Wt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Wt,"href","#token-merging"),i(Ht,"class","relative group"),i(he,"href","https://arxiv.org/abs/2210.09461"),i(he,"rel","nofollow"),i(ce,"href","https://arxiv.org/abs/2303.17604"),i(ce,"rel","nofollow"),i(Je,"href","/docs/diffusers/v0.17.1/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),i(xe,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Be,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(qt,"id","using-tome"),i(qt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(qt,"href","#using-tome"),i(Nt,"class","relative group"),i(Te,"href","https://github.com/dbolya/tomesd"),i(Te,"rel","nofollow"),i(Re,"href","/docs/diffusers/v0.17.1/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),i(ue,"href","https://github.com/dbolya/tomesd#usage"),i(ue,"rel","nofollow"),i(ve,"href","https://github.com/dbolya/tomesd"),i(ve,"rel","nofollow"),i(_e,"href","https://arxiv.org/abs/2303.17604"),i(_e,"rel","nofollow"),i(Lt,"id","benchmarking-tomesd-with-stablediffusionpipeline"),i(Lt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Lt,"href","#benchmarking-tomesd-with-stablediffusionpipeline"),i(Vt,"class","relative group"),i(Ie,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(me,"href","https://huggingface.co/docs/diffusers/optimization/xformers"),i(me,"rel","nofollow"),i(be,"href","https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),i(be,"rel","nofollow"),i(zt,"id","a100"),i(zt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(zt,"href","#a100"),i(Gt,"class","relative group"),i(Kt,"id","v100"),i(Kt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Kt,"href","#v100"),i(Ct,"class","relative group"),i(ye,"href","https://huggingface.co/docs/diffusers/optimization/torch2.0"),i(ye,"rel","nofollow"),i(le,"id","quality"),i(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(le,"href","#quality"),i(Ft,"class","relative group"),i(Pe,"href","https://arxiv.org/abs/2303.17604"),i(Pe,"rel","nofollow"),i(Ae,"href","https://parti.research.google/"),i(Ae,"rel","nofollow"),i(He,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Ve,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Ce,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(We,"href","/docs/diffusers/v0.17.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),Vu(Le.src,Qp="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/tome/tome_samples.png")||i(Le,"src",Qp),i(Le,"alt","tome-samples"),i(Se,"href","https://wandb.ai/sayakpaul/tomesd-results/runs/23j4bj3i?workspace="),i(Se,"rel","nofollow"),i($e,"href","https://gist.github.com/sayakpaul/8cac98d7f22399085a060992f411ecbd"),i($e,"rel","nofollow")},m(n,h){t(document.head,Zt),c(n,na,h),c(n,Ht,h),t(Ht,Wt),t(Wt,ll),de(ie,ll,null),t(Ht,gs),t(Ht,rl),t(rl,Os),c(n,ia,h),c(n,jt,h),t(jt,ys),t(jt,he),t(he,ks),t(jt,Ps),c(n,ha,h),c(n,z,h),t(z,As),t(z,ce),t(ce,Ss),t(z,$s),t(z,Je),t(Je,Js),t(z,xs),t(z,xe),t(xe,Bs),t(z,Rs),t(z,Be),t(Be,Us),t(z,Is),c(n,ca,h),c(n,Nt,h),t(Nt,qt),t(qt,ol),de(pe,ol,null),t(Nt,Zs),t(Nt,al),t(al,Hs),c(n,pa,h),c(n,$t,h),t($t,Ns),t($t,Te),t(Te,dl),t(dl,Vs),t($t,Gs),t($t,Re),t(Re,Cs),t($t,Fs),c(n,Ta,h),de(Ee,n,h),c(n,Ea,h),c(n,Ue,h),t(Ue,Ws),c(n,ua,h),c(n,v,h),t(v,sl),t(sl,js),t(v,qs),t(v,ue),t(ue,Ls),t(v,Ys),t(v,fl),t(fl,Xs),t(v,zs),t(v,nl),t(nl,Qs),t(v,Ks),t(v,il),t(il,tf),t(v,ef),t(v,ve),t(ve,lf),t(v,rf),t(v,_e),t(_e,of),t(v,af),c(n,va,h),c(n,Vt,h),t(Vt,Lt),t(Lt,hl),de(De,hl,null),t(V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t(Y,fp),t(Y,ta),t(ta,np),t(Y,ip),t(Y,ea),t(ea,hp),t(Y,cp),t(Y,ts),t(Y,pp),t(Y,es),c(n,ls,h),c(n,Jt,h),t(Jt,Tp),t(Jt,la),t(la,Ep),t(Jt,up),t(Jt,ra),t(ra,vp),t(Jt,_p),c(n,rs,h),c(n,ee,h),t(ee,Dp),t(ee,ye),t(ye,oa),t(oa,mp),t(ee,Mp),c(n,os,h),c(n,Ft,h),t(Ft,le),t(le,aa),de(ke,aa,null),t(Ft,bp),t(Ft,da),t(da,wp),c(n,as,h),c(n,xt,h),t(xt,gp),t(xt,Pe),t(Pe,Op),t(xt,yp),t(xt,sa),t(sa,kp),t(xt,Pp),c(n,ds,h),c(n,Bt,h),t(Bt,Ap),t(Bt,Ae),t(Ae,Sp),t(Bt,$p),t(Bt,He),t(He,Jp),t(Bt,xp),c(n,ss,h),c(n,Rt,h),t(Rt,Ne),t(Ne,Bp),t(Ne,Ve),t(Ve,Rp),t(Rt,Up),t(Rt,Ge),t(Ge,Ce),t(Ce,Ip),t(Ge,Zp),t(Rt,Hp),t(Rt,Fe),t(Fe,We),t(We,Np),t(Fe,Vp),c(n,fs,h),c(n,je,h),t(je,Gp),c(n,ns,h),c(n,qe,h),t(qe,Le),c(n,is,h),c(n,Ut,h),t(Ut,Cp),t(Ut,Se),t(Se,Fp),t(Ut,Wp),t(Ut,$e),t($e,jp),t(Ut,qp),hs=!0},p:Gu,i(n){hs||(se(ie.$$.fragment,n),se(pe.$$.fragment,n),se(Ee.$$.fragment,n),se(De.$$.fragment,n),se(Me.$$.fragment,n),se(we.$$.fragment,n),se(Oe.$$.fragment,n),se(ke.$$.fragment,n),hs=!0)},o(n){fe(ie.$$.fragment,n),fe(pe.$$.fragment,n),fe(Ee.$$.fragment,n),fe(De.$$.fragment,n),fe(Me.$$.fragment,n),fe(we.$$.fragment,n),fe(Oe.$$.fragment,n),fe(ke.$$.fragment,n),hs=!1},d(n){e(Zt),n&&e(na),n&&e(Ht),ne(ie),n&&e(ia),n&&e(jt),n&&e(ha),n&&e(z),n&&e(ca),n&&e(Nt),ne(pe),n&&e(pa),n&&e($t),n&&e(Ta),ne(Ee,n),n&&e(Ea),n&&e(Ue),n&&e(ua),n&&e(v),n&&e(va),n&&e(Vt),ne(De),n&&e(_a),n&&e(St),n&&e(Da),ne(Me,n),n&&e(ma),n&&e(Xt),n&&e(Ma),n&&e(Gt),ne(we),n&&e(ba),n&&e(Qt),n&&e(ad),n&&e(Ze),n&&e(dd),n&&e(Ct),ne(Oe),n&&e(sd),n&&e(te),n&&e(ls),n&&e(Jt),n&&e(rs),n&&e(ee),n&&e(os),n&&e(Ft),ne(ke),n&&e(as),n&&e(xt),n&&e(ds),n&&e(Bt),n&&e(ss),n&&e(Rt),n&&e(fs),n&&e(je),n&&e(ns),n&&e(qe),n&&e(is),n&&e(Ut)}}}const Wu={local:"token-merging",sections:[{local:"using-tome",title:"Using ToMe"},{local:"benchmarking-tomesd-with-stablediffusionpipeline",sections:[{local:"a100",title:"A100"},{local:"v100",title:"V100"}],title:"Benchmarking `tomesd` with `StableDiffusionPipeline`"},{local:"quality",title:"Quality"}],title:"Token Merging"};function ju(zp){return Cu(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xu extends Iu{constructor(Zt){super();Zu(this,Zt,ju,Fu,Hu,{})}}export{Xu as default,Wu as metadata};
