import{S as Ql,i as Fl,s as Pl,e as o,k as m,w as d,t as c,M as Hl,c as r,d as a,m as u,a as i,x as h,h as p,b as s,G as l,g as n,y as f,L as xl,q as M,o as w,B as y,v as Kl}from"../chunks/vendor-hf-doc-builder.js";import{I as ne}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as N}from"../chunks/CodeBlock-hf-doc-builder.js";function ql(il){let v,ze,j,_,fe,S,Ja,Me,ba,Ge,k,va,V,ja,Ua,We,U,B,we,R,Ta,ye,Aa,Xe,se,ga,Ye,Q,Ne,J,Ia,F,Je,$a,_a,be,ka,Ba,Se,P,Ve,T,C,ve,H,Ca,je,Ea,Re,E,Za,x,Ue,za,Ga,Qe,K,Fe,A,Z,Te,q,Wa,Ae,Xa,Pe,b,Ya,ge,Na,Sa,L,Ie,Va,Ra,He,D,xe,ce,Qa,Ke,O,qe,g,z,$e,ee,Fa,_e,Pa,Le,pe,Ha,De,I,G,ke,ae,xa,Be,Ka,Oe,me,qa,ea,le,aa,ue,La,la,te,ta,$,W,Ce,oe,Da,Ee,Oa,oa,X,el,Ze,al,ll,ra,re,ia,Y,tl,ie,ol,rl,na;return S=new ne({}),R=new ne({}),Q=new N({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFjY2VsZXJhdGU=",highlighted:"pip install accelerate"}}),P=new N({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()`}}),H=new ne({}),K=new N({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>)`}}),q=new ne({}),D=new N({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>)`}}),O=new N({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)`}}),ee=new ne({}),ae=new ne({}),le=new N({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),te=new N({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluLnB5",highlighted:"accelerate launch train.py"}}),oe=new ne({}),re=new N({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=o("meta"),ze=m(),j=o("h1"),_=o("a"),fe=o("span"),d(S.$$.fragment),Ja=m(),Me=o("span"),ba=c("Allenamento distribuito con \u{1F917} Accelerate"),Ge=m(),k=o("p"),va=c("La parallelizzazione \xE8 emersa come strategia per allenare modelli sempre pi\xF9 grandi su hardware limitato e accelerarne la velocit\xE0 di allenamento di diversi ordini di magnitudine. In Hugging Face, abbiamo creato la libreria "),V=o("a"),ja=c("\u{1F917} Accelerate"),Ua=c(" per aiutarti ad allenare in modo semplice un modello \u{1F917} Transformers su qualsiasi tipo di configurazione distribuita, sia che si tratti di pi\xF9 GPU su una sola macchina o di pi\xF9 GPU su pi\xF9 macchine. In questo tutorial, imparerai come personalizzare il training loop nativo di PyTorch per consentire l\u2019addestramento in un ambiente distribuito."),We=m(),U=o("h2"),B=o("a"),we=o("span"),d(R.$$.fragment),Ta=m(),ye=o("span"),Aa=c("Configurazione"),Xe=m(),se=o("p"),ga=c("Inizia installando \u{1F917} Accelerate:"),Ye=m(),d(Q.$$.fragment),Ne=m(),J=o("p"),Ia=c("Poi importa e crea un oggetto "),F=o("a"),Je=o("code"),$a=c("Accelerator"),_a=c(". "),be=o("code"),ka=c("Accelerator"),Ba=c(" rilever\xE0 automaticamente il tuo setup distribuito e inizializzer\xE0 tutte le componenti necessarie per l\u2019allenamento. Non dovrai allocare esplicitamente il tuo modello su un device."),Se=m(),d(P.$$.fragment),Ve=m(),T=o("h2"),C=o("a"),ve=o("span"),d(H.$$.fragment),Ca=m(),je=o("span"),Ea=c("Preparati ad accelerare"),Re=m(),E=o("p"),Za=c("Il prossimo passo \xE8 quello di passare tutti gli oggetti rilevanti per l\u2019allenamento al metodo "),x=o("a"),Ue=o("code"),za=c("prepare"),Ga=c(". Questo include i tuoi DataLoaders per l\u2019allenamento e per la valutazione, un modello e un ottimizzatore:"),Qe=m(),d(K.$$.fragment),Fe=m(),A=o("h2"),Z=o("a"),Te=o("span"),d(q.$$.fragment),Wa=m(),Ae=o("span"),Xa=c("Backward"),Pe=m(),b=o("p"),Ya=c("Infine, sostituisci il tipico metodo "),ge=o("code"),Na=c("loss.backward()"),Sa=c(" nel tuo loop di allenamento con il metodo "),L=o("a"),Ie=o("code"),Va=c("backward"),Ra=c(" di \u{1F917} Accelerate:"),He=m(),d(D.$$.fragment),xe=m(),ce=o("p"),Qa=c("Come puoi vedere nel seguente codice, hai solo bisogno di aggiungere quattro righe in pi\xF9 di codice al tuo training loop per abilitare l\u2019allenamento distribuito!"),Ke=m(),d(O.$$.fragment),qe=m(),g=o("h2"),z=o("a"),$e=o("span"),d(ee.$$.fragment),Fa=m(),_e=o("span"),Pa=c("Allenamento"),Le=m(),pe=o("p"),Ha=c("Una volta che hai aggiunto le righe di codice rilevanti, lancia il tuo allenamento in uno script o in un notebook come Colaboratory."),De=m(),I=o("h3"),G=o("a"),ke=o("span"),d(ae.$$.fragment),xa=m(),Be=o("span"),Ka=c("Allenamento con uno script"),Oe=m(),me=o("p"),qa=c("Se stai eseguendo il tuo allenamento da uno script, esegui il comando seguente per creare e salvare un file di configurazione:"),ea=m(),d(le.$$.fragment),aa=m(),ue=o("p"),La=c("Poi lancia il tuo allenamento con:"),la=m(),d(te.$$.fragment),ta=m(),$=o("h3"),W=o("a"),Ce=o("span"),d(oe.$$.fragment),Da=m(),Ee=o("span"),Oa=c("Allenamento con un notebook"),oa=m(),X=o("p"),el=c("La libreria \u{1F917} Accelerate pu\xF2 anche essere utilizzata in un notebook se stai pianificando di utilizzare le TPU di Colaboratory. Inserisci tutto il codice legato all\u2019allenamento in una funzione, e passala al "),Ze=o("code"),al=c("notebook_launcher"),ll=c(":"),ra=m(),d(re.$$.fragment),ia=m(),Y=o("p"),tl=c("Per maggiori informazioni relative a \u{1F917} Accelerate e le sue numerose funzionalit\xE0, fai riferimento alla "),ie=o("a"),ol=c("documentazione"),rl=c("."),this.h()},l(e){const t=Hl('[data-svelte="svelte-1phssyn"]',document.head);v=r(t,"META",{name:!0,content:!0}),t.forEach(a),ze=u(e),j=r(e,"H1",{class:!0});var sa=i(j);_=r(sa,"A",{id:!0,class:!0,href:!0});var nl=i(_);fe=r(nl,"SPAN",{});var sl=i(fe);h(S.$$.fragment,sl),sl.forEach(a),nl.forEach(a),Ja=u(sa),Me=r(sa,"SPAN",{});var cl=i(Me);ba=p(cl,"Allenamento distribuito con \u{1F917} Accelerate"),cl.forEach(a),sa.forEach(a),Ge=u(e),k=r(e,"P",{});var ca=i(k);va=p(ca,"La parallelizzazione \xE8 emersa come strategia per allenare modelli sempre pi\xF9 grandi su hardware limitato e accelerarne la velocit\xE0 di allenamento di diversi ordini di magnitudine. In Hugging Face, abbiamo creato la libreria "),V=r(ca,"A",{href:!0,rel:!0});var pl=i(V);ja=p(pl,"\u{1F917} Accelerate"),pl.forEach(a),Ua=p(ca," per aiutarti ad allenare in modo semplice un modello \u{1F917} Transformers su qualsiasi tipo di configurazione distribuita, sia che si tratti di pi\xF9 GPU su una sola macchina o di pi\xF9 GPU su pi\xF9 macchine. In questo tutorial, imparerai come personalizzare il training loop nativo di PyTorch per consentire l\u2019addestramento in un ambiente distribuito."),ca.forEach(a),We=u(e),U=r(e,"H2",{class:!0});var pa=i(U);B=r(pa,"A",{id:!0,class:!0,href:!0});var ml=i(B);we=r(ml,"SPAN",{});var ul=i(we);h(R.$$.fragment,ul),ul.forEach(a),ml.forEach(a),Ta=u(pa),ye=r(pa,"SPAN",{});var dl=i(ye);Aa=p(dl,"Configurazione"),dl.forEach(a),pa.forEach(a),Xe=u(e),se=r(e,"P",{});var hl=i(se);ga=p(hl,"Inizia installando \u{1F917} Accelerate:"),hl.forEach(a),Ye=u(e),h(Q.$$.fragment,e),Ne=u(e),J=r(e,"P",{});var de=i(J);Ia=p(de,"Poi importa e crea un oggetto "),F=r(de,"A",{href:!0,rel:!0});var fl=i(F);Je=r(fl,"CODE",{});var Ml=i(Je);$a=p(Ml,"Accelerator"),Ml.forEach(a),fl.forEach(a),_a=p(de,". "),be=r(de,"CODE",{});var wl=i(be);ka=p(wl,"Accelerator"),wl.forEach(a),Ba=p(de," rilever\xE0 automaticamente il tuo setup distribuito e inizializzer\xE0 tutte le componenti necessarie per l\u2019allenamento. Non dovrai allocare esplicitamente il tuo modello su un device."),de.forEach(a),Se=u(e),h(P.$$.fragment,e),Ve=u(e),T=r(e,"H2",{class:!0});var ma=i(T);C=r(ma,"A",{id:!0,class:!0,href:!0});var yl=i(C);ve=r(yl,"SPAN",{});var Jl=i(ve);h(H.$$.fragment,Jl),Jl.forEach(a),yl.forEach(a),Ca=u(ma),je=r(ma,"SPAN",{});var bl=i(je);Ea=p(bl,"Preparati ad accelerare"),bl.forEach(a),ma.forEach(a),Re=u(e),E=r(e,"P",{});var ua=i(E);Za=p(ua,"Il prossimo passo \xE8 quello di passare tutti gli oggetti rilevanti per l\u2019allenamento al metodo "),x=r(ua,"A",{href:!0,rel:!0});var vl=i(x);Ue=r(vl,"CODE",{});var jl=i(Ue);za=p(jl,"prepare"),jl.forEach(a),vl.forEach(a),Ga=p(ua,". Questo include i tuoi DataLoaders per l\u2019allenamento e per la valutazione, un modello e un ottimizzatore:"),ua.forEach(a),Qe=u(e),h(K.$$.fragment,e),Fe=u(e),A=r(e,"H2",{class:!0});var da=i(A);Z=r(da,"A",{id:!0,class:!0,href:!0});var Ul=i(Z);Te=r(Ul,"SPAN",{});var Tl=i(Te);h(q.$$.fragment,Tl),Tl.forEach(a),Ul.forEach(a),Wa=u(da),Ae=r(da,"SPAN",{});var Al=i(Ae);Xa=p(Al,"Backward"),Al.forEach(a),da.forEach(a),Pe=u(e),b=r(e,"P",{});var he=i(b);Ya=p(he,"Infine, sostituisci il tipico metodo "),ge=r(he,"CODE",{});var gl=i(ge);Na=p(gl,"loss.backward()"),gl.forEach(a),Sa=p(he," nel tuo loop di allenamento con il metodo "),L=r(he,"A",{href:!0,rel:!0});var Il=i(L);Ie=r(Il,"CODE",{});var $l=i(Ie);Va=p($l,"backward"),$l.forEach(a),Il.forEach(a),Ra=p(he," di \u{1F917} Accelerate:"),he.forEach(a),He=u(e),h(D.$$.fragment,e),xe=u(e),ce=r(e,"P",{});var _l=i(ce);Qa=p(_l,"Come puoi vedere nel seguente codice, hai solo bisogno di aggiungere quattro righe in pi\xF9 di codice al tuo training loop per abilitare l\u2019allenamento distribuito!"),_l.forEach(a),Ke=u(e),h(O.$$.fragment,e),qe=u(e),g=r(e,"H2",{class:!0});var ha=i(g);z=r(ha,"A",{id:!0,class:!0,href:!0});var kl=i(z);$e=r(kl,"SPAN",{});var Bl=i($e);h(ee.$$.fragment,Bl),Bl.forEach(a),kl.forEach(a),Fa=u(ha),_e=r(ha,"SPAN",{});var Cl=i(_e);Pa=p(Cl,"Allenamento"),Cl.forEach(a),ha.forEach(a),Le=u(e),pe=r(e,"P",{});var El=i(pe);Ha=p(El,"Una volta che hai aggiunto le righe di codice rilevanti, lancia il tuo allenamento in uno script o in un notebook come Colaboratory."),El.forEach(a),De=u(e),I=r(e,"H3",{class:!0});var fa=i(I);G=r(fa,"A",{id:!0,class:!0,href:!0});var Zl=i(G);ke=r(Zl,"SPAN",{});var zl=i(ke);h(ae.$$.fragment,zl),zl.forEach(a),Zl.forEach(a),xa=u(fa),Be=r(fa,"SPAN",{});var Gl=i(Be);Ka=p(Gl,"Allenamento con uno script"),Gl.forEach(a),fa.forEach(a),Oe=u(e),me=r(e,"P",{});var Wl=i(me);qa=p(Wl,"Se stai eseguendo il tuo allenamento da uno script, esegui il comando seguente per creare e salvare un file di configurazione:"),Wl.forEach(a),ea=u(e),h(le.$$.fragment,e),aa=u(e),ue=r(e,"P",{});var Xl=i(ue);La=p(Xl,"Poi lancia il tuo allenamento con:"),Xl.forEach(a),la=u(e),h(te.$$.fragment,e),ta=u(e),$=r(e,"H3",{class:!0});var Ma=i($);W=r(Ma,"A",{id:!0,class:!0,href:!0});var Yl=i(W);Ce=r(Yl,"SPAN",{});var Nl=i(Ce);h(oe.$$.fragment,Nl),Nl.forEach(a),Yl.forEach(a),Da=u(Ma),Ee=r(Ma,"SPAN",{});var Sl=i(Ee);Oa=p(Sl,"Allenamento con un notebook"),Sl.forEach(a),Ma.forEach(a),oa=u(e),X=r(e,"P",{});var wa=i(X);el=p(wa,"La libreria \u{1F917} Accelerate pu\xF2 anche essere utilizzata in un notebook se stai pianificando di utilizzare le TPU di Colaboratory. Inserisci tutto il codice legato all\u2019allenamento in una funzione, e passala al "),Ze=r(wa,"CODE",{});var Vl=i(Ze);al=p(Vl,"notebook_launcher"),Vl.forEach(a),ll=p(wa,":"),wa.forEach(a),ra=u(e),h(re.$$.fragment,e),ia=u(e),Y=r(e,"P",{});var ya=i(Y);tl=p(ya,"Per maggiori informazioni relative a \u{1F917} Accelerate e le sue numerose funzionalit\xE0, fai riferimento alla "),ie=r(ya,"A",{href:!0,rel:!0});var Rl=i(ie);ol=p(Rl,"documentazione"),Rl.forEach(a),rl=p(ya,"."),ya.forEach(a),this.h()},h(){s(v,"name","hf:doc:metadata"),s(v,"content",JSON.stringify(Ll)),s(_,"id","allenamento-distribuito-con-accelerate"),s(_,"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"),s(_,"href","#allenamento-distribuito-con-accelerate"),s(j,"class","relative group"),s(V,"href","https://huggingface.co/docs/accelerate"),s(V,"rel","nofollow"),s(B,"id","configurazione"),s(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"),s(B,"href","#configurazione"),s(U,"class","relative group"),s(F,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator"),s(F,"rel","nofollow"),s(C,"id","preparati-ad-accelerare"),s(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"),s(C,"href","#preparati-ad-accelerare"),s(T,"class","relative group"),s(x,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator.prepare"),s(x,"rel","nofollow"),s(Z,"id","backward"),s(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"),s(Z,"href","#backward"),s(A,"class","relative group"),s(L,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator.backward"),s(L,"rel","nofollow"),s(z,"id","allenamento"),s(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"),s(z,"href","#allenamento"),s(g,"class","relative group"),s(G,"id","allenamento-con-uno-script"),s(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"),s(G,"href","#allenamento-con-uno-script"),s(I,"class","relative group"),s(W,"id","allenamento-con-un-notebook"),s(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"),s(W,"href","#allenamento-con-un-notebook"),s($,"class","relative group"),s(ie,"href","https://huggingface.co/docs/accelerate"),s(ie,"rel","nofollow")},m(e,t){l(document.head,v),n(e,ze,t),n(e,j,t),l(j,_),l(_,fe),f(S,fe,null),l(j,Ja),l(j,Me),l(Me,ba),n(e,Ge,t),n(e,k,t),l(k,va),l(k,V),l(V,ja),l(k,Ua),n(e,We,t),n(e,U,t),l(U,B),l(B,we),f(R,we,null),l(U,Ta),l(U,ye),l(ye,Aa),n(e,Xe,t),n(e,se,t),l(se,ga),n(e,Ye,t),f(Q,e,t),n(e,Ne,t),n(e,J,t),l(J,Ia),l(J,F),l(F,Je),l(Je,$a),l(J,_a),l(J,be),l(be,ka),l(J,Ba),n(e,Se,t),f(P,e,t),n(e,Ve,t),n(e,T,t),l(T,C),l(C,ve),f(H,ve,null),l(T,Ca),l(T,je),l(je,Ea),n(e,Re,t),n(e,E,t),l(E,Za),l(E,x),l(x,Ue),l(Ue,za),l(E,Ga),n(e,Qe,t),f(K,e,t),n(e,Fe,t),n(e,A,t),l(A,Z),l(Z,Te),f(q,Te,null),l(A,Wa),l(A,Ae),l(Ae,Xa),n(e,Pe,t),n(e,b,t),l(b,Ya),l(b,ge),l(ge,Na),l(b,Sa),l(b,L),l(L,Ie),l(Ie,Va),l(b,Ra),n(e,He,t),f(D,e,t),n(e,xe,t),n(e,ce,t),l(ce,Qa),n(e,Ke,t),f(O,e,t),n(e,qe,t),n(e,g,t),l(g,z),l(z,$e),f(ee,$e,null),l(g,Fa),l(g,_e),l(_e,Pa),n(e,Le,t),n(e,pe,t),l(pe,Ha),n(e,De,t),n(e,I,t),l(I,G),l(G,ke),f(ae,ke,null),l(I,xa),l(I,Be),l(Be,Ka),n(e,Oe,t),n(e,me,t),l(me,qa),n(e,ea,t),f(le,e,t),n(e,aa,t),n(e,ue,t),l(ue,La),n(e,la,t),f(te,e,t),n(e,ta,t),n(e,$,t),l($,W),l(W,Ce),f(oe,Ce,null),l($,Da),l($,Ee),l(Ee,Oa),n(e,oa,t),n(e,X,t),l(X,el),l(X,Ze),l(Ze,al),l(X,ll),n(e,ra,t),f(re,e,t),n(e,ia,t),n(e,Y,t),l(Y,tl),l(Y,ie),l(ie,ol),l(Y,rl),na=!0},p:xl,i(e){na||(M(S.$$.fragment,e),M(R.$$.fragment,e),M(Q.$$.fragment,e),M(P.$$.fragment,e),M(H.$$.fragment,e),M(K.$$.fragment,e),M(q.$$.fragment,e),M(D.$$.fragment,e),M(O.$$.fragment,e),M(ee.$$.fragment,e),M(ae.$$.fragment,e),M(le.$$.fragment,e),M(te.$$.fragment,e),M(oe.$$.fragment,e),M(re.$$.fragment,e),na=!0)},o(e){w(S.$$.fragment,e),w(R.$$.fragment,e),w(Q.$$.fragment,e),w(P.$$.fragment,e),w(H.$$.fragment,e),w(K.$$.fragment,e),w(q.$$.fragment,e),w(D.$$.fragment,e),w(O.$$.fragment,e),w(ee.$$.fragment,e),w(ae.$$.fragment,e),w(le.$$.fragment,e),w(te.$$.fragment,e),w(oe.$$.fragment,e),w(re.$$.fragment,e),na=!1},d(e){a(v),e&&a(ze),e&&a(j),y(S),e&&a(Ge),e&&a(k),e&&a(We),e&&a(U),y(R),e&&a(Xe),e&&a(se),e&&a(Ye),y(Q,e),e&&a(Ne),e&&a(J),e&&a(Se),y(P,e),e&&a(Ve),e&&a(T),y(H),e&&a(Re),e&&a(E),e&&a(Qe),y(K,e),e&&a(Fe),e&&a(A),y(q),e&&a(Pe),e&&a(b),e&&a(He),y(D,e),e&&a(xe),e&&a(ce),e&&a(Ke),y(O,e),e&&a(qe),e&&a(g),y(ee),e&&a(Le),e&&a(pe),e&&a(De),e&&a(I),y(ae),e&&a(Oe),e&&a(me),e&&a(ea),y(le,e),e&&a(aa),e&&a(ue),e&&a(la),y(te,e),e&&a(ta),e&&a($),y(oe),e&&a(oa),e&&a(X),e&&a(ra),y(re,e),e&&a(ia),e&&a(Y)}}}const Ll={local:"allenamento-distribuito-con-accelerate",sections:[{local:"configurazione",title:"Configurazione"},{local:"preparati-ad-accelerare",title:"Preparati ad accelerare"},{local:"backward",title:"Backward"},{local:"allenamento",sections:[{local:"allenamento-con-uno-script",title:"Allenamento con uno script"},{local:"allenamento-con-un-notebook",title:"Allenamento con un notebook"}],title:"Allenamento"}],title:"Allenamento distribuito con \u{1F917} Accelerate"};function Dl(il){return Kl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class lt extends Ql{constructor(v){super();Fl(this,v,Dl,ql,Pl,{})}}export{lt as default,Ll as metadata};
