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,ml,Wr,GP,UP,Vr,kP,TP,vl,Hr,IP,SP,ce,Xr,Yr,AP,OP,Jr,Kr,MP,$P,ue,Qr,xP,zP,es,NP,RP,ts,ZP,CP,Pl,ls,jP,FP,wl,as,BP,qP,is,WP,eh,Li,os,VP,th,Fe,yl,rs,HP,XP,bl,ss,YP,JP,ns,KP,QP,_l,ps,e1,t1,hs,fs,l1,lh;return Xe=new O({}),Ye=new O({}),Je=new O({}),Ke=new O({}),Qe=new O({}),tt=new Wh({props:{code:`La | Lb | Lc
---|----|---
a0 | b0 | c0
a1 | b1 | c1
a2 | b2 | c2`,highlighted:`La |<span class="hljs-string"> Lb </span>|<span class="hljs-string"> Lc
---</span>|<span class="hljs-string">----</span>|<span class="hljs-string">---
a0 </span>|<span class="hljs-string"> b0 </span>|<span class="hljs-string"> c0
a1 </span>|<span class="hljs-string"> b1 </span>|<span class="hljs-string"> c1
a2 </span>|<span class="hljs-string"> b2 </span>|<span class="hljs-string"> c2</span>`}}),lt=new Wh({props:{code:`GPU0:
La | Lb | Lc
---|----|---
a0 | b0 | c0

GPU1:
La | Lb | Lc
---|----|---
a1 | b1 | c1

GPU2:
La | Lb | Lc
---|----|---
a2 | b2 | c2`,highlighted:`GPU0:
La |<span class="hljs-string"> Lb </span>|<span class="hljs-string"> Lc
---</span>|<span class="hljs-string">----</span>|<span class="hljs-string">---
a0 </span>|<span class="hljs-string"> b0 </span>|<span class="hljs-string"> c0

GPU1:
La </span>|<span class="hljs-string"> Lb </span>|<span class="hljs-string"> Lc
---</span>|<span class="hljs-string">----</span>|<span class="hljs-string">---
a1 </span>|<span class="hljs-string"> b1 </span>|<span class="hljs-string"> c1

GPU2:
La </span>|<span class="hljs-string"> Lb </span>|<span class="hljs-string"> Lc
---</span>|<span class="hljs-string">----</span>|<span class="hljs-string">---
a2 </span>|<span class="hljs-string"> b2 </span>|<span class="hljs-string"> c2</span>`}}),at=new Wh({props:{code:`x0 => GPU0
x1 => GPU1
x2 => GPU2`,highlighted:`<span class="hljs-attribute">x0</span> <span class="hljs-operator">=</span>&gt; GPU0
<span class="hljs-attribute">x1</span> <span class="hljs-operator">=</span>&gt; GPU1
<span class="hljs-attribute">x2</span> <span class="hljs-operator">=</span>&gt; GPU2`}}),st=new O({}),nt=new Wh({props:{code:`===================  ===================
|  0 | 1 | 2 | 3  |  |  4 | 5 | 6 | 7  |
===================  ===================
        gpu0                 gpu1`,highlighted:`===================  ===================
|<span class="hljs-string">  0 </span>|<span class="hljs-string"> 1 </span>|<span class="hljs-string"> 2 </span>|<span class="hljs-string"> 3  </span>|<span class="hljs-string">  </span>|<span class="hljs-string">  4 </span>|<span class="hljs-string"> 5 </span>|<span class="hljs-string"> 6 </span>|<span class="hljs-string"> 7  </span>|
===================  ===================
        gpu0                 gpu1`}}),Et=new O({}),Nt=new O({}),qt=new O({}),Kt=new O({}),al=new O({}),pl=new O({}),{c(){$=a("meta"),El=h(),U=a("h1"),M=a("a"),Zi=a("span"),v(Xe.$$.fragment),Hh=h(),Ci=a("span"),Xh=r("Model Parallelism"),ms=h(),Q=a("h2"),me=a("a"),ji=a("span"),v(Ye.$$.fragment),Yh=h(),Fi=a("span"),Jh=r("Parallelism overview"),vs=h(),gl=a("p"),Kh=r("In the modern machine learning the various approaches to parallelism are used to:"),Ps=h(),ve=a("ol"),Bi=a("li"),Qh=r("fit very large models onto limited hardware - e.g. t5-11b is 45GB in just model params"),ef=h(),qi=a("li"),tf=r("significantly speed up training - finish training that would take a year in hours"),ws=h(),Ll=a("p"),lf=r("We will first discuss in depth various 1D parallelism techniques and their pros and cons and then look at how they can be combined into 2D and 3D parallelism to enable an even faster training and to support even bigger models. Various other powerful alternative approaches will be presented."),ys=h(),Dl=a("p"),af=r("While the main concepts most likely will apply to any other framework, this article is focused on PyTorch-based implementations."),bs=h(),ee=a("h2"),Pe=a("a"),Wi=a("span"),v(Je.$$.fragment),of=h(),Vi=a("span"),rf=r("Concepts"),_s=h(),Gl=a("p"),sf=r("The following is the brief description of the main concepts that will be described later in depth in this document."),Es=h(),E=a("ol"),Hi=a("li"),nf=r("DataParallel (DP) - the same setup is replicated multiple times, and each being fed a slice of the data. The processing is done in parallel and all setups are synchronized at the end of each training step."),pf=h(),Xi=a("li"),hf=r("TensorParallel (TP) - each tensor is split up into multiple chunks, so instead of having the whole tensor reside on a single gpu, each shard of the tensor resides on its designated gpu. During processing each shard gets processed separately and in parallel on different GPUs and the results are synced at the end of the step. This is what one may call horizontal parallelism, as the splitting happens on horizontal level."),ff=h(),Yi=a("li"),df=r("PipelineParallel (PP) - the model is split up vertically (layer-level) across multiple GPUs, so that only one or several layers of the model are places on a single gpu. Each gpu processes in parallel different stages of the pipeline and working on a small chunk of the batch."),cf=h(),Ji=a("li"),uf=r("Zero Redundancy Optimizer (ZeRO) - Also performs sharding of the tensors somewhat similar to TP, except the whole tensor gets reconstructed in time for a forward or backward computation, therefore the model doesn\u2019t need to be modified. It also supports various offloading techniques to compensate for limited GPU memory."),mf=h(),Ki=a("li"),vf=r("Sharded DDP - is another name for the foundational ZeRO concept as used by various other implementations of ZeRO."),gs=h(),te=a("h2"),we=a("a"),Qi=a("span"),v(Ke.$$.fragment),Pf=h(),eo=a("span"),wf=r("Data Parallelism"),Ls=h(),x=a("p"),yf=r("Most users with just 2 GPUs already enjoy the increased training speed up thanks to "),to=a("code"),bf=r("DataParallel"),_f=r(" (DP) and "),lo=a("code"),Ef=r("DistributedDataParallel"),gf=r(" (DDP) that are almost trivial to use. This is a built-in feature of Pytorch."),Ds=h(),le=a("h2"),ye=a("a"),ao=a("span"),v(Qe.$$.fragment),Lf=h(),io=a("span"),Df=r("ZeRO Data Parallelism"),Gs=h(),ae=a("p"),Gf=r("ZeRO-powered data parallelism (ZeRO-DP) is described on the following diagram from this "),et=a("a"),Uf=r("blog post"),kf=h(),Ul=a("img"),Us=h(),be=a("p"),Tf=r("It can be difficult to wrap one\u2019s head around it, but in reality the concept is quite simple. This is just the usual "),oo=a("code"),If=r("DataParallel"),Sf=r(" (DP), except, instead of replicating the full model params, gradients and optimizer states, each GPU stores only a slice of it.  And then at run-time when the full layer params are needed just for the given layer, all GPUs synchronize to give each other parts that they miss - this is it."),ks=h(),kl=a("p"),Af=r("Consider this simple model with 3 layers, where each layer has 3 params:"),Ts=h(),v(tt.$$.fragment),Is=h(),Tl=a("p"),Of=r("Layer La has weights a0, a1 and a2."),Ss=h(),Il=a("p"),Mf=r("If we have 3 GPUs, the Sharded DDP (= Zero-DP) splits the model onto 3 GPUs like so:"),As=h(),v(lt.$$.fragment),Os=h(),Sl=a("p"),$f=r("In a way this is the same horizontal slicing, as tensor parallelism, if you imagine the typical DNN diagram. Vertical slicing is where one puts whole layer-groups on different GPUs. But it\u2019s just the starting point."),Ms=h(),Al=a("p"),xf=r("Now each of these GPUs will get the usual mini-batch as it works in DP:"),$s=h(),v(at.$$.fragment),xs=h(),Ol=a("p"),zf=r("The inputs are unmodified - they think they are going to be processed by the normal model."),zs=h(),Ml=a("p"),Nf=r("First, the inputs hit the layer La."),Ns=h(),$l=a("p"),Rf=r("Let\u2019s focus just on GPU0: x0 needs a0, a1, a2 params to do its forward path, but GPU0 has only a0 - it gets sent a1 from GPU1 and a2 from GPU2, bringing all pieces of the model together."),Rs=h(),xl=a("p"),Zf=r("In parallel, GPU1 gets mini-batch x1 and it only has a1, but needs a0 and a2 params, so it gets those from GPU0 and GPU2."),Zs=h(),zl=a("p"),Cf=r("Same happens to GPU2 that gets input x2. It gets a0 and a1 from GPU0 and GPU1, and with its a2 it reconstructs the full tensor."),Cs=h(),Nl=a("p"),jf=r("All 3 GPUs get the full tensors reconstructed and a forward happens."),js=h(),Rl=a("p"),Ff=r("As soon as the calculation is done, the data that is no longer needed gets dropped - it\u2019s only used during the calculation. The reconstruction is done efficiently via a pre-fetch."),Fs=h(),Zl=a("p"),Bf=r("And the whole process is repeated for layer Lb, then Lc forward-wise, and then backward Lc -> Lb -> La."),Bs=h(),Cl=a("p"),qf=r("To me this sounds like an efficient group backpacking weight distribution strategy:"),qs=h(),z=a("ol"),ro=a("li"),Wf=r("person A carries the tent"),Vf=h(),so=a("li"),Hf=r("person B carries the stove"),Xf=h(),no=a("li"),Yf=r("person C carries the axe"),Ws=h(),jl=a("p"),Jf=r("Now each night they all share what they have with others and get from others what they don\u2019t have, and in the morning they pack up their allocated type of gear and continue on their way. This is Sharded DDP / Zero DP."),Vs=h(),Fl=a("p"),Kf=r("Compare this strategy to the simple one where each person has to carry their own tent, stove and axe, which would be far more inefficient. This is DataParallel (DP and DDP) in Pytorch."),Hs=h(),Bl=a("p"),Qf=r("While reading the literature on this topic you may encounter the following synonyms: Sharded, Partitioned."),Xs=h(),ql=a("p"),ed=r("If you pay close attention the way ZeRO partitions the model\u2019s weights - it looks very similar to tensor parallelism which will be discussed later. This is because it partitions/shards each layer\u2019s weights, unlike vertical model parallelism which is discussed next."),Ys=h(),Wl=a("p"),td=r("Implementations:"),Js=h(),N=a("ul"),Vl=a("li"),it=a("a"),ld=r("DeepSpeed"),ad=r(" ZeRO-DP stages 1+2+3"),id=h(),Hl=a("li"),ot=a("a"),od=r("Fairscale"),rd=r(" ZeRO-DP stages 1+2+3"),sd=h(),po=a("li"),rt=a("a"),ho=a("code"),nd=r("transformers"),pd=r(" integration"),Ks=h(),ie=a("h2"),_e=a("a"),fo=a("span"),v(st.$$.fragment),hd=h(),co=a("span"),fd=r("Naive Model Parallelism (Vertical) and Pipeline Parallelism"),Qs=h(),Ee=a("p"),dd=r("Naive Model Parallelism (MP) is where one spreads groups of model layers across multiple GPUs. The mechanism is relatively simple - switch the desired layers "),uo=a("code"),cd=r(".to()"),ud=r(" the desired devices and now whenever the data goes in and out those layers switch the data to the same device as the layer and leave the rest unmodified."),en=h(),Xl=a("p"),md=r("We refer to it as Vertical MP, because if you remember how most models are drawn, we slice the layers vertically. For example, if the following diagram shows an 8-layer model:"),tn=h(),v(nt.$$.fragment),ln=h(),Yl=a("p"),vd=r("we just sliced it in 2 vertically, placing layers 0-3 onto GPU0 and 4-7 to GPU1."),an=h(),Jl=a("p"),Pd=r("Now while data travels from layer 0 to 1, 1 to 2 and 2 to 3 this is just the normal model. But when data needs to pass from layer 3 to layer 4 it needs to travel from GPU0 to GPU1 which introduces a communication overhead. If the participating GPUs are on the same compute node (e.g. same physical machine) this copying is pretty fast, but if the GPUs are located on different compute nodes (e.g. multiple machines) the communication overhead could be significantly larger."),on=h(),Kl=a("p"),wd=r("Then layers 4 to 5 to 6 to 7 are as a normal model would have and when the 7th layer completes we often need to send the data back to layer 0 where the labels are (or alternatively send the labels to the last layer). Now the loss can be computed and the optimizer can do its work."),rn=h(),Ql=a("p"),yd=r("Problems:"),sn=h(),ge=a("ul"),mo=a("li"),bd=r("the main deficiency and why this one is called \u201Cnaive\u201D MP, is that all but one GPU is idle at any given moment. So if 4 GPUs are used, it\u2019s almost identical to quadrupling the amount of memory of a single GPU, and ignoring the rest of the hardware. Plus there is the overhead of copying the data between devices. So 4x 6GB cards will be able to accommodate the same size as 1x 24GB card using naive MP, except the latter will complete the training faster, since it doesn\u2019t have the data copying overhead. But, say, if you have 40GB cards and need to fit a 45GB model you can with 4x 40GB cards (but barely because of the gradient and optimizer states)"),_d=h(),vo=a("li"),Ed=r("shared embeddings may need to get copied back and forth between GPUs."),nn=h(),ea=a("p"),gd=r("Pipeline Parallelism (PP) is almost identical to a naive MP, but it solves the GPU idling problem, by chunking the incoming batch into micro-batches and artificially creating a pipeline, which allows different GPUs to concurrently participate in the computation process."),pn=h(),Le=a("p"),Ld=r("The following illustration from the "),pt=a("a"),Dd=r("GPipe paper"),Gd=r(" shows the naive MP on the top, and PP on the bottom:"),hn=h(),ta=a("p"),la=a("img"),fn=h(),aa=a("p"),Ud=r("It\u2019s easy to see from the bottom diagram how PP has less dead zones, where GPUs are idle. The idle parts are referred to as the \u201Cbubble\u201D."),dn=h(),ia=a("p"),kd=r("Both parts of the diagram show a parallelism that is of degree 4. That is 4 GPUs are participating in the pipeline. So there is the forward path of 4 pipe stages F0, F1, F2 and F3 and then the return reverse order backward path of B3, B2, B1 and B0."),cn=h(),R=a("p"),Td=r("PP introduces a new hyper-parameter to tune and it\u2019s "),Po=a("code"),Id=r("chunks"),Sd=r(" which defines how many chunks of data are sent in a sequence through the same pipe stage. For example, in the bottomw diagram you can see that "),wo=a("code"),Ad=r("chunks=4"),Od=r(". GPU0 performs the same forward path on chunk 0, 1, 2 and 3 (F0,0, F0,1, F0,2, F0,3) and then it waits for other GPUs to do their work and only when their work is starting to be complete, GPU0 starts to work again doing the backward path for chunks 3, 2, 1 and 0 (B0,3, B0,2, B0,1, B0,0)."),un=h(),De=a("p"),Md=r("Note that conceptually this is the same concept as gradient accumulation steps (GAS). Pytorch uses "),yo=a("code"),$d=r("chunks"),xd=r(", whereas DeepSpeed refers to the same hyper-parameter as GAS."),mn=h(),Ge=a("p"),zd=r("Because of the chunks, PP introduces the concept of micro-batches (MBS). DP splits the global data batch size into mini-batches, so if you have a DP degree of 4, a global batch size of 1024 gets split up into 4 mini-batches of 256 each (1024/4). And if the number of "),bo=a("code"),Nd=r("chunks"),Rd=r(" (or GAS) is 32 we end up with a micro-batch size of 8 (256/32). Each Pipeline stage works with a single micro-batch at a time."),vn=h(),Z=a("p"),Zd=r("To calculate the global batch size of the DP + PP setup we then do: "),_o=a("code"),Cd=r("mbs*chunks*dp_degree"),jd=r(" ("),Eo=a("code"),Fd=r("8*32*4=1024"),Bd=r(")."),Pn=h(),oa=a("p"),qd=r("Let\u2019s go back to the diagram."),wn=h(),C=a("p"),Wd=r("With "),go=a("code"),Vd=r("chunks=1"),Hd=r(" you end up with the naive MP, which is very inefficient. With a very large "),Lo=a("code"),Xd=r("chunks"),Yd=r(" value you end up with tiny micro-batch sizes which could be not every efficient either. So one has to experiment to find the value that leads to the highest efficient utilization of the gpus."),yn=h(),k=a("p"),Jd=r("While the diagram shows that there is a bubble of \u201Cdead\u201D time that can\u2019t be parallelized because the last "),Do=a("code"),Kd=r("forward"),Qd=r(" stage has to wait for "),Go=a("code"),ec=r("backward"),tc=r(" to complete the pipeline, the purpose of finding the best value for "),Uo=a("code"),lc=r("chunks"),ac=r(" is to enable a high concurrent GPU utilization across all participating GPUs which translates to minimizing the size of the bubble."),bn=h(),ra=a("p"),ic=r("There are 2 groups of solutions - the traditional Pipeline API and the more modern solutions that make things much easier for the end user."),_n=h(),sa=a("p"),oc=r("Traditional Pipeline API solutions:"),En=h(),T=a("ul"),ko=a("li"),rc=r("PyTorch"),sc=h(),To=a("li"),nc=r("FairScale"),pc=h(),Io=a("li"),hc=r("DeepSpeed"),fc=h(),So=a("li"),dc=r("Megatron-LM"),gn=h(),na=a("p"),cc=r("Modern solutions:"),Ln=h(),Ue=a("ul"),Ao=a("li"),uc=r("Varuna"),mc=h(),Oo=a("li"),vc=r("Sagemaker"),Dn=h(),pa=a("p"),Pc=r("Problems with traditional Pipeline API solutions:"),Gn=h(),I=a("ul"),ht=a("li"),wc=r("have to modify the model quite heavily, because Pipeline requires one to rewrite the normal flow of modules into a "),Mo=a("code"),yc=r("nn.Sequential"),bc=r(" sequence of the same, which may require changes to the design of the model."),_c=h(),ha=a("li"),Ec=r("currently the Pipeline API is very restricted. If you had a bunch of python variables being passed in the very first stage of the Pipeline, you will have to find a way around it. Currently, the pipeline interface requires either a single Tensor or a tuple of Tensors as the only input and output. These tensors must have a batch size as the very first dimension, since pipeline is going to chunk the mini batch into micro-batches. Possible improvements are being discussed here "),ft=a("a"),gc=r("https://github.com/pytorch/pytorch/pull/50693"),Lc=h(),$o=a("li"),Dc=r("conditional control flow at the level of pipe stages is not possible - e.g., Encoder-Decoder models like T5 require special workarounds to handle a conditional encoder stage."),Gc=h(),xo=a("li"),Uc=r("have to arrange each layer so that the output of one model becomes an input to the other model."),Un=h(),fa=a("p"),kc=r("We are yet to experiment with Varuna and SageMaker but their papers report that they have overcome the list of problems mentioned above and that they require much smaller changes to the user\u2019s model."),kn=h(),da=a("p"),Tc=r("Implementations:"),Tn=h(),u=a("ul"),dt=a("li"),ct=a("a"),Ic=r("Pytorch"),Sc=r(" (initial support in pytorch-1.8, and progressively getting improved in 1.9 and more so in 1.10). Some "),ut=a("a"),Ac=r("examples"),Oc=h(),zo=a("li"),mt=a("a"),Mc=r("FairScale"),$c=h(),No=a("li"),vt=a("a"),xc=r("DeepSpeed"),zc=h(),ca=a("li"),Pt=a("a"),Nc=r("Megatron-LM"),Rc=r(" has an internal implementation - no API."),Zc=h(),Ro=a("li"),wt=a("a"),Cc=r("Varuna"),jc=h(),ua=a("li"),yt=a("a"),Fc=r("SageMaker"),Bc=r(" - this is a proprietary solution that can only be used on AWS."),qc=h(),ma=a("li"),bt=a("a"),Wc=r("OSLO"),Vc=r(" - this is implemented based on the Hugging Face Transformers."),In=h(),ke=a("p"),Hc=r("\u{1F917} Transformers status: as of this writing none of the models supports full-PP. GPT2 and T5 models have naive MP support. The main obstacle is being unable to convert the models to "),Zo=a("code"),Xc=r("nn.Sequential"),Yc=r(" and have all the inputs to be Tensors. This is because currently the models include many features that make the conversion very complicated, and will need to be removed to accomplish that."),Sn=h(),va=a("p"),Jc=r("Other approaches:"),An=h(),oe=a("p"),Kc=r("DeepSpeed, Varuna and SageMaker use the concept of an "),_t=a("a"),Qc=r("Interleaved Pipeline"),eu=h(),Pa=a("img"),On=h(),wa=a("p"),tu=r("Here the bubble (idle time) is further minimized by prioritizing backward passes."),Mn=h(),ya=a("p"),lu=r("Varuna further tries to improve the schedule by using simulations to discover the most efficient scheduling."),$n=h(),Te=a("p"),au=r("OSLO has pipeline parallelism implementation based on the Transformers without "),Co=a("code"),iu=r("nn.Sequential"),ou=r(" converting."),xn=h(),re=a("h2"),Ie=a("a"),jo=a("span"),v(Et.$$.fragment),ru=h(),Fo=a("span"),su=r("Tensor Parallelism"),zn=h(),ba=a("p"),nu=r("In Tensor Parallelism each GPU processes only a slice of a tensor and only aggregates the full tensor for operations that require the whole thing."),Nn=h(),j=a("p"),pu=r("In this section we use concepts and diagrams from the "),gt=a("a"),hu=r("Megatron-LM"),fu=r(" paper: "),Lt=a("a"),du=r("Efficient Large-Scale Language Model Training on GPU Clusters"),cu=r("."),Rn=h(),F=a("p"),uu=r("The main building block of any transformer is a fully connected "),Bo=a("code"),mu=r("nn.Linear"),vu=r(" followed by a nonlinear activation "),qo=a("code"),Pu=r("GeLU"),wu=r("."),Zn=h(),g=a("p"),yu=r("Following the Megatron\u2019s paper notation, we can write the dot-product part of it as "),Wo=a("code"),bu=r("Y = GeLU(XA)"),_u=r(", where "),Vo=a("code"),Eu=r("X"),gu=r(" and "),Ho=a("code"),Lu=r("Y"),Du=r(" are the input and output vectors, and "),Xo=a("code"),Gu=r("A"),Uu=r(" is the weight matrix."),Cn=h(),Dt=a("p"),ku=r(`If we look at the computation in matrix form, it\u2019s easy to see how the matrix multiplication can be split between multiple GPUs:
`),_a=a("img"),jn=h(),c=a("p"),Tu=r("If we split the weight matrix "),Yo=a("code"),Iu=r("A"),Su=r(" column-wise across "),Jo=a("code"),Au=r("N"),Ou=r(" GPUs and perform matrix multiplications "),Ko=a("code"),Mu=r("XA_1"),$u=r(" through "),Qo=a("code"),xu=r("XA_n"),zu=r(" in parallel, then we will end up with "),er=a("code"),Nu=r("N"),Ru=r(" output vectors "),tr=a("code"),Zu=r("Y_1, Y_2, ..., Y_n"),Cu=r(" which can be fed into "),lr=a("code"),ju=r("GeLU"),Fu=r(` independently:
`),Ea=a("img"),Fn=h(),Gt=a("p"),Bu=r(`Using this principle, we can update an MLP of arbitrary depth, without the need for any synchronization between GPUs until the very end, where we need to reconstruct the output vector from shards. The Megatron-LM paper authors provide a helpful illustration for that:
`),ga=a("img"),Bn=h(),Ut=a("p"),qu=r(`Parallelizing the multi-headed attention layers is even simpler, since they are already inherently parallel, due to having multiple independent heads!
`),La=a("img"),qn=h(),Da=a("p"),Wu=r("Special considerations: TP requires very fast network, and therefore it\u2019s not advisable to do TP across more than one node. Practically, if a node has 4 GPUs, the highest TP degree is therefore 4. If you need a TP degree of 8, you need to use nodes that have at least 8 GPUs."),Wn=h(),B=a("p"),Vu=r("This section is based on the original much more "),kt=a("a"),Hu=r("detailed TP overview"),Xu=r(`.
by `),Tt=a("a"),Yu=r("@anton-l"),Ju=r("."),Vn=h(),Ga=a("p"),Ku=r("SageMaker combines TP with DP for a more efficient processing."),Hn=h(),Ua=a("p"),Qu=r("Alternative names:"),Xn=h(),ka=a("ul"),Ta=a("li"),em=r("DeepSpeed calls it "),It=a("a"),tm=r("tensor slicing"),Yn=h(),Ia=a("p"),lm=r("Implementations:"),Jn=h(),S=a("ul"),Sa=a("li"),St=a("a"),am=r("Megatron-LM"),im=r(" has an internal implementation, as it\u2019s very model-specific"),om=h(),Aa=a("li"),At=a("a"),rm=r("parallelformers"),sm=r(" (only inference at the moment)"),nm=h(),Oa=a("li"),Ot=a("a"),pm=r("SageMaker"),hm=r(" - this is a proprietary solution that can only be used on AWS."),fm=h(),Ma=a("li"),Mt=a("a"),dm=r("OSLO"),cm=r(" has the tensor parallelism implementation based on the Transformers."),Kn=h(),$a=a("p"),um=r("\u{1F917} Transformers status:"),Qn=h(),q=a("ul"),ar=a("li"),mm=r("core: not yet implemented in the core"),vm=h(),$t=a("li"),Pm=r("but if you want inference "),xt=a("a"),wm=r("parallelformers"),ym=r(" provides this support for most of our models. So until this is implemented in the core you can use theirs. And hopefully training mode will be supported too."),bm=h(),xa=a("li"),_m=r("Deepspeed-Inference also supports our BERT, GPT-2, and GPT-Neo models in their super-fast CUDA-kernel-based inference mode, see more "),zt=a("a"),Em=r("here"),ep=h(),se=a("h2"),Se=a("a"),ir=a("span"),v(Nt.$$.fragment),gm=h(),or=a("span"),Lm=r("DP+PP"),tp=h(),Ae=a("p"),Dm=r("The following diagram from the DeepSpeed "),Rt=a("a"),Gm=r("pipeline tutorial"),Um=r(" demonstrates how one combines DP with PP."),lp=h(),za=a("p"),Na=a("img"),ap=h(),Ra=a("p"),km=r("Here it\u2019s important to see how DP rank 0 doesn\u2019t see GPU2 and DP rank 1 doesn\u2019t see GPU3. To DP there is just GPUs 0 and 1 where it feeds data as if there were just 2 GPUs. GPU0 \u201Csecretly\u201D offloads some of its load to GPU2 using PP. And GPU1 does the same by enlisting GPU3 to its aid."),ip=h(),Za=a("p"),Tm=r("Since each dimension requires at least 2 GPUs, here you\u2019d need at least 4 GPUs."),op=h(),Ca=a("p"),Im=r("Implementations:"),rp=h(),L=a("ul"),rr=a("li"),Zt=a("a"),Sm=r("DeepSpeed"),Am=h(),sr=a("li"),Ct=a("a"),Om=r("Megatron-LM"),Mm=h(),nr=a("li"),jt=a("a"),$m=r("Varuna"),xm=h(),pr=a("li"),Ft=a("a"),zm=r("SageMaker"),Nm=h(),hr=a("li"),Bt=a("a"),Rm=r("OSLO"),sp=h(),ja=a("p"),Zm=r("\u{1F917} Transformers status: not yet implemented"),np=h(),ne=a("h2"),Oe=a("a"),fr=a("span"),v(qt.$$.fragment),Cm=h(),dr=a("span"),jm=r("DP+PP+TP"),pp=h(),Fa=a("p"),Fm=r("To get an even more efficient training a 3D parallelism is used where PP is combined with TP and DP. This can be seen in the following diagram."),hp=h(),Ba=a("p"),qa=a("img"),fp=h(),Me=a("p"),Bm=r("This diagram is from a blog post "),Wt=a("a"),qm=r("3D parallelism: Scaling to trillion-parameter models"),Wm=r(", which is a good read as well."),dp=h(),Wa=a("p"),Vm=r("Since each dimension requires at least 2 GPUs, here you\u2019d need at least 8 GPUs."),cp=h(),Va=a("p"),Hm=r("Implementations:"),up=h(),D=a("ul"),Ha=a("li"),Vt=a("a"),Xm=r("DeepSpeed"),Ym=r(" - DeepSpeed also includes an even more efficient DP, which they call ZeRO-DP."),Jm=h(),cr=a("li"),Ht=a("a"),Km=r("Megatron-LM"),Qm=h(),ur=a("li"),Xt=a("a"),ev=r("Varuna"),tv=h(),mr=a("li"),Yt=a("a"),lv=r("SageMaker"),av=h(),vr=a("li"),Jt=a("a"),iv=r("OSLO"),mp=h(),Xa=a("p"),ov=r("\u{1F917} Transformers status: not yet implemented, since we have no PP and TP."),vp=h(),pe=a("h2"),$e=a("a"),Pr=a("span"),v(Kt.$$.fragment),rv=h(),wr=a("span"),sv=r("ZeRO DP+PP+TP"),Pp=h(),xe=a("p"),nv=r("One of the main features of DeepSpeed is ZeRO, which is a super-scalable extension of DP. It has already been discussed in "),Ya=a("a"),pv=r("ZeRO Data Parallelism"),hv=r(". Normally it\u2019s a standalone feature that doesn\u2019t require PP or TP. But it can be combined with PP and TP."),wp=h(),Ja=a("p"),fv=r("When ZeRO-DP is combined with PP (and optionally TP) it typically enables only ZeRO stage 1 (optimizer sharding)."),yp=h(),Ka=a("p"),dv=r("While it\u2019s theoretically possible to use ZeRO stage 2 (gradient sharding) with Pipeline Parallelism, it will have bad performance impacts. There would need to be an additional reduce-scatter collective for every micro-batch to aggregate the gradients before sharding, which adds a potentially significant communication overhead. By nature of Pipeline Parallelism, small micro-batches are used and instead the focus is on trying to balance arithmetic intensity (micro-batch size) with minimizing the Pipeline bubble (number of micro-batches). Therefore those communication costs are going to hurt."),bp=h(),ze=a("p"),cv=r("In addition, There are already fewer layers than normal due to PP and so the memory savings won\u2019t be huge. PP already reduces gradient size by "),yr=a("code"),uv=r("1/PP"),mv=r(", and so gradient sharding savings on top of that are less significant than pure DP."),_p=h(),Qa=a("p"),vv=r("ZeRO stage 3 is not a good choice either for the same reason - more inter-node communications required."),Ep=h(),ei=a("p"),Pv=r("And since we have ZeRO, the other benefit is ZeRO-Offload. Since this is stage 1 optimizer states can be offloaded to CPU."),gp=h(),ti=a("p"),wv=r("Implementations:"),Lp=h(),Ne=a("ul"),Re=a("li"),Qt=a("a"),yv=r("Megatron-DeepSpeed"),bv=r(" and "),el=a("a"),_v=r("Megatron-Deepspeed from BigScience"),Ev=r(", which is the fork of the former repo."),gv=h(),br=a("li"),tl=a("a"),Lv=r("OSLO"),Dp=h(),li=a("p"),Dv=r("Important papers:"),Gp=h(),ai=a("ul"),_r=a("li"),ll=a("a"),Gv=r("Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530B, A Large-Scale Generative Language Model"),Up=h(),ii=a("p"),Uv=r("\u{1F917} Transformers status: not yet implemented, since we have no PP and TP."),kp=h(),he=a("h2"),Ze=a("a"),Er=a("span"),v(al.$$.fragment),kv=h(),gr=a("span"),Tv=r("FlexFlow"),Tp=h(),il=a("p"),ol=a("a"),Iv=r("FlexFlow"),Sv=r(" also solves the parallelization problem in a slightly different approach."),Ip=h(),rl=a("p"),Av=r("Paper: "),sl=a("a"),Ov=r("\u201CBeyond Data and Model Parallelism for Deep Neural Networks\u201D by Zhihao Jia, Matei Zaharia, Alex Aiken"),Sp=h(),oi=a("p"),Mv=r("It performs a sort of 4D Parallelism over Sample-Operator-Attribute-Parameter."),Ap=h(),A=a("ol"),Lr=a("li"),$v=r("Sample = Data Parallelism (sample-wise parallel)"),xv=h(),Dr=a("li"),zv=r("Operator = Parallelize a single operation into several sub-operations"),Nv=h(),Gr=a("li"),Rv=r("Attribute = Data Parallelism (length-wise parallel)"),Zv=h(),Ur=a("li"),Cv=r("Parameter = Model Parallelism (regardless of dimension - horizontal or vertical)"),Op=h(),ri=a("p"),jv=r("Examples:"),Mp=h(),si=a("ul"),kr=a("li"),Fv=r("Sample"),$p=h(),ni=a("p"),Bv=r("Let\u2019s take 10 batches of sequence length 512. If we parallelize them by sample dimension into 2 devices, we get 10 x 512 which becomes be 5 x 2 x 512."),xp=h(),pi=a("ul"),Tr=a("li"),qv=r("Operator"),zp=h(),hi=a("p"),Wv=r("If we perform layer normalization, we compute std first and mean second, and then we can normalize data. Operator parallelism allows computing std and mean in parallel. So if we parallelize them by operator dimension into 2 devices (cuda:0, cuda:1), first we copy input data into both devices, and cuda:0 computes std, cuda:1 computes mean at the same time."),Np=h(),fi=a("ul"),Ir=a("li"),Vv=r("Attribute"),Rp=h(),di=a("p"),Hv=r("We have 10 batches of 512 length. If we parallelize them by attribute dimension into 2 devices, 10 x 512 will be 10 x 2 x 256."),Zp=h(),ci=a("ul"),Sr=a("li"),Xv=r("Parameter"),Cp=h(),ui=a("p"),Yv=r("It is similar with tensor model parallelism or naive layer-wise model parallelism."),jp=h(),mi=a("p"),vi=a("img"),Fp=h(),Pi=a("p"),Jv=r("The significance of this framework is that it takes resources like (1) GPU/TPU/CPU vs. (2) RAM/DRAM vs. (3) fast-intra-connect/slow-inter-connect and it automatically optimizes all these  algorithmically deciding which parallelisation to use where."),Bp=h(),wi=a("p"),Kv=r("One very important aspect is that FlexFlow is designed for optimizing DNN parallelizations for models with static and fixed workloads, since models with dynamic behavior may prefer different parallelization strategies across iterations."),qp=h(),yi=a("p"),Qv=r("So the promise is very attractive - it runs a 30min simulation on the cluster of choice and it comes up with the best strategy to utilise this specific environment. If you add/remove/replace any parts it\u2019ll run and re-optimize the plan for that. And then you can train. A different setup will have its own custom optimization."),Wp=h(),Ce=a("p"),eP=r("\u{1F917} Transformers status: not yet integrated. We already have our models FX-trace-able via "),nl=a("a"),tP=r("transformers.utils.fx"),lP=r(", which is a prerequisite for FlexFlow, so someone needs to figure out what needs to be done to make FlexFlow work with our models."),Vp=h(),fe=a("h2"),je=a("a"),Ar=a("span"),v(pl.$$.fragment),aP=h(),Or=a("span"),iP=r("Which Strategy To Use When"),Hp=h(),bi=a("p"),oP=r("Here is a very rough outline at which parallelism strategy to use when. The first on each list is typically faster."),Xp=h(),_i=a("p"),Mr=a("strong"),rP=r("\u21E8 Single GPU"),Yp=h(),W=a("ul"),hl=a("li"),$r=a("p"),sP=r("Model fits onto a single GPU:"),nP=h(),xr=a("ol"),zr=a("li"),pP=r("Normal use"),hP=h(),fl=a("li"),Nr=a("p"),fP=r("Model doesn\u2019t fit onto a single GPU:"),dP=h(),dl=a("ol"),Rr=a("li"),cP=r("ZeRO + Offload CPU and optionally NVMe"),uP=h(),Zr=a("li"),mP=r("as above plus Memory Centric Tiling (see below for details) if the largest layer can\u2019t fit into a single GPU"),vP=h(),Cr=a("li"),jr=a("p"),PP=r("Largest Layer not fitting into a single GPU:"),Jp=h(),Ei=a("ol"),de=a("li"),wP=r("ZeRO - Enable "),cl=a("a"),yP=r("Memory Centric Tiling"),bP=r(" (MCT). It allows you to run arbitrarily large layers by automatically splitting them and executing them sequentially. MCT reduces the number of parameters that are live on a GPU, but it does not affect the activation memory. As this need is very rare as of this writing a manual override of "),Fr=a("code"),_P=r("torch.nn.Linear"),EP=r(" needs to be done by the user."),Kp=h(),gi=a("p"),Br=a("strong"),gP=r("\u21E8 Single Node / Multi-GPU"),Qp=h(),V=a("ul"),ul=a("li"),qr=a("p"),LP=r("Model fits onto a single GPU:"),DP=h(),ml=a("ol"),Wr=a("li"),GP=r("DDP - Distributed DP"),UP=h(),Vr=a("li"),kP=r("ZeRO - may or may not be faster depending on the situation and configuration used"),TP=h(),vl=a("li"),Hr=a("p"),IP=r("Model doesn\u2019t fit onto a single GPU:"),SP=h(),ce=a("ol"),Xr=a("li"),Yr=a("p"),AP=r("PP"),OP=h(),Jr=a("li"),Kr=a("p"),MP=r("ZeRO"),$P=h(),ue=a("li"),Qr=a("p"),xP=r("TP"),zP=h(),es=a("p"),NP=r("With very fast intra-node connectivity of NVLINK or NVSwitch all three should be mostly on par, without these PP will be faster than TP or ZeRO. The degree of TP may also make a difference. Best to experiment to find the winner on your particular setup."),RP=h(),ts=a("p"),ZP=r("TP is almost always used within a single node. That is TP size <= gpus per node."),CP=h(),Pl=a("li"),ls=a("p"),jP=r("Largest Layer not fitting into a single GPU:"),FP=h(),wl=a("ol"),as=a("li"),BP=r("If not using ZeRO - must use TP, as PP alone won\u2019t be able to fit."),qP=h(),is=a("li"),WP=r("With ZeRO see the same entry for \u201CSingle GPU\u201D above"),eh=h(),Li=a("p"),os=a("strong"),VP=r("\u21E8 Multi-Node / Multi-GPU"),th=h(),Fe=a("ul"),yl=a("li"),rs=a("p"),HP=r("When you have fast inter-node connectivity:"),XP=h(),bl=a("ol"),ss=a("li"),YP=r("ZeRO - as it requires close to no modifications to the model"),JP=h(),ns=a("li"),KP=r("PP+TP+DP - less communications, but requires massive changes to the model"),QP=h(),_l=a("li"),ps=a("p"),e1=r("when you have slow inter-node connectivity and still low on GPU memory:"),t1=h(),hs=a("ol"),fs=a("li"),l1=r("DP+PP+TP+ZeRO-1"),this.h()},l(e){const n=j3('[data-svelte="svelte-1phssyn"]',document.head);$=i(n,"META",{name:!0,content:!0}),n.forEach(t),El=f(e),U=i(e,"H1",{class:!0});var ah=o(U);M=i(ah,"A",{id:!0,class:!0,href:!0});var A1=o(M);Zi=i(A1,"SPAN",{});var O1=o(Zi);P(Xe.$$.fragment,O1),O1.forEach(t),A1.forEach(t),Hh=f(ah),Ci=i(ah,"SPAN",{});var M1=o(Ci);Xh=s(M1,"Model Parallelism"),M1.forEach(t),ah.forEach(t),ms=f(e),Q=i(e,"H2",{class:!0});var ih=o(Q);me=i(ih,"A",{id:!0,class:!0,href:!0});var $1=o(me);ji=i($1,"SPAN",{});var x1=o(ji);P(Ye.$$.fragment,x1),x1.forEach(t),$1.forEach(t),Yh=f(ih),Fi=i(ih,"SPAN",{});var z1=o(Fi);Jh=s(z1,"Parallelism overview"),z1.forEach(t),ih.forEach(t),vs=f(e),gl=i(e,"P",{});var N1=o(gl);Kh=s(N1,"In the modern machine learning the various approaches to parallelism are used to:"),N1.forEach(t),Ps=f(e),ve=i(e,"OL",{});var oh=o(ve);Bi=i(oh,"LI",{});var R1=o(Bi);Qh=s(R1,"fit very large models onto limited hardware - e.g. t5-11b is 45GB in just model params"),R1.forEach(t),ef=f(oh),qi=i(oh,"LI",{});var Z1=o(qi);tf=s(Z1,"significantly speed up training - finish training that would take a year in hours"),Z1.forEach(t),oh.forEach(t),ws=f(e),Ll=i(e,"P",{});var C1=o(Ll);lf=s(C1,"We will first discuss in depth various 1D parallelism techniques and their pros and cons and then look at how they can be combined into 2D and 3D parallelism to enable an even faster training and to support even bigger models. Various other powerful alternative approaches will be presented."),C1.forEach(t),ys=f(e),Dl=i(e,"P",{});var j1=o(Dl);af=s(j1,"While the main concepts most likely will apply to any other framework, this article is focused on PyTorch-based implementations."),j1.forEach(t),bs=f(e),ee=i(e,"H2",{class:!0});var rh=o(ee);Pe=i(rh,"A",{id:!0,class:!0,href:!0});var F1=o(Pe);Wi=i(F1,"SPAN",{});var B1=o(Wi);P(Je.$$.fragment,B1),B1.forEach(t),F1.forEach(t),of=f(rh),Vi=i(rh,"SPAN",{});var q1=o(Vi);rf=s(q1,"Concepts"),q1.forEach(t),rh.forEach(t),_s=f(e),Gl=i(e,"P",{});var W1=o(Gl);sf=s(W1,"The following is the brief description of the main concepts that will be described later in depth in this document."),W1.forEach(t),Es=f(e),E=i(e,"OL",{});var H=o(E);Hi=i(H,"LI",{});var V1=o(Hi);nf=s(V1,"DataParallel (DP) - the same setup is replicated multiple times, and each being fed a slice of the data. The processing is done in parallel and all setups are synchronized at the end of each training step."),V1.forEach(t),pf=f(H),Xi=i(H,"LI",{});var H1=o(Xi);hf=s(H1,"TensorParallel (TP) - each tensor is split up into multiple chunks, so instead of having the whole tensor reside on a single gpu, each shard of the tensor resides on its designated gpu. During processing each shard gets processed separately and in parallel on different GPUs and the results are synced at the end of the step. This is what one may call horizontal parallelism, as the splitting happens on horizontal level."),H1.forEach(t),ff=f(H),Yi=i(H,"LI",{});var X1=o(Yi);df=s(X1,"PipelineParallel (PP) - the model is split up vertically (layer-level) across multiple GPUs, so that only one or several layers of the model are places on a single gpu. Each gpu processes in parallel different stages of the pipeline and working on a small chunk of the batch."),X1.forEach(t),cf=f(H),Ji=i(H,"LI",{});var Y1=o(Ji);uf=s(Y1,"Zero Redundancy Optimizer (ZeRO) - Also performs sharding of the tensors somewhat similar to TP, except the whole tensor gets reconstructed in time for a forward or backward computation, therefore the model doesn\u2019t need to be modified. It also supports various offloading techniques to compensate for limited GPU memory."),Y1.forEach(t),mf=f(H),Ki=i(H,"LI",{});var J1=o(Ki);vf=s(J1,"Sharded DDP - is another name for the foundational ZeRO concept as used by various other implementations of ZeRO."),J1.forEach(t),H.forEach(t),gs=f(e),te=i(e,"H2",{class:!0});var sh=o(te);we=i(sh,"A",{id:!0,class:!0,href:!0});var K1=o(we);Qi=i(K1,"SPAN",{});var Q1=o(Qi);P(Ke.$$.fragment,Q1),Q1.forEach(t),K1.forEach(t),Pf=f(sh),eo=i(sh,"SPAN",{});var ew=o(eo);wf=s(ew,"Data Parallelism"),ew.forEach(t),sh.forEach(t),Ls=f(e),x=i(e,"P",{});var Di=o(x);yf=s(Di,"Most users with just 2 GPUs already enjoy the increased training speed up thanks to "),to=i(Di,"CODE",{});var tw=o(to);bf=s(tw,"DataParallel"),tw.forEach(t),_f=s(Di," (DP) and "),lo=i(Di,"CODE",{});var lw=o(lo);Ef=s(lw,"DistributedDataParallel"),lw.forEach(t),gf=s(Di," (DDP) that are almost trivial to use. This is a built-in feature of Pytorch."),Di.forEach(t),Ds=f(e),le=i(e,"H2",{class:!0});var nh=o(le);ye=i(nh,"A",{id:!0,class:!0,href:!0});var aw=o(ye);ao=i(aw,"SPAN",{});var iw=o(ao);P(Qe.$$.fragment,iw),iw.forEach(t),aw.forEach(t),Lf=f(nh),io=i(nh,"SPAN",{});var ow=o(io);Df=s(ow,"ZeRO Data Parallelism"),ow.forEach(t),nh.forEach(t),Gs=f(e),ae=i(e,"P",{});var ds=o(ae);Gf=s(ds,"ZeRO-powered data parallelism (ZeRO-DP) is described on the following diagram from this "),et=i(ds,"A",{href:!0,rel:!0});var rw=o(et);Uf=s(rw,"blog post"),rw.forEach(t),kf=f(ds),Ul=i(ds,"IMG",{src:!0,alt:!0}),ds.forEach(t),Us=f(e),be=i(e,"P",{});var ph=o(be);Tf=s(ph,"It can be difficult to wrap one\u2019s head around it, but in reality the concept is quite simple. This is just the usual "),oo=i(ph,"CODE",{});var sw=o(oo);If=s(sw,"DataParallel"),sw.forEach(t),Sf=s(ph," (DP), except, instead of replicating the full model params, gradients and optimizer states, each GPU stores only a slice of it.  And then at run-time when the full layer params are needed just for the given layer, all GPUs synchronize to give each other parts that they miss - this is it."),ph.forEach(t),ks=f(e),kl=i(e,"P",{});var nw=o(kl);Af=s(nw,"Consider this simple model with 3 layers, where each layer has 3 params:"),nw.forEach(t),Ts=f(e),P(tt.$$.fragment,e),Is=f(e),Tl=i(e,"P",{});var pw=o(Tl);Of=s(pw,"Layer La has weights a0, a1 and a2."),pw.forEach(t),Ss=f(e),Il=i(e,"P",{});var hw=o(Il);Mf=s(hw,"If we have 3 GPUs, the Sharded DDP (= Zero-DP) splits the model onto 3 GPUs like so:"),hw.forEach(t),As=f(e),P(lt.$$.fragment,e),Os=f(e),Sl=i(e,"P",{});var fw=o(Sl);$f=s(fw,"In a way this is the same horizontal slicing, as tensor parallelism, if you imagine the typical DNN diagram. Vertical slicing is where one puts whole layer-groups on different GPUs. But it\u2019s just the starting point."),fw.forEach(t),Ms=f(e),Al=i(e,"P",{});var dw=o(Al);xf=s(dw,"Now each of these GPUs will get the usual mini-batch as it works in DP:"),dw.forEach(t),$s=f(e),P(at.$$.fragment,e),xs=f(e),Ol=i(e,"P",{});var cw=o(Ol);zf=s(cw,"The inputs are unmodified - they think they are going to be processed by the normal model."),cw.forEach(t),zs=f(e),Ml=i(e,"P",{});var uw=o(Ml);Nf=s(uw,"First, the inputs hit the layer La."),uw.forEach(t),Ns=f(e),$l=i(e,"P",{});var mw=o($l);Rf=s(mw,"Let\u2019s focus just on GPU0: x0 needs a0, a1, a2 params to do its forward path, but GPU0 has only a0 - it gets sent a1 from GPU1 and a2 from GPU2, bringing all pieces of the model together."),mw.forEach(t),Rs=f(e),xl=i(e,"P",{});var vw=o(xl);Zf=s(vw,"In parallel, GPU1 gets mini-batch x1 and it only has a1, but needs a0 and a2 params, so it gets those from GPU0 and GPU2."),vw.forEach(t),Zs=f(e),zl=i(e,"P",{});var Pw=o(zl);Cf=s(Pw,"Same happens to GPU2 that gets input x2. It gets a0 and a1 from GPU0 and GPU1, and with its a2 it reconstructs the full tensor."),Pw.forEach(t),Cs=f(e),Nl=i(e,"P",{});var ww=o(Nl);jf=s(ww,"All 3 GPUs get the full tensors reconstructed and a forward happens."),ww.forEach(t),js=f(e),Rl=i(e,"P",{});var yw=o(Rl);Ff=s(yw,"As soon as the calculation is done, the data that is no longer needed gets dropped - it\u2019s only used during the calculation. The reconstruction is done efficiently via a pre-fetch."),yw.forEach(t),Fs=f(e),Zl=i(e,"P",{});var bw=o(Zl);Bf=s(bw,"And the whole process is repeated for layer Lb, then Lc forward-wise, and then backward Lc -> Lb -> La."),bw.forEach(t),Bs=f(e),Cl=i(e,"P",{});var _w=o(Cl);qf=s(_w,"To me this sounds like an efficient group backpacking weight distribution strategy:"),_w.forEach(t),qs=f(e),z=i(e,"OL",{});var Gi=o(z);ro=i(Gi,"LI",{});var Ew=o(ro);Wf=s(Ew,"person A carries the tent"),Ew.forEach(t),Vf=f(Gi),so=i(Gi,"LI",{});var gw=o(so);Hf=s(gw,"person B carries the stove"),gw.forEach(t),Xf=f(Gi),no=i(Gi,"LI",{});var Lw=o(no);Yf=s(Lw,"person C carries the axe"),Lw.forEach(t),Gi.forEach(t),Ws=f(e),jl=i(e,"P",{});var Dw=o(jl);Jf=s(Dw,"Now each night they all share what they have with others and get from others what they don\u2019t have, and in the morning they pack up their allocated type of gear and continue on their way. This is Sharded DDP / Zero DP."),Dw.forEach(t),Vs=f(e),Fl=i(e,"P",{});var Gw=o(Fl);Kf=s(Gw,"Compare this strategy to the simple one where each person has to carry their own tent, stove and axe, which would be far more inefficient. This is DataParallel (DP and DDP) in Pytorch."),Gw.forEach(t),Hs=f(e),Bl=i(e,"P",{});var Uw=o(Bl);Qf=s(Uw,"While reading the literature on this topic you may encounter the following synonyms: Sharded, Partitioned."),Uw.forEach(t),Xs=f(e),ql=i(e,"P",{});var kw=o(ql);ed=s(kw,"If you pay close attention the way ZeRO partitions the model\u2019s weights - it looks very similar to tensor parallelism which will be discussed later. This is because it partitions/shards each layer\u2019s weights, unlike vertical model parallelism which is discussed next."),kw.forEach(t),Ys=f(e),Wl=i(e,"P",{});var Tw=o(Wl);td=s(Tw,"Implementations:"),Tw.forEach(t),Js=f(e),N=i(e,"UL",{});var Ui=o(N);Vl=i(Ui,"LI",{});var a1=o(Vl);it=i(a1,"A",{href:!0,rel:!0});var Iw=o(it);ld=s(Iw,"DeepSpeed"),Iw.forEach(t),ad=s(a1," ZeRO-DP stages 1+2+3"),a1.forEach(t),id=f(Ui),Hl=i(Ui,"LI",{});var i1=o(Hl);ot=i(i1,"A",{href:!0,rel:!0});var Sw=o(ot);od=s(Sw,"Fairscale"),Sw.forEach(t),rd=s(i1," ZeRO-DP stages 1+2+3"),i1.forEach(t),sd=f(Ui),po=i(Ui,"LI",{});var Aw=o(po);rt=i(Aw,"A",{href:!0});var o1=o(rt);ho=i(o1,"CODE",{});var Ow=o(ho);nd=s(Ow,"transformers"),Ow.forEach(t),pd=s(o1," integration"),o1.forEach(t),Aw.forEach(t),Ui.forEach(t),Ks=f(e),ie=i(e,"H2",{class:!0});var hh=o(ie);_e=i(hh,"A",{id:!0,class:!0,href:!0});var Mw=o(_e);fo=i(Mw,"SPAN",{});var $w=o(fo);P(st.$$.fragment,$w),$w.forEach(t),Mw.forEach(t),hd=f(hh),co=i(hh,"SPAN",{});var xw=o(co);fd=s(xw,"Naive Model Parallelism (Vertical) and Pipeline Parallelism"),xw.forEach(t),hh.forEach(t),Qs=f(e),Ee=i(e,"P",{});var fh=o(Ee);dd=s(fh,"Naive Model Parallelism (MP) is where one spreads groups of model layers across multiple GPUs. The mechanism is relatively simple - switch the desired layers "),uo=i(fh,"CODE",{});var zw=o(uo);cd=s(zw,".to()"),zw.forEach(t),ud=s(fh," the desired devices and now whenever the data goes in and out those layers switch the data to the same device as the layer and leave the rest unmodified."),fh.forEach(t),en=f(e),Xl=i(e,"P",{});var Nw=o(Xl);md=s(Nw,"We refer to it as Vertical MP, because if you remember how most models are drawn, we slice the layers vertically. For example, if the following diagram shows an 8-layer model:"),Nw.forEach(t),tn=f(e),P(nt.$$.fragment,e),ln=f(e),Yl=i(e,"P",{});var Rw=o(Yl);vd=s(Rw,"we just sliced it in 2 vertically, placing layers 0-3 onto GPU0 and 4-7 to GPU1."),Rw.forEach(t),an=f(e),Jl=i(e,"P",{});var Zw=o(Jl);Pd=s(Zw,"Now while data travels from layer 0 to 1, 1 to 2 and 2 to 3 this is just the normal model. But when data needs to pass from layer 3 to layer 4 it needs to travel from GPU0 to GPU1 which introduces a communication overhead. If the participating GPUs are on the same compute node (e.g. same physical machine) this copying is pretty fast, but if the GPUs are located on different compute nodes (e.g. multiple machines) the communication overhead could be significantly larger."),Zw.forEach(t),on=f(e),Kl=i(e,"P",{});var Cw=o(Kl);wd=s(Cw,"Then layers 4 to 5 to 6 to 7 are as a normal model would have and when the 7th layer completes we often need to send the data back to layer 0 where the labels are (or alternatively send the labels to the last layer). Now the loss can be computed and the optimizer can do its work."),Cw.forEach(t),rn=f(e),Ql=i(e,"P",{});var jw=o(Ql);yd=s(jw,"Problems:"),jw.forEach(t),sn=f(e),ge=i(e,"UL",{});var dh=o(ge);mo=i(dh,"LI",{});var Fw=o(mo);bd=s(Fw,"the main deficiency and why this one is called \u201Cnaive\u201D MP, is that all but one GPU is idle at any given moment. So if 4 GPUs are used, it\u2019s almost identical to quadrupling the amount of memory of a single GPU, and ignoring the rest of the hardware. Plus there is the overhead of copying the data between devices. So 4x 6GB cards will be able to accommodate the same size as 1x 24GB card using naive MP, except the latter will complete the training faster, since it doesn\u2019t have the data copying overhead. But, say, if you have 40GB cards and need to fit a 45GB model you can with 4x 40GB cards (but barely because of the gradient and optimizer states)"),Fw.forEach(t),_d=f(dh),vo=i(dh,"LI",{});var Bw=o(vo);Ed=s(Bw,"shared embeddings may need to get copied back and forth between GPUs."),Bw.forEach(t),dh.forEach(t),nn=f(e),ea=i(e,"P",{});var qw=o(ea);gd=s(qw,"Pipeline Parallelism (PP) is almost identical to a naive MP, but it solves the GPU idling problem, by chunking the incoming batch into micro-batches and artificially creating a pipeline, which allows different GPUs to concurrently participate in the computation process."),qw.forEach(t),pn=f(e),Le=i(e,"P",{});var ch=o(Le);Ld=s(ch,"The following illustration from the "),pt=i(ch,"A",{href:!0,rel:!0});var Ww=o(pt);Dd=s(Ww,"GPipe paper"),Ww.forEach(t),Gd=s(ch," shows the naive MP on the top, and PP on the bottom:"),ch.forEach(t),hn=f(e),ta=i(e,"P",{});var Vw=o(ta);la=i(Vw,"IMG",{src:!0,alt:!0}),Vw.forEach(t),fn=f(e),aa=i(e,"P",{});var Hw=o(aa);Ud=s(Hw,"It\u2019s easy to see from the bottom diagram how PP has less dead zones, where GPUs are idle. The idle parts are referred to as the \u201Cbubble\u201D."),Hw.forEach(t),dn=f(e),ia=i(e,"P",{});var Xw=o(ia);kd=s(Xw,"Both parts of the diagram show a parallelism that is of degree 4. That is 4 GPUs are participating in the pipeline. So there is the forward path of 4 pipe stages F0, F1, F2 and F3 and then the return reverse order backward path of B3, B2, B1 and B0."),Xw.forEach(t),cn=f(e),R=i(e,"P",{});var ki=o(R);Td=s(ki,"PP introduces a new hyper-parameter to tune and it\u2019s "),Po=i(ki,"CODE",{});var Yw=o(Po);Id=s(Yw,"chunks"),Yw.forEach(t),Sd=s(ki," which defines how many chunks of data are sent in a sequence through the same pipe stage. For example, in the bottomw diagram you can see that "),wo=i(ki,"CODE",{});var Jw=o(wo);Ad=s(Jw,"chunks=4"),Jw.forEach(t),Od=s(ki,". GPU0 performs the same forward path on chunk 0, 1, 2 and 3 (F0,0, F0,1, F0,2, F0,3) and then it waits for other GPUs to do their work and only when their work is starting to be complete, GPU0 starts to work again doing the backward path for chunks 3, 2, 1 and 0 (B0,3, B0,2, B0,1, B0,0)."),ki.forEach(t),un=f(e),De=i(e,"P",{});var uh=o(De);Md=s(uh,"Note that conceptually this is the same concept as gradient accumulation steps (GAS). Pytorch uses "),yo=i(uh,"CODE",{});var Kw=o(yo);$d=s(Kw,"chunks"),Kw.forEach(t),xd=s(uh,", whereas DeepSpeed refers to the same hyper-parameter as GAS."),uh.forEach(t),mn=f(e),Ge=i(e,"P",{});var mh=o(Ge);zd=s(mh,"Because of the chunks, PP introduces the concept of micro-batches (MBS). DP splits the global data batch size into mini-batches, so if you have a DP degree of 4, a global batch size of 1024 gets split up into 4 mini-batches of 256 each (1024/4). And if the number of "),bo=i(mh,"CODE",{});var Qw=o(bo);Nd=s(Qw,"chunks"),Qw.forEach(t),Rd=s(mh," (or GAS) is 32 we end up with a micro-batch size of 8 (256/32). Each Pipeline stage works with a single micro-batch at a time."),mh.forEach(t),vn=f(e),Z=i(e,"P",{});var Ti=o(Z);Zd=s(Ti,"To calculate the global batch size of the DP + PP setup we then do: "),_o=i(Ti,"CODE",{});var e2=o(_o);Cd=s(e2,"mbs*chunks*dp_degree"),e2.forEach(t),jd=s(Ti," ("),Eo=i(Ti,"CODE",{});var t2=o(Eo);Fd=s(t2,"8*32*4=1024"),t2.forEach(t),Bd=s(Ti,")."),Ti.forEach(t),Pn=f(e),oa=i(e,"P",{});var l2=o(oa);qd=s(l2,"Let\u2019s go back to the diagram."),l2.forEach(t),wn=f(e),C=i(e,"P",{});var Ii=o(C);Wd=s(Ii,"With "),go=i(Ii,"CODE",{});var a2=o(go);Vd=s(a2,"chunks=1"),a2.forEach(t),Hd=s(Ii," you end up with the naive MP, which is very inefficient. With a very large "),Lo=i(Ii,"CODE",{});var i2=o(Lo);Xd=s(i2,"chunks"),i2.forEach(t),Yd=s(Ii," value you end up with tiny micro-batch sizes which could be not every efficient either. So one has to experiment to find the value that leads to the highest efficient utilization of the gpus."),Ii.forEach(t),yn=f(e),k=i(e,"P",{});var Be=o(k);Jd=s(Be,"While the diagram shows that there is a bubble of \u201Cdead\u201D time that can\u2019t be parallelized because the last "),Do=i(Be,"CODE",{});var o2=o(Do);Kd=s(o2,"forward"),o2.forEach(t),Qd=s(Be," stage has to wait for "),Go=i(Be,"CODE",{});var r2=o(Go);ec=s(r2,"backward"),r2.forEach(t),tc=s(Be," to complete the pipeline, the purpose of finding the best value for "),Uo=i(Be,"CODE",{});var s2=o(Uo);lc=s(s2,"chunks"),s2.forEach(t),ac=s(Be," is to enable a high concurrent GPU utilization across all participating GPUs which translates to minimizing the size of the bubble."),Be.forEach(t),bn=f(e),ra=i(e,"P",{});var n2=o(ra);ic=s(n2,"There are 2 groups of solutions - the traditional Pipeline API and the more modern solutions that make things much easier for the end user."),n2.forEach(t),_n=f(e),sa=i(e,"P",{});var p2=o(sa);oc=s(p2,"Traditional Pipeline API solutions:"),p2.forEach(t),En=f(e),T=i(e,"UL",{});var qe=o(T);ko=i(qe,"LI",{});var h2=o(ko);rc=s(h2,"PyTorch"),h2.forEach(t),sc=f(qe),To=i(qe,"LI",{});var f2=o(To);nc=s(f2,"FairScale"),f2.forEach(t),pc=f(qe),Io=i(qe,"LI",{});var d2=o(Io);hc=s(d2,"DeepSpeed"),d2.forEach(t),fc=f(qe),So=i(qe,"LI",{});var c2=o(So);dc=s(c2,"Megatron-LM"),c2.forEach(t),qe.forEach(t),gn=f(e),na=i(e,"P",{});var u2=o(na);cc=s(u2,"Modern solutions:"),u2.forEach(t),Ln=f(e),Ue=i(e,"UL",{});var vh=o(Ue);Ao=i(vh,"LI",{});var m2=o(Ao);uc=s(m2,"Varuna"),m2.forEach(t),mc=f(vh),Oo=i(vh,"LI",{});var v2=o(Oo);vc=s(v2,"Sagemaker"),v2.forEach(t),vh.forEach(t),Dn=f(e),pa=i(e,"P",{});var P2=o(pa);Pc=s(P2,"Problems with traditional Pipeline API solutions:"),P2.forEach(t),Gn=f(e),I=i(e,"UL",{});var We=o(I);ht=i(We,"LI",{});var Ph=o(ht);wc=s(Ph,"have to modify the model quite heavily, because Pipeline requires one to rewrite the normal flow of modules into a "),Mo=i(Ph,"CODE",{});var w2=o(Mo);yc=s(w2,"nn.Sequential"),w2.forEach(t),bc=s(Ph," sequence of the same, which may require changes to the design of the model."),Ph.forEach(t),_c=f(We),ha=i(We,"LI",{});var r1=o(ha);Ec=s(r1,"currently the Pipeline API is very restricted. If you had a bunch of python variables being passed in the very first stage of the Pipeline, you will have to find a way around it. Currently, the pipeline interface requires either a single Tensor or a tuple of Tensors as the only input and output. These tensors must have a batch size as the very first dimension, since pipeline is going to chunk the mini batch into micro-batches. Possible improvements are being discussed here "),ft=i(r1,"A",{href:!0,rel:!0});var y2=o(ft);gc=s(y2,"https://github.com/pytorch/pytorch/pull/50693"),y2.forEach(t),r1.forEach(t),Lc=f(We),$o=i(We,"LI",{});var b2=o($o);Dc=s(b2,"conditional control flow at the level of pipe stages is not possible - e.g., Encoder-Decoder models like T5 require special workarounds to handle a conditional encoder stage."),b2.forEach(t),Gc=f(We),xo=i(We,"LI",{});var _2=o(xo);Uc=s(_2,"have to arrange each layer so that the output of one model becomes an input to the other model."),_2.forEach(t),We.forEach(t),Un=f(e),fa=i(e,"P",{});var E2=o(fa);kc=s(E2,"We are yet to experiment with Varuna and SageMaker but their papers report that they have overcome the list of problems mentioned above and that they require much smaller changes to the user\u2019s model."),E2.forEach(t),kn=f(e),da=i(e,"P",{});var g2=o(da);Tc=s(g2,"Implementations:"),g2.forEach(t),Tn=f(e),u=i(e,"UL",{});var G=o(u);dt=i(G,"LI",{});var wh=o(dt);ct=i(wh,"A",{href:!0,rel:!0});var L2=o(ct);Ic=s(L2,"Pytorch"),L2.forEach(t),Sc=s(wh," (initial support in pytorch-1.8, and progressively getting improved in 1.9 and more so in 1.10). Some "),ut=i(wh,"A",{href:!0,rel:!0});var D2=o(ut);Ac=s(D2,"examples"),D2.forEach(t),wh.forEach(t),Oc=f(G),zo=i(G,"LI",{});var G2=o(zo);mt=i(G2,"A",{href:!0,rel:!0});var U2=o(mt);Mc=s(U2,"FairScale"),U2.forEach(t),G2.forEach(t),$c=f(G),No=i(G,"LI",{});var k2=o(No);vt=i(k2,"A",{href:!0,rel:!0});var T2=o(vt);xc=s(T2,"DeepSpeed"),T2.forEach(t),k2.forEach(t),zc=f(G),ca=i(G,"LI",{});var s1=o(ca);Pt=i(s1,"A",{href:!0,rel:!0});var I2=o(Pt);Nc=s(I2,"Megatron-LM"),I2.forEach(t),Rc=s(s1," has an internal implementation - no API."),s1.forEach(t),Zc=f(G),Ro=i(G,"LI",{});var S2=o(Ro);wt=i(S2,"A",{href:!0,rel:!0});var A2=o(wt);Cc=s(A2,"Varuna"),A2.forEach(t),S2.forEach(t),jc=f(G),ua=i(G,"LI",{});var n1=o(ua);yt=i(n1,"A",{href:!0,rel:!0});var O2=o(yt);Fc=s(O2,"SageMaker"),O2.forEach(t),Bc=s(n1," - this is a proprietary solution that can only be used on AWS."),n1.forEach(t),qc=f(G),ma=i(G,"LI",{});var p1=o(ma);bt=i(p1,"A",{href:!0,rel:!0});var M2=o(bt);Wc=s(M2,"OSLO"),M2.forEach(t),Vc=s(p1," - this is implemented based on the Hugging Face Transformers."),p1.forEach(t),G.forEach(t),In=f(e),ke=i(e,"P",{});var yh=o(ke);Hc=s(yh,"\u{1F917} Transformers status: as of this writing none of the models supports full-PP. GPT2 and T5 models have naive MP support. The main obstacle is being unable to convert the models to "),Zo=i(yh,"CODE",{});var $2=o(Zo);Xc=s($2,"nn.Sequential"),$2.forEach(t),Yc=s(yh," and have all the inputs to be Tensors. This is because currently the models include many features that make the conversion very complicated, and will need to be removed to accomplish that."),yh.forEach(t),Sn=f(e),va=i(e,"P",{});var x2=o(va);Jc=s(x2,"Other approaches:"),x2.forEach(t),An=f(e),oe=i(e,"P",{});var cs=o(oe);Kc=s(cs,"DeepSpeed, Varuna and SageMaker use the concept of an "),_t=i(cs,"A",{href:!0,rel:!0});var z2=o(_t);Qc=s(z2,"Interleaved Pipeline"),z2.forEach(t),eu=f(cs),Pa=i(cs,"IMG",{src:!0,alt:!0}),cs.forEach(t),On=f(e),wa=i(e,"P",{});var N2=o(wa);tu=s(N2,"Here the bubble (idle time) is further minimized by prioritizing backward passes."),N2.forEach(t),Mn=f(e),ya=i(e,"P",{});var R2=o(ya);lu=s(R2,"Varuna further tries to improve the schedule by using simulations to discover the most efficient scheduling."),R2.forEach(t),$n=f(e),Te=i(e,"P",{});var bh=o(Te);au=s(bh,"OSLO has pipeline parallelism implementation based on the Transformers without "),Co=i(bh,"CODE",{});var Z2=o(Co);iu=s(Z2,"nn.Sequential"),Z2.forEach(t),ou=s(bh," converting."),bh.forEach(t),xn=f(e),re=i(e,"H2",{class:!0});var _h=o(re);Ie=i(_h,"A",{id:!0,class:!0,href:!0});var C2=o(Ie);jo=i(C2,"SPAN",{});var j2=o(jo);P(Et.$$.fragment,j2),j2.forEach(t),C2.forEach(t),ru=f(_h),Fo=i(_h,"SPAN",{});var F2=o(Fo);su=s(F2,"Tensor Parallelism"),F2.forEach(t),_h.forEach(t),zn=f(e),ba=i(e,"P",{});var B2=o(ba);nu=s(B2,"In Tensor Parallelism each GPU processes only a slice of a tensor and only aggregates the full tensor for operations that require the whole thing."),B2.forEach(t),Nn=f(e),j=i(e,"P",{});var Si=o(j);pu=s(Si,"In this section we use concepts and diagrams from the "),gt=i(Si,"A",{href:!0,rel:!0});var q2=o(gt);hu=s(q2,"Megatron-LM"),q2.forEach(t),fu=s(Si," paper: "),Lt=i(Si,"A",{href:!0,rel:!0});var W2=o(Lt);du=s(W2,"Efficient Large-Scale Language Model Training on GPU Clusters"),W2.forEach(t),cu=s(Si,"."),Si.forEach(t),Rn=f(e),F=i(e,"P",{});var Ai=o(F);uu=s(Ai,"The main building block of any transformer is a fully connected "),Bo=i(Ai,"CODE",{});var V2=o(Bo);mu=s(V2,"nn.Linear"),V2.forEach(t),vu=s(Ai," followed by a nonlinear activation "),qo=i(Ai,"CODE",{});var H2=o(qo);Pu=s(H2,"GeLU"),H2.forEach(t),wu=s(Ai,"."),Ai.forEach(t),Zn=f(e),g=i(e,"P",{});var X=o(g);yu=s(X,"Following the Megatron\u2019s paper notation, we can write the dot-product part of it as "),Wo=i(X,"CODE",{});var X2=o(Wo);bu=s(X2,"Y = GeLU(XA)"),X2.forEach(t),_u=s(X,", where "),Vo=i(X,"CODE",{});var Y2=o(Vo);Eu=s(Y2,"X"),Y2.forEach(t),gu=s(X," and "),Ho=i(X,"CODE",{});var J2=o(Ho);Lu=s(J2,"Y"),J2.forEach(t),Du=s(X," are the input and output vectors, and "),Xo=i(X,"CODE",{});var K2=o(Xo);Gu=s(K2,"A"),K2.forEach(t),Uu=s(X," is the weight matrix."),X.forEach(t),Cn=f(e),Dt=i(e,"P",{});var h1=o(Dt);ku=s(h1,`If we look at the computation in matrix form, it\u2019s easy to see how the matrix multiplication can be split between multiple GPUs:
`),_a=i(h1,"IMG",{src:!0,alt:!0}),h1.forEach(t),jn=f(e),c=i(e,"P",{});var m=o(c);Tu=s(m,"If we split the weight matrix "),Yo=i(m,"CODE",{});var Q2=o(Yo);Iu=s(Q2,"A"),Q2.forEach(t),Su=s(m," column-wise across "),Jo=i(m,"CODE",{});var ey=o(Jo);Au=s(ey,"N"),ey.forEach(t),Ou=s(m," GPUs and perform matrix multiplications "),Ko=i(m,"CODE",{});var ty=o(Ko);Mu=s(ty,"XA_1"),ty.forEach(t),$u=s(m," through "),Qo=i(m,"CODE",{});var ly=o(Qo);xu=s(ly,"XA_n"),ly.forEach(t),zu=s(m," in parallel, then we will end up with "),er=i(m,"CODE",{});var ay=o(er);Nu=s(ay,"N"),ay.forEach(t),Ru=s(m," output vectors "),tr=i(m,"CODE",{});var iy=o(tr);Zu=s(iy,"Y_1, Y_2, ..., Y_n"),iy.forEach(t),Cu=s(m," which can be fed into "),lr=i(m,"CODE",{});var oy=o(lr);ju=s(oy,"GeLU"),oy.forEach(t),Fu=s(m,` independently:
`),Ea=i(m,"IMG",{src:!0,alt:!0}),m.forEach(t),Fn=f(e),Gt=i(e,"P",{});var f1=o(Gt);Bu=s(f1,`Using this principle, we can update an MLP of arbitrary depth, without the need for any synchronization between GPUs until the very end, where we need to reconstruct the output vector from shards. The Megatron-LM paper authors provide a helpful illustration for that:
`),ga=i(f1,"IMG",{src:!0,alt:!0}),f1.forEach(t),Bn=f(e),Ut=i(e,"P",{});var d1=o(Ut);qu=s(d1,`Parallelizing the multi-headed attention layers is even simpler, since they are already inherently parallel, due to having multiple independent heads!
`),La=i(d1,"IMG",{src:!0,alt:!0}),d1.forEach(t),qn=f(e),Da=i(e,"P",{});var ry=o(Da);Wu=s(ry,"Special considerations: TP requires very fast network, and therefore it\u2019s not advisable to do TP across more than one node. Practically, if a node has 4 GPUs, the highest TP degree is therefore 4. If you need a TP degree of 8, you need to use nodes that have at least 8 GPUs."),ry.forEach(t),Wn=f(e),B=i(e,"P",{});var Oi=o(B);Vu=s(Oi,"This section is based on the original much more "),kt=i(Oi,"A",{href:!0,rel:!0});var sy=o(kt);Hu=s(sy,"detailed TP overview"),sy.forEach(t),Xu=s(Oi,`.
by `),Tt=i(Oi,"A",{href:!0,rel:!0});var ny=o(Tt);Yu=s(ny,"@anton-l"),ny.forEach(t),Ju=s(Oi,"."),Oi.forEach(t),Vn=f(e),Ga=i(e,"P",{});var py=o(Ga);Ku=s(py,"SageMaker combines TP with DP for a more efficient processing."),py.forEach(t),Hn=f(e),Ua=i(e,"P",{});var hy=o(Ua);Qu=s(hy,"Alternative names:"),hy.forEach(t),Xn=f(e),ka=i(e,"UL",{});var fy=o(ka);Ta=i(fy,"LI",{});var c1=o(Ta);em=s(c1,"DeepSpeed calls it "),It=i(c1,"A",{href:!0,rel:!0});var dy=o(It);tm=s(dy,"tensor slicing"),dy.forEach(t),c1.forEach(t),fy.forEach(t),Yn=f(e),Ia=i(e,"P",{});var cy=o(Ia);lm=s(cy,"Implementations:"),cy.forEach(t),Jn=f(e),S=i(e,"UL",{});var Ve=o(S);Sa=i(Ve,"LI",{});var u1=o(Sa);St=i(u1,"A",{href:!0,rel:!0});var uy=o(St);am=s(uy,"Megatron-LM"),uy.forEach(t),im=s(u1," has an internal implementation, as it\u2019s very model-specific"),u1.forEach(t),om=f(Ve),Aa=i(Ve,"LI",{});var m1=o(Aa);At=i(m1,"A",{href:!0,rel:!0});var my=o(At);rm=s(my,"parallelformers"),my.forEach(t),sm=s(m1," (only inference at the moment)"),m1.forEach(t),nm=f(Ve),Oa=i(Ve,"LI",{});var v1=o(Oa);Ot=i(v1,"A",{href:!0,rel:!0});var vy=o(Ot);pm=s(vy,"SageMaker"),vy.forEach(t),hm=s(v1," - this is a proprietary solution that can only be used on AWS."),v1.forEach(t),fm=f(Ve),Ma=i(Ve,"LI",{});var P1=o(Ma);Mt=i(P1,"A",{href:!0,rel:!0});var Py=o(Mt);dm=s(Py,"OSLO"),Py.forEach(t),cm=s(P1," has the tensor parallelism implementation based on the Transformers."),P1.forEach(t),Ve.forEach(t),Kn=f(e),$a=i(e,"P",{});var wy=o($a);um=s(wy,"\u{1F917} Transformers status:"),wy.forEach(t),Qn=f(e),q=i(e,"UL",{});var Mi=o(q);ar=i(Mi,"LI",{});var yy=o(ar);mm=s(yy,"core: not yet implemented in the core"),yy.forEach(t),vm=f(Mi),$t=i(Mi,"LI",{});var Eh=o($t);Pm=s(Eh,"but if you want inference "),xt=i(Eh,"A",{href:!0,rel:!0});var by=o(xt);wm=s(by,"parallelformers"),by.forEach(t),ym=s(Eh," provides this support for most of our models. So until this is implemented in the core you can use theirs. And hopefully training mode will be supported too."),Eh.forEach(t),bm=f(Mi),xa=i(Mi,"LI",{});var w1=o(xa);_m=s(w1,"Deepspeed-Inference also supports our BERT, GPT-2, and GPT-Neo models in their super-fast CUDA-kernel-based inference mode, see more "),zt=i(w1,"A",{href:!0,rel:!0});var _y=o(zt);Em=s(_y,"here"),_y.forEach(t),w1.forEach(t),Mi.forEach(t),ep=f(e),se=i(e,"H2",{class:!0});var gh=o(se);Se=i(gh,"A",{id:!0,class:!0,href:!0});var Ey=o(Se);ir=i(Ey,"SPAN",{});var gy=o(ir);P(Nt.$$.fragment,gy),gy.forEach(t),Ey.forEach(t),gm=f(gh),or=i(gh,"SPAN",{});var Ly=o(or);Lm=s(Ly,"DP+PP"),Ly.forEach(t),gh.forEach(t),tp=f(e),Ae=i(e,"P",{});var Lh=o(Ae);Dm=s(Lh,"The following diagram from the DeepSpeed "),Rt=i(Lh,"A",{href:!0,rel:!0});var Dy=o(Rt);Gm=s(Dy,"pipeline tutorial"),Dy.forEach(t),Um=s(Lh," demonstrates how one combines DP with PP."),Lh.forEach(t),lp=f(e),za=i(e,"P",{});var Gy=o(za);Na=i(Gy,"IMG",{src:!0,alt:!0}),Gy.forEach(t),ap=f(e),Ra=i(e,"P",{});var Uy=o(Ra);km=s(Uy,"Here it\u2019s important to see how DP rank 0 doesn\u2019t see GPU2 and DP rank 1 doesn\u2019t see GPU3. To DP there is just GPUs 0 and 1 where it feeds data as if there were just 2 GPUs. GPU0 \u201Csecretly\u201D offloads some of its load to GPU2 using PP. And GPU1 does the same by enlisting GPU3 to its aid."),Uy.forEach(t),ip=f(e),Za=i(e,"P",{});var ky=o(Za);Tm=s(ky,"Since each dimension requires at least 2 GPUs, here you\u2019d need at least 4 GPUs."),ky.forEach(t),op=f(e),Ca=i(e,"P",{});var Ty=o(Ca);Im=s(Ty,"Implementations:"),Ty.forEach(t),rp=f(e),L=i(e,"UL",{});var Y=o(L);rr=i(Y,"LI",{});var Iy=o(rr);Zt=i(Iy,"A",{href:!0,rel:!0});var Sy=o(Zt);Sm=s(Sy,"DeepSpeed"),Sy.forEach(t),Iy.forEach(t),Am=f(Y),sr=i(Y,"LI",{});var Ay=o(sr);Ct=i(Ay,"A",{href:!0,rel:!0});var Oy=o(Ct);Om=s(Oy,"Megatron-LM"),Oy.forEach(t),Ay.forEach(t),Mm=f(Y),nr=i(Y,"LI",{});var My=o(nr);jt=i(My,"A",{href:!0,rel:!0});var $y=o(jt);$m=s($y,"Varuna"),$y.forEach(t),My.forEach(t),xm=f(Y),pr=i(Y,"LI",{});var xy=o(pr);Ft=i(xy,"A",{href:!0,rel:!0});var zy=o(Ft);zm=s(zy,"SageMaker"),zy.forEach(t),xy.forEach(t),Nm=f(Y),hr=i(Y,"LI",{});var Ny=o(hr);Bt=i(Ny,"A",{href:!0,rel:!0});var Ry=o(Bt);Rm=s(Ry,"OSLO"),Ry.forEach(t),Ny.forEach(t),Y.forEach(t),sp=f(e),ja=i(e,"P",{});var Zy=o(ja);Zm=s(Zy,"\u{1F917} Transformers status: not yet implemented"),Zy.forEach(t),np=f(e),ne=i(e,"H2",{class:!0});var Dh=o(ne);Oe=i(Dh,"A",{id:!0,class:!0,href:!0});var Cy=o(Oe);fr=i(Cy,"SPAN",{});var jy=o(fr);P(qt.$$.fragment,jy),jy.forEach(t),Cy.forEach(t),Cm=f(Dh),dr=i(Dh,"SPAN",{});var Fy=o(dr);jm=s(Fy,"DP+PP+TP"),Fy.forEach(t),Dh.forEach(t),pp=f(e),Fa=i(e,"P",{});var By=o(Fa);Fm=s(By,"To get an even more efficient training a 3D parallelism is used where PP is combined with TP and DP. This can be seen in the following diagram."),By.forEach(t),hp=f(e),Ba=i(e,"P",{});var qy=o(Ba);qa=i(qy,"IMG",{src:!0,alt:!0}),qy.forEach(t),fp=f(e),Me=i(e,"P",{});var Gh=o(Me);Bm=s(Gh,"This diagram is from a blog post "),Wt=i(Gh,"A",{href:!0,rel:!0});var Wy=o(Wt);qm=s(Wy,"3D parallelism: Scaling to trillion-parameter models"),Wy.forEach(t),Wm=s(Gh,", which is a good read as well."),Gh.forEach(t),dp=f(e),Wa=i(e,"P",{});var Vy=o(Wa);Vm=s(Vy,"Since each dimension requires at least 2 GPUs, here you\u2019d need at least 8 GPUs."),Vy.forEach(t),cp=f(e),Va=i(e,"P",{});var Hy=o(Va);Hm=s(Hy,"Implementations:"),Hy.forEach(t),up=f(e),D=i(e,"UL",{});var J=o(D);Ha=i(J,"LI",{});var y1=o(Ha);Vt=i(y1,"A",{href:!0,rel:!0});var Xy=o(Vt);Xm=s(Xy,"DeepSpeed"),Xy.forEach(t),Ym=s(y1," - DeepSpeed also includes an even more efficient DP, which they call ZeRO-DP."),y1.forEach(t),Jm=f(J),cr=i(J,"LI",{});var Yy=o(cr);Ht=i(Yy,"A",{href:!0,rel:!0});var Jy=o(Ht);Km=s(Jy,"Megatron-LM"),Jy.forEach(t),Yy.forEach(t),Qm=f(J),ur=i(J,"LI",{});var Ky=o(ur);Xt=i(Ky,"A",{href:!0,rel:!0});var Qy=o(Xt);ev=s(Qy,"Varuna"),Qy.forEach(t),Ky.forEach(t),tv=f(J),mr=i(J,"LI",{});var eb=o(mr);Yt=i(eb,"A",{href:!0,rel:!0});var tb=o(Yt);lv=s(tb,"SageMaker"),tb.forEach(t),eb.forEach(t),av=f(J),vr=i(J,"LI",{});var lb=o(vr);Jt=i(lb,"A",{href:!0,rel:!0});var ab=o(Jt);iv=s(ab,"OSLO"),ab.forEach(t),lb.forEach(t),J.forEach(t),mp=f(e),Xa=i(e,"P",{});var ib=o(Xa);ov=s(ib,"\u{1F917} Transformers status: not yet implemented, since we have no PP and TP."),ib.forEach(t),vp=f(e),pe=i(e,"H2",{class:!0});var Uh=o(pe);$e=i(Uh,"A",{id:!0,class:!0,href:!0});var ob=o($e);Pr=i(ob,"SPAN",{});var rb=o(Pr);P(Kt.$$.fragment,rb),rb.forEach(t),ob.forEach(t),rv=f(Uh),wr=i(Uh,"SPAN",{});var sb=o(wr);sv=s(sb,"ZeRO DP+PP+TP"),sb.forEach(t),Uh.forEach(t),Pp=f(e),xe=i(e,"P",{});var kh=o(xe);nv=s(kh,"One of the main features of DeepSpeed is ZeRO, which is a super-scalable extension of DP. It has already been discussed in "),Ya=i(kh,"A",{href:!0});var nb=o(Ya);pv=s(nb,"ZeRO Data Parallelism"),nb.forEach(t),hv=s(kh,". Normally it\u2019s a standalone feature that doesn\u2019t require PP or TP. But it can be combined with PP and TP."),kh.forEach(t),wp=f(e),Ja=i(e,"P",{});var pb=o(Ja);fv=s(pb,"When ZeRO-DP is combined with PP (and optionally TP) it typically enables only ZeRO stage 1 (optimizer sharding)."),pb.forEach(t),yp=f(e),Ka=i(e,"P",{});var hb=o(Ka);dv=s(hb,"While it\u2019s theoretically possible to use ZeRO stage 2 (gradient sharding) with Pipeline Parallelism, it will have bad performance impacts. There would need to be an additional reduce-scatter collective for every micro-batch to aggregate the gradients before sharding, which adds a potentially significant communication overhead. By nature of Pipeline Parallelism, small micro-batches are used and instead the focus is on trying to balance arithmetic intensity (micro-batch size) with minimizing the Pipeline bubble (number of micro-batches). Therefore those communication costs are going to hurt."),hb.forEach(t),bp=f(e),ze=i(e,"P",{});var Th=o(ze);cv=s(Th,"In addition, There are already fewer layers than normal due to PP and so the memory savings won\u2019t be huge. PP already reduces gradient size by "),yr=i(Th,"CODE",{});var fb=o(yr);uv=s(fb,"1/PP"),fb.forEach(t),mv=s(Th,", and so gradient sharding savings on top of that are less significant than pure DP."),Th.forEach(t),_p=f(e),Qa=i(e,"P",{});var db=o(Qa);vv=s(db,"ZeRO stage 3 is not a good choice either for the same reason - more inter-node communications required."),db.forEach(t),Ep=f(e),ei=i(e,"P",{});var cb=o(ei);Pv=s(cb,"And since we have ZeRO, the other benefit is ZeRO-Offload. Since this is stage 1 optimizer states can be offloaded to CPU."),cb.forEach(t),gp=f(e),ti=i(e,"P",{});var ub=o(ti);wv=s(ub,"Implementations:"),ub.forEach(t),Lp=f(e),Ne=i(e,"UL",{});var Ih=o(Ne);Re=i(Ih,"LI",{});var us=o(Re);Qt=i(us,"A",{href:!0,rel:!0});var mb=o(Qt);yv=s(mb,"Megatron-DeepSpeed"),mb.forEach(t),bv=s(us," and "),el=i(us,"A",{href:!0,rel:!0});var vb=o(el);_v=s(vb,"Megatron-Deepspeed from BigScience"),vb.forEach(t),Ev=s(us,", which is the fork of the former repo."),us.forEach(t),gv=f(Ih),br=i(Ih,"LI",{});var Pb=o(br);tl=i(Pb,"A",{href:!0,rel:!0});var wb=o(tl);Lv=s(wb,"OSLO"),wb.forEach(t),Pb.forEach(t),Ih.forEach(t),Dp=f(e),li=i(e,"P",{});var yb=o(li);Dv=s(yb,"Important papers:"),yb.forEach(t),Gp=f(e),ai=i(e,"UL",{});var bb=o(ai);_r=i(bb,"LI",{});var _b=o(_r);ll=i(_b,"A",{href:!0,rel:!0});var Eb=o(ll);Gv=s(Eb,"Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530B, A Large-Scale Generative Language Model"),Eb.forEach(t),_b.forEach(t),bb.forEach(t),Up=f(e),ii=i(e,"P",{});var gb=o(ii);Uv=s(gb,"\u{1F917} Transformers status: not yet implemented, since we have no PP and TP."),gb.forEach(t),kp=f(e),he=i(e,"H2",{class:!0});var Sh=o(he);Ze=i(Sh,"A",{id:!0,class:!0,href:!0});var Lb=o(Ze);Er=i(Lb,"SPAN",{});var Db=o(Er);P(al.$$.fragment,Db),Db.forEach(t),Lb.forEach(t),kv=f(Sh),gr=i(Sh,"SPAN",{});var Gb=o(gr);Tv=s(Gb,"FlexFlow"),Gb.forEach(t),Sh.forEach(t),Tp=f(e),il=i(e,"P",{});var b1=o(il);ol=i(b1,"A",{href:!0,rel:!0});var Ub=o(ol);Iv=s(Ub,"FlexFlow"),Ub.forEach(t),Sv=s(b1," also solves the parallelization problem in a slightly different approach."),b1.forEach(t),Ip=f(e),rl=i(e,"P",{});var _1=o(rl);Av=s(_1,"Paper: "),sl=i(_1,"A",{href:!0,rel:!0});var kb=o(sl);Ov=s(kb,"\u201CBeyond Data and Model Parallelism for Deep Neural Networks\u201D by Zhihao Jia, Matei Zaharia, Alex Aiken"),kb.forEach(t),_1.forEach(t),Sp=f(e),oi=i(e,"P",{});var Tb=o(oi);Mv=s(Tb,"It performs a sort of 4D Parallelism over Sample-Operator-Attribute-Parameter."),Tb.forEach(t),Ap=f(e),A=i(e,"OL",{});var He=o(A);Lr=i(He,"LI",{});var Ib=o(Lr);$v=s(Ib,"Sample = Data Parallelism (sample-wise parallel)"),Ib.forEach(t),xv=f(He),Dr=i(He,"LI",{});var Sb=o(Dr);zv=s(Sb,"Operator = Parallelize a single operation into several sub-operations"),Sb.forEach(t),Nv=f(He),Gr=i(He,"LI",{});var Ab=o(Gr);Rv=s(Ab,"Attribute = Data Parallelism (length-wise parallel)"),Ab.forEach(t),Zv=f(He),Ur=i(He,"LI",{});var Ob=o(Ur);Cv=s(Ob,"Parameter = Model Parallelism (regardless of dimension - horizontal or vertical)"),Ob.forEach(t),He.forEach(t),Op=f(e),ri=i(e,"P",{});var Mb=o(ri);jv=s(Mb,"Examples:"),Mb.forEach(t),Mp=f(e),si=i(e,"UL",{});var $b=o(si);kr=i($b,"LI",{});var xb=o(kr);Fv=s(xb,"Sample"),xb.forEach(t),$b.forEach(t),$p=f(e),ni=i(e,"P",{});var zb=o(ni);Bv=s(zb,"Let\u2019s take 10 batches of sequence length 512. If we parallelize them by sample dimension into 2 devices, we get 10 x 512 which becomes be 5 x 2 x 512."),zb.forEach(t),xp=f(e),pi=i(e,"UL",{});var Nb=o(pi);Tr=i(Nb,"LI",{});var Rb=o(Tr);qv=s(Rb,"Operator"),Rb.forEach(t),Nb.forEach(t),zp=f(e),hi=i(e,"P",{});var Zb=o(hi);Wv=s(Zb,"If we perform layer normalization, we compute std first and mean second, and then we can normalize data. Operator parallelism allows computing std and mean in parallel. So if we parallelize them by operator dimension into 2 devices (cuda:0, cuda:1), first we copy input data into both devices, and cuda:0 computes std, cuda:1 computes mean at the same time."),Zb.forEach(t),Np=f(e),fi=i(e,"UL",{});var Cb=o(fi);Ir=i(Cb,"LI",{});var jb=o(Ir);Vv=s(jb,"Attribute"),jb.forEach(t),Cb.forEach(t),Rp=f(e),di=i(e,"P",{});var Fb=o(di);Hv=s(Fb,"We have 10 batches of 512 length. If we parallelize them by attribute dimension into 2 devices, 10 x 512 will be 10 x 2 x 256."),Fb.forEach(t),Zp=f(e),ci=i(e,"UL",{});var Bb=o(ci);Sr=i(Bb,"LI",{});var qb=o(Sr);Xv=s(qb,"Parameter"),qb.forEach(t),Bb.forEach(t),Cp=f(e),ui=i(e,"P",{});var Wb=o(ui);Yv=s(Wb,"It is similar with tensor model parallelism or naive layer-wise model parallelism."),Wb.forEach(t),jp=f(e),mi=i(e,"P",{});var Vb=o(mi);vi=i(Vb,"IMG",{src:!0,alt:!0}),Vb.forEach(t),Fp=f(e),Pi=i(e,"P",{});var Hb=o(Pi);Jv=s(Hb,"The significance of this framework is that it takes resources like (1) GPU/TPU/CPU vs. (2) RAM/DRAM vs. (3) fast-intra-connect/slow-inter-connect and it automatically optimizes all these  algorithmically deciding which parallelisation to use where."),Hb.forEach(t),Bp=f(e),wi=i(e,"P",{});var Xb=o(wi);Kv=s(Xb,"One very important aspect is that FlexFlow is designed for optimizing DNN parallelizations for models with static and fixed workloads, since models with dynamic behavior may prefer different parallelization strategies across iterations."),Xb.forEach(t),qp=f(e),yi=i(e,"P",{});var Yb=o(yi);Qv=s(Yb,"So the promise is very attractive - it runs a 30min simulation on the cluster of choice and it comes up with the best strategy to utilise this specific environment. If you add/remove/replace any parts it\u2019ll run and re-optimize the plan for that. And then you can train. A different setup will have its own custom optimization."),Yb.forEach(t),Wp=f(e),Ce=i(e,"P",{});var Ah=o(Ce);eP=s(Ah,"\u{1F917} Transformers status: not yet integrated. We already have our models FX-trace-able via "),nl=i(Ah,"A",{href:!0,rel:!0});var Jb=o(nl);tP=s(Jb,"transformers.utils.fx"),Jb.forEach(t),lP=s(Ah,", which is a prerequisite for FlexFlow, so someone needs to figure out what needs to be done to make FlexFlow work with our models."),Ah.forEach(t),Vp=f(e),fe=i(e,"H2",{class:!0});var Oh=o(fe);je=i(Oh,"A",{id:!0,class:!0,href:!0});var Kb=o(je);Ar=i(Kb,"SPAN",{});var Qb=o(Ar);P(pl.$$.fragment,Qb),Qb.forEach(t),Kb.forEach(t),aP=f(Oh),Or=i(Oh,"SPAN",{});var e3=o(Or);iP=s(e3,"Which Strategy To Use When"),e3.forEach(t),Oh.forEach(t),Hp=f(e),bi=i(e,"P",{});var t3=o(bi);oP=s(t3,"Here is a very rough outline at which parallelism strategy to use when. The first on each list is typically faster."),t3.forEach(t),Xp=f(e),_i=i(e,"P",{});var l3=o(_i);Mr=i(l3,"STRONG",{});var a3=o(Mr);rP=s(a3,"\u21E8 Single GPU"),a3.forEach(t),l3.forEach(t),Yp=f(e),W=i(e,"UL",{});var $i=o(W);hl=i($i,"LI",{});var Mh=o(hl);$r=i(Mh,"P",{});var i3=o($r);sP=s(i3,"Model fits onto a single GPU:"),i3.forEach(t),nP=f(Mh),xr=i(Mh,"OL",{});var o3=o(xr);zr=i(o3,"LI",{});var r3=o(zr);pP=s(r3,"Normal use"),r3.forEach(t),o3.forEach(t),Mh.forEach(t),hP=f($i),fl=i($i,"LI",{});var $h=o(fl);Nr=i($h,"P",{});var s3=o(Nr);fP=s(s3,"Model doesn\u2019t fit onto a single GPU:"),s3.forEach(t),dP=f($h),dl=i($h,"OL",{});var xh=o(dl);Rr=i(xh,"LI",{});var n3=o(Rr);cP=s(n3,"ZeRO + Offload CPU and optionally NVMe"),n3.forEach(t),uP=f(xh),Zr=i(xh,"LI",{});var p3=o(Zr);mP=s(p3,"as above plus Memory Centric Tiling (see below for details) if the largest layer can\u2019t fit into a single GPU"),p3.forEach(t),xh.forEach(t),$h.forEach(t),vP=f($i),Cr=i($i,"LI",{});var h3=o(Cr);jr=i(h3,"P",{});var f3=o(jr);PP=s(f3,"Largest Layer not fitting into a single GPU:"),f3.forEach(t),h3.forEach(t),$i.forEach(t),Jp=f(e),Ei=i(e,"OL",{});var d3=o(Ei);de=i(d3,"LI",{});var xi=o(de);wP=s(xi,"ZeRO - Enable "),cl=i(xi,"A",{href:!0,rel:!0});var c3=o(cl);yP=s(c3,"Memory Centric Tiling"),c3.forEach(t),bP=s(xi," (MCT). It allows you to run arbitrarily large layers by automatically splitting them and executing them sequentially. MCT reduces the number of parameters that are live on a GPU, but it does not affect the activation memory. As this need is very rare as of this writing a manual override of "),Fr=i(xi,"CODE",{});var u3=o(Fr);_P=s(u3,"torch.nn.Linear"),u3.forEach(t),EP=s(xi," needs to be done by the user."),xi.forEach(t),d3.forEach(t),Kp=f(e),gi=i(e,"P",{});var m3=o(gi);Br=i(m3,"STRONG",{});var v3=o(Br);gP=s(v3,"\u21E8 Single Node / Multi-GPU"),v3.forEach(t),m3.forEach(t),Qp=f(e),V=i(e,"UL",{});var zi=o(V);ul=i(zi,"LI",{});var zh=o(ul);qr=i(zh,"P",{});var P3=o(qr);LP=s(P3,"Model fits onto a single GPU:"),P3.forEach(t),DP=f(zh),ml=i(zh,"OL",{});var Nh=o(ml);Wr=i(Nh,"LI",{});var w3=o(Wr);GP=s(w3,"DDP - Distributed DP"),w3.forEach(t),UP=f(Nh),Vr=i(Nh,"LI",{});var y3=o(Vr);kP=s(y3,"ZeRO - may or may not be faster depending on the situation and configuration used"),y3.forEach(t),Nh.forEach(t),zh.forEach(t),TP=f(zi),vl=i(zi,"LI",{});var Rh=o(vl);Hr=i(Rh,"P",{});var b3=o(Hr);IP=s(b3,"Model doesn\u2019t fit onto a single GPU:"),b3.forEach(t),SP=f(Rh),ce=i(Rh,"OL",{});var Ni=o(ce);Xr=i(Ni,"LI",{});var _3=o(Xr);Yr=i(_3,"P",{});var E3=o(Yr);AP=s(E3,"PP"),E3.forEach(t),_3.forEach(t),OP=f(Ni),Jr=i(Ni,"LI",{});var g3=o(Jr);Kr=i(g3,"P",{});var L3=o(Kr);MP=s(L3,"ZeRO"),L3.forEach(t),g3.forEach(t),$P=f(Ni),ue=i(Ni,"LI",{});var Ri=o(ue);Qr=i(Ri,"P",{});var D3=o(Qr);xP=s(D3,"TP"),D3.forEach(t),zP=f(Ri),es=i(Ri,"P",{});var G3=o(es);NP=s(G3,"With very fast intra-node connectivity of NVLINK or NVSwitch all three should be mostly on par, without these PP will be faster than TP or ZeRO. The degree of TP may also make a difference. Best to experiment to find the winner on your particular setup."),G3.forEach(t),RP=f(Ri),ts=i(Ri,"P",{});var U3=o(ts);ZP=s(U3,"TP is almost always used within a single node. That is TP size <= gpus per node."),U3.forEach(t),Ri.forEach(t),Ni.forEach(t),Rh.forEach(t),CP=f(zi),Pl=i(zi,"LI",{});var Zh=o(Pl);ls=i(Zh,"P",{});var k3=o(ls);jP=s(k3,"Largest Layer not fitting into a single GPU:"),k3.forEach(t),FP=f(Zh),wl=i(Zh,"OL",{});var Ch=o(wl);as=i(Ch,"LI",{});var T3=o(as);BP=s(T3,"If not using ZeRO - must use TP, as PP alone won\u2019t be able to fit."),T3.forEach(t),qP=f(Ch),is=i(Ch,"LI",{});var I3=o(is);WP=s(I3,"With ZeRO see the same entry for \u201CSingle GPU\u201D above"),I3.forEach(t),Ch.forEach(t),Zh.forEach(t),zi.forEach(t),eh=f(e),Li=i(e,"P",{});var S3=o(Li);os=i(S3,"STRONG",{});var A3=o(os);VP=s(A3,"\u21E8 Multi-Node / Multi-GPU"),A3.forEach(t),S3.forEach(t),th=f(e),Fe=i(e,"UL",{});var jh=o(Fe);yl=i(jh,"LI",{});var Fh=o(yl);rs=i(Fh,"P",{});var O3=o(rs);HP=s(O3,"When you have fast inter-node connectivity:"),O3.forEach(t),XP=f(Fh),bl=i(Fh,"OL",{});var Bh=o(bl);ss=i(Bh,"LI",{});var M3=o(ss);YP=s(M3,"ZeRO - as it requires close to no modifications to the model"),M3.forEach(t),JP=f(Bh),ns=i(Bh,"LI",{});var $3=o(ns);KP=s($3,"PP+TP+DP - less communications, but requires massive changes to the model"),$3.forEach(t),Bh.forEach(t),Fh.forEach(t),QP=f(jh),_l=i(jh,"LI",{});var qh=o(_l);ps=i(qh,"P",{});var x3=o(ps);e1=s(x3,"when you have slow inter-node connectivity and still low on GPU memory:"),x3.forEach(t),t1=f(qh),hs=i(qh,"OL",{});var z3=o(hs);fs=i(z3,"LI",{});var N3=o(fs);l1=s(N3,"DP+PP+TP+ZeRO-1"),N3.forEach(t),z3.forEach(t),qh.forEach(t),jh.forEach(t),this.h()},h(){d($,"name","hf:doc:metadata"),d($,"content",JSON.stringify(q3)),d(M,"id","model-parallelism"),d(M,"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"),d(M,"href","#model-parallelism"),d(U,"class","relative group"),d(me,"id","parallelism-overview"),d(me,"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"),d(me,"href","#parallelism-overview"),d(Q,"class","relative group"),d(Pe,"id","concepts"),d(Pe,"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"),d(Pe,"href","#concepts"),d(ee,"class","relative group"),d(we,"id","data-parallelism"),d(we,"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"),d(we,"href","#data-parallelism"),d(te,"class","relative group"),d(ye,"id","zero-data-parallelism"),d(ye,"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"),d(ye,"href","#zero-data-parallelism"),d(le,"class","relative group"),d(et,"href","https://www.microsoft.com/en-us/research/blog/zero-deepspeed-new-system-optimizations-enable-training-models-with-over-100-billion-parameters/"),d(et,"rel","nofollow"),K(Ul.src,E1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-zero.png")||d(Ul,"src",E1),d(Ul,"alt","DeepSpeed-Image-1"),d(it,"href","https://www.deepspeed.ai/features/#the-zero-redundancy-optimizer"),d(it,"rel","nofollow"),d(ot,"href","https://github.com/facebookresearch/fairscale/#optimizer-state-sharding-zero"),d(ot,"rel","nofollow"),d(rt,"href","main_classes/trainer#trainer-integrations"),d(_e,"id","naive-model-parallelism-vertical-and-pipeline-parallelism"),d(_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"),d(_e,"href","#naive-model-parallelism-vertical-and-pipeline-parallelism"),d(ie,"class","relative group"),d(pt,"href","https://ai.googleblog.com/2019/03/introducing-gpipe-open-source-library.html"),d(pt,"rel","nofollow"),K(la.src,g1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-gpipe-bubble.png")||d(la,"src",g1),d(la,"alt","mp-pp"),d(ft,"href","https://github.com/pytorch/pytorch/pull/50693"),d(ft,"rel","nofollow"),d(ct,"href","https://pytorch.org/docs/stable/pipeline.html"),d(ct,"rel","nofollow"),d(ut,"href","https://github.com/pytorch/pytorch/blob/master/benchmarks/distributed/pipeline/pipe.py"),d(ut,"rel","nofollow"),d(mt,"href","https://fairscale.readthedocs.io/en/latest/tutorials/pipe.html"),d(mt,"rel","nofollow"),d(vt,"href","https://www.deepspeed.ai/tutorials/pipeline/"),d(vt,"rel","nofollow"),d(Pt,"href","https://github.com/NVIDIA/Megatron-LM"),d(Pt,"rel","nofollow"),d(wt,"href","https://github.com/microsoft/varuna"),d(wt,"rel","nofollow"),d(yt,"href","https://arxiv.org/abs/2111.05972"),d(yt,"rel","nofollow"),d(bt,"href","https://github.com/tunib-ai/oslo"),d(bt,"rel","nofollow"),d(_t,"href","https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel-core-features.html"),d(_t,"rel","nofollow"),K(Pa.src,L1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-sagemaker-interleaved-pipeline.png")||d(Pa,"src",L1),d(Pa,"alt","interleaved-pipeline-execution"),d(Ie,"id","tensor-parallelism"),d(Ie,"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"),d(Ie,"href","#tensor-parallelism"),d(re,"class","relative group"),d(gt,"href","https://github.com/NVIDIA/Megatron-LM"),d(gt,"rel","nofollow"),d(Lt,"href","https://arxiv.org/abs/2104.04473"),d(Lt,"rel","nofollow"),K(_a.src,D1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-tp-parallel_gemm.png")||d(_a,"src",D1),d(_a,"alt","Parallel GEMM"),K(Ea.src,G1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-tp-independent-gelu.png")||d(Ea,"src",G1),d(Ea,"alt","independent GeLU"),K(ga.src,U1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-tp-parallel_shard_processing.png")||d(ga,"src",U1),d(ga,"alt","parallel shard processing"),K(La.src,k1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-tp-parallel_self_attention.png")||d(La,"src",k1),d(La,"alt","parallel self-attention"),d(kt,"href","https://github.com/huggingface/transformers/issues/10321#issuecomment-783543530"),d(kt,"rel","nofollow"),d(Tt,"href","https://github.com/anton-l"),d(Tt,"rel","nofollow"),d(It,"href","https://www.deepspeed.ai/features/#model-parallelism"),d(It,"rel","nofollow"),d(St,"href","https://github.com/NVIDIA/Megatron-LM"),d(St,"rel","nofollow"),d(At,"href","https://github.com/tunib-ai/parallelformers"),d(At,"rel","nofollow"),d(Ot,"href","https://arxiv.org/abs/2111.05972"),d(Ot,"rel","nofollow"),d(Mt,"href","https://github.com/tunib-ai/oslo"),d(Mt,"rel","nofollow"),d(xt,"href","https://github.com/tunib-ai/parallelformers"),d(xt,"rel","nofollow"),d(zt,"href","https://www.deepspeed.ai/tutorials/inference-tutorial/"),d(zt,"rel","nofollow"),d(Se,"id","dppp"),d(Se,"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"),d(Se,"href","#dppp"),d(se,"class","relative group"),d(Rt,"href","https://www.deepspeed.ai/tutorials/pipeline/"),d(Rt,"rel","nofollow"),K(Na.src,T1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-zero-dp-pp.png")||d(Na,"src",T1),d(Na,"alt","dp-pp-2d"),d(Zt,"href","https://github.com/microsoft/DeepSpeed"),d(Zt,"rel","nofollow"),d(Ct,"href","https://github.com/NVIDIA/Megatron-LM"),d(Ct,"rel","nofollow"),d(jt,"href","https://github.com/microsoft/varuna"),d(jt,"rel","nofollow"),d(Ft,"href","https://arxiv.org/abs/2111.05972"),d(Ft,"rel","nofollow"),d(Bt,"href","https://github.com/tunib-ai/oslo"),d(Bt,"rel","nofollow"),d(Oe,"id","dppptp"),d(Oe,"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"),d(Oe,"href","#dppptp"),d(ne,"class","relative group"),K(qa.src,I1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-deepspeed-3d.png")||d(qa,"src",I1),d(qa,"alt","dp-pp-tp-3d"),d(Wt,"href","https://www.microsoft.com/en-us/research/blog/deepspeed-extreme-scale-model-training-for-everyone/"),d(Wt,"rel","nofollow"),d(Vt,"href","https://github.com/microsoft/DeepSpeed"),d(Vt,"rel","nofollow"),d(Ht,"href","https://github.com/NVIDIA/Megatron-LM"),d(Ht,"rel","nofollow"),d(Xt,"href","https://github.com/microsoft/varuna"),d(Xt,"rel","nofollow"),d(Yt,"href","https://arxiv.org/abs/2111.05972"),d(Yt,"rel","nofollow"),d(Jt,"href","https://github.com/tunib-ai/oslo"),d(Jt,"rel","nofollow"),d($e,"id","zero-dppptp"),d($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"),d($e,"href","#zero-dppptp"),d(pe,"class","relative group"),d(Ya,"href","#zero-data-parallelism"),d(Qt,"href","https://github.com/microsoft/Megatron-DeepSpeed"),d(Qt,"rel","nofollow"),d(el,"href","https://github.com/bigscience-workshop/Megatron-DeepSpeed"),d(el,"rel","nofollow"),d(tl,"href","https://github.com/tunib-ai/oslo"),d(tl,"rel","nofollow"),d(ll,"href","https://arxiv.org/abs/2201.11990"),d(ll,"rel","nofollow"),d(Ze,"id","flexflow"),d(Ze,"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"),d(Ze,"href","#flexflow"),d(he,"class","relative group"),d(ol,"href","https://github.com/flexflow/FlexFlow"),d(ol,"rel","nofollow"),d(sl,"href","https://arxiv.org/abs/1807.05358"),d(sl,"rel","nofollow"),K(vi.src,S1="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/parallelism-flexflow.jpeg")||d(vi,"src",S1),d(vi,"alt","flex-flow-soap"),d(nl,"href","https://github.com/huggingface/transformers/blob/master/src/transformers/utils/fx.py"),d(nl,"rel","nofollow"),d(je,"id","which-strategy-to-use-when"),d(je,"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"),d(je,"href","#which-strategy-to-use-when"),d(fe,"class","relative group"),d(cl,"href","https://deepspeed.readthedocs.io/en/latest/zero3.html#memory-centric-tiling"),d(cl,"rel","nofollow")},m(e,n){l(document.head,$),p(e,El,n),p(e,U,n),l(U,M),l(M,Zi),w(Xe,Zi,null),l(U,Hh),l(U,Ci),l(Ci,Xh),p(e,ms,n),p(e,Q,n),l(Q,me),l(me,ji),w(Ye,ji,null),l(Q,Yh),l(Q,Fi),l(Fi,Jh),p(e,vs,n),p(e,gl,n),l(gl,Kh),p(e,Ps,n),p(e,ve,n),l(ve,Bi),l(Bi,Qh),l(ve,ef),l(ve,qi),l(qi,tf),p(e,ws,n),p(e,Ll,n),l(Ll,lf),p(e,ys,n),p(e,Dl,n),l(Dl,af),p(e,bs,n),p(e,ee,n),l(ee,Pe),l(Pe,Wi),w(Je,Wi,null),l(ee,of),l(ee,Vi),l(Vi,rf),p(e,_s,n),p(e,Gl,n),l(Gl,sf),p(e,Es,n),p(e,E,n),l(E,Hi),l(Hi,nf),l(E,pf),l(E,Xi),l(Xi,hf),l(E,ff),l(E,Yi),l(Yi,df),l(E,cf),l(E,Ji),l(Ji,uf),l(E,mf),l(E,Ki),l(Ki,vf),p(e,gs,n),p(e,te,n),l(te,we),l(we,Qi),w(Ke,Qi,null),l(te,Pf),l(te,eo),l(eo,wf),p(e,Ls,n),p(e,x,n),l(x,yf),l(x,to),l(to,bf),l(x,_f),l(x,lo),l(lo,Ef),l(x,gf),p(e,Ds,n),p(e,le,n),l(le,ye),l(ye,ao),w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ns,KP),l(Fe,QP),l(Fe,_l),l(_l,ps),l(ps,e1),l(_l,t1),l(_l,hs),l(hs,fs),l(fs,l1),lh=!0},p:F3,i(e){lh||(y(Xe.$$.fragment,e),y(Ye.$$.fragment,e),y(Je.$$.fragment,e),y(Ke.$$.fragment,e),y(Qe.$$.fragment,e),y(tt.$$.fragment,e),y(lt.$$.fragment,e),y(at.$$.fragment,e),y(st.$$.fragment,e),y(nt.$$.fragment,e),y(Et.$$.fragment,e),y(Nt.$$.fragment,e),y(qt.$$.fragment,e),y(Kt.$$.fragment,e),y(al.$$.fragment,e),y(pl.$$.fragment,e),lh=!0)},o(e){b(Xe.$$.fragment,e),b(Ye.$$.fragment,e),b(Je.$$.fragment,e),b(Ke.$$.fragment,e),b(Qe.$$.fragment,e),b(tt.$$.fragment,e),b(lt.$$.fragment,e),b(at.$$.fragment,e),b(st.$$.fragment,e),b(nt.$$.fragment,e),b(Et.$$.fragment,e),b(Nt.$$.fragment,e),b(qt.$$.fragment,e),b(Kt.$$.fragment,e),b(al.$$.fragment,e),b(pl.$$.fragment,e),lh=!1},d(e){t($),e&&t(El),e&&t(U),_(Xe),e&&t(ms),e&&t(Q),_(Ye),e&&t(vs),e&&t(gl),e&&t(Ps),e&&t(ve),e&&t(ws),e&&t(Ll),e&&t(ys),e&&t(Dl),e&&t(bs),e&&t(ee),_(Je),e&&t(_s),e&&t(Gl),e&&t(Es),e&&t(E),e&&t(gs),e&&t(te),_(Ke),e&&t(Ls),e&&t(x),e&&t(Ds),e&&t(le),_(Qe),e&&t(Gs),e&&t(ae),e&&t(Us),e&&t(be),e&&t(ks),e&&t(kl),e&&t(Ts),_(tt,e),e&&t(Is),e&&t(Tl),e&&t(Ss),e&&t(Il),e&&t(As),_(lt,e),e&&t(Os),e&&t(Sl),e&&t(Ms),e&&t(Al),e&&t($s),_(at,e),e&&t(xs),e&&t(Ol),e&&t(zs),e&&t(Ml),e&&t(Ns),e&&t($l),e&&t(Rs),e&&t(xl),e&&t(Zs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(ka),e&&t(Yn),e&&t(Ia),e&&t(Jn),e&&t(S),e&&t(Kn),e&&t($a),e&&t(Qn),e&&t(q),e&&t(ep),e&&t(se),_(Nt),e&&t(tp),e&&t(Ae),e&&t(lp),e&&t(za),e&&t(ap),e&&t(Ra),e&&t(ip),e&&t(Za),e&&t(op),e&&t(Ca),e&&t(rp),e&&t(L),e&&t(sp),e&&t(ja),e&&t(np),e&&t(ne),_(qt),e&&t(pp),e&&t(Fa),e&&t(hp),e&&t(Ba),e&&t(fp),e&&t(Me),e&&t(dp),e&&t(Wa),e&&t(cp),e&&t(Va),e&&t(up),e&&t(D),e&&t(mp),e&&t(Xa),e&&t(vp),e&&t(pe),_(Kt),e&&t(Pp),e&&t(xe),e&&t(wp),e&&t(Ja),e&&t(yp),e&&t(Ka),e&&t(bp),e&&t(ze),e&&t(_p),e&&t(Qa),e&&t(Ep),e&&t(ei),e&&t(gp),e&&t(ti),e&&t(Lp),e&&t(Ne),e&&t(Dp),e&&t(li),e&&t(Gp),e&&t(ai),e&&t(Up),e&&t(ii),e&&t(kp),e&&t(he),_(al),e&&t(Tp),e&&t(il),e&&t(Ip),e&&t(rl),e&&t(Sp),e&&t(oi),e&&t(Ap),e&&t(A),e&&t(Op),e&&t(ri),e&&t(Mp),e&&t(si),e&&t($p),e&&t(ni),e&&t(xp),e&&t(pi),e&&t(zp),e&&t(hi),e&&t(Np),e&&t(fi),e&&t(Rp),e&&t(di),e&&t(Zp),e&&t(ci),e&&t(Cp),e&&t(ui),e&&t(jp),e&&t(mi),e&&t(Fp),e&&t(Pi),e&&t(Bp),e&&t(wi),e&&t(qp),e&&t(yi),e&&t(Wp),e&&t(Ce),e&&t(Vp),e&&t(fe),_(pl),e&&t(Hp),e&&t(bi),e&&t(Xp),e&&t(_i),e&&t(Yp),e&&t(W),e&&t(Jp),e&&t(Ei),e&&t(Kp),e&&t(gi),e&&t(Qp),e&&t(V),e&&t(eh),e&&t(Li),e&&t(th),e&&t(Fe)}}}const q3={local:"model-parallelism",sections:[{local:"parallelism-overview",title:"Parallelism overview"},{local:"concepts",title:"Concepts"},{local:"data-parallelism",title:"Data Parallelism"},{local:"zero-data-parallelism",title:"ZeRO Data Parallelism"},{local:"naive-model-parallelism-vertical-and-pipeline-parallelism",title:"Naive Model Parallelism (Vertical) and Pipeline Parallelism"},{local:"tensor-parallelism",title:"Tensor Parallelism"},{local:"dppp",title:"DP+PP"},{local:"dppptp",title:"DP+PP+TP"},{local:"zero-dppptp",title:"ZeRO DP+PP+TP"},{local:"flexflow",title:"FlexFlow"},{local:"which-strategy-to-use-when",title:"Which Strategy To Use When"}],title:"Model Parallelism"};function W3(Vh,$,El){let{fw:U}=$;return Vh.$$set=M=>{"fw"in M&&El(0,U=M.fw)},[U]}class J3 extends R3{constructor($){super();Z3(this,$,W3,B3,C3,{fw:0})}}export{J3 as default,q3 as metadata};
