import{S as Yt,i as Nt,s as St,e as r,k as h,w as f,t as c,M as Vt,c as o,d as a,m as d,a as s,x as u,h as p,b as n,G as t,g as i,y,L as Rt,q as m,o as w,B as M,v as Qt}from"../chunks/vendor-hf-doc-builder.js";import{I as ce}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as S}from"../chunks/CodeBlock-hf-doc-builder.js";function Ft(lt){let v,Ze,j,k,we,V,ma,Me,wa,Ee,_,Ma,R,ba,Ja,Ce,T,B,be,Q,va,Je,ja,Ge,pe,Ta,We,F,Xe,b,Ua,z,ga,Aa,x,Ia,$a,Ye,H,Ne,U,Z,ve,P,ka,je,_a,Se,E,Ba,K,Za,Ea,Ve,D,Re,g,C,Te,L,Ca,Ue,Ga,Qe,J,Wa,ge,Xa,Ya,q,Na,Sa,Fe,O,ze,he,Va,xe,ee,He,A,G,Ae,ae,Ra,Ie,Qa,Pe,de,Fa,Ke,I,W,$e,te,za,ke,xa,De,fe,Ha,Le,le,qe,ue,Pa,Oe,re,ea,$,X,_e,oe,Ka,Be,Da,aa,Y,La,se,qa,Oa,ta,ne,la,N,et,ie,at,tt,ra;return V=new ce({}),Q=new ce({}),F=new S({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFjY2VsZXJhdGU=",highlighted:"pip install accelerate"}}),H=new S({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IoKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

<span class="hljs-meta">&gt;&gt;&gt; </span>accelerator = Accelerator()`}}),P=new ce({}),D=new S({props:{code:"dHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyQyUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTIwJTNEJTIwYWNjZWxlcmF0b3IucHJlcGFyZSglMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhbG9hZGVyJTJDJTIwZXZhbF9kYXRhbG9hZGVyJTJDJTIwbW9kZWwlMkMlMjBvcHRpbWl6ZXIlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(
<span class="hljs-meta">... </span>    train_dataloader, eval_dataloader, model, optimizer
<span class="hljs-meta">... </span>)`}}),L=new ce({}),O=new S({props:{code:"Zm9yJTIwZXBvY2glMjBpbiUyMHJhbmdlKG51bV9lcG9jaHMpJTNBJTBBJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMHRyYWluX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWNjZWxlcmF0b3IuYmFja3dhcmQobG9zcyklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuc3RlcCgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbHJfc2NoZWR1bGVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplci56ZXJvX2dyYWQoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByb2dyZXNzX2Jhci51cGRhdGUoMSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs.loss
<span class="hljs-meta">... </span>        accelerator.backward(loss)

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`}}),ee=new S({props:{code:"JTJCJTIwZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUyMCUyMGZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBZGFtVyUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMkMlMjBnZXRfc2NoZWR1bGVyJTBBJTBBJTJCJTIwYWNjZWxlcmF0b3IlMjAlM0QlMjBBY2NlbGVyYXRvcigpJTBBJTBBJTIwJTIwbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50JTJDJTIwbnVtX2xhYmVscyUzRDIpJTBBJTIwJTIwb3B0aW1pemVyJTIwJTNEJTIwQWRhbVcobW9kZWwucGFyYW1ldGVycygpJTJDJTIwbHIlM0QzZS01KSUwQSUwQS0lMjBkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEEtJTIwbW9kZWwudG8oZGV2aWNlKSUwQSUwQSUyQiUyMHRyYWluX2RhdGFsb2FkZXIlMkMlMjBldmFsX2RhdGFsb2FkZXIlMkMlMjBtb2RlbCUyQyUyMG9wdGltaXplciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoJTBBJTJCJTIwJTIwJTIwJTIwJTIwdHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyQyUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTBBJTJCJTIwKSUwQSUwQSUyMCUyMG51bV9lcG9jaHMlMjAlM0QlMjAzJTBBJTIwJTIwbnVtX3RyYWluaW5nX3N0ZXBzJTIwJTNEJTIwbnVtX2Vwb2NocyUyMColMjBsZW4odHJhaW5fZGF0YWxvYWRlciklMEElMjAlMjBscl9zY2hlZHVsZXIlMjAlM0QlMjBnZXRfc2NoZWR1bGVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMmxpbmVhciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplciUzRG9wdGltaXplciUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMG51bV93YXJtdXBfc3RlcHMlM0QwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3RyYWluaW5nX3N0ZXBzJTNEbnVtX3RyYWluaW5nX3N0ZXBzJTBBJTIwJTIwKSUwQSUwQSUyMCUyMHByb2dyZXNzX2JhciUyMCUzRCUyMHRxZG0ocmFuZ2UobnVtX3RyYWluaW5nX3N0ZXBzKSklMEElMEElMjAlMjBtb2RlbC50cmFpbigpJTBBJTIwJTIwZm9yJTIwZXBvY2glMjBpbiUyMHJhbmdlKG51bV9lcG9jaHMpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMHRyYWluX2RhdGFsb2FkZXIlM0ElMEEtJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBLSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvc3MuYmFja3dhcmQoKSUwQSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjY2VsZXJhdG9yLmJhY2t3YXJkKGxvc3MpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-addition">+ from accelerate import Accelerator</span>
  from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

<span class="hljs-addition">+ accelerator = Accelerator()</span>

  model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
  optimizer = AdamW(model.parameters(), lr=3e-5)

<span class="hljs-deletion">- device = torch.device(&quot;cuda&quot;) if torch.cuda.is_available() else torch.device(&quot;cpu&quot;)</span>
<span class="hljs-deletion">- model.to(device)</span>

<span class="hljs-addition">+ train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(</span>
<span class="hljs-addition">+     train_dataloader, eval_dataloader, model, optimizer</span>
<span class="hljs-addition">+ )</span>

  num_epochs = 3
  num_training_steps = num_epochs * len(train_dataloader)
  lr_scheduler = get_scheduler(
      &quot;linear&quot;,
      optimizer=optimizer,
      num_warmup_steps=0,
      num_training_steps=num_training_steps
  )

  progress_bar = tqdm(range(num_training_steps))

  model.train()
  for epoch in range(num_epochs):
      for batch in train_dataloader:
<span class="hljs-deletion">-         batch = {k: v.to(device) for k, v in batch.items()}</span>
          outputs = model(**batch)
          loss = outputs.loss
<span class="hljs-deletion">-         loss.backward()</span>
<span class="hljs-addition">+         accelerator.backward(loss)</span>

          optimizer.step()
          lr_scheduler.step()
          optimizer.zero_grad()
          progress_bar.update(1)`}}),ae=new ce({}),te=new ce({}),le=new S({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),re=new S({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluLnB5",highlighted:"accelerate launch train.py"}}),oe=new ce({}),ne=new S({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBub3RlYm9va19sYXVuY2hlciUwQSUwQW5vdGVib29rX2xhdW5jaGVyKHRyYWluaW5nX2Z1bmN0aW9uKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> notebook_launcher

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_launcher(training_function)`}}),{c(){v=r("meta"),Ze=h(),j=r("h1"),k=r("a"),we=r("span"),f(V.$$.fragment),ma=h(),Me=r("span"),wa=c("Distributed training with \u{1F917} Accelerate"),Ee=h(),_=r("p"),Ma=c("As models get bigger, parallelism has emerged as a strategy for training larger models on limited hardware and accelerating training speed by several orders of magnitude. At Hugging Face, we created the "),R=r("a"),ba=c("\u{1F917} Accelerate"),Ja=c(" library to help users easily train a \u{1F917} Transformers model on any type of distributed setup, whether it is multiple GPU\u2019s on one machine or multiple GPU\u2019s across several machines. In this tutorial, learn how to customize your native PyTorch training loop to enable training in a distributed environment."),Ce=h(),T=r("h2"),B=r("a"),be=r("span"),f(Q.$$.fragment),va=h(),Je=r("span"),ja=c("Setup"),Ge=h(),pe=r("p"),Ta=c("Get started by installing \u{1F917} Accelerate:"),We=h(),f(F.$$.fragment),Xe=h(),b=r("p"),Ua=c("Then import and create an "),z=r("a"),ga=c("Accelerator"),Aa=c(" object. The "),x=r("a"),Ia=c("Accelerator"),$a=c(" will automatically detect your type of distributed setup and initialize all the necessary components for training. You don\u2019t need to explicitly place your model on a device."),Ye=h(),f(H.$$.fragment),Ne=h(),U=r("h2"),Z=r("a"),ve=r("span"),f(P.$$.fragment),ka=h(),je=r("span"),_a=c("Prepare to accelerate"),Se=h(),E=r("p"),Ba=c("The next step is to pass all the relevant training objects to the "),K=r("a"),Za=c("prepare"),Ea=c(" method. This includes your training and evaluation DataLoaders, a model and an optimizer:"),Ve=h(),f(D.$$.fragment),Re=h(),g=r("h2"),C=r("a"),Te=r("span"),f(L.$$.fragment),Ca=h(),Ue=r("span"),Ga=c("Backward"),Qe=h(),J=r("p"),Wa=c("The last addition is to replace the typical "),ge=r("code"),Xa=c("loss.backward()"),Ya=c(" in your training loop with \u{1F917} Accelerate\u2019s "),q=r("a"),Na=c("backward"),Sa=c("method:"),Fe=h(),f(O.$$.fragment),ze=h(),he=r("p"),Va=c("As you can see in the following code, you only need to add four additional lines of code to your training loop to enable distributed training!"),xe=h(),f(ee.$$.fragment),He=h(),A=r("h2"),G=r("a"),Ae=r("span"),f(ae.$$.fragment),Ra=h(),Ie=r("span"),Qa=c("Train"),Pe=h(),de=r("p"),Fa=c("Once you\u2019ve added the relevant lines of code, launch your training in a script or a notebook like Colaboratory."),Ke=h(),I=r("h3"),W=r("a"),$e=r("span"),f(te.$$.fragment),za=h(),ke=r("span"),xa=c("Train with a script"),De=h(),fe=r("p"),Ha=c("If you are running your training from a script, run the following command to create and save a configuration file:"),Le=h(),f(le.$$.fragment),qe=h(),ue=r("p"),Pa=c("Then launch your training with:"),Oe=h(),f(re.$$.fragment),ea=h(),$=r("h3"),X=r("a"),_e=r("span"),f(oe.$$.fragment),Ka=h(),Be=r("span"),Da=c("Train with a notebook"),aa=h(),Y=r("p"),La=c("\u{1F917} Accelerate can also run in a notebook if you\u2019re planning on using Colaboratory\u2019s TPUs. Wrap all the code responsible for training in a function, and pass it to "),se=r("a"),qa=c("notebook_launcher"),Oa=c(":"),ta=h(),f(ne.$$.fragment),la=h(),N=r("p"),et=c("For more information about \u{1F917} Accelerate and its rich features, refer to the "),ie=r("a"),at=c("documentation"),tt=c("."),this.h()},l(e){const l=Vt('[data-svelte="svelte-1phssyn"]',document.head);v=o(l,"META",{name:!0,content:!0}),l.forEach(a),Ze=d(e),j=o(e,"H1",{class:!0});var oa=s(j);k=o(oa,"A",{id:!0,class:!0,href:!0});var rt=s(k);we=o(rt,"SPAN",{});var ot=s(we);u(V.$$.fragment,ot),ot.forEach(a),rt.forEach(a),ma=d(oa),Me=o(oa,"SPAN",{});var st=s(Me);wa=p(st,"Distributed training with \u{1F917} Accelerate"),st.forEach(a),oa.forEach(a),Ee=d(e),_=o(e,"P",{});var sa=s(_);Ma=p(sa,"As models get bigger, parallelism has emerged as a strategy for training larger models on limited hardware and accelerating training speed by several orders of magnitude. At Hugging Face, we created the "),R=o(sa,"A",{href:!0,rel:!0});var nt=s(R);ba=p(nt,"\u{1F917} Accelerate"),nt.forEach(a),Ja=p(sa," library to help users easily train a \u{1F917} Transformers model on any type of distributed setup, whether it is multiple GPU\u2019s on one machine or multiple GPU\u2019s across several machines. In this tutorial, learn how to customize your native PyTorch training loop to enable training in a distributed environment."),sa.forEach(a),Ce=d(e),T=o(e,"H2",{class:!0});var na=s(T);B=o(na,"A",{id:!0,class:!0,href:!0});var it=s(B);be=o(it,"SPAN",{});var ct=s(be);u(Q.$$.fragment,ct),ct.forEach(a),it.forEach(a),va=d(na),Je=o(na,"SPAN",{});var pt=s(Je);ja=p(pt,"Setup"),pt.forEach(a),na.forEach(a),Ge=d(e),pe=o(e,"P",{});var ht=s(pe);Ta=p(ht,"Get started by installing \u{1F917} Accelerate:"),ht.forEach(a),We=d(e),u(F.$$.fragment,e),Xe=d(e),b=o(e,"P",{});var ye=s(b);Ua=p(ye,"Then import and create an "),z=o(ye,"A",{href:!0,rel:!0});var dt=s(z);ga=p(dt,"Accelerator"),dt.forEach(a),Aa=p(ye," object. The "),x=o(ye,"A",{href:!0,rel:!0});var ft=s(x);Ia=p(ft,"Accelerator"),ft.forEach(a),$a=p(ye," will automatically detect your type of distributed setup and initialize all the necessary components for training. You don\u2019t need to explicitly place your model on a device."),ye.forEach(a),Ye=d(e),u(H.$$.fragment,e),Ne=d(e),U=o(e,"H2",{class:!0});var ia=s(U);Z=o(ia,"A",{id:!0,class:!0,href:!0});var ut=s(Z);ve=o(ut,"SPAN",{});var yt=s(ve);u(P.$$.fragment,yt),yt.forEach(a),ut.forEach(a),ka=d(ia),je=o(ia,"SPAN",{});var mt=s(je);_a=p(mt,"Prepare to accelerate"),mt.forEach(a),ia.forEach(a),Se=d(e),E=o(e,"P",{});var ca=s(E);Ba=p(ca,"The next step is to pass all the relevant training objects to the "),K=o(ca,"A",{href:!0,rel:!0});var wt=s(K);Za=p(wt,"prepare"),wt.forEach(a),Ea=p(ca," method. This includes your training and evaluation DataLoaders, a model and an optimizer:"),ca.forEach(a),Ve=d(e),u(D.$$.fragment,e),Re=d(e),g=o(e,"H2",{class:!0});var pa=s(g);C=o(pa,"A",{id:!0,class:!0,href:!0});var Mt=s(C);Te=o(Mt,"SPAN",{});var bt=s(Te);u(L.$$.fragment,bt),bt.forEach(a),Mt.forEach(a),Ca=d(pa),Ue=o(pa,"SPAN",{});var Jt=s(Ue);Ga=p(Jt,"Backward"),Jt.forEach(a),pa.forEach(a),Qe=d(e),J=o(e,"P",{});var me=s(J);Wa=p(me,"The last addition is to replace the typical "),ge=o(me,"CODE",{});var vt=s(ge);Xa=p(vt,"loss.backward()"),vt.forEach(a),Ya=p(me," in your training loop with \u{1F917} Accelerate\u2019s "),q=o(me,"A",{href:!0,rel:!0});var jt=s(q);Na=p(jt,"backward"),jt.forEach(a),Sa=p(me,"method:"),me.forEach(a),Fe=d(e),u(O.$$.fragment,e),ze=d(e),he=o(e,"P",{});var Tt=s(he);Va=p(Tt,"As you can see in the following code, you only need to add four additional lines of code to your training loop to enable distributed training!"),Tt.forEach(a),xe=d(e),u(ee.$$.fragment,e),He=d(e),A=o(e,"H2",{class:!0});var ha=s(A);G=o(ha,"A",{id:!0,class:!0,href:!0});var Ut=s(G);Ae=o(Ut,"SPAN",{});var gt=s(Ae);u(ae.$$.fragment,gt),gt.forEach(a),Ut.forEach(a),Ra=d(ha),Ie=o(ha,"SPAN",{});var At=s(Ie);Qa=p(At,"Train"),At.forEach(a),ha.forEach(a),Pe=d(e),de=o(e,"P",{});var It=s(de);Fa=p(It,"Once you\u2019ve added the relevant lines of code, launch your training in a script or a notebook like Colaboratory."),It.forEach(a),Ke=d(e),I=o(e,"H3",{class:!0});var da=s(I);W=o(da,"A",{id:!0,class:!0,href:!0});var $t=s(W);$e=o($t,"SPAN",{});var kt=s($e);u(te.$$.fragment,kt),kt.forEach(a),$t.forEach(a),za=d(da),ke=o(da,"SPAN",{});var _t=s(ke);xa=p(_t,"Train with a script"),_t.forEach(a),da.forEach(a),De=d(e),fe=o(e,"P",{});var Bt=s(fe);Ha=p(Bt,"If you are running your training from a script, run the following command to create and save a configuration file:"),Bt.forEach(a),Le=d(e),u(le.$$.fragment,e),qe=d(e),ue=o(e,"P",{});var Zt=s(ue);Pa=p(Zt,"Then launch your training with:"),Zt.forEach(a),Oe=d(e),u(re.$$.fragment,e),ea=d(e),$=o(e,"H3",{class:!0});var fa=s($);X=o(fa,"A",{id:!0,class:!0,href:!0});var Et=s(X);_e=o(Et,"SPAN",{});var Ct=s(_e);u(oe.$$.fragment,Ct),Ct.forEach(a),Et.forEach(a),Ka=d(fa),Be=o(fa,"SPAN",{});var Gt=s(Be);Da=p(Gt,"Train with a notebook"),Gt.forEach(a),fa.forEach(a),aa=d(e),Y=o(e,"P",{});var ua=s(Y);La=p(ua,"\u{1F917} Accelerate can also run in a notebook if you\u2019re planning on using Colaboratory\u2019s TPUs. Wrap all the code responsible for training in a function, and pass it to "),se=o(ua,"A",{href:!0,rel:!0});var Wt=s(se);qa=p(Wt,"notebook_launcher"),Wt.forEach(a),Oa=p(ua,":"),ua.forEach(a),ta=d(e),u(ne.$$.fragment,e),la=d(e),N=o(e,"P",{});var ya=s(N);et=p(ya,"For more information about \u{1F917} Accelerate and its rich features, refer to the "),ie=o(ya,"A",{href:!0,rel:!0});var Xt=s(ie);at=p(Xt,"documentation"),Xt.forEach(a),tt=p(ya,"."),ya.forEach(a),this.h()},h(){n(v,"name","hf:doc:metadata"),n(v,"content",JSON.stringify(zt)),n(k,"id","distributed-training-with-accelerate"),n(k,"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"),n(k,"href","#distributed-training-with-accelerate"),n(j,"class","relative group"),n(R,"href","https://huggingface.co/docs/accelerate"),n(R,"rel","nofollow"),n(B,"id","setup"),n(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(B,"href","#setup"),n(T,"class","relative group"),n(z,"href","https://huggingface.co/docs/accelerate/v0.22.0/en/package_reference/accelerator#accelerate.Accelerator"),n(z,"rel","nofollow"),n(x,"href","https://huggingface.co/docs/accelerate/v0.22.0/en/package_reference/accelerator#accelerate.Accelerator"),n(x,"rel","nofollow"),n(Z,"id","prepare-to-accelerate"),n(Z,"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"),n(Z,"href","#prepare-to-accelerate"),n(U,"class","relative group"),n(K,"href","https://huggingface.co/docs/accelerate/v0.22.0/en/package_reference/accelerator#accelerate.Accelerator.prepare"),n(K,"rel","nofollow"),n(C,"id","backward"),n(C,"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"),n(C,"href","#backward"),n(g,"class","relative group"),n(q,"href","https://huggingface.co/docs/accelerate/v0.22.0/en/package_reference/accelerator#accelerate.Accelerator.backward"),n(q,"rel","nofollow"),n(G,"id","train"),n(G,"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"),n(G,"href","#train"),n(A,"class","relative group"),n(W,"id","train-with-a-script"),n(W,"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"),n(W,"href","#train-with-a-script"),n(I,"class","relative group"),n(X,"id","train-with-a-notebook"),n(X,"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"),n(X,"href","#train-with-a-notebook"),n($,"class","relative group"),n(se,"href","https://huggingface.co/docs/accelerate/v0.22.0/en/package_reference/launchers#accelerate.notebook_launcher"),n(se,"rel","nofollow"),n(ie,"href","https://huggingface.co/docs/accelerate"),n(ie,"rel","nofollow")},m(e,l){t(document.head,v),i(e,Ze,l),i(e,j,l),t(j,k),t(k,we),y(V,we,null),t(j,ma),t(j,Me),t(Me,wa),i(e,Ee,l),i(e,_,l),t(_,Ma),t(_,R),t(R,ba),t(_,Ja),i(e,Ce,l),i(e,T,l),t(T,B),t(B,be),y(Q,be,null),t(T,va),t(T,Je),t(Je,ja),i(e,Ge,l),i(e,pe,l),t(pe,Ta),i(e,We,l),y(F,e,l),i(e,Xe,l),i(e,b,l),t(b,Ua),t(b,z),t(z,ga),t(b,Aa),t(b,x),t(x,Ia),t(b,$a),i(e,Ye,l),y(H,e,l),i(e,Ne,l),i(e,U,l),t(U,Z),t(Z,ve),y(P,ve,null),t(U,ka),t(U,je),t(je,_a),i(e,Se,l),i(e,E,l),t(E,Ba),t(E,K),t(K,Za),t(E,Ea),i(e,Ve,l),y(D,e,l),i(e,Re,l),i(e,g,l),t(g,C),t(C,Te),y(L,Te,null),t(g,Ca),t(g,Ue),t(Ue,Ga),i(e,Qe,l),i(e,J,l),t(J,Wa),t(J,ge),t(ge,Xa),t(J,Ya),t(J,q),t(q,Na),t(J,Sa),i(e,Fe,l),y(O,e,l),i(e,ze,l),i(e,he,l),t(he,Va),i(e,xe,l),y(ee,e,l),i(e,He,l),i(e,A,l),t(A,G),t(G,Ae),y(ae,Ae,null),t(A,Ra),t(A,Ie),t(Ie,Qa),i(e,Pe,l),i(e,de,l),t(de,Fa),i(e,Ke,l),i(e,I,l),t(I,W),t(W,$e),y(te,$e,null),t(I,za),t(I,ke),t(ke,xa),i(e,De,l),i(e,fe,l),t(fe,Ha),i(e,Le,l),y(le,e,l),i(e,qe,l),i(e,ue,l),t(ue,Pa),i(e,Oe,l),y(re,e,l),i(e,ea,l),i(e,$,l),t($,X),t(X,_e),y(oe,_e,null),t($,Ka),t($,Be),t(Be,Da),i(e,aa,l),i(e,Y,l),t(Y,La),t(Y,se),t(se,qa),t(Y,Oa),i(e,ta,l),y(ne,e,l),i(e,la,l),i(e,N,l),t(N,et),t(N,ie),t(ie,at),t(N,tt),ra=!0},p:Rt,i(e){ra||(m(V.$$.fragment,e),m(Q.$$.fragment,e),m(F.$$.fragment,e),m(H.$$.fragment,e),m(P.$$.fragment,e),m(D.$$.fragment,e),m(L.$$.fragment,e),m(O.$$.fragment,e),m(ee.$$.fragment,e),m(ae.$$.fragment,e),m(te.$$.fragment,e),m(le.$$.fragment,e),m(re.$$.fragment,e),m(oe.$$.fragment,e),m(ne.$$.fragment,e),ra=!0)},o(e){w(V.$$.fragment,e),w(Q.$$.fragment,e),w(F.$$.fragment,e),w(H.$$.fragment,e),w(P.$$.fragment,e),w(D.$$.fragment,e),w(L.$$.fragment,e),w(O.$$.fragment,e),w(ee.$$.fragment,e),w(ae.$$.fragment,e),w(te.$$.fragment,e),w(le.$$.fragment,e),w(re.$$.fragment,e),w(oe.$$.fragment,e),w(ne.$$.fragment,e),ra=!1},d(e){a(v),e&&a(Ze),e&&a(j),M(V),e&&a(Ee),e&&a(_),e&&a(Ce),e&&a(T),M(Q),e&&a(Ge),e&&a(pe),e&&a(We),M(F,e),e&&a(Xe),e&&a(b),e&&a(Ye),M(H,e),e&&a(Ne),e&&a(U),M(P),e&&a(Se),e&&a(E),e&&a(Ve),M(D,e),e&&a(Re),e&&a(g),M(L),e&&a(Qe),e&&a(J),e&&a(Fe),M(O,e),e&&a(ze),e&&a(he),e&&a(xe),M(ee,e),e&&a(He),e&&a(A),M(ae),e&&a(Pe),e&&a(de),e&&a(Ke),e&&a(I),M(te),e&&a(De),e&&a(fe),e&&a(Le),M(le,e),e&&a(qe),e&&a(ue),e&&a(Oe),M(re,e),e&&a(ea),e&&a($),M(oe),e&&a(aa),e&&a(Y),e&&a(ta),M(ne,e),e&&a(la),e&&a(N)}}}const zt={local:"distributed-training-with-accelerate",sections:[{local:"setup",title:"Setup"},{local:"prepare-to-accelerate",title:"Prepare to accelerate"},{local:"backward",title:"Backward"},{local:"train",sections:[{local:"train-with-a-script",title:"Train with a script"},{local:"train-with-a-notebook",title:"Train with a notebook"}],title:"Train"}],title:"Distributed training with \u{1F917} Accelerate"};function xt(lt){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dt extends Yt{constructor(v){super();Nt(this,v,xt,Ft,St,{})}}export{Dt as default,zt as metadata};
