import{S as Jn,i as On,s as jn,e as r,k as c,w as be,t as s,M as Kn,c as a,d as t,m as u,a as i,x as $e,h,b as l,G as n,g as f,y as Te,L as Qn,q as Ae,o as Ie,B as Ge,v as Vn}from"../chunks/vendor-hf-doc-builder.js";import{I as ke}from"../chunks/IconCopyLink-hf-doc-builder.js";function Yn(nn){let g,Ce,v,E,le,k,tt,se,nt,Le,U,rt,at,it,xe,q,ot,Se,M,lt,qe,_,b,he,C,st,fe,ht,Me,H,ft,He,p,N,z,ct,ut,pt,W,B,dt,mt,gt,F,R,vt,_t,yt,X,D,Pt,wt,Et,J,O,Ut,bt,$t,j,K,Tt,At,It,ce,Q,Gt,Ne,y,$,ue,L,kt,pe,Ct,ze,V,Lt,We,m,de,Y,xt,St,me,Z,qt,Mt,ge,ee,Ht,Nt,ve,te,zt,Be,P,T,_e,x,Wt,ye,Bt,Fe,ne,Ft,Re,A,Pe,re,Rt,Xt,we,ae,Dt,Xe,w,I,Ee,S,Jt,Ue,Ot,De,ie,jt,Je,oe,Kt,Oe;return k=new ke({}),C=new ke({}),L=new ke({}),x=new ke({}),S=new ke({}),{c(){g=r("meta"),Ce=c(),v=r("h1"),E=r("a"),le=r("span"),be(k.$$.fragment),tt=c(),se=r("span"),nt=s("Performance and Scalability"),Le=c(),U=r("p"),rt=s("Training large transformer models and deploying them to production present various challenges."),at=r("br"),it=s(`
During training, the model may require more GPU memory than available or exhibit slow training speed. In the deployment
phase, the model can struggle to handle the required throughput in a production environment.`),xe=c(),q=r("p"),ot=s(`This documentation aims to assist you in overcoming these challenges and finding the optimal setting for your use-case.
The guides are divided into training and inference sections, as each comes with different challenges and solutions.
Within each section you\u2019ll find separate guides for different hardware configurations, such as single GPU vs. multi-GPU
for training or CPU vs. GPU for inference.`),Se=c(),M=r("p"),lt=s("Use this document as your starting point to navigate further to the methods that match your scenario."),qe=c(),_=r("h2"),b=r("a"),he=r("span"),be(C.$$.fragment),st=c(),fe=r("span"),ht=s("Training"),Me=c(),H=r("p"),ft=s(`Training large transformer models efficiently requires an accelerator such as a GPU or TPU. The most common case is where
you have a single GPU. The methods that you can apply to improve training efficiency on a single GPU extend to other setups
such as multiple GPU. However, there are also techniques that are specific to multi-GPU or CPU training. We cover them in
separate sections.`),He=c(),p=r("ul"),N=r("li"),z=r("a"),ct=s("Methods and tools for efficient training on a single GPU"),ut=s(": start here to learn common approaches that can help optimize GPU memory utilization, speed up the training, or both."),pt=c(),W=r("li"),B=r("a"),dt=s("Multi-GPU training section"),mt=s(": explore this section to learn about further optimization methods that apply to a multi-GPU settings, such as data, tensor, and pipeline parallelism."),gt=c(),F=r("li"),R=r("a"),vt=s("CPU training section"),_t=s(": learn about mixed precision training on CPU."),yt=c(),X=r("li"),D=r("a"),Pt=s("Efficient Training on Multiple CPUs"),wt=s(": learn about distributed CPU training."),Et=c(),J=r("li"),O=r("a"),Ut=s("Training on TPU with TensorFlow"),bt=s(": if you are new to TPUs, refer to this section for an opinionated introduction to training on TPUs and using XLA."),$t=c(),j=r("li"),K=r("a"),Tt=s("Custom hardware for training"),At=s(": find tips and tricks when building your own deep learning rig."),It=c(),ce=r("li"),Q=r("a"),Gt=s("Hyperparameter Search using Trainer API"),Ne=c(),y=r("h2"),$=r("a"),ue=r("span"),be(L.$$.fragment),kt=c(),pe=r("span"),Ct=s("Inference"),ze=c(),V=r("p"),Lt=s(`Efficient inference with large models in a production environment can be as challenging as training them. In the following
sections we go through the steps to run inference on CPU and single/multi-GPU setups.`),We=c(),m=r("ul"),de=r("li"),Y=r("a"),xt=s("Inference on a single CPU"),St=c(),me=r("li"),Z=r("a"),qt=s("Inference on a single GPU"),Mt=c(),ge=r("li"),ee=r("a"),Ht=s("Multi-GPU inference"),Nt=c(),ve=r("li"),te=r("a"),zt=s("XLA Integration for TensorFlow Models"),Be=c(),P=r("h2"),T=r("a"),_e=r("span"),be(x.$$.fragment),Wt=c(),ye=r("span"),Bt=s("Training and inference"),Fe=c(),ne=r("p"),Ft=s("Here you\u2019ll find techniques, tips and tricks that apply whether you are training a model, or running inference with it."),Re=c(),A=r("ul"),Pe=r("li"),re=r("a"),Rt=s("Instantiating a big model"),Xt=c(),we=r("li"),ae=r("a"),Dt=s("Troubleshooting performance issues"),Xe=c(),w=r("h2"),I=r("a"),Ee=r("span"),be(S.$$.fragment),Jt=c(),Ue=r("span"),Ot=s("Contribute"),De=c(),ie=r("p"),jt=s(`This document is far from being complete and a lot more needs to be added, so if you have additions or corrections to
make please don\u2019t hesitate to open a PR or if you aren\u2019t sure start an Issue and we can discuss the details there.`),Je=c(),oe=r("p"),Kt=s(`When making contributions that A is better than B, please try to include a reproducible benchmark and/or a link to the
source of that information (unless it comes directly from you).`),this.h()},l(e){const o=Kn('[data-svelte="svelte-1phssyn"]',document.head);g=a(o,"META",{name:!0,content:!0}),o.forEach(t),Ce=u(e),v=a(e,"H1",{class:!0});var je=i(v);E=a(je,"A",{id:!0,class:!0,href:!0});var rn=i(E);le=a(rn,"SPAN",{});var an=i(le);$e(k.$$.fragment,an),an.forEach(t),rn.forEach(t),tt=u(je),se=a(je,"SPAN",{});var on=i(se);nt=h(on,"Performance and Scalability"),on.forEach(t),je.forEach(t),Le=u(e),U=a(e,"P",{});var Ke=i(U);rt=h(Ke,"Training large transformer models and deploying them to production present various challenges."),at=a(Ke,"BR",{}),it=h(Ke,`
During training, the model may require more GPU memory than available or exhibit slow training speed. In the deployment
phase, the model can struggle to handle the required throughput in a production environment.`),Ke.forEach(t),xe=u(e),q=a(e,"P",{});var ln=i(q);ot=h(ln,`This documentation aims to assist you in overcoming these challenges and finding the optimal setting for your use-case.
The guides are divided into training and inference sections, as each comes with different challenges and solutions.
Within each section you\u2019ll find separate guides for different hardware configurations, such as single GPU vs. multi-GPU
for training or CPU vs. GPU for inference.`),ln.forEach(t),Se=u(e),M=a(e,"P",{});var sn=i(M);lt=h(sn,"Use this document as your starting point to navigate further to the methods that match your scenario."),sn.forEach(t),qe=u(e),_=a(e,"H2",{class:!0});var Qe=i(_);b=a(Qe,"A",{id:!0,class:!0,href:!0});var hn=i(b);he=a(hn,"SPAN",{});var fn=i(he);$e(C.$$.fragment,fn),fn.forEach(t),hn.forEach(t),st=u(Qe),fe=a(Qe,"SPAN",{});var cn=i(fe);ht=h(cn,"Training"),cn.forEach(t),Qe.forEach(t),Me=u(e),H=a(e,"P",{});var un=i(H);ft=h(un,`Training large transformer models efficiently requires an accelerator such as a GPU or TPU. The most common case is where
you have a single GPU. The methods that you can apply to improve training efficiency on a single GPU extend to other setups
such as multiple GPU. However, there are also techniques that are specific to multi-GPU or CPU training. We cover them in
separate sections.`),un.forEach(t),He=u(e),p=a(e,"UL",{});var d=i(p);N=a(d,"LI",{});var Qt=i(N);z=a(Qt,"A",{href:!0});var pn=i(z);ct=h(pn,"Methods and tools for efficient training on a single GPU"),pn.forEach(t),ut=h(Qt,": start here to learn common approaches that can help optimize GPU memory utilization, speed up the training, or both."),Qt.forEach(t),pt=u(d),W=a(d,"LI",{});var Vt=i(W);B=a(Vt,"A",{href:!0});var dn=i(B);dt=h(dn,"Multi-GPU training section"),dn.forEach(t),mt=h(Vt,": explore this section to learn about further optimization methods that apply to a multi-GPU settings, such as data, tensor, and pipeline parallelism."),Vt.forEach(t),gt=u(d),F=a(d,"LI",{});var Yt=i(F);R=a(Yt,"A",{href:!0});var mn=i(R);vt=h(mn,"CPU training section"),mn.forEach(t),_t=h(Yt,": learn about mixed precision training on CPU."),Yt.forEach(t),yt=u(d),X=a(d,"LI",{});var Zt=i(X);D=a(Zt,"A",{href:!0});var gn=i(D);Pt=h(gn,"Efficient Training on Multiple CPUs"),gn.forEach(t),wt=h(Zt,": learn about distributed CPU training."),Zt.forEach(t),Et=u(d),J=a(d,"LI",{});var en=i(J);O=a(en,"A",{href:!0});var vn=i(O);Ut=h(vn,"Training on TPU with TensorFlow"),vn.forEach(t),bt=h(en,": if you are new to TPUs, refer to this section for an opinionated introduction to training on TPUs and using XLA."),en.forEach(t),$t=u(d),j=a(d,"LI",{});var tn=i(j);K=a(tn,"A",{href:!0});var _n=i(K);Tt=h(_n,"Custom hardware for training"),_n.forEach(t),At=h(tn,": find tips and tricks when building your own deep learning rig."),tn.forEach(t),It=u(d),ce=a(d,"LI",{});var yn=i(ce);Q=a(yn,"A",{href:!0});var Pn=i(Q);Gt=h(Pn,"Hyperparameter Search using Trainer API"),Pn.forEach(t),yn.forEach(t),d.forEach(t),Ne=u(e),y=a(e,"H2",{class:!0});var Ve=i(y);$=a(Ve,"A",{id:!0,class:!0,href:!0});var wn=i($);ue=a(wn,"SPAN",{});var En=i(ue);$e(L.$$.fragment,En),En.forEach(t),wn.forEach(t),kt=u(Ve),pe=a(Ve,"SPAN",{});var Un=i(pe);Ct=h(Un,"Inference"),Un.forEach(t),Ve.forEach(t),ze=u(e),V=a(e,"P",{});var bn=i(V);Lt=h(bn,`Efficient inference with large models in a production environment can be as challenging as training them. In the following
sections we go through the steps to run inference on CPU and single/multi-GPU setups.`),bn.forEach(t),We=u(e),m=a(e,"UL",{});var G=i(m);de=a(G,"LI",{});var $n=i(de);Y=a($n,"A",{href:!0});var Tn=i(Y);xt=h(Tn,"Inference on a single CPU"),Tn.forEach(t),$n.forEach(t),St=u(G),me=a(G,"LI",{});var An=i(me);Z=a(An,"A",{href:!0});var In=i(Z);qt=h(In,"Inference on a single GPU"),In.forEach(t),An.forEach(t),Mt=u(G),ge=a(G,"LI",{});var Gn=i(ge);ee=a(Gn,"A",{href:!0});var kn=i(ee);Ht=h(kn,"Multi-GPU inference"),kn.forEach(t),Gn.forEach(t),Nt=u(G),ve=a(G,"LI",{});var Cn=i(ve);te=a(Cn,"A",{href:!0});var Ln=i(te);zt=h(Ln,"XLA Integration for TensorFlow Models"),Ln.forEach(t),Cn.forEach(t),G.forEach(t),Be=u(e),P=a(e,"H2",{class:!0});var Ye=i(P);T=a(Ye,"A",{id:!0,class:!0,href:!0});var xn=i(T);_e=a(xn,"SPAN",{});var Sn=i(_e);$e(x.$$.fragment,Sn),Sn.forEach(t),xn.forEach(t),Wt=u(Ye),ye=a(Ye,"SPAN",{});var qn=i(ye);Bt=h(qn,"Training and inference"),qn.forEach(t),Ye.forEach(t),Fe=u(e),ne=a(e,"P",{});var Mn=i(ne);Ft=h(Mn,"Here you\u2019ll find techniques, tips and tricks that apply whether you are training a model, or running inference with it."),Mn.forEach(t),Re=u(e),A=a(e,"UL",{});var Ze=i(A);Pe=a(Ze,"LI",{});var Hn=i(Pe);re=a(Hn,"A",{href:!0});var Nn=i(re);Rt=h(Nn,"Instantiating a big model"),Nn.forEach(t),Hn.forEach(t),Xt=u(Ze),we=a(Ze,"LI",{});var zn=i(we);ae=a(zn,"A",{href:!0});var Wn=i(ae);Dt=h(Wn,"Troubleshooting performance issues"),Wn.forEach(t),zn.forEach(t),Ze.forEach(t),Xe=u(e),w=a(e,"H2",{class:!0});var et=i(w);I=a(et,"A",{id:!0,class:!0,href:!0});var Bn=i(I);Ee=a(Bn,"SPAN",{});var Fn=i(Ee);$e(S.$$.fragment,Fn),Fn.forEach(t),Bn.forEach(t),Jt=u(et),Ue=a(et,"SPAN",{});var Rn=i(Ue);Ot=h(Rn,"Contribute"),Rn.forEach(t),et.forEach(t),De=u(e),ie=a(e,"P",{});var Xn=i(ie);jt=h(Xn,`This document is far from being complete and a lot more needs to be added, so if you have additions or corrections to
make please don\u2019t hesitate to open a PR or if you aren\u2019t sure start an Issue and we can discuss the details there.`),Xn.forEach(t),Je=u(e),oe=a(e,"P",{});var Dn=i(oe);Kt=h(Dn,`When making contributions that A is better than B, please try to include a reproducible benchmark and/or a link to the
source of that information (unless it comes directly from you).`),Dn.forEach(t),this.h()},h(){l(g,"name","hf:doc:metadata"),l(g,"content",JSON.stringify(Zn)),l(E,"id","performance-and-scalability"),l(E,"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"),l(E,"href","#performance-and-scalability"),l(v,"class","relative group"),l(b,"id","training"),l(b,"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"),l(b,"href","#training"),l(_,"class","relative group"),l(z,"href","perf_train_gpu_one"),l(B,"href","perf_train_gpu_many"),l(R,"href","perf_train_cpu"),l(D,"href","perf_train_cpu_many"),l(O,"href","perf_train_tpu_tf"),l(K,"href","perf_hardware"),l(Q,"href","hpo_train"),l($,"id","inference"),l($,"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"),l($,"href","#inference"),l(y,"class","relative group"),l(Y,"href","perf_infer_cpu"),l(Z,"href","perf_infer_gpu_one"),l(ee,"href","perf_infer_gpu_many"),l(te,"href","tf_xla"),l(T,"id","training-and-inference"),l(T,"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"),l(T,"href","#training-and-inference"),l(P,"class","relative group"),l(re,"href","big_models"),l(ae,"href","debugging"),l(I,"id","contribute"),l(I,"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"),l(I,"href","#contribute"),l(w,"class","relative group")},m(e,o){n(document.head,g),f(e,Ce,o),f(e,v,o),n(v,E),n(E,le),Te(k,le,null),n(v,tt),n(v,se),n(se,nt),f(e,Le,o),f(e,U,o),n(U,rt),n(U,at),n(U,it),f(e,xe,o),f(e,q,o),n(q,ot),f(e,Se,o),f(e,M,o),n(M,lt),f(e,qe,o),f(e,_,o),n(_,b),n(b,he),Te(C,he,null),n(_,st),n(_,fe),n(fe,ht),f(e,Me,o),f(e,H,o),n(H,ft),f(e,He,o),f(e,p,o),n(p,N),n(N,z),n(z,ct),n(N,ut),n(p,pt),n(p,W),n(W,B),n(B,dt),n(W,mt),n(p,gt),n(p,F),n(F,R),n(R,vt),n(F,_t),n(p,yt),n(p,X),n(X,D),n(D,Pt),n(X,wt),n(p,Et),n(p,J),n(J,O),n(O,Ut),n(J,bt),n(p,$t),n(p,j),n(j,K),n(K,Tt),n(j,At),n(p,It),n(p,ce),n(ce,Q),n(Q,Gt),f(e,Ne,o),f(e,y,o),n(y,$),n($,ue),Te(L,ue,null),n(y,kt),n(y,pe),n(pe,Ct),f(e,ze,o),f(e,V,o),n(V,Lt),f(e,We,o),f(e,m,o),n(m,de),n(de,Y),n(Y,xt),n(m,St),n(m,me),n(me,Z),n(Z,qt),n(m,Mt),n(m,ge),n(ge,ee),n(ee,Ht),n(m,Nt),n(m,ve),n(ve,te),n(te,zt),f(e,Be,o),f(e,P,o),n(P,T),n(T,_e),Te(x,_e,null),n(P,Wt),n(P,ye),n(ye,Bt),f(e,Fe,o),f(e,ne,o),n(ne,Ft),f(e,Re,o),f(e,A,o),n(A,Pe),n(Pe,re),n(re,Rt),n(A,Xt),n(A,we),n(we,ae),n(ae,Dt),f(e,Xe,o),f(e,w,o),n(w,I),n(I,Ee),Te(S,Ee,null),n(w,Jt),n(w,Ue),n(Ue,Ot),f(e,De,o),f(e,ie,o),n(ie,jt),f(e,Je,o),f(e,oe,o),n(oe,Kt),Oe=!0},p:Qn,i(e){Oe||(Ae(k.$$.fragment,e),Ae(C.$$.fragment,e),Ae(L.$$.fragment,e),Ae(x.$$.fragment,e),Ae(S.$$.fragment,e),Oe=!0)},o(e){Ie(k.$$.fragment,e),Ie(C.$$.fragment,e),Ie(L.$$.fragment,e),Ie(x.$$.fragment,e),Ie(S.$$.fragment,e),Oe=!1},d(e){t(g),e&&t(Ce),e&&t(v),Ge(k),e&&t(Le),e&&t(U),e&&t(xe),e&&t(q),e&&t(Se),e&&t(M),e&&t(qe),e&&t(_),Ge(C),e&&t(Me),e&&t(H),e&&t(He),e&&t(p),e&&t(Ne),e&&t(y),Ge(L),e&&t(ze),e&&t(V),e&&t(We),e&&t(m),e&&t(Be),e&&t(P),Ge(x),e&&t(Fe),e&&t(ne),e&&t(Re),e&&t(A),e&&t(Xe),e&&t(w),Ge(S),e&&t(De),e&&t(ie),e&&t(Je),e&&t(oe)}}}const Zn={local:"performance-and-scalability",sections:[{local:"training",title:"Training"},{local:"inference",title:"Inference"},{local:"training-and-inference",title:"Training and inference"},{local:"contribute",title:"Contribute"}],title:"Performance and Scalability"};function er(nn){return Vn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rr extends Jn{constructor(g){super();On(this,g,er,Yn,jn,{})}}export{rr as default,Zn as metadata};
