import{S as eM,i as tM,s as oM,e as n,k as l,w as h,t as r,M as rM,c as s,d as o,m as d,a as i,x as u,h as a,b as m,G as e,g as p,y as f,q as g,o as _,B as v,v as aM,L as nM}from"../../chunks/vendor-hf-doc-builder.js";import{T as gp}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as O}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Y}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as sM}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function iM(Z){let T,D,$,k,L,A,S,W,fe,oe,G,se,ie,re,le,H,Ze,ge,z,I,st,ae,it,lt,_e,Ia,Ua,Ke,Pe,Na,ve,za,Fa;return{c(){T=n("p"),D=r("The "),$=n("a"),k=r("Trainer"),L=r(` class is optimized for \u{1F917} Transformers models and can have surprising behaviors
when you use it on other models. When using it on your own model, make sure:`),A=l(),S=n("ul"),W=n("li"),fe=r("your model always return tuples or subclasses of "),oe=n("a"),G=r("ModelOutput"),se=r("."),ie=l(),re=n("li"),le=r("your model can compute the loss if a "),H=n("code"),Ze=r("labels"),ge=r(` argument is provided and that loss is returned as the first
element of the tuple (if your model returns tuples)`),z=l(),I=n("li"),st=r("your model can accept multiple label arguments (use the "),ae=n("code"),it=r("label_names"),lt=r(" in your "),_e=n("a"),Ia=r("TrainingArguments"),Ua=r(" to indicate their name to the "),Ke=n("a"),Pe=r("Trainer"),Na=r(") but none of them should be named "),ve=n("code"),za=r('"label"'),Fa=r("."),this.h()},l(K){T=s(K,"P",{});var B=i(T);D=a(B,"The "),$=s(B,"A",{href:!0});var el=i($);k=a(el,"Trainer"),el.forEach(o),L=a(B,` class is optimized for \u{1F917} Transformers models and can have surprising behaviors
when you use it on other models. When using it on your own model, make sure:`),B.forEach(o),A=d(K),S=s(K,"UL",{});var be=i(S);W=s(be,"LI",{});var Xo=i(W);fe=a(Xo,"your model always return tuples or subclasses of "),oe=s(Xo,"A",{href:!0});var tl=i(oe);G=a(tl,"ModelOutput"),tl.forEach(o),se=a(Xo,"."),Xo.forEach(o),ie=d(be),re=s(be,"LI",{});var ro=i(re);le=a(ro,"your model can compute the loss if a "),H=s(ro,"CODE",{});var C=i(H);Ze=a(C,"labels"),C.forEach(o),ge=a(ro,` argument is provided and that loss is returned as the first
element of the tuple (if your model returns tuples)`),ro.forEach(o),z=d(be),I=s(be,"LI",{});var V=i(I);st=a(V,"your model can accept multiple label arguments (use the "),ae=s(V,"CODE",{});var Qo=i(ae);it=a(Qo,"label_names"),Qo.forEach(o),lt=a(V," in your "),_e=s(V,"A",{href:!0});var ol=i(_e);Ia=a(ol,"TrainingArguments"),ol.forEach(o),Ua=a(V," to indicate their name to the "),Ke=s(V,"A",{href:!0});var rl=i(Ke);Pe=a(rl,"Trainer"),rl.forEach(o),Na=a(V,") but none of them should be named "),ve=s(V,"CODE",{});var al=i(ve);za=a(al,'"label"'),al.forEach(o),Fa=a(V,"."),V.forEach(o),be.forEach(o),this.h()},h(){m($,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(oe,"href","/docs/transformers/pr_19907/en/main_classes/output#transformers.utils.ModelOutput"),m(_e,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(Ke,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer")},m(K,B){p(K,T,B),e(T,D),e(T,$),e($,k),e(T,L),p(K,A,B),p(K,S,B),e(S,W),e(W,fe),e(W,oe),e(oe,G),e(W,se),e(S,ie),e(S,re),e(re,le),e(re,H),e(H,Ze),e(re,ge),e(S,z),e(S,I),e(I,st),e(I,ae),e(ae,it),e(I,lt),e(I,_e),e(_e,Ia),e(I,Ua),e(I,Ke),e(Ke,Pe),e(I,Na),e(I,ve),e(ve,za),e(I,Fa)},d(K){K&&o(T),K&&o(A),K&&o(S)}}}function lM(Z){let T,D,$,k,L,A,S,W,fe,oe,G,se,ie,re,le,H,Ze;return{c(){T=n("p"),D=r("To use this method, you need to have provided a "),$=n("code"),k=r("model_init"),L=r(" when initializing your "),A=n("a"),S=r("Trainer"),W=r(`: we need to
reinitialize the model at each new run. This is incompatible with the `),fe=n("code"),oe=r("optimizers"),G=r(` argument, so you need to
subclass `),se=n("a"),ie=r("Trainer"),re=r(" and override the method "),le=n("a"),H=r("create_optimizer_and_scheduler()"),Ze=r(` for custom
optimizer/scheduler.`),this.h()},l(ge){T=s(ge,"P",{});var z=i(T);D=a(z,"To use this method, you need to have provided a "),$=s(z,"CODE",{});var I=i($);k=a(I,"model_init"),I.forEach(o),L=a(z," when initializing your "),A=s(z,"A",{href:!0});var st=i(A);S=a(st,"Trainer"),st.forEach(o),W=a(z,`: we need to
reinitialize the model at each new run. This is incompatible with the `),fe=s(z,"CODE",{});var ae=i(fe);oe=a(ae,"optimizers"),ae.forEach(o),G=a(z,` argument, so you need to
subclass `),se=s(z,"A",{href:!0});var it=i(se);ie=a(it,"Trainer"),it.forEach(o),re=a(z," and override the method "),le=s(z,"A",{href:!0});var lt=i(le);H=a(lt,"create_optimizer_and_scheduler()"),lt.forEach(o),Ze=a(z,` for custom
optimizer/scheduler.`),z.forEach(o),this.h()},h(){m(A,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(se,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(le,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.create_optimizer_and_scheduler")},m(ge,z){p(ge,T,z),e(T,D),e(T,$),e($,k),e(T,L),e(T,A),e(A,S),e(T,W),e(T,fe),e(fe,oe),e(T,G),e(T,se),e(se,ie),e(T,re),e(T,le),e(le,H),e(T,Ze)},d(ge){ge&&o(T)}}}function dM(Z){let T,D,$,k,L;return k=new O({props:{code:`init_mem_cpu_alloc_delta   =     1301MB
init_mem_cpu_peaked_delta  =      154MB
init_mem_gpu_alloc_delta   =      230MB
init_mem_gpu_peaked_delta  =        0MB
train_mem_cpu_alloc_delta  =     1345MB
train_mem_cpu_peaked_delta =        0MB
train_mem_gpu_alloc_delta  =      693MB
train_mem_gpu_peaked_delta =        7MB`,highlighted:`<span class="hljs-attr">init_mem_cpu_alloc_delta</span>   =     <span class="hljs-number">1301</span>MB
<span class="hljs-attr">init_mem_cpu_peaked_delta</span>  =      <span class="hljs-number">154</span>MB
<span class="hljs-attr">init_mem_gpu_alloc_delta</span>   =      <span class="hljs-number">230</span>MB
<span class="hljs-attr">init_mem_gpu_peaked_delta</span>  =        <span class="hljs-number">0</span>MB
<span class="hljs-attr">train_mem_cpu_alloc_delta</span>  =     <span class="hljs-number">1345</span>MB
<span class="hljs-attr">train_mem_cpu_peaked_delta</span> =        <span class="hljs-number">0</span>MB
<span class="hljs-attr">train_mem_gpu_alloc_delta</span>  =      <span class="hljs-number">693</span>MB
<span class="hljs-attr">train_mem_gpu_peaked_delta</span> =        <span class="hljs-number">7</span>MB`}}),{c(){T=n("p"),D=r("Now when this method is run, you will see a report that will include: :"),$=l(),h(k.$$.fragment)},l(A){T=s(A,"P",{});var S=i(T);D=a(S,"Now when this method is run, you will see a report that will include: :"),S.forEach(o),$=d(A),u(k.$$.fragment,A)},m(A,S){p(A,T,S),e(T,D),p(A,$,S),f(k,A,S),L=!0},p:nM,i(A){L||(g(k.$$.fragment,A),L=!0)},o(A){_(k.$$.fragment,A),L=!1},d(A){A&&o(T),A&&o($),v(k,A)}}}function cM(Z){let T,D;return{c(){T=n("p"),D=r(`If your predictions or labels have different sequence length (for instance because you\u2019re doing dynamic padding
in a token classification task) the predictions will be padded (on the right) to allow for concatenation into
one array. The padding index is -100.`)},l($){T=s($,"P",{});var k=i(T);D=a(k,`If your predictions or labels have different sequence length (for instance because you\u2019re doing dynamic padding
in a token classification task) the predictions will be padded (on the right) to allow for concatenation into
one array. The padding index is -100.`),k.forEach(o)},m($,k){p($,T,k),e(T,D)},d($){$&&o(T)}}}function pM(Z){let T,D;return{c(){T=n("p"),D=r(`If your predictions or labels have different sequence lengths (for instance because you\u2019re doing dynamic
padding in a token classification task) the predictions will be padded (on the right) to allow for
concatenation into one array. The padding index is -100.`)},l($){T=s($,"P",{});var k=i(T);D=a(k,`If your predictions or labels have different sequence lengths (for instance because you\u2019re doing dynamic
padding in a token classification task) the predictions will be padded (on the right) to allow for
concatenation into one array. The padding index is -100.`),k.forEach(o)},m($,k){p($,T,k),e(T,D)},d($){$&&o(T)}}}function mM(Z){let T,D;return{c(){T=n("p"),D=r("This integration is not supported anymore, we recommend you either use DeepSpeed or PyTorch FSDP.")},l($){T=s($,"P",{});var k=i(T);D=a(k,"This integration is not supported anymore, we recommend you either use DeepSpeed or PyTorch FSDP."),k.forEach(o)},m($,k){p($,T,k),e(T,D)},d($){$&&o(T)}}}function hM(Z){let T,D,$,k,L;return{c(){T=n("p"),D=r(`We strongly recommend to install PyTorch >= 1.13 (nightly version at the time of writing) on your MacOS machine.
It has major fixes related to model correctness and performance improvements for transformer based models.
Please refer to `),$=n("a"),k=r("https://github.com/pytorch/pytorch/issues/82707"),L=r(" for more details."),this.h()},l(A){T=s(A,"P",{});var S=i(T);D=a(S,`We strongly recommend to install PyTorch >= 1.13 (nightly version at the time of writing) on your MacOS machine.
It has major fixes related to model correctness and performance improvements for transformer based models.
Please refer to `),$=s(S,"A",{href:!0,rel:!0});var W=i($);k=a(W,"https://github.com/pytorch/pytorch/issues/82707"),W.forEach(o),L=a(S," for more details."),S.forEach(o),this.h()},h(){m($,"href","https://github.com/pytorch/pytorch/issues/82707"),m($,"rel","nofollow")},m(A,S){p(A,T,S),e(T,D),e(T,$),e($,k),e(T,L)},d(A){A&&o(T)}}}function uM(Z){let T,D,$,k,L,A,S,W,fe,oe,G,se,ie,re,le,H,Ze,ge,z,I,st,ae,it,lt,_e,Ia,Ua,Ke,Pe,Na,ve,za,Fa,K,B,el,be,Xo,tl,ro,C,V,Qo,ol,rl,al,nl,_p,A0,P0,D0,sl,vp,S0,q0,O0,il,bp,C0,I0,U0,dt,yp,N0,z0,wp,F0,L0,Tp,R0,W0,G0,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t,P_,tO,oO,D_,rO,aO,S_,nO,yy,Vo,q_,sO,iO,Bi,lO,dO,wy,Yo,O_,cO,pO,C_,mO,hO,Ty,Vi,Ey,zd,I_,uO,$y,ua,Yi,fO,U_,gO,_O,vO,ke,bO,N_,yO,wO,z_,TO,EO,F_,$O,xO,L_,kO,AO,xy,jt,PO,R_,DO,SO,Zi,qO,OO,ky,Fd,CO,Ay,w,IO,Ld,UO,W_,NO,Rd,zO,G_,FO,Wd,LO,M_,RO,Gd,WO,j_,GO,Md,MO,H_,jO,jd,HO,B_,BO,Hd,VO,V_,YO,Bd,ZO,Y_,KO,Vd,JO,Z_,XO,Yd,QO,K_,eC,Zd,tC,J_,oC,Kd,rC,X_,aC,Jd,nC,Q_,sC,Xd,iC,ev,lC,Qd,dC,tv,cC,ec,pC,ov,mC,tc,hC,rv,uC,oc,fC,av,gC,rc,_C,nv,vC,ac,bC,sv,yC,nc,wC,iv,TC,sc,EC,lv,$C,ic,xC,dv,kC,Py;return A=new Y({}),er=new gp({props:{warning:!0,$$slots:{default:[iM]},$$scope:{ctx:Z}}}),La=new O({props:{code:`from torch import nn
from transformers import Trainer


class CustomTrainer(Trainer):
    def compute_loss(self, model, inputs, return_outputs=False):
        labels = inputs.get("labels")
        # forward pass
        outputs = model(**inputs)
        logits = outputs.get("logits")
        # compute custom loss (suppose one has 3 labels with different weights)
        loss_fct = nn.CrossEntropyLoss(weight=torch.tensor([1.0, 2.0, 3.0]))
        loss = loss_fct(logits.view(-1, self.model.config.num_labels), labels.view(-1))
        return (loss, outputs) if return_outputs else loss`,highlighted:`<span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> nn
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer


<span class="hljs-keyword">class</span> <span class="hljs-title class_">CustomTrainer</span>(<span class="hljs-title class_ inherited__">Trainer</span>):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_loss</span>(<span class="hljs-params">self, model, inputs, return_outputs=<span class="hljs-literal">False</span></span>):
        labels = inputs.get(<span class="hljs-string">&quot;labels&quot;</span>)
        <span class="hljs-comment"># forward pass</span>
        outputs = model(**inputs)
        logits = outputs.get(<span class="hljs-string">&quot;logits&quot;</span>)
        <span class="hljs-comment"># compute custom loss (suppose one has 3 labels with different weights)</span>
        loss_fct = nn.CrossEntropyLoss(weight=torch.tensor([<span class="hljs-number">1.0</span>, <span class="hljs-number">2.0</span>, <span class="hljs-number">3.0</span>]))
        loss = loss_fct(logits.view(-<span class="hljs-number">1</span>, self.model.config.num_labels), labels.view(-<span class="hljs-number">1</span>))
        <span class="hljs-keyword">return</span> (loss, outputs) <span class="hljs-keyword">if</span> return_outputs <span class="hljs-keyword">else</span> loss`}}),Ra=new Y({}),Wa=new x({props:{name:"class transformers.Trainer",anchor:"transformers.Trainer",parameters:[{name:"model",val:": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module] = None"},{name:"args",val:": TrainingArguments = None"},{name:"data_collator",val:": typing.Optional[DataCollator] = None"},{name:"train_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"eval_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"tokenizer",val:": typing.Optional[transformers.tokenization_utils_base.PreTrainedTokenizerBase] = None"},{name:"model_init",val:": typing.Callable[[], transformers.modeling_utils.PreTrainedModel] = None"},{name:"compute_metrics",val:": typing.Union[typing.Callable[[transformers.trainer_utils.EvalPrediction], typing.Dict], NoneType] = None"},{name:"callbacks",val:": typing.Optional[typing.List[transformers.trainer_callback.TrainerCallback]] = None"},{name:"optimizers",val:": typing.Tuple[torch.optim.optimizer.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None)"},{name:"preprocess_logits_for_metrics",val:": typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor] = None"}],parametersDescription:[{anchor:"transformers.Trainer.model",description:`<strong>model</strong> (<a href="/docs/transformers/pr_19907/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a> or <code>torch.nn.Module</code>, <em>optional</em>) &#x2014;
The model to train, evaluate or use for predictions. If not provided, a <code>model_init</code> must be passed.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p><a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a> is optimized to work with the <a href="/docs/transformers/pr_19907/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a> provided by the library. You can still use
your own models defined as <code>torch.nn.Module</code> as long as they work the same way as the &#x1F917; Transformers
models.</p>

					</div>`,name:"model"},{anchor:"transformers.Trainer.args",description:`<strong>args</strong> (<a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>, <em>optional</em>) &#x2014;
The arguments to tweak for training. Will default to a basic instance of <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> with the
<code>output_dir</code> set to a directory named <em>tmp_trainer</em> in the current directory if not provided.`,name:"args"},{anchor:"transformers.Trainer.data_collator",description:`<strong>data_collator</strong> (<code>DataCollator</code>, <em>optional</em>) &#x2014;
The function to use to form a batch from a list of elements of <code>train_dataset</code> or <code>eval_dataset</code>. Will
default to <a href="/docs/transformers/pr_19907/en/main_classes/data_collator#transformers.default_data_collator">default_data_collator()</a> if no <code>tokenizer</code> is provided, an instance of
<a href="/docs/transformers/pr_19907/en/main_classes/data_collator#transformers.DataCollatorWithPadding">DataCollatorWithPadding</a> otherwise.`,name:"data_collator"},{anchor:"transformers.Trainer.train_dataset",description:`<strong>train_dataset</strong> (<code>torch.utils.data.Dataset</code> or <code>torch.utils.data.IterableDataset</code>, <em>optional</em>) &#x2014;
The dataset to use for training. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns not accepted by the
<code>model.forward()</code> method are automatically removed.</p>
<p>Note that if it&#x2019;s a <code>torch.utils.data.IterableDataset</code> with some randomization and you are training in a
distributed fashion, your iterable dataset should either use a internal attribute <code>generator</code> that is a
<code>torch.Generator</code> for the randomization that must be identical on all processes (and the Trainer will
manually set the seed of this <code>generator</code> at each epoch) or have a <code>set_epoch()</code> method that internally
sets the seed of the RNGs used.`,name:"train_dataset"},{anchor:"transformers.Trainer.eval_dataset",description:`<strong>eval_dataset</strong> (Union[<code>torch.utils.data.Dataset</code>, Dict[str, <code>torch.utils.data.Dataset</code>]), <em>optional</em>) &#x2014;
The dataset to use for evaluation. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns not accepted by the
<code>model.forward()</code> method are automatically removed. If it is a dictionary, it will evaluate on each
dataset prepending the dictionary key to the metric name.`,name:"eval_dataset"},{anchor:"transformers.Trainer.tokenizer",description:`<strong>tokenizer</strong> (<a href="/docs/transformers/pr_19907/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase">PreTrainedTokenizerBase</a>, <em>optional</em>) &#x2014;
The tokenizer used to preprocess the data. If provided, will be used to automatically pad the inputs the
maximum length when batching inputs, and it will be saved along the model to make it easier to rerun an
interrupted training or reuse the fine-tuned model.`,name:"tokenizer"},{anchor:"transformers.Trainer.model_init",description:`<strong>model_init</strong> (<code>Callable[[], PreTrainedModel]</code>, <em>optional</em>) &#x2014;
A function that instantiates the model to be used. If provided, each call to <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.train">train()</a> will start
from a new instance of the model as given by this function.</p>
<p>The function may have zero argument, or a single one containing the optuna/Ray Tune/SigOpt trial object, to
be able to choose different architectures according to hyper parameters (such as layer count, sizes of
inner layers, dropout probabilities etc).`,name:"model_init"},{anchor:"transformers.Trainer.compute_metrics",description:`<strong>compute_metrics</strong> (<code>Callable[[EvalPrediction], Dict]</code>, <em>optional</em>) &#x2014;
The function that will be used to compute metrics at evaluation. Must take a <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.EvalPrediction">EvalPrediction</a> and return
a dictionary string to metric values.`,name:"compute_metrics"},{anchor:"transformers.Trainer.callbacks",description:`<strong>callbacks</strong> (List of <a href="/docs/transformers/pr_19907/en/main_classes/callback#transformers.TrainerCallback">TrainerCallback</a>, <em>optional</em>) &#x2014;
A list of callbacks to customize the training loop. Will add those to the list of default callbacks
detailed in <a href="callback">here</a>.</p>
<p>If you want to remove one of the default callbacks used, use the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.remove_callback">Trainer.remove_callback()</a> method.`,name:"callbacks"},{anchor:"transformers.Trainer.optimizers",description:`<strong>optimizers</strong> (<code>Tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]</code>, <em>optional</em>) &#x2014; A tuple
containing the optimizer and the scheduler to use. Will default to an instance of <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> on your model
and a scheduler given by <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.get_linear_schedule_with_warmup">get_linear_schedule_with_warmup()</a> controlled by <code>args</code>.`,name:"optimizers"},{anchor:"transformers.Trainer.preprocess_logits_for_metrics",description:`<strong>preprocess_logits_for_metrics</strong> (<code>Callable[[torch.Tensor, torch.Tensor], torch.Tensor]</code>, <em>optional</em>) &#x2014;
A function that preprocess the logits right before caching them at each evaluation step. Must take two
tensors, the logits and the labels, and return the logits once processed as desired. The modifications made
by this function will be reflected in the predictions received by <code>compute_metrics</code>.</p>
<p>Note that the labels (second parameter) will be <code>None</code> if the dataset does not have them.`,name:"preprocess_logits_for_metrics"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L209"}}),Ga=new x({props:{name:"add_callback",anchor:"transformers.Trainer.add_callback",parameters:[{name:"callback",val:""}],parametersDescription:[{anchor:"transformers.Trainer.add_callback.callback",description:`<strong>callback</strong> (<code>type</code> or <code>~transformer.TrainerCallback</code>) &#x2014;
A <code>~transformer.TrainerCallback</code> class or an instance of a <code>~transformer.TrainerCallback</code>. In the
first case, will instantiate a member of that class.`,name:"callback"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L664"}}),ja=new x({props:{name:"autocast_smart_context_manager",anchor:"transformers.Trainer.autocast_smart_context_manager",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2465"}}),Ba=new x({props:{name:"compute_loss",anchor:"transformers.Trainer.compute_loss",parameters:[{name:"model",val:""},{name:"inputs",val:""},{name:"return_outputs",val:" = False"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2532"}}),Va=new x({props:{name:"compute_loss_context_manager",anchor:"transformers.Trainer.compute_loss_context_manager",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2448"}}),Ya=new x({props:{name:"create_model_card",anchor:"transformers.Trainer.create_model_card",parameters:[{name:"language",val:": typing.Optional[str] = None"},{name:"license",val:": typing.Optional[str] = None"},{name:"tags",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"model_name",val:": typing.Optional[str] = None"},{name:"finetuned_from",val:": typing.Optional[str] = None"},{name:"tasks",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"dataset_tags",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"dataset",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"dataset_args",val:": typing.Union[str, typing.List[str], NoneType] = None"}],parametersDescription:[{anchor:"transformers.Trainer.create_model_card.language",description:`<strong>language</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language of the model (if applicable)`,name:"language"},{anchor:"transformers.Trainer.create_model_card.license",description:`<strong>license</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The license of the model. Will default to the license of the pretrained model used, if the original
model given to the <code>Trainer</code> comes from a repo on the Hub.`,name:"license"},{anchor:"transformers.Trainer.create_model_card.tags",description:`<strong>tags</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
Some tags to be included in the metadata of the model card.`,name:"tags"},{anchor:"transformers.Trainer.create_model_card.model_name",description:`<strong>model_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The name of the model.`,name:"model_name"},{anchor:"transformers.Trainer.create_model_card.finetuned_from",description:`<strong>finetuned_from</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The name of the model used to fine-tune this one (if applicable). Will default to the name of the repo
of the original model given to the <code>Trainer</code> (if it comes from the Hub).`,name:"finetuned_from"},{anchor:"transformers.Trainer.create_model_card.tasks",description:`<strong>tasks</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
One or several task identifiers, to be included in the metadata of the model card.`,name:"tasks"},{anchor:"transformers.Trainer.create_model_card.dataset_tags",description:`<strong>dataset_tags</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
One or several dataset tags, to be included in the metadata of the model card.`,name:"dataset_tags"},{anchor:"transformers.Trainer.create_model_card.dataset",description:`<strong>dataset</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
One or several dataset identifiers, to be included in the metadata of the model card.`,name:"dataset"},{anchor:"transformers.Trainer.create_model_card.dataset_args",description:`<strong>dataset_args</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
One or several dataset arguments, to be included in the metadata of the model card.`,name:"dataset_args"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3316"}}),Ka=new x({props:{name:"create_optimizer",anchor:"transformers.Trainer.create_optimizer",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1024"}}),Xa=new x({props:{name:"create_optimizer_and_scheduler",anchor:"transformers.Trainer.create_optimizer_and_scheduler",parameters:[{name:"num_training_steps",val:": int"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1008"}}),Qa=new x({props:{name:"create_scheduler",anchor:"transformers.Trainer.create_scheduler",parameters:[{name:"num_training_steps",val:": int"},{name:"optimizer",val:": Optimizer = None"}],parametersDescription:[{anchor:"transformers.Trainer.create_scheduler.num_training_steps",description:"<strong>num_training_steps</strong> (int) &#x2014; The number of training steps to do.",name:"num_training_steps"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1132"}}),en=new x({props:{name:"evaluate",anchor:"transformers.Trainer.evaluate",parameters:[{name:"eval_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'eval'"}],parametersDescription:[{anchor:"transformers.Trainer.evaluate.eval_dataset",description:`<strong>eval_dataset</strong> (<code>Dataset</code>, <em>optional</em>) &#x2014;
Pass a dataset if you wish to override <code>self.eval_dataset</code>. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns
not accepted by the <code>model.forward()</code> method are automatically removed. It must implement the <code>__len__</code>
method.`,name:"eval_dataset"},{anchor:"transformers.Trainer.evaluate.ignore_keys",description:`<strong>ignore_keys</strong> (<code>Lst[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions.`,name:"ignore_keys"},{anchor:"transformers.Trainer.evaluate.metric_key_prefix",description:`<strong>metric_key_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;eval&quot;</code>) &#x2014;
An optional prefix to be used as the metrics key prefix. For example the metrics &#x201C;bleu&#x201D; will be named
&#x201C;eval_bleu&#x201D; if the prefix is &#x201C;eval&#x201D; (default)`,name:"metric_key_prefix"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2761",returnDescription:`
<p>A dictionary containing the evaluation loss and the potential metrics computed from the predictions. The
dictionary also contains the epoch number which comes from the training state.</p>
`}}),on=new x({props:{name:"evaluation_loop",anchor:"transformers.Trainer.evaluation_loop",parameters:[{name:"dataloader",val:": DataLoader"},{name:"description",val:": str"},{name:"prediction_loss_only",val:": typing.Optional[bool] = None"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'eval'"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2890"}}),rn=new x({props:{name:"floating_point_ops",anchor:"transformers.Trainer.floating_point_ops",parameters:[{name:"inputs",val:": typing.Dict[str, typing.Union[torch.Tensor, typing.Any]]"}],parametersDescription:[{anchor:"transformers.Trainer.floating_point_ops.inputs",description:`<strong>inputs</strong> (<code>Dict[str, Union[torch.Tensor, Any]]</code>) &#x2014;
The inputs and targets of the model.`,name:"inputs"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3247",returnDescription:`
<p>The number of floating-point operations.</p>
`,returnType:`
<p><code>int</code></p>
`}}),nn=new x({props:{name:"get_eval_dataloader",anchor:"transformers.Trainer.get_eval_dataloader",parameters:[{name:"eval_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"}],parametersDescription:[{anchor:"transformers.Trainer.get_eval_dataloader.eval_dataset",description:`<strong>eval_dataset</strong> (<code>torch.utils.data.Dataset</code>, <em>optional</em>) &#x2014;
If provided, will override <code>self.eval_dataset</code>. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns not accepted
by the <code>model.forward()</code> method are automatically removed. It must implement <code>__len__</code>.`,name:"eval_dataset"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L910"}}),ln=new x({props:{name:"get_optimizer_cls_and_kwargs",anchor:"transformers.Trainer.get_optimizer_cls_and_kwargs",parameters:[{name:"args",val:": TrainingArguments"}],parametersDescription:[{anchor:"transformers.Trainer.get_optimizer_cls_and_kwargs.args",description:`<strong>args</strong> (<code>transformers.training_args.TrainingArguments</code>) &#x2014;
The training arguments for the training session.`,name:"args"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1072"}}),dn=new x({props:{name:"get_test_dataloader",anchor:"transformers.Trainer.get_test_dataloader",parameters:[{name:"test_dataset",val:": Dataset"}],parametersDescription:[{anchor:"transformers.Trainer.get_test_dataloader.test_dataset",description:`<strong>test_dataset</strong> (<code>torch.utils.data.Dataset</code>, <em>optional</em>) &#x2014;
The test dataset to use. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns not accepted by the
<code>model.forward()</code> method are automatically removed. It must implement <code>__len__</code>.`,name:"test_dataset"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L960"}}),pn=new x({props:{name:"get_train_dataloader",anchor:"transformers.Trainer.get_train_dataloader",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L831"}}),hn=new x({props:{name:"hyperparameter_search",anchor:"transformers.Trainer.hyperparameter_search",parameters:[{name:"hp_space",val:": typing.Union[typing.Callable[[ForwardRef('optuna.Trial')], typing.Dict[str, float]], NoneType] = None"},{name:"compute_objective",val:": typing.Union[typing.Callable[[typing.Dict[str, float]], float], NoneType] = None"},{name:"n_trials",val:": int = 20"},{name:"direction",val:": str = 'minimize'"},{name:"backend",val:": typing.Union[ForwardRef('str'), transformers.trainer_utils.HPSearchBackend, NoneType] = None"},{name:"hp_name",val:": typing.Union[typing.Callable[[ForwardRef('optuna.Trial')], str], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Trainer.hyperparameter_search.hp_space",description:`<strong>hp_space</strong> (<code>Callable[[&quot;optuna.Trial&quot;], Dict[str, float]]</code>, <em>optional</em>) &#x2014;
A function that defines the hyperparameter search space. Will default to
<code>default_hp_space_optuna()</code> or <code>default_hp_space_ray()</code> or
<code>default_hp_space_sigopt()</code> depending on your backend.`,name:"hp_space"},{anchor:"transformers.Trainer.hyperparameter_search.compute_objective",description:`<strong>compute_objective</strong> (<code>Callable[[Dict[str, float]], float]</code>, <em>optional</em>) &#x2014;
A function computing the objective to minimize or maximize from the metrics returned by the <code>evaluate</code>
method. Will default to <code>default_compute_objective()</code>.`,name:"compute_objective"},{anchor:"transformers.Trainer.hyperparameter_search.n_trials",description:`<strong>n_trials</strong> (<code>int</code>, <em>optional</em>, defaults to 100) &#x2014;
The number of trial runs to test.`,name:"n_trials"},{anchor:"transformers.Trainer.hyperparameter_search.direction",description:`<strong>direction</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;minimize&quot;</code>) &#x2014;
Whether to optimize greater or lower objects. Can be <code>&quot;minimize&quot;</code> or <code>&quot;maximize&quot;</code>, you should pick
<code>&quot;minimize&quot;</code> when optimizing the validation loss, <code>&quot;maximize&quot;</code> when optimizing one or several metrics.`,name:"direction"},{anchor:"transformers.Trainer.hyperparameter_search.backend",description:`<strong>backend</strong> (<code>str</code> or <code>~training_utils.HPSearchBackend</code>, <em>optional</em>) &#x2014;
The backend to use for hyperparameter search. Will default to optuna or Ray Tune or SigOpt, depending
on which one is installed. If all are installed, will default to optuna.`,name:"backend"},{anchor:"transformers.Trainer.hyperparameter_search.hp_name",description:`<strong>hp_name</strong> (<code>Callable[[&quot;optuna.Trial&quot;], str]]</code>, <em>optional</em>) &#x2014;
A function that defines the trial/run name. Will default to None.`,name:"hp_name"},{anchor:"transformers.Trainer.hyperparameter_search.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments passed along to <code>optuna.create_study</code> or <code>ray.tune.run</code>. For more
information see:</p>
<ul>
<li>the documentation of
<a href="https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.create_study.html" rel="nofollow">optuna.create_study</a></li>
<li>the documentation of <a href="https://docs.ray.io/en/latest/tune/api_docs/execution.html#tune-run" rel="nofollow">tune.run</a></li>
<li>the documentation of <a href="https://app.sigopt.com/docs/endpoints/experiments/create" rel="nofollow">sigopt</a></li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2302",returnDescription:`
<p>All the information about the best run.</p>
`,returnType:`
<p><code>trainer_utils.BestRun</code></p>
`}}),pr=new gp({props:{warning:!0,$$slots:{default:[lM]},$$scope:{ctx:Z}}}),un=new x({props:{name:"init_git_repo",anchor:"transformers.Trainer.init_git_repo",parameters:[{name:"at_init",val:": bool = False"}],parametersDescription:[{anchor:"transformers.Trainer.init_git_repo.at_init",description:`<strong>at_init</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether this function is called before any training or not. If <code>self.args.overwrite_output_dir</code> is
<code>True</code> and <code>at_init</code> is <code>True</code>, the path to the repo (which is <code>self.args.output_dir</code>) might be wiped
out.`,name:"at_init"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3265"}}),gn=new x({props:{name:"is_local_process_zero",anchor:"transformers.Trainer.is_local_process_zero",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2564"}}),_n=new x({props:{name:"is_world_process_zero",anchor:"transformers.Trainer.is_world_process_zero",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2571"}}),bn=new x({props:{name:"log",anchor:"transformers.Trainer.log",parameters:[{name:"logs",val:": typing.Dict[str, float]"}],parametersDescription:[{anchor:"transformers.Trainer.log.logs",description:`<strong>logs</strong> (<code>Dict[str, float]</code>) &#x2014;
The values to log.`,name:"logs"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2397"}}),wn=new x({props:{name:"log_metrics",anchor:"transformers.Trainer.log_metrics",parameters:[{name:"split",val:""},{name:"metrics",val:""}],parametersDescription:[{anchor:"transformers.Trainer.log_metrics.split",description:`<strong>split</strong> (<code>str</code>) &#x2014;
Mode/split name: one of <code>train</code>, <code>eval</code>, <code>test</code>`,name:"split"},{anchor:"transformers.Trainer.log_metrics.metrics",description:`<strong>metrics</strong> (<code>Dict[str, float]</code>) &#x2014;
The metrics returned from train/evaluate/predictmetrics: metrics dict`,name:"metrics"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_pt_utils.py#L891"}}),fr=new sM({props:{anchor:"transformers.Trainer.log_metrics.example",$$slots:{default:[dM]},$$scope:{ctx:Z}}}),$n=new x({props:{name:"metrics_format",anchor:"transformers.Trainer.metrics_format",parameters:[{name:"metrics",val:": typing.Dict[str, float]"}],parametersDescription:[{anchor:"transformers.Trainer.metrics_format.metrics",description:`<strong>metrics</strong> (<code>Dict[str, float]</code>) &#x2014;
The metrics returned from train/evaluate/predict`,name:"metrics"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_pt_utils.py#L865",returnDescription:`
<p>The reformatted metrics</p>
`,returnType:`
<p>metrics (<code>Dict[str, float]</code>)</p>
`}}),xn=new x({props:{name:"num_examples",anchor:"transformers.Trainer.num_examples",parameters:[{name:"dataloader",val:": DataLoader"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1149"}}),An=new x({props:{name:"pop_callback",anchor:"transformers.Trainer.pop_callback",parameters:[{name:"callback",val:""}],parametersDescription:[{anchor:"transformers.Trainer.pop_callback.callback",description:`<strong>callback</strong> (<code>type</code> or <code>~transformer.TrainerCallback</code>) &#x2014;
A <code>~transformer.TrainerCallback</code> class or an instance of a <code>~transformer.TrainerCallback</code>. In the
first case, will pop the first member of that class found in the list of callbacks.`,name:"callback"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L675",returnDescription:`
<p>The callback removed, if found.</p>
`,returnType:`
<p><code>~transformer.TrainerCallback</code></p>
`}}),Sn=new x({props:{name:"predict",anchor:"transformers.Trainer.predict",parameters:[{name:"test_dataset",val:": Dataset"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'test'"}],parametersDescription:[{anchor:"transformers.Trainer.predict.test_dataset",description:`<strong>test_dataset</strong> (<code>Dataset</code>) &#x2014;
Dataset to run the predictions on. If it is an <code>datasets.Dataset</code>, columns not accepted by the
<code>model.forward()</code> method are automatically removed. Has to implement the method <code>__len__</code>`,name:"test_dataset"},{anchor:"transformers.Trainer.predict.ignore_keys",description:`<strong>ignore_keys</strong> (<code>Lst[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions.`,name:"ignore_keys"},{anchor:"transformers.Trainer.predict.metric_key_prefix",description:`<strong>metric_key_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;test&quot;</code>) &#x2014;
An optional prefix to be used as the metrics key prefix. For example the metrics &#x201C;bleu&#x201D; will be named
&#x201C;test_bleu&#x201D; if the prefix is &#x201C;test&#x201D; (default)`,name:"metric_key_prefix"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2830"}}),vr=new gp({props:{$$slots:{default:[cM]},$$scope:{ctx:Z}}}),Cn=new x({props:{name:"prediction_loop",anchor:"transformers.Trainer.prediction_loop",parameters:[{name:"dataloader",val:": DataLoader"},{name:"description",val:": str"},{name:"prediction_loss_only",val:": typing.Optional[bool] = None"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'eval'"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3473"}}),In=new x({props:{name:"prediction_step",anchor:"transformers.Trainer.prediction_step",parameters:[{name:"model",val:": Module"},{name:"inputs",val:": typing.Dict[str, typing.Union[torch.Tensor, typing.Any]]"},{name:"prediction_loss_only",val:": bool"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"}],parametersDescription:[{anchor:"transformers.Trainer.prediction_step.model",description:`<strong>model</strong> (<code>nn.Module</code>) &#x2014;
The model to evaluate.`,name:"model"},{anchor:"transformers.Trainer.prediction_step.inputs",description:`<strong>inputs</strong> (<code>Dict[str, Union[torch.Tensor, Any]]</code>) &#x2014;
The inputs and targets of the model.</p>
<p>The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
argument <code>labels</code>. Check your model&#x2019;s documentation for all accepted arguments.`,name:"inputs"},{anchor:"transformers.Trainer.prediction_step.prediction_loss_only",description:`<strong>prediction_loss_only</strong> (<code>bool</code>) &#x2014;
Whether or not to return the loss only.`,name:"prediction_loss_only"},{anchor:"transformers.Trainer.prediction_step.ignore_keys",description:`<strong>ignore_keys</strong> (<code>Lst[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions.`,name:"ignore_keys"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3150",returnDescription:`
<p>A tuple with the loss,
logits and labels (each being optional).</p>
`,returnType:`
<p>Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]</p>
`}}),Un=new x({props:{name:"push_to_hub",anchor:"transformers.Trainer.push_to_hub",parameters:[{name:"commit_message",val:": typing.Optional[str] = 'End of training'"},{name:"blocking",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Trainer.push_to_hub.commit_message",description:`<strong>commit_message</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;End of training&quot;</code>) &#x2014;
Message to commit while pushing.`,name:"commit_message"},{anchor:"transformers.Trainer.push_to_hub.blocking",description:`<strong>blocking</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the function should return only when the <code>git push</code> has finished.
kwargs &#x2014;
Additional keyword arguments passed along to <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.create_model_card">create_model_card()</a>.`,name:"blocking"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L3414",returnDescription:`
<p>The url of the commit of your model in the given repository if <code>blocking=False</code>, a tuple with the url of
the commit and an object to track the progress of the commit if <code>blocking=True</code></p>
`}}),Nn=new x({props:{name:"remove_callback",anchor:"transformers.Trainer.remove_callback",parameters:[{name:"callback",val:""}],parametersDescription:[{anchor:"transformers.Trainer.remove_callback.callback",description:`<strong>callback</strong> (<code>type</code> or <code>~transformer.TrainerCallback</code>) &#x2014;
A <code>~transformer.TrainerCallback</code> class or an instance of a <code>~transformer.TrainerCallback</code>. In the
first case, will remove the first member of that class found in the list of callbacks.`,name:"callback"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L691"}}),Fn=new x({props:{name:"save_metrics",anchor:"transformers.Trainer.save_metrics",parameters:[{name:"split",val:""},{name:"metrics",val:""},{name:"combined",val:" = True"}],parametersDescription:[{anchor:"transformers.Trainer.save_metrics.split",description:`<strong>split</strong> (<code>str</code>) &#x2014;
Mode/split name: one of <code>train</code>, <code>eval</code>, <code>test</code>, <code>all</code>`,name:"split"},{anchor:"transformers.Trainer.save_metrics.metrics",description:`<strong>metrics</strong> (<code>Dict[str, float]</code>) &#x2014;
The metrics returned from train/evaluate/predict`,name:"metrics"},{anchor:"transformers.Trainer.save_metrics.combined",description:`<strong>combined</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Creates combined metrics by updating <code>all_results.json</code> with metrics of this call`,name:"combined"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_pt_utils.py#L981"}}),Wn=new x({props:{name:"save_model",anchor:"transformers.Trainer.save_model",parameters:[{name:"output_dir",val:": typing.Optional[str] = None"},{name:"_internal_call",val:": bool = False"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2583"}}),Mn=new x({props:{name:"save_state",anchor:"transformers.Trainer.save_state",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_pt_utils.py#L1019"}}),jn=new x({props:{name:"torchdynamo_smart_context_manager",anchor:"transformers.Trainer.torchdynamo_smart_context_manager",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2459"}}),Bn=new x({props:{name:"train",anchor:"transformers.Trainer.train",parameters:[{name:"resume_from_checkpoint",val:": typing.Union[str, bool, NoneType] = None"},{name:"trial",val:": typing.Union[ForwardRef('optuna.Trial'), typing.Dict[str, typing.Any]] = None"},{name:"ignore_keys_for_eval",val:": typing.Optional[typing.List[str]] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Trainer.train.resume_from_checkpoint",description:`<strong>resume_from_checkpoint</strong> (<code>str</code> or <code>bool</code>, <em>optional</em>) &#x2014;
If a <code>str</code>, local path to a saved checkpoint as saved by a previous instance of <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>. If a
<code>bool</code> and equals <code>True</code>, load the last checkpoint in <em>args.output_dir</em> as saved by a previous instance
of <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>. If present, training will resume from the model/optimizer/scheduler states loaded here.`,name:"resume_from_checkpoint"},{anchor:"transformers.Trainer.train.trial",description:`<strong>trial</strong> (<code>optuna.Trial</code> or <code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
The trial run or the hyperparameter dictionary for hyperparameter search.`,name:"trial"},{anchor:"transformers.Trainer.train.ignore_keys_for_eval",description:`<strong>ignore_keys_for_eval</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions for evaluation during the training.
kwargs &#x2014;
Additional keyword arguments used to hide deprecated arguments`,name:"ignore_keys_for_eval"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L1427"}}),Vn=new x({props:{name:"training_step",anchor:"transformers.Trainer.training_step",parameters:[{name:"model",val:": Module"},{name:"inputs",val:": typing.Dict[str, typing.Union[torch.Tensor, typing.Any]]"}],parametersDescription:[{anchor:"transformers.Trainer.training_step.model",description:`<strong>model</strong> (<code>nn.Module</code>) &#x2014;
The model to train.`,name:"model"},{anchor:"transformers.Trainer.training_step.inputs",description:`<strong>inputs</strong> (<code>Dict[str, Union[torch.Tensor, Any]]</code>) &#x2014;
The inputs and targets of the model.</p>
<p>The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
argument <code>labels</code>. Check your model&#x2019;s documentation for all accepted arguments.`,name:"inputs"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer.py#L2484",returnDescription:`
<p>The tensor with training loss on this batch.</p>
`,returnType:`
<p><code>torch.Tensor</code></p>
`}}),Yn=new Y({}),Zn=new x({props:{name:"class transformers.Seq2SeqTrainer",anchor:"transformers.Seq2SeqTrainer",parameters:[{name:"model",val:": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module] = None"},{name:"args",val:": TrainingArguments = None"},{name:"data_collator",val:": typing.Optional[DataCollator] = None"},{name:"train_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"eval_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"tokenizer",val:": typing.Optional[transformers.tokenization_utils_base.PreTrainedTokenizerBase] = None"},{name:"model_init",val:": typing.Callable[[], transformers.modeling_utils.PreTrainedModel] = None"},{name:"compute_metrics",val:": typing.Union[typing.Callable[[transformers.trainer_utils.EvalPrediction], typing.Dict], NoneType] = None"},{name:"callbacks",val:": typing.Optional[typing.List[transformers.trainer_callback.TrainerCallback]] = None"},{name:"optimizers",val:": typing.Tuple[torch.optim.optimizer.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None)"},{name:"preprocess_logits_for_metrics",val:": typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor] = None"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_seq2seq.py#L30"}}),Kn=new x({props:{name:"evaluate",anchor:"transformers.Seq2SeqTrainer.evaluate",parameters:[{name:"eval_dataset",val:": typing.Optional[torch.utils.data.dataset.Dataset] = None"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'eval'"},{name:"**gen_kwargs",val:""}],parametersDescription:[{anchor:"transformers.Seq2SeqTrainer.evaluate.eval_dataset",description:`<strong>eval_dataset</strong> (<code>Dataset</code>, <em>optional</em>) &#x2014;
Pass a dataset if you wish to override <code>self.eval_dataset</code>. If it is an <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns
not accepted by the <code>model.forward()</code> method are automatically removed. It must implement the <code>__len__</code>
method.`,name:"eval_dataset"},{anchor:"transformers.Seq2SeqTrainer.evaluate.ignore_keys",description:`<strong>ignore_keys</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions.`,name:"ignore_keys"},{anchor:"transformers.Seq2SeqTrainer.evaluate.metric_key_prefix",description:`<strong>metric_key_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;eval&quot;</code>) &#x2014;
An optional prefix to be used as the metrics key prefix. For example the metrics &#x201C;bleu&#x201D; will be named
&#x201C;eval_bleu&#x201D; if the prefix is <code>&quot;eval&quot;</code> (default)`,name:"metric_key_prefix"},{anchor:"transformers.Seq2SeqTrainer.evaluate.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The maximum target length to use when predicting with the generate method.`,name:"max_length"},{anchor:"transformers.Seq2SeqTrainer.evaluate.num_beams",description:`<strong>num_beams</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of beams for beam search that will be used when predicting with the generate method. 1 means no
beam search.
gen_kwargs &#x2014;
Additional <code>generate</code> specific kwargs.`,name:"num_beams"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_seq2seq.py#L31",returnDescription:`
<p>A dictionary containing the evaluation loss and the potential metrics computed from the predictions. The
dictionary also contains the epoch number which comes from the training state.</p>
`}}),Xn=new x({props:{name:"predict",anchor:"transformers.Seq2SeqTrainer.predict",parameters:[{name:"test_dataset",val:": Dataset"},{name:"ignore_keys",val:": typing.Optional[typing.List[str]] = None"},{name:"metric_key_prefix",val:": str = 'test'"},{name:"**gen_kwargs",val:""}],parametersDescription:[{anchor:"transformers.Seq2SeqTrainer.predict.test_dataset",description:`<strong>test_dataset</strong> (<code>Dataset</code>) &#x2014;
Dataset to run the predictions on. If it is a <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset" rel="nofollow">Dataset</a>, columns not accepted by the
<code>model.forward()</code> method are automatically removed. Has to implement the method <code>__len__</code>`,name:"test_dataset"},{anchor:"transformers.Seq2SeqTrainer.predict.ignore_keys",description:`<strong>ignore_keys</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
A list of keys in the output of your model (if it is a dictionary) that should be ignored when
gathering predictions.`,name:"ignore_keys"},{anchor:"transformers.Seq2SeqTrainer.predict.metric_key_prefix",description:`<strong>metric_key_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;eval&quot;</code>) &#x2014;
An optional prefix to be used as the metrics key prefix. For example the metrics &#x201C;bleu&#x201D; will be named
&#x201C;eval_bleu&#x201D; if the prefix is <code>&quot;eval&quot;</code> (default)`,name:"metric_key_prefix"},{anchor:"transformers.Seq2SeqTrainer.predict.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The maximum target length to use when predicting with the generate method.`,name:"max_length"},{anchor:"transformers.Seq2SeqTrainer.predict.num_beams",description:`<strong>num_beams</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of beams for beam search that will be used when predicting with the generate method. 1 means no
beam search.
gen_kwargs &#x2014;
Additional <code>generate</code> specific kwargs.`,name:"num_beams"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/trainer_seq2seq.py#L80"}}),$r=new gp({props:{$$slots:{default:[pM]},$$scope:{ctx:Z}}}),ts=new Y({}),os=new x({props:{name:"class transformers.TrainingArguments",anchor:"transformers.TrainingArguments",parameters:[{name:"output_dir",val:": str"},{name:"overwrite_output_dir",val:": bool = False"},{name:"do_train",val:": bool = False"},{name:"do_eval",val:": bool = False"},{name:"do_predict",val:": bool = False"},{name:"evaluation_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'no'"},{name:"prediction_loss_only",val:": bool = False"},{name:"per_device_train_batch_size",val:": int = 8"},{name:"per_device_eval_batch_size",val:": int = 8"},{name:"per_gpu_train_batch_size",val:": typing.Optional[int] = None"},{name:"per_gpu_eval_batch_size",val:": typing.Optional[int] = None"},{name:"gradient_accumulation_steps",val:": int = 1"},{name:"eval_accumulation_steps",val:": typing.Optional[int] = None"},{name:"eval_delay",val:": typing.Optional[float] = 0"},{name:"learning_rate",val:": float = 5e-05"},{name:"weight_decay",val:": float = 0.0"},{name:"adam_beta1",val:": float = 0.9"},{name:"adam_beta2",val:": float = 0.999"},{name:"adam_epsilon",val:": float = 1e-08"},{name:"max_grad_norm",val:": float = 1.0"},{name:"num_train_epochs",val:": float = 3.0"},{name:"max_steps",val:": int = -1"},{name:"lr_scheduler_type",val:": typing.Union[transformers.trainer_utils.SchedulerType, str] = 'linear'"},{name:"warmup_ratio",val:": float = 0.0"},{name:"warmup_steps",val:": int = 0"},{name:"log_level",val:": typing.Optional[str] = 'passive'"},{name:"log_level_replica",val:": typing.Optional[str] = 'passive'"},{name:"log_on_each_node",val:": bool = True"},{name:"logging_dir",val:": typing.Optional[str] = None"},{name:"logging_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"},{name:"logging_first_step",val:": bool = False"},{name:"logging_steps",val:": int = 500"},{name:"logging_nan_inf_filter",val:": bool = True"},{name:"save_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"},{name:"save_steps",val:": int = 500"},{name:"save_total_limit",val:": typing.Optional[int] = None"},{name:"save_on_each_node",val:": bool = False"},{name:"no_cuda",val:": bool = False"},{name:"use_mps_device",val:": bool = False"},{name:"seed",val:": int = 42"},{name:"data_seed",val:": typing.Optional[int] = None"},{name:"jit_mode_eval",val:": bool = False"},{name:"use_ipex",val:": bool = False"},{name:"bf16",val:": bool = False"},{name:"fp16",val:": bool = False"},{name:"fp16_opt_level",val:": str = 'O1'"},{name:"half_precision_backend",val:": str = 'auto'"},{name:"bf16_full_eval",val:": bool = False"},{name:"fp16_full_eval",val:": bool = False"},{name:"tf32",val:": typing.Optional[bool] = None"},{name:"local_rank",val:": int = -1"},{name:"xpu_backend",val:": typing.Optional[str] = None"},{name:"tpu_num_cores",val:": typing.Optional[int] = None"},{name:"tpu_metrics_debug",val:": bool = False"},{name:"debug",val:": str = ''"},{name:"dataloader_drop_last",val:": bool = False"},{name:"eval_steps",val:": typing.Optional[int] = None"},{name:"dataloader_num_workers",val:": int = 0"},{name:"past_index",val:": int = -1"},{name:"run_name",val:": typing.Optional[str] = None"},{name:"disable_tqdm",val:": typing.Optional[bool] = None"},{name:"remove_unused_columns",val:": typing.Optional[bool] = True"},{name:"label_names",val:": typing.Optional[typing.List[str]] = None"},{name:"load_best_model_at_end",val:": typing.Optional[bool] = False"},{name:"metric_for_best_model",val:": typing.Optional[str] = None"},{name:"greater_is_better",val:": typing.Optional[bool] = None"},{name:"ignore_data_skip",val:": bool = False"},{name:"sharded_ddp",val:": str = ''"},{name:"fsdp",val:": str = ''"},{name:"fsdp_min_num_params",val:": int = 0"},{name:"fsdp_transformer_layer_cls_to_wrap",val:": typing.Optional[str] = None"},{name:"deepspeed",val:": typing.Optional[str] = None"},{name:"label_smoothing_factor",val:": float = 0.0"},{name:"optim",val:": typing.Union[transformers.training_args.OptimizerNames, str] = 'adamw_hf'"},{name:"adafactor",val:": bool = False"},{name:"group_by_length",val:": bool = False"},{name:"length_column_name",val:": typing.Optional[str] = 'length'"},{name:"report_to",val:": typing.Optional[typing.List[str]] = None"},{name:"ddp_find_unused_parameters",val:": typing.Optional[bool] = None"},{name:"ddp_bucket_cap_mb",val:": typing.Optional[int] = None"},{name:"dataloader_pin_memory",val:": bool = True"},{name:"skip_memory_metrics",val:": bool = True"},{name:"use_legacy_prediction_loop",val:": bool = False"},{name:"push_to_hub",val:": bool = False"},{name:"resume_from_checkpoint",val:": typing.Optional[str] = None"},{name:"hub_model_id",val:": typing.Optional[str] = None"},{name:"hub_strategy",val:": typing.Union[transformers.trainer_utils.HubStrategy, str] = 'every_save'"},{name:"hub_token",val:": typing.Optional[str] = None"},{name:"hub_private_repo",val:": bool = False"},{name:"gradient_checkpointing",val:": bool = False"},{name:"include_inputs_for_metrics",val:": bool = False"},{name:"fp16_backend",val:": str = 'auto'"},{name:"push_to_hub_model_id",val:": typing.Optional[str] = None"},{name:"push_to_hub_organization",val:": typing.Optional[str] = None"},{name:"push_to_hub_token",val:": typing.Optional[str] = None"},{name:"mp_parameters",val:": str = ''"},{name:"auto_find_batch_size",val:": bool = False"},{name:"full_determinism",val:": bool = False"},{name:"torchdynamo",val:": typing.Optional[str] = None"},{name:"ray_scope",val:": typing.Optional[str] = 'last'"},{name:"ddp_timeout",val:": typing.Optional[int] = 1800"}],parametersDescription:[{anchor:"transformers.TrainingArguments.output_dir",description:`<strong>output_dir</strong> (<code>str</code>) &#x2014;
The output directory where the model predictions and checkpoints will be written.`,name:"output_dir"},{anchor:"transformers.TrainingArguments.overwrite_output_dir",description:`<strong>overwrite_output_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, overwrite the content of the output directory. Use this to continue training if <code>output_dir</code>
points to a checkpoint directory.`,name:"overwrite_output_dir"},{anchor:"transformers.TrainingArguments.do_train",description:`<strong>do_train</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run training or not. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used
by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_train"},{anchor:"transformers.TrainingArguments.do_eval",description:`<strong>do_eval</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to run evaluation on the validation set or not. Will be set to <code>True</code> if <code>evaluation_strategy</code> is
different from <code>&quot;no&quot;</code>. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used by your
training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_eval"},{anchor:"transformers.TrainingArguments.do_predict",description:`<strong>do_predict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run predictions on the test set or not. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s
intended to be used by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_predict"},{anchor:"transformers.TrainingArguments.evaluation_strategy",description:`<strong>evaluation_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;no&quot;</code>) &#x2014;
The evaluation strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No evaluation is done during training.</li>
<li><code>&quot;steps&quot;</code>: Evaluation is done (and logged) every <code>eval_steps</code>.</li>
<li><code>&quot;epoch&quot;</code>: Evaluation is done at the end of each epoch.</li>
</ul>`,name:"evaluation_strategy"},{anchor:"transformers.TrainingArguments.prediction_loss_only",description:`<strong>prediction_loss_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When performing evaluation and generating predictions, only returns the loss.`,name:"prediction_loss_only"},{anchor:"transformers.TrainingArguments.per_device_train_batch_size",description:`<strong>per_device_train_batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
The batch size per GPU/TPU core/CPU for training.`,name:"per_device_train_batch_size"},{anchor:"transformers.TrainingArguments.per_device_eval_batch_size",description:`<strong>per_device_eval_batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
The batch size per GPU/TPU core/CPU for evaluation.`,name:"per_device_eval_batch_size"},{anchor:"transformers.TrainingArguments.gradient_accumulation_steps",description:`<strong>gradient_accumulation_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of updates steps to accumulate the gradients for, before performing a backward/update pass.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>When using gradient accumulation, one step is counted as one step with backward pass. Therefore, logging,
evaluation, save will be conducted every <code>gradient_accumulation_steps * xxx_step</code> training examples.</p>

					</div>`,name:"gradient_accumulation_steps"},{anchor:"transformers.TrainingArguments.eval_accumulation_steps",description:`<strong>eval_accumulation_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of predictions steps to accumulate the output tensors for, before moving the results to the CPU. If
left unset, the whole predictions are accumulated on GPU/TPU before being moved to the CPU (faster but
requires more memory).`,name:"eval_accumulation_steps"},{anchor:"transformers.TrainingArguments.eval_delay",description:`<strong>eval_delay</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Number of epochs or steps to wait for before the first evaluation can be performed, depending on the
evaluation_strategy.`,name:"eval_delay"},{anchor:"transformers.TrainingArguments.learning_rate",description:`<strong>learning_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 5e-5) &#x2014;
The initial learning rate for <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"learning_rate"},{anchor:"transformers.TrainingArguments.weight_decay",description:`<strong>weight_decay</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a>
optimizer.`,name:"weight_decay"},{anchor:"transformers.TrainingArguments.adam_beta1",description:`<strong>adam_beta1</strong> (<code>float</code>, <em>optional</em>, defaults to 0.9) &#x2014;
The beta1 hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_beta1"},{anchor:"transformers.TrainingArguments.adam_beta2",description:`<strong>adam_beta2</strong> (<code>float</code>, <em>optional</em>, defaults to 0.999) &#x2014;
The beta2 hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_beta2"},{anchor:"transformers.TrainingArguments.adam_epsilon",description:`<strong>adam_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-8) &#x2014;
The epsilon hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_epsilon"},{anchor:"transformers.TrainingArguments.max_grad_norm",description:`<strong>max_grad_norm</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Maximum gradient norm (for gradient clipping).`,name:"max_grad_norm"},{anchor:"transformers.TrainingArguments.num_train_epochs(float,",description:`<strong>num_train_epochs(<code>float</code>,</strong> <em>optional</em>, defaults to 3.0) &#x2014;
Total number of training epochs to perform (if not an integer, will perform the decimal part percents of
the last epoch before stopping training).`,name:"num_train_epochs(float,"},{anchor:"transformers.TrainingArguments.max_steps",description:`<strong>max_steps</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
If set to a positive number, the total number of training steps to perform. Overrides <code>num_train_epochs</code>.
In case of using a finite iterable dataset the training may stop before reaching the set number of steps
when all data is exhausted`,name:"max_steps"},{anchor:"transformers.TrainingArguments.lr_scheduler_type",description:`<strong>lr_scheduler_type</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.SchedulerType">SchedulerType</a>, <em>optional</em>, defaults to <code>&quot;linear&quot;</code>) &#x2014;
The scheduler type to use. See the documentation of <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.SchedulerType">SchedulerType</a> for all possible values.`,name:"lr_scheduler_type"},{anchor:"transformers.TrainingArguments.warmup_ratio",description:`<strong>warmup_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Ratio of total training steps used for a linear warmup from 0 to <code>learning_rate</code>.`,name:"warmup_ratio"},{anchor:"transformers.TrainingArguments.warmup_steps",description:`<strong>warmup_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of steps used for a linear warmup from 0 to <code>learning_rate</code>. Overrides any effect of <code>warmup_ratio</code>.`,name:"warmup_steps"},{anchor:"transformers.TrainingArguments.log_level",description:`<strong>log_level</strong> (<code>str</code>, <em>optional</em>, defaults to <code>passive</code>) &#x2014;
Logger log level to use on the main process. Possible choices are the log levels as strings: &#x2018;debug&#x2019;,
&#x2018;info&#x2019;, &#x2018;warning&#x2019;, &#x2018;error&#x2019; and &#x2018;critical&#x2019;, plus a &#x2018;passive&#x2019; level which doesn&#x2019;t set anything and lets the
application set the level.`,name:"log_level"},{anchor:"transformers.TrainingArguments.log_level_replica",description:`<strong>log_level_replica</strong> (<code>str</code>, <em>optional</em>, defaults to <code>passive</code>) &#x2014;
Logger log level to use on replicas. Same choices as <code>log_level</code>&#x201D;`,name:"log_level_replica"},{anchor:"transformers.TrainingArguments.log_on_each_node",description:`<strong>log_on_each_node</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
In multinode distributed training, whether to log using <code>log_level</code> once per node, or only on the main
node.`,name:"log_on_each_node"},{anchor:"transformers.TrainingArguments.logging_dir",description:`<strong>logging_dir</strong> (<code>str</code>, <em>optional</em>) &#x2014;
<a href="https://www.tensorflow.org/tensorboard" rel="nofollow">TensorBoard</a> log directory. Will default to
*output_dir/runs/<strong>CURRENT_DATETIME_HOSTNAME*</strong>.`,name:"logging_dir"},{anchor:"transformers.TrainingArguments.logging_strategy",description:`<strong>logging_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;steps&quot;</code>) &#x2014;
The logging strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No logging is done during training.</li>
<li><code>&quot;epoch&quot;</code>: Logging is done at the end of each epoch.</li>
<li><code>&quot;steps&quot;</code>: Logging is done every <code>logging_steps</code>.</li>
</ul>`,name:"logging_strategy"},{anchor:"transformers.TrainingArguments.logging_first_step",description:`<strong>logging_first_step</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to log and evaluate the first <code>global_step</code> or not.`,name:"logging_first_step"},{anchor:"transformers.TrainingArguments.logging_steps",description:`<strong>logging_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 500) &#x2014;
Number of update steps between two logs if <code>logging_strategy=&quot;steps&quot;</code>.`,name:"logging_steps"},{anchor:"transformers.TrainingArguments.logging_nan_inf_filter",description:`<strong>logging_nan_inf_filter</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to filter <code>nan</code> and <code>inf</code> losses for logging. If set to <code>True</code> the loss of every step that is <code>nan</code>
or <code>inf</code> is filtered and the average loss of the current logging window is taken instead.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p><code>logging_nan_inf_filter</code> only influences the logging of loss values, it does not change the behavior the
gradient is computed or applied to the model.</p>

					</div>`,name:"logging_nan_inf_filter"},{anchor:"transformers.TrainingArguments.save_strategy",description:`<strong>save_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;steps&quot;</code>) &#x2014;
The checkpoint save strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No save is done during training.</li>
<li><code>&quot;epoch&quot;</code>: Save is done at the end of each epoch.</li>
<li><code>&quot;steps&quot;</code>: Save is done every <code>save_steps</code>.</li>
</ul>`,name:"save_strategy"},{anchor:"transformers.TrainingArguments.save_steps",description:`<strong>save_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 500) &#x2014;
Number of updates steps before two checkpoint saves if <code>save_strategy=&quot;steps&quot;</code>.`,name:"save_steps"},{anchor:"transformers.TrainingArguments.save_total_limit",description:`<strong>save_total_limit</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If a value is passed, will limit the total amount of checkpoints. Deletes the older checkpoints in
<code>output_dir</code>.`,name:"save_total_limit"},{anchor:"transformers.TrainingArguments.save_on_each_node",description:`<strong>save_on_each_node</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When doing multi-node distributed training, whether to save models and checkpoints on each node, or only on
the main one.</p>
<p>This should not be activated when the different nodes use the same storage as the files will be saved with
the same names for each node.`,name:"save_on_each_node"},{anchor:"transformers.TrainingArguments.no_cuda",description:`<strong>no_cuda</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to not use CUDA even when it is available or not.`,name:"no_cuda"},{anchor:"transformers.TrainingArguments.seed",description:`<strong>seed</strong> (<code>int</code>, <em>optional</em>, defaults to 42) &#x2014;
Random seed that will be set at the beginning of training. To ensure reproducibility across runs, use the
<code>~Trainer.model_init</code> function to instantiate the model if it has some randomly initialized parameters.`,name:"seed"},{anchor:"transformers.TrainingArguments.data_seed",description:`<strong>data_seed</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Random seed to be used with data samplers. If not set, random generators for data sampling will use the
same seed as <code>seed</code>. This can be used to ensure reproducibility of data sampling, independent of the model
seed.`,name:"data_seed"},{anchor:"transformers.TrainingArguments.jit_mode_eval",description:`<strong>jit_mode_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use PyTorch jit trace for inference.`,name:"jit_mode_eval"},{anchor:"transformers.TrainingArguments.use_ipex",description:`<strong>use_ipex</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use Intel extension for PyTorch when it is available. <a href="https://github.com/intel/intel-extension-for-pytorch" rel="nofollow">IPEX
installation</a>.`,name:"use_ipex"},{anchor:"transformers.TrainingArguments.bf16",description:`<strong>bf16</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use bf16 16-bit (mixed) precision training instead of 32-bit training. Requires Ampere or higher
NVIDIA architecture or using CPU (no_cuda). This is an experimental API and it may change.`,name:"bf16"},{anchor:"transformers.TrainingArguments.fp16",description:`<strong>fp16</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use fp16 16-bit (mixed) precision training instead of 32-bit training.`,name:"fp16"},{anchor:"transformers.TrainingArguments.fp16_opt_level",description:`<strong>fp16_opt_level</strong> (<code>str</code>, <em>optional</em>, defaults to &#x2018;O1&#x2019;) &#x2014;
For <code>fp16</code> training, Apex AMP optimization level selected in [&#x2018;O0&#x2019;, &#x2018;O1&#x2019;, &#x2018;O2&#x2019;, and &#x2018;O3&#x2019;]. See details on
the <a href="https://nvidia.github.io/apex/amp" rel="nofollow">Apex documentation</a>.`,name:"fp16_opt_level"},{anchor:"transformers.TrainingArguments.fp16_backend",description:`<strong>fp16_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
This argument is deprecated. Use <code>half_precision_backend</code> instead.`,name:"fp16_backend"},{anchor:"transformers.TrainingArguments.half_precision_backend",description:`<strong>half_precision_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
The backend to use for mixed precision training. Must be one of <code>&quot;auto&quot;, &quot;cuda_amp&quot;, &quot;apex&quot;, &quot;cpu_amp&quot;</code>.
<code>&quot;auto&quot;</code> will use CPU/CUDA AMP or APEX depending on the PyTorch version detected, while the other choices
will force the requested backend.`,name:"half_precision_backend"},{anchor:"transformers.TrainingArguments.bf16_full_eval",description:`<strong>bf16_full_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use full bfloat16 evaluation instead of 32-bit. This will be faster and save memory but can harm
metric values. This is an experimental API and it may change.`,name:"bf16_full_eval"},{anchor:"transformers.TrainingArguments.fp16_full_eval",description:`<strong>fp16_full_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use full float16 evaluation instead of 32-bit. This will be faster and save memory but can harm
metric values.`,name:"fp16_full_eval"},{anchor:"transformers.TrainingArguments.tf32",description:`<strong>tf32</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to enable the TF32 mode, available in Ampere and newer GPU architectures. The default value depends
on PyTorch&#x2019;s version default of <code>torch.backends.cuda.matmul.allow_tf32</code>. For more details please refer to
the <a href="https://huggingface.co/docs/transformers/performance#tf32" rel="nofollow">TF32</a> documentation. This is an
experimental API and it may change.`,name:"tf32"},{anchor:"transformers.TrainingArguments.local_rank",description:`<strong>local_rank</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
Rank of the process during distributed training.`,name:"local_rank"},{anchor:"transformers.TrainingArguments.xpu_backend",description:`<strong>xpu_backend</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The backend to use for xpu distributed training. Must be one of <code>&quot;mpi&quot;</code> or <code>&quot;ccl&quot;</code> or <code>&quot;gloo&quot;</code>.`,name:"xpu_backend"},{anchor:"transformers.TrainingArguments.tpu_num_cores",description:`<strong>tpu_num_cores</strong> (<code>int</code>, <em>optional</em>) &#x2014;
When training on TPU, the number of TPU cores (automatically passed by launcher script).`,name:"tpu_num_cores"},{anchor:"transformers.TrainingArguments.dataloader_drop_last",description:`<strong>dataloader_drop_last</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to drop the last incomplete batch (if the length of the dataset is not divisible by the batch size)
or not.`,name:"dataloader_drop_last"},{anchor:"transformers.TrainingArguments.eval_steps",description:`<strong>eval_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of update steps between two evaluations if <code>evaluation_strategy=&quot;steps&quot;</code>. Will default to the same
value as <code>logging_steps</code> if not set.`,name:"eval_steps"},{anchor:"transformers.TrainingArguments.dataloader_num_workers",description:`<strong>dataloader_num_workers</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of subprocesses to use for data loading (PyTorch only). 0 means that the data will be loaded in the
main process.`,name:"dataloader_num_workers"},{anchor:"transformers.TrainingArguments.past_index",description:`<strong>past_index</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
Some models like <a href="../model_doc/transformerxl">TransformerXL</a> or <a href="../model_doc/xlnet">XLNet</a> can make use of
the past hidden states for their predictions. If this argument is set to a positive int, the <code>Trainer</code> will
use the corresponding output (usually index 2) as the past state and feed it to the model at the next
training step under the keyword argument <code>mems</code>.`,name:"past_index"},{anchor:"transformers.TrainingArguments.run_name",description:`<strong>run_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
A descriptor for the run. Typically used for <a href="https://www.wandb.com/" rel="nofollow">wandb</a> and
<a href="https://www.mlflow.org/" rel="nofollow">mlflow</a> logging.`,name:"run_name"},{anchor:"transformers.TrainingArguments.disable_tqdm",description:`<strong>disable_tqdm</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to disable the tqdm progress bars and table of metrics produced by
<code>~notebook.NotebookTrainingTracker</code> in Jupyter Notebooks. Will default to <code>True</code> if the logging level is
set to warn or lower (default), <code>False</code> otherwise.`,name:"disable_tqdm"},{anchor:"transformers.TrainingArguments.remove_unused_columns",description:`<strong>remove_unused_columns</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to automatically remove the columns unused by the model forward method.</p>
<p>(Note that this behavior is not implemented for <code>TFTrainer</code> yet.)`,name:"remove_unused_columns"},{anchor:"transformers.TrainingArguments.label_names",description:`<strong>label_names</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
The list of keys in your dictionary of inputs that correspond to the labels.</p>
<p>Will eventually default to <code>[&quot;labels&quot;]</code> except if the model used is one of the <code>XxxForQuestionAnswering</code> in
which case it will default to <code>[&quot;start_positions&quot;, &quot;end_positions&quot;]</code>.`,name:"label_names"},{anchor:"transformers.TrainingArguments.load_best_model_at_end",description:`<strong>load_best_model_at_end</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to load the best model found during training at the end of training.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When set to <code>True</code>, the parameters <code>save_strategy</code> needs to be the same as <code>evaluation_strategy</code>, and in
the case it is &#x201C;steps&#x201D;, <code>save_steps</code> must be a round multiple of <code>eval_steps</code>.</p>

					</div>`,name:"load_best_model_at_end"},{anchor:"transformers.TrainingArguments.metric_for_best_model",description:`<strong>metric_for_best_model</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Use in conjunction with <code>load_best_model_at_end</code> to specify the metric to use to compare two different
models. Must be the name of a metric returned by the evaluation with or without the prefix <code>&quot;eval_&quot;</code>. Will
default to <code>&quot;loss&quot;</code> if unspecified and <code>load_best_model_at_end=True</code> (to use the evaluation loss).</p>
<p>If you set this value, <code>greater_is_better</code> will default to <code>True</code>. Don&#x2019;t forget to set it to <code>False</code> if
your metric is better when lower.`,name:"metric_for_best_model"},{anchor:"transformers.TrainingArguments.greater_is_better",description:`<strong>greater_is_better</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Use in conjunction with <code>load_best_model_at_end</code> and <code>metric_for_best_model</code> to specify if better models
should have a greater metric or not. Will default to:</p>
<ul>
<li><code>True</code> if <code>metric_for_best_model</code> is set to a value that isn&#x2019;t <code>&quot;loss&quot;</code> or <code>&quot;eval_loss&quot;</code>.</li>
<li><code>False</code> if <code>metric_for_best_model</code> is not set, or set to <code>&quot;loss&quot;</code> or <code>&quot;eval_loss&quot;</code>.</li>
</ul>`,name:"greater_is_better"},{anchor:"transformers.TrainingArguments.ignore_data_skip",description:`<strong>ignore_data_skip</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When resuming training, whether or not to skip the epochs and batches to get the data loading at the same
stage as in the previous training. If set to <code>True</code>, the training will begin faster (as that skipping step
can take a long time) but will not yield the same results as the interrupted training would have.`,name:"ignore_data_skip"},{anchor:"transformers.TrainingArguments.sharded_ddp",description:`<strong>sharded_ddp</strong> (<code>bool</code>, <code>str</code> or list of <code>ShardedDDPOption</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use Sharded DDP training from <a href="https://github.com/facebookresearch/fairscale" rel="nofollow">FairScale</a> (in distributed
training only). This is an experimental feature.</p>
<p>A list of options along the following:</p>
<ul>
<li><code>&quot;simple&quot;</code>: to use first instance of sharded DDP released by fairscale (<code>ShardedDDP</code>) similar to ZeRO-2.</li>
<li><code>&quot;zero_dp_2&quot;</code>: to use the second instance of sharded DPP released by fairscale (<code>FullyShardedDDP</code>) in
Zero-2 mode (with <code>reshard_after_forward=False</code>).</li>
<li><code>&quot;zero_dp_3&quot;</code>: to use the second instance of sharded DPP released by fairscale (<code>FullyShardedDDP</code>) in
Zero-3 mode (with <code>reshard_after_forward=True</code>).</li>
<li><code>&quot;offload&quot;</code>: to add ZeRO-offload (only compatible with <code>&quot;zero_dp_2&quot;</code> and <code>&quot;zero_dp_3&quot;</code>).</li>
</ul>
<p>If a string is passed, it will be split on space. If a bool is passed, it will be converted to an empty
list for <code>False</code> and <code>[&quot;simple&quot;]</code> for <code>True</code>.`,name:"sharded_ddp"},{anchor:"transformers.TrainingArguments.fsdp",description:`<strong>fsdp</strong> (<code>bool</code>, <code>str</code> or list of <code>FSDPOption</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use PyTorch Distributed Parallel Training (in distributed training only).</p>
<p>A list of options along the following:</p>
<ul>
<li><code>&quot;full_shard&quot;</code>: Shard parameters, gradients and optimizer states.</li>
<li><code>&quot;shard_grad_op&quot;</code>: Shard optimizer states and gradients.</li>
<li><code>&quot;offload&quot;</code>: Offload parameters and gradients to CPUs (only compatible with <code>&quot;full_shard&quot;</code> and
<code>&quot;shard_grad_op&quot;</code>).</li>
<li><code>&quot;auto_wrap&quot;</code>: Automatically recursively wrap layers with FSDP using <code>default_auto_wrap_policy</code>.</li>
</ul>`,name:"fsdp"},{anchor:"transformers.TrainingArguments.fsdp_min_num_params",description:`<strong>fsdp_min_num_params</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
FSDP&#x2019;s minimum number of parameters for Default Auto Wrapping. (useful only when <code>fsdp</code> field is passed).`,name:"fsdp_min_num_params"},{anchor:"transformers.TrainingArguments.deepspeed",description:`<strong>deepspeed</strong> (<code>str</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Use <a href="https://github.com/microsoft/deepspeed" rel="nofollow">Deepspeed</a>. This is an experimental feature and its API may
evolve in the future. The value is either the location of DeepSpeed json config file (e.g.,
<code>ds_config.json</code>) or an already loaded json file as a <code>dict</code>&#x201D;`,name:"deepspeed"},{anchor:"transformers.TrainingArguments.label_smoothing_factor",description:`<strong>label_smoothing_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The label smoothing factor to use. Zero means no label smoothing, otherwise the underlying onehot-encoded
labels are changed from 0s and 1s to <code>label_smoothing_factor/num_labels</code> and <code>1 - label_smoothing_factor + label_smoothing_factor/num_labels</code> respectively.`,name:"label_smoothing_factor"},{anchor:"transformers.TrainingArguments.debug",description:`<strong>debug</strong> (<code>str</code> or list of <code>DebugOption</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
Enable one or more debug features. This is an experimental feature.</p>
<p>Possible options are:</p>
<ul>
<li><code>&quot;underflow_overflow&quot;</code>: detects overflow in model&#x2019;s input/outputs and reports the last frames that led to
the event</li>
<li><code>&quot;tpu_metrics_debug&quot;</code>: print debug metrics on TPU</li>
</ul>
<p>The options should be separated by whitespaces.`,name:"debug"},{anchor:"transformers.TrainingArguments.optim",description:`<strong>optim</strong> (<code>str</code> or <code>training_args.OptimizerNames</code>, <em>optional</em>, defaults to <code>&quot;adamw_hf&quot;</code>) &#x2014;
The optimizer to use: adamw_hf, adamw_torch, adamw_apex_fused, or adafactor.`,name:"optim"},{anchor:"transformers.TrainingArguments.adafactor",description:`<strong>adafactor</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This argument is deprecated. Use <code>--optim adafactor</code> instead.`,name:"adafactor"},{anchor:"transformers.TrainingArguments.group_by_length",description:`<strong>group_by_length</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to group together samples of roughly the same length in the training dataset (to minimize
padding applied and be more efficient). Only useful if applying dynamic padding.`,name:"group_by_length"},{anchor:"transformers.TrainingArguments.length_column_name",description:`<strong>length_column_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;length&quot;</code>) &#x2014;
Column name for precomputed lengths. If the column exists, grouping by length will use these values rather
than computing them on train startup. Ignored unless <code>group_by_length</code> is <code>True</code> and the dataset is an
instance of <code>Dataset</code>.`,name:"length_column_name"},{anchor:"transformers.TrainingArguments.report_to",description:`<strong>report_to</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>, defaults to <code>&quot;all&quot;</code>) &#x2014;
The list of integrations to report the results and logs to. Supported platforms are <code>&quot;azure_ml&quot;</code>,
<code>&quot;comet_ml&quot;</code>, <code>&quot;mlflow&quot;</code>, <code>&quot;neptune&quot;</code>, <code>&quot;tensorboard&quot;</code> and <code>&quot;wandb&quot;</code>. Use <code>&quot;all&quot;</code> to report to all
integrations installed, <code>&quot;none&quot;</code> for no integrations.`,name:"report_to"},{anchor:"transformers.TrainingArguments.ddp_find_unused_parameters",description:`<strong>ddp_find_unused_parameters</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
When using distributed training, the value of the flag <code>find_unused_parameters</code> passed to
<code>DistributedDataParallel</code>. Will default to <code>False</code> if gradient checkpointing is used, <code>True</code> otherwise.`,name:"ddp_find_unused_parameters"},{anchor:"transformers.TrainingArguments.ddp_bucket_cap_mb",description:`<strong>ddp_bucket_cap_mb</strong> (<code>int</code>, <em>optional</em>) &#x2014;
When using distributed training, the value of the flag <code>bucket_cap_mb</code> passed to <code>DistributedDataParallel</code>.`,name:"ddp_bucket_cap_mb"},{anchor:"transformers.TrainingArguments.dataloader_pin_memory",description:`<strong>dataloader_pin_memory</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether you want to pin memory in data loaders or not. Will default to <code>True</code>.`,name:"dataloader_pin_memory"},{anchor:"transformers.TrainingArguments.skip_memory_metrics",description:`<strong>skip_memory_metrics</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to skip adding of memory profiler reports to metrics. This is skipped by default because it slows
down the training and evaluation speed.`,name:"skip_memory_metrics"},{anchor:"transformers.TrainingArguments.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push the model to the Hub every time the model is saved. If this is activated,
<code>output_dir</code> will begin a git directory synced with the repo (determined by <code>hub_model_id</code>) and the content
will be pushed each time a save is triggered (depending on your <code>save_strategy</code>). Calling
<a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.save_model">save_model()</a> will also trigger a push.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>If <code>output_dir</code> exists, it needs to be a local clone of the repository to which the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a> will be
pushed.</p>

					</div>`,name:"push_to_hub"},{anchor:"transformers.TrainingArguments.resume_from_checkpoint",description:`<strong>resume_from_checkpoint</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to a folder with a valid checkpoint for your model. This argument is not directly used by
<a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"resume_from_checkpoint"},{anchor:"transformers.TrainingArguments.hub_model_id",description:`<strong>hub_model_id</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The name of the repository to keep in sync with the local <em>output_dir</em>. It can be a simple model ID in
which case the model will be pushed in your namespace. Otherwise it should be the whole repository name,
for instance <code>&quot;user_name/model&quot;</code>, which allows you to push to an organization you are a member of with
<code>&quot;organization_name/model&quot;</code>. Will default to <code>user_name/output_dir_name</code> with <em>output_dir_name</em> being the
name of <code>output_dir</code>.</p>
<p>Will default to the name of <code>output_dir</code>.`,name:"hub_model_id"},{anchor:"transformers.TrainingArguments.hub_strategy",description:`<strong>hub_strategy</strong> (<code>str</code> or <code>HubStrategy</code>, <em>optional</em>, defaults to <code>&quot;every_save&quot;</code>) &#x2014;
Defines the scope of what is pushed to the Hub and when. Possible values are:</p>
<ul>
<li><code>&quot;end&quot;</code>: push the model, its configuration, the tokenizer (if passed along to the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>) and a
draft of a model card when the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.save_model">save_model()</a> method is called.</li>
<li><code>&quot;every_save&quot;</code>: push the model, its configuration, the tokenizer (if passed along to the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>) and
a draft of a model card each time there is a model save. The pushes are asynchronous to not block
training, and in case the save are very frequent, a new push is only attempted if the previous one is
finished. A last push is made with the final model at the end of training.</li>
<li><code>&quot;checkpoint&quot;</code>: like <code>&quot;every_save&quot;</code> but the latest checkpoint is also pushed in a subfolder named
last-checkpoint, allowing you to resume training easily with
<code>trainer.train(resume_from_checkpoint=&quot;last-checkpoint&quot;)</code>.</li>
<li><code>&quot;all_checkpoints&quot;</code>: like <code>&quot;checkpoint&quot;</code> but all checkpoints are pushed like they appear in the output
folder (so you will get one checkpoint folder per folder in your final repository)</li>
</ul>`,name:"hub_strategy"},{anchor:"transformers.TrainingArguments.hub_token",description:`<strong>hub_token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The token to use to push the model to the Hub. Will default to the token in the cache folder obtained with
<code>huggingface-cli login</code>.`,name:"hub_token"},{anchor:"transformers.TrainingArguments.hub_private_repo",description:`<strong>hub_private_repo</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If True, the Hub repo will be set to private.`,name:"hub_private_repo"},{anchor:"transformers.TrainingArguments.gradient_checkpointing",description:`<strong>gradient_checkpointing</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If True, use gradient checkpointing to save memory at the expense of slower backward pass.`,name:"gradient_checkpointing"},{anchor:"transformers.TrainingArguments.include_inputs_for_metrics",description:`<strong>include_inputs_for_metrics</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the inputs will be passed to the <code>compute_metrics</code> function. This is intended for metrics
that need inputs, predictions and references for scoring calculation in Metric class.`,name:"include_inputs_for_metrics"},{anchor:"transformers.TrainingArguments.auto_find_batch_size",description:`<strong>auto_find_batch_size</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to find a batch size that will fit into memory automatically through exponential decay, avoiding
CUDA Out-of-Memory errors. Requires accelerate to be installed (<code>pip install accelerate</code>)`,name:"auto_find_batch_size"},{anchor:"transformers.TrainingArguments.full_determinism",description:`<strong>full_determinism</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.enable_full_determinism">enable_full_determinism()</a> is called instead of <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.set_seed">set_seed()</a> to ensure reproducible results in
distributed training`,name:"full_determinism"},{anchor:"transformers.TrainingArguments.torchdynamo",description:`<strong>torchdynamo</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The token that is used to set the backend compiler for TorchDynamo. Possible choices are [&#x201C;eager&#x201D;,
&#x201C;nvfuser]. This is an experimental API and subject to change.`,name:"torchdynamo"},{anchor:"transformers.TrainingArguments.ray_scope",description:`<strong>ray_scope</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;last&quot;</code>) &#x2014;
The scope to use when doing hyperparameter search with Ray. By default, <code>&quot;last&quot;</code> will be used. Ray will
then use the last checkpoint of all trials, compare those, and select the best one. However, other options
are also available. See the <a href="https://docs.ray.io/en/latest/tune/api_docs/analysis.html#ray.tune.ExperimentAnalysis.get_best_trial" rel="nofollow">Ray documentation</a> for
more options.`,name:"ray_scope"},{anchor:"transformers.TrainingArguments.ddp_timeout",description:`<strong>ddp_timeout</strong> (<code>int</code>, <em>optional</em>, defaults to 1800) &#x2014;
The timeout for <code>torch.distributed.init_process_group</code> calls, used to avoid GPU socket timeouts when
performing slow operations in distributed runnings. Please refer the [PyTorch documentation]
(<a href="https://pytorch.org/docs/stable/distributed.html#torch.distributed.init_process_group" rel="nofollow">https://pytorch.org/docs/stable/distributed.html#torch.distributed.init_process_group</a>) for more
information.`,name:"ddp_timeout"},{anchor:"transformers.TrainingArguments.use_mps_device",description:`<strong>use_mps_device</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use Apple Silicon chip based <code>mps</code> device.`,name:"use_mps_device"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L123"}}),ns=new x({props:{name:"get_process_log_level",anchor:"transformers.TrainingArguments.get_process_log_level",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1595"}}),is=new x({props:{name:"get_warmup_steps",anchor:"transformers.TrainingArguments.get_warmup_steps",parameters:[{name:"num_training_steps",val:": int"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1685"}}),ls=new x({props:{name:"main_process_first",anchor:"transformers.TrainingArguments.main_process_first",parameters:[{name:"local",val:" = True"},{name:"desc",val:" = 'work'"}],parametersDescription:[{anchor:"transformers.TrainingArguments.main_process_first.local",description:`<strong>local</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
if <code>True</code> first means process of rank 0 of each node if <code>False</code> first means process of rank 0 of node
rank 0 In multi-node environment with a shared filesystem you most likely will want to use
<code>local=False</code> so that only the main process of the first node will do the processing. If however, the
filesystem is not shared, then the main process of each node will need to do the processing, which is
the default behavior.`,name:"local"},{anchor:"transformers.TrainingArguments.main_process_first.desc",description:`<strong>desc</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;work&quot;</code>) &#x2014;
a work description to be used in debug logs`,name:"desc"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1630"}}),ds=new x({props:{name:"to_dict",anchor:"transformers.TrainingArguments.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1694"}}),ps=new x({props:{name:"to_json_string",anchor:"transformers.TrainingArguments.to_json_string",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1711"}}),ms=new x({props:{name:"to_sanitized_dict",anchor:"transformers.TrainingArguments.to_sanitized_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args.py#L1717"}}),hs=new Y({}),us=new x({props:{name:"class transformers.Seq2SeqTrainingArguments",anchor:"transformers.Seq2SeqTrainingArguments",parameters:[{name:"output_dir",val:": str"},{name:"overwrite_output_dir",val:": bool = False"},{name:"do_train",val:": bool = False"},{name:"do_eval",val:": bool = False"},{name:"do_predict",val:": bool = False"},{name:"evaluation_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'no'"},{name:"prediction_loss_only",val:": bool = False"},{name:"per_device_train_batch_size",val:": int = 8"},{name:"per_device_eval_batch_size",val:": int = 8"},{name:"per_gpu_train_batch_size",val:": typing.Optional[int] = None"},{name:"per_gpu_eval_batch_size",val:": typing.Optional[int] = None"},{name:"gradient_accumulation_steps",val:": int = 1"},{name:"eval_accumulation_steps",val:": typing.Optional[int] = None"},{name:"eval_delay",val:": typing.Optional[float] = 0"},{name:"learning_rate",val:": float = 5e-05"},{name:"weight_decay",val:": float = 0.0"},{name:"adam_beta1",val:": float = 0.9"},{name:"adam_beta2",val:": float = 0.999"},{name:"adam_epsilon",val:": float = 1e-08"},{name:"max_grad_norm",val:": float = 1.0"},{name:"num_train_epochs",val:": float = 3.0"},{name:"max_steps",val:": int = -1"},{name:"lr_scheduler_type",val:": typing.Union[transformers.trainer_utils.SchedulerType, str] = 'linear'"},{name:"warmup_ratio",val:": float = 0.0"},{name:"warmup_steps",val:": int = 0"},{name:"log_level",val:": typing.Optional[str] = 'passive'"},{name:"log_level_replica",val:": typing.Optional[str] = 'passive'"},{name:"log_on_each_node",val:": bool = True"},{name:"logging_dir",val:": typing.Optional[str] = None"},{name:"logging_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"},{name:"logging_first_step",val:": bool = False"},{name:"logging_steps",val:": int = 500"},{name:"logging_nan_inf_filter",val:": bool = True"},{name:"save_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"},{name:"save_steps",val:": int = 500"},{name:"save_total_limit",val:": typing.Optional[int] = None"},{name:"save_on_each_node",val:": bool = False"},{name:"no_cuda",val:": bool = False"},{name:"use_mps_device",val:": bool = False"},{name:"seed",val:": int = 42"},{name:"data_seed",val:": typing.Optional[int] = None"},{name:"jit_mode_eval",val:": bool = False"},{name:"use_ipex",val:": bool = False"},{name:"bf16",val:": bool = False"},{name:"fp16",val:": bool = False"},{name:"fp16_opt_level",val:": str = 'O1'"},{name:"half_precision_backend",val:": str = 'auto'"},{name:"bf16_full_eval",val:": bool = False"},{name:"fp16_full_eval",val:": bool = False"},{name:"tf32",val:": typing.Optional[bool] = None"},{name:"local_rank",val:": int = -1"},{name:"xpu_backend",val:": typing.Optional[str] = None"},{name:"tpu_num_cores",val:": typing.Optional[int] = None"},{name:"tpu_metrics_debug",val:": bool = False"},{name:"debug",val:": str = ''"},{name:"dataloader_drop_last",val:": bool = False"},{name:"eval_steps",val:": typing.Optional[int] = None"},{name:"dataloader_num_workers",val:": int = 0"},{name:"past_index",val:": int = -1"},{name:"run_name",val:": typing.Optional[str] = None"},{name:"disable_tqdm",val:": typing.Optional[bool] = None"},{name:"remove_unused_columns",val:": typing.Optional[bool] = True"},{name:"label_names",val:": typing.Optional[typing.List[str]] = None"},{name:"load_best_model_at_end",val:": typing.Optional[bool] = False"},{name:"metric_for_best_model",val:": typing.Optional[str] = None"},{name:"greater_is_better",val:": typing.Optional[bool] = None"},{name:"ignore_data_skip",val:": bool = False"},{name:"sharded_ddp",val:": str = ''"},{name:"fsdp",val:": str = ''"},{name:"fsdp_min_num_params",val:": int = 0"},{name:"fsdp_transformer_layer_cls_to_wrap",val:": typing.Optional[str] = None"},{name:"deepspeed",val:": typing.Optional[str] = None"},{name:"label_smoothing_factor",val:": float = 0.0"},{name:"optim",val:": typing.Union[transformers.training_args.OptimizerNames, str] = 'adamw_hf'"},{name:"adafactor",val:": bool = False"},{name:"group_by_length",val:": bool = False"},{name:"length_column_name",val:": typing.Optional[str] = 'length'"},{name:"report_to",val:": typing.Optional[typing.List[str]] = None"},{name:"ddp_find_unused_parameters",val:": typing.Optional[bool] = None"},{name:"ddp_bucket_cap_mb",val:": typing.Optional[int] = None"},{name:"dataloader_pin_memory",val:": bool = True"},{name:"skip_memory_metrics",val:": bool = True"},{name:"use_legacy_prediction_loop",val:": bool = False"},{name:"push_to_hub",val:": bool = False"},{name:"resume_from_checkpoint",val:": typing.Optional[str] = None"},{name:"hub_model_id",val:": typing.Optional[str] = None"},{name:"hub_strategy",val:": typing.Union[transformers.trainer_utils.HubStrategy, str] = 'every_save'"},{name:"hub_token",val:": typing.Optional[str] = None"},{name:"hub_private_repo",val:": bool = False"},{name:"gradient_checkpointing",val:": bool = False"},{name:"include_inputs_for_metrics",val:": bool = False"},{name:"fp16_backend",val:": str = 'auto'"},{name:"push_to_hub_model_id",val:": typing.Optional[str] = None"},{name:"push_to_hub_organization",val:": typing.Optional[str] = None"},{name:"push_to_hub_token",val:": typing.Optional[str] = None"},{name:"mp_parameters",val:": str = ''"},{name:"auto_find_batch_size",val:": bool = False"},{name:"full_determinism",val:": bool = False"},{name:"torchdynamo",val:": typing.Optional[str] = None"},{name:"ray_scope",val:": typing.Optional[str] = 'last'"},{name:"ddp_timeout",val:": typing.Optional[int] = 1800"},{name:"sortish_sampler",val:": bool = False"},{name:"predict_with_generate",val:": bool = False"},{name:"generation_max_length",val:": typing.Optional[int] = None"},{name:"generation_num_beams",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"transformers.Seq2SeqTrainingArguments.output_dir",description:`<strong>output_dir</strong> (<code>str</code>) &#x2014;
The output directory where the model predictions and checkpoints will be written.`,name:"output_dir"},{anchor:"transformers.Seq2SeqTrainingArguments.overwrite_output_dir",description:`<strong>overwrite_output_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, overwrite the content of the output directory. Use this to continue training if <code>output_dir</code>
points to a checkpoint directory.`,name:"overwrite_output_dir"},{anchor:"transformers.Seq2SeqTrainingArguments.do_train",description:`<strong>do_train</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run training or not. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used
by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_train"},{anchor:"transformers.Seq2SeqTrainingArguments.do_eval",description:`<strong>do_eval</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to run evaluation on the validation set or not. Will be set to <code>True</code> if <code>evaluation_strategy</code> is
different from <code>&quot;no&quot;</code>. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used by your
training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_eval"},{anchor:"transformers.Seq2SeqTrainingArguments.do_predict",description:`<strong>do_predict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run predictions on the test set or not. This argument is not directly used by <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s
intended to be used by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"do_predict"},{anchor:"transformers.Seq2SeqTrainingArguments.evaluation_strategy",description:`<strong>evaluation_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;no&quot;</code>) &#x2014;
The evaluation strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No evaluation is done during training.</li>
<li><code>&quot;steps&quot;</code>: Evaluation is done (and logged) every <code>eval_steps</code>.</li>
<li><code>&quot;epoch&quot;</code>: Evaluation is done at the end of each epoch.</li>
</ul>`,name:"evaluation_strategy"},{anchor:"transformers.Seq2SeqTrainingArguments.prediction_loss_only",description:`<strong>prediction_loss_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When performing evaluation and generating predictions, only returns the loss.`,name:"prediction_loss_only"},{anchor:"transformers.Seq2SeqTrainingArguments.per_device_train_batch_size",description:`<strong>per_device_train_batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
The batch size per GPU/TPU core/CPU for training.`,name:"per_device_train_batch_size"},{anchor:"transformers.Seq2SeqTrainingArguments.per_device_eval_batch_size",description:`<strong>per_device_eval_batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
The batch size per GPU/TPU core/CPU for evaluation.`,name:"per_device_eval_batch_size"},{anchor:"transformers.Seq2SeqTrainingArguments.gradient_accumulation_steps",description:`<strong>gradient_accumulation_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of updates steps to accumulate the gradients for, before performing a backward/update pass.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>When using gradient accumulation, one step is counted as one step with backward pass. Therefore, logging,
evaluation, save will be conducted every <code>gradient_accumulation_steps * xxx_step</code> training examples.</p>

					</div>`,name:"gradient_accumulation_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.eval_accumulation_steps",description:`<strong>eval_accumulation_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of predictions steps to accumulate the output tensors for, before moving the results to the CPU. If
left unset, the whole predictions are accumulated on GPU/TPU before being moved to the CPU (faster but
requires more memory).`,name:"eval_accumulation_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.eval_delay",description:`<strong>eval_delay</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Number of epochs or steps to wait for before the first evaluation can be performed, depending on the
evaluation_strategy.`,name:"eval_delay"},{anchor:"transformers.Seq2SeqTrainingArguments.learning_rate",description:`<strong>learning_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 5e-5) &#x2014;
The initial learning rate for <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"learning_rate"},{anchor:"transformers.Seq2SeqTrainingArguments.weight_decay",description:`<strong>weight_decay</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a>
optimizer.`,name:"weight_decay"},{anchor:"transformers.Seq2SeqTrainingArguments.adam_beta1",description:`<strong>adam_beta1</strong> (<code>float</code>, <em>optional</em>, defaults to 0.9) &#x2014;
The beta1 hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_beta1"},{anchor:"transformers.Seq2SeqTrainingArguments.adam_beta2",description:`<strong>adam_beta2</strong> (<code>float</code>, <em>optional</em>, defaults to 0.999) &#x2014;
The beta2 hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_beta2"},{anchor:"transformers.Seq2SeqTrainingArguments.adam_epsilon",description:`<strong>adam_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-8) &#x2014;
The epsilon hyperparameter for the <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.AdamW">AdamW</a> optimizer.`,name:"adam_epsilon"},{anchor:"transformers.Seq2SeqTrainingArguments.max_grad_norm",description:`<strong>max_grad_norm</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Maximum gradient norm (for gradient clipping).`,name:"max_grad_norm"},{anchor:"transformers.Seq2SeqTrainingArguments.num_train_epochs(float,",description:`<strong>num_train_epochs(<code>float</code>,</strong> <em>optional</em>, defaults to 3.0) &#x2014;
Total number of training epochs to perform (if not an integer, will perform the decimal part percents of
the last epoch before stopping training).`,name:"num_train_epochs(float,"},{anchor:"transformers.Seq2SeqTrainingArguments.max_steps",description:`<strong>max_steps</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
If set to a positive number, the total number of training steps to perform. Overrides <code>num_train_epochs</code>.
In case of using a finite iterable dataset the training may stop before reaching the set number of steps
when all data is exhausted`,name:"max_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.lr_scheduler_type",description:`<strong>lr_scheduler_type</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.SchedulerType">SchedulerType</a>, <em>optional</em>, defaults to <code>&quot;linear&quot;</code>) &#x2014;
The scheduler type to use. See the documentation of <a href="/docs/transformers/pr_19907/en/main_classes/optimizer_schedules#transformers.SchedulerType">SchedulerType</a> for all possible values.`,name:"lr_scheduler_type"},{anchor:"transformers.Seq2SeqTrainingArguments.warmup_ratio",description:`<strong>warmup_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Ratio of total training steps used for a linear warmup from 0 to <code>learning_rate</code>.`,name:"warmup_ratio"},{anchor:"transformers.Seq2SeqTrainingArguments.warmup_steps",description:`<strong>warmup_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of steps used for a linear warmup from 0 to <code>learning_rate</code>. Overrides any effect of <code>warmup_ratio</code>.`,name:"warmup_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.log_level",description:`<strong>log_level</strong> (<code>str</code>, <em>optional</em>, defaults to <code>passive</code>) &#x2014;
Logger log level to use on the main process. Possible choices are the log levels as strings: &#x2018;debug&#x2019;,
&#x2018;info&#x2019;, &#x2018;warning&#x2019;, &#x2018;error&#x2019; and &#x2018;critical&#x2019;, plus a &#x2018;passive&#x2019; level which doesn&#x2019;t set anything and lets the
application set the level.`,name:"log_level"},{anchor:"transformers.Seq2SeqTrainingArguments.log_level_replica",description:`<strong>log_level_replica</strong> (<code>str</code>, <em>optional</em>, defaults to <code>passive</code>) &#x2014;
Logger log level to use on replicas. Same choices as <code>log_level</code>&#x201D;`,name:"log_level_replica"},{anchor:"transformers.Seq2SeqTrainingArguments.log_on_each_node",description:`<strong>log_on_each_node</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
In multinode distributed training, whether to log using <code>log_level</code> once per node, or only on the main
node.`,name:"log_on_each_node"},{anchor:"transformers.Seq2SeqTrainingArguments.logging_dir",description:`<strong>logging_dir</strong> (<code>str</code>, <em>optional</em>) &#x2014;
<a href="https://www.tensorflow.org/tensorboard" rel="nofollow">TensorBoard</a> log directory. Will default to
*output_dir/runs/<strong>CURRENT_DATETIME_HOSTNAME*</strong>.`,name:"logging_dir"},{anchor:"transformers.Seq2SeqTrainingArguments.logging_strategy",description:`<strong>logging_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;steps&quot;</code>) &#x2014;
The logging strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No logging is done during training.</li>
<li><code>&quot;epoch&quot;</code>: Logging is done at the end of each epoch.</li>
<li><code>&quot;steps&quot;</code>: Logging is done every <code>logging_steps</code>.</li>
</ul>`,name:"logging_strategy"},{anchor:"transformers.Seq2SeqTrainingArguments.logging_first_step",description:`<strong>logging_first_step</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to log and evaluate the first <code>global_step</code> or not.`,name:"logging_first_step"},{anchor:"transformers.Seq2SeqTrainingArguments.logging_steps",description:`<strong>logging_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 500) &#x2014;
Number of update steps between two logs if <code>logging_strategy=&quot;steps&quot;</code>.`,name:"logging_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.logging_nan_inf_filter",description:`<strong>logging_nan_inf_filter</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to filter <code>nan</code> and <code>inf</code> losses for logging. If set to <code>True</code> the loss of every step that is <code>nan</code>
or <code>inf</code> is filtered and the average loss of the current logging window is taken instead.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p><code>logging_nan_inf_filter</code> only influences the logging of loss values, it does not change the behavior the
gradient is computed or applied to the model.</p>

					</div>`,name:"logging_nan_inf_filter"},{anchor:"transformers.Seq2SeqTrainingArguments.save_strategy",description:`<strong>save_strategy</strong> (<code>str</code> or <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.IntervalStrategy">IntervalStrategy</a>, <em>optional</em>, defaults to <code>&quot;steps&quot;</code>) &#x2014;
The checkpoint save strategy to adopt during training. Possible values are:</p>
<ul>
<li><code>&quot;no&quot;</code>: No save is done during training.</li>
<li><code>&quot;epoch&quot;</code>: Save is done at the end of each epoch.</li>
<li><code>&quot;steps&quot;</code>: Save is done every <code>save_steps</code>.</li>
</ul>`,name:"save_strategy"},{anchor:"transformers.Seq2SeqTrainingArguments.save_steps",description:`<strong>save_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 500) &#x2014;
Number of updates steps before two checkpoint saves if <code>save_strategy=&quot;steps&quot;</code>.`,name:"save_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.save_total_limit",description:`<strong>save_total_limit</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If a value is passed, will limit the total amount of checkpoints. Deletes the older checkpoints in
<code>output_dir</code>.`,name:"save_total_limit"},{anchor:"transformers.Seq2SeqTrainingArguments.save_on_each_node",description:`<strong>save_on_each_node</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When doing multi-node distributed training, whether to save models and checkpoints on each node, or only on
the main one.</p>
<p>This should not be activated when the different nodes use the same storage as the files will be saved with
the same names for each node.`,name:"save_on_each_node"},{anchor:"transformers.Seq2SeqTrainingArguments.no_cuda",description:`<strong>no_cuda</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to not use CUDA even when it is available or not.`,name:"no_cuda"},{anchor:"transformers.Seq2SeqTrainingArguments.seed",description:`<strong>seed</strong> (<code>int</code>, <em>optional</em>, defaults to 42) &#x2014;
Random seed that will be set at the beginning of training. To ensure reproducibility across runs, use the
<code>~Trainer.model_init</code> function to instantiate the model if it has some randomly initialized parameters.`,name:"seed"},{anchor:"transformers.Seq2SeqTrainingArguments.data_seed",description:`<strong>data_seed</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Random seed to be used with data samplers. If not set, random generators for data sampling will use the
same seed as <code>seed</code>. This can be used to ensure reproducibility of data sampling, independent of the model
seed.`,name:"data_seed"},{anchor:"transformers.Seq2SeqTrainingArguments.jit_mode_eval",description:`<strong>jit_mode_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use PyTorch jit trace for inference.`,name:"jit_mode_eval"},{anchor:"transformers.Seq2SeqTrainingArguments.use_ipex",description:`<strong>use_ipex</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use Intel extension for PyTorch when it is available. <a href="https://github.com/intel/intel-extension-for-pytorch" rel="nofollow">IPEX
installation</a>.`,name:"use_ipex"},{anchor:"transformers.Seq2SeqTrainingArguments.bf16",description:`<strong>bf16</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use bf16 16-bit (mixed) precision training instead of 32-bit training. Requires Ampere or higher
NVIDIA architecture or using CPU (no_cuda). This is an experimental API and it may change.`,name:"bf16"},{anchor:"transformers.Seq2SeqTrainingArguments.fp16",description:`<strong>fp16</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use fp16 16-bit (mixed) precision training instead of 32-bit training.`,name:"fp16"},{anchor:"transformers.Seq2SeqTrainingArguments.fp16_opt_level",description:`<strong>fp16_opt_level</strong> (<code>str</code>, <em>optional</em>, defaults to &#x2018;O1&#x2019;) &#x2014;
For <code>fp16</code> training, Apex AMP optimization level selected in [&#x2018;O0&#x2019;, &#x2018;O1&#x2019;, &#x2018;O2&#x2019;, and &#x2018;O3&#x2019;]. See details on
the <a href="https://nvidia.github.io/apex/amp" rel="nofollow">Apex documentation</a>.`,name:"fp16_opt_level"},{anchor:"transformers.Seq2SeqTrainingArguments.fp16_backend",description:`<strong>fp16_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
This argument is deprecated. Use <code>half_precision_backend</code> instead.`,name:"fp16_backend"},{anchor:"transformers.Seq2SeqTrainingArguments.half_precision_backend",description:`<strong>half_precision_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
The backend to use for mixed precision training. Must be one of <code>&quot;auto&quot;, &quot;cuda_amp&quot;, &quot;apex&quot;, &quot;cpu_amp&quot;</code>.
<code>&quot;auto&quot;</code> will use CPU/CUDA AMP or APEX depending on the PyTorch version detected, while the other choices
will force the requested backend.`,name:"half_precision_backend"},{anchor:"transformers.Seq2SeqTrainingArguments.bf16_full_eval",description:`<strong>bf16_full_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use full bfloat16 evaluation instead of 32-bit. This will be faster and save memory but can harm
metric values. This is an experimental API and it may change.`,name:"bf16_full_eval"},{anchor:"transformers.Seq2SeqTrainingArguments.fp16_full_eval",description:`<strong>fp16_full_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use full float16 evaluation instead of 32-bit. This will be faster and save memory but can harm
metric values.`,name:"fp16_full_eval"},{anchor:"transformers.Seq2SeqTrainingArguments.tf32",description:`<strong>tf32</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to enable the TF32 mode, available in Ampere and newer GPU architectures. The default value depends
on PyTorch&#x2019;s version default of <code>torch.backends.cuda.matmul.allow_tf32</code>. For more details please refer to
the <a href="https://huggingface.co/docs/transformers/performance#tf32" rel="nofollow">TF32</a> documentation. This is an
experimental API and it may change.`,name:"tf32"},{anchor:"transformers.Seq2SeqTrainingArguments.local_rank",description:`<strong>local_rank</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
Rank of the process during distributed training.`,name:"local_rank"},{anchor:"transformers.Seq2SeqTrainingArguments.xpu_backend",description:`<strong>xpu_backend</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The backend to use for xpu distributed training. Must be one of <code>&quot;mpi&quot;</code> or <code>&quot;ccl&quot;</code> or <code>&quot;gloo&quot;</code>.`,name:"xpu_backend"},{anchor:"transformers.Seq2SeqTrainingArguments.tpu_num_cores",description:`<strong>tpu_num_cores</strong> (<code>int</code>, <em>optional</em>) &#x2014;
When training on TPU, the number of TPU cores (automatically passed by launcher script).`,name:"tpu_num_cores"},{anchor:"transformers.Seq2SeqTrainingArguments.dataloader_drop_last",description:`<strong>dataloader_drop_last</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to drop the last incomplete batch (if the length of the dataset is not divisible by the batch size)
or not.`,name:"dataloader_drop_last"},{anchor:"transformers.Seq2SeqTrainingArguments.eval_steps",description:`<strong>eval_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of update steps between two evaluations if <code>evaluation_strategy=&quot;steps&quot;</code>. Will default to the same
value as <code>logging_steps</code> if not set.`,name:"eval_steps"},{anchor:"transformers.Seq2SeqTrainingArguments.dataloader_num_workers",description:`<strong>dataloader_num_workers</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of subprocesses to use for data loading (PyTorch only). 0 means that the data will be loaded in the
main process.`,name:"dataloader_num_workers"},{anchor:"transformers.Seq2SeqTrainingArguments.past_index",description:`<strong>past_index</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
Some models like <a href="../model_doc/transformerxl">TransformerXL</a> or <a href="../model_doc/xlnet">XLNet</a> can make use of
the past hidden states for their predictions. If this argument is set to a positive int, the <code>Trainer</code> will
use the corresponding output (usually index 2) as the past state and feed it to the model at the next
training step under the keyword argument <code>mems</code>.`,name:"past_index"},{anchor:"transformers.Seq2SeqTrainingArguments.run_name",description:`<strong>run_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
A descriptor for the run. Typically used for <a href="https://www.wandb.com/" rel="nofollow">wandb</a> and
<a href="https://www.mlflow.org/" rel="nofollow">mlflow</a> logging.`,name:"run_name"},{anchor:"transformers.Seq2SeqTrainingArguments.disable_tqdm",description:`<strong>disable_tqdm</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to disable the tqdm progress bars and table of metrics produced by
<code>~notebook.NotebookTrainingTracker</code> in Jupyter Notebooks. Will default to <code>True</code> if the logging level is
set to warn or lower (default), <code>False</code> otherwise.`,name:"disable_tqdm"},{anchor:"transformers.Seq2SeqTrainingArguments.remove_unused_columns",description:`<strong>remove_unused_columns</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to automatically remove the columns unused by the model forward method.</p>
<p>(Note that this behavior is not implemented for <code>TFTrainer</code> yet.)`,name:"remove_unused_columns"},{anchor:"transformers.Seq2SeqTrainingArguments.label_names",description:`<strong>label_names</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
The list of keys in your dictionary of inputs that correspond to the labels.</p>
<p>Will eventually default to <code>[&quot;labels&quot;]</code> except if the model used is one of the <code>XxxForQuestionAnswering</code> in
which case it will default to <code>[&quot;start_positions&quot;, &quot;end_positions&quot;]</code>.`,name:"label_names"},{anchor:"transformers.Seq2SeqTrainingArguments.load_best_model_at_end",description:`<strong>load_best_model_at_end</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to load the best model found during training at the end of training.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When set to <code>True</code>, the parameters <code>save_strategy</code> needs to be the same as <code>evaluation_strategy</code>, and in
the case it is &#x201C;steps&#x201D;, <code>save_steps</code> must be a round multiple of <code>eval_steps</code>.</p>

					</div>`,name:"load_best_model_at_end"},{anchor:"transformers.Seq2SeqTrainingArguments.metric_for_best_model",description:`<strong>metric_for_best_model</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Use in conjunction with <code>load_best_model_at_end</code> to specify the metric to use to compare two different
models. Must be the name of a metric returned by the evaluation with or without the prefix <code>&quot;eval_&quot;</code>. Will
default to <code>&quot;loss&quot;</code> if unspecified and <code>load_best_model_at_end=True</code> (to use the evaluation loss).</p>
<p>If you set this value, <code>greater_is_better</code> will default to <code>True</code>. Don&#x2019;t forget to set it to <code>False</code> if
your metric is better when lower.`,name:"metric_for_best_model"},{anchor:"transformers.Seq2SeqTrainingArguments.greater_is_better",description:`<strong>greater_is_better</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Use in conjunction with <code>load_best_model_at_end</code> and <code>metric_for_best_model</code> to specify if better models
should have a greater metric or not. Will default to:</p>
<ul>
<li><code>True</code> if <code>metric_for_best_model</code> is set to a value that isn&#x2019;t <code>&quot;loss&quot;</code> or <code>&quot;eval_loss&quot;</code>.</li>
<li><code>False</code> if <code>metric_for_best_model</code> is not set, or set to <code>&quot;loss&quot;</code> or <code>&quot;eval_loss&quot;</code>.</li>
</ul>`,name:"greater_is_better"},{anchor:"transformers.Seq2SeqTrainingArguments.ignore_data_skip",description:`<strong>ignore_data_skip</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
When resuming training, whether or not to skip the epochs and batches to get the data loading at the same
stage as in the previous training. If set to <code>True</code>, the training will begin faster (as that skipping step
can take a long time) but will not yield the same results as the interrupted training would have.`,name:"ignore_data_skip"},{anchor:"transformers.Seq2SeqTrainingArguments.sharded_ddp",description:`<strong>sharded_ddp</strong> (<code>bool</code>, <code>str</code> or list of <code>ShardedDDPOption</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use Sharded DDP training from <a href="https://github.com/facebookresearch/fairscale" rel="nofollow">FairScale</a> (in distributed
training only). This is an experimental feature.</p>
<p>A list of options along the following:</p>
<ul>
<li><code>&quot;simple&quot;</code>: to use first instance of sharded DDP released by fairscale (<code>ShardedDDP</code>) similar to ZeRO-2.</li>
<li><code>&quot;zero_dp_2&quot;</code>: to use the second instance of sharded DPP released by fairscale (<code>FullyShardedDDP</code>) in
Zero-2 mode (with <code>reshard_after_forward=False</code>).</li>
<li><code>&quot;zero_dp_3&quot;</code>: to use the second instance of sharded DPP released by fairscale (<code>FullyShardedDDP</code>) in
Zero-3 mode (with <code>reshard_after_forward=True</code>).</li>
<li><code>&quot;offload&quot;</code>: to add ZeRO-offload (only compatible with <code>&quot;zero_dp_2&quot;</code> and <code>&quot;zero_dp_3&quot;</code>).</li>
</ul>
<p>If a string is passed, it will be split on space. If a bool is passed, it will be converted to an empty
list for <code>False</code> and <code>[&quot;simple&quot;]</code> for <code>True</code>.`,name:"sharded_ddp"},{anchor:"transformers.Seq2SeqTrainingArguments.fsdp",description:`<strong>fsdp</strong> (<code>bool</code>, <code>str</code> or list of <code>FSDPOption</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use PyTorch Distributed Parallel Training (in distributed training only).</p>
<p>A list of options along the following:</p>
<ul>
<li><code>&quot;full_shard&quot;</code>: Shard parameters, gradients and optimizer states.</li>
<li><code>&quot;shard_grad_op&quot;</code>: Shard optimizer states and gradients.</li>
<li><code>&quot;offload&quot;</code>: Offload parameters and gradients to CPUs (only compatible with <code>&quot;full_shard&quot;</code> and
<code>&quot;shard_grad_op&quot;</code>).</li>
<li><code>&quot;auto_wrap&quot;</code>: Automatically recursively wrap layers with FSDP using <code>default_auto_wrap_policy</code>.</li>
</ul>`,name:"fsdp"},{anchor:"transformers.Seq2SeqTrainingArguments.fsdp_min_num_params",description:`<strong>fsdp_min_num_params</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
FSDP&#x2019;s minimum number of parameters for Default Auto Wrapping. (useful only when <code>fsdp</code> field is passed).`,name:"fsdp_min_num_params"},{anchor:"transformers.Seq2SeqTrainingArguments.deepspeed",description:`<strong>deepspeed</strong> (<code>str</code> or <code>dict</code>, <em>optional</em>) &#x2014;
Use <a href="https://github.com/microsoft/deepspeed" rel="nofollow">Deepspeed</a>. This is an experimental feature and its API may
evolve in the future. The value is either the location of DeepSpeed json config file (e.g.,
<code>ds_config.json</code>) or an already loaded json file as a <code>dict</code>&#x201D;`,name:"deepspeed"},{anchor:"transformers.Seq2SeqTrainingArguments.label_smoothing_factor",description:`<strong>label_smoothing_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The label smoothing factor to use. Zero means no label smoothing, otherwise the underlying onehot-encoded
labels are changed from 0s and 1s to <code>label_smoothing_factor/num_labels</code> and <code>1 - label_smoothing_factor + label_smoothing_factor/num_labels</code> respectively.`,name:"label_smoothing_factor"},{anchor:"transformers.Seq2SeqTrainingArguments.debug",description:`<strong>debug</strong> (<code>str</code> or list of <code>DebugOption</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
Enable one or more debug features. This is an experimental feature.</p>
<p>Possible options are:</p>
<ul>
<li><code>&quot;underflow_overflow&quot;</code>: detects overflow in model&#x2019;s input/outputs and reports the last frames that led to
the event</li>
<li><code>&quot;tpu_metrics_debug&quot;</code>: print debug metrics on TPU</li>
</ul>
<p>The options should be separated by whitespaces.`,name:"debug"},{anchor:"transformers.Seq2SeqTrainingArguments.optim",description:`<strong>optim</strong> (<code>str</code> or <code>training_args.OptimizerNames</code>, <em>optional</em>, defaults to <code>&quot;adamw_hf&quot;</code>) &#x2014;
The optimizer to use: adamw_hf, adamw_torch, adamw_apex_fused, or adafactor.`,name:"optim"},{anchor:"transformers.Seq2SeqTrainingArguments.adafactor",description:`<strong>adafactor</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This argument is deprecated. Use <code>--optim adafactor</code> instead.`,name:"adafactor"},{anchor:"transformers.Seq2SeqTrainingArguments.group_by_length",description:`<strong>group_by_length</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to group together samples of roughly the same length in the training dataset (to minimize
padding applied and be more efficient). Only useful if applying dynamic padding.`,name:"group_by_length"},{anchor:"transformers.Seq2SeqTrainingArguments.length_column_name",description:`<strong>length_column_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;length&quot;</code>) &#x2014;
Column name for precomputed lengths. If the column exists, grouping by length will use these values rather
than computing them on train startup. Ignored unless <code>group_by_length</code> is <code>True</code> and the dataset is an
instance of <code>Dataset</code>.`,name:"length_column_name"},{anchor:"transformers.Seq2SeqTrainingArguments.report_to",description:`<strong>report_to</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>, defaults to <code>&quot;all&quot;</code>) &#x2014;
The list of integrations to report the results and logs to. Supported platforms are <code>&quot;azure_ml&quot;</code>,
<code>&quot;comet_ml&quot;</code>, <code>&quot;mlflow&quot;</code>, <code>&quot;neptune&quot;</code>, <code>&quot;tensorboard&quot;</code> and <code>&quot;wandb&quot;</code>. Use <code>&quot;all&quot;</code> to report to all
integrations installed, <code>&quot;none&quot;</code> for no integrations.`,name:"report_to"},{anchor:"transformers.Seq2SeqTrainingArguments.ddp_find_unused_parameters",description:`<strong>ddp_find_unused_parameters</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
When using distributed training, the value of the flag <code>find_unused_parameters</code> passed to
<code>DistributedDataParallel</code>. Will default to <code>False</code> if gradient checkpointing is used, <code>True</code> otherwise.`,name:"ddp_find_unused_parameters"},{anchor:"transformers.Seq2SeqTrainingArguments.ddp_bucket_cap_mb",description:`<strong>ddp_bucket_cap_mb</strong> (<code>int</code>, <em>optional</em>) &#x2014;
When using distributed training, the value of the flag <code>bucket_cap_mb</code> passed to <code>DistributedDataParallel</code>.`,name:"ddp_bucket_cap_mb"},{anchor:"transformers.Seq2SeqTrainingArguments.dataloader_pin_memory",description:`<strong>dataloader_pin_memory</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether you want to pin memory in data loaders or not. Will default to <code>True</code>.`,name:"dataloader_pin_memory"},{anchor:"transformers.Seq2SeqTrainingArguments.skip_memory_metrics",description:`<strong>skip_memory_metrics</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to skip adding of memory profiler reports to metrics. This is skipped by default because it slows
down the training and evaluation speed.`,name:"skip_memory_metrics"},{anchor:"transformers.Seq2SeqTrainingArguments.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push the model to the Hub every time the model is saved. If this is activated,
<code>output_dir</code> will begin a git directory synced with the repo (determined by <code>hub_model_id</code>) and the content
will be pushed each time a save is triggered (depending on your <code>save_strategy</code>). Calling
<a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.save_model">save_model()</a> will also trigger a push.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>If <code>output_dir</code> exists, it needs to be a local clone of the repository to which the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a> will be
pushed.</p>

					</div>`,name:"push_to_hub"},{anchor:"transformers.Seq2SeqTrainingArguments.resume_from_checkpoint",description:`<strong>resume_from_checkpoint</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to a folder with a valid checkpoint for your model. This argument is not directly used by
<a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>, it&#x2019;s intended to be used by your training/evaluation scripts instead. See the <a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">example
scripts</a> for more details.`,name:"resume_from_checkpoint"},{anchor:"transformers.Seq2SeqTrainingArguments.hub_model_id",description:`<strong>hub_model_id</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The name of the repository to keep in sync with the local <em>output_dir</em>. It can be a simple model ID in
which case the model will be pushed in your namespace. Otherwise it should be the whole repository name,
for instance <code>&quot;user_name/model&quot;</code>, which allows you to push to an organization you are a member of with
<code>&quot;organization_name/model&quot;</code>. Will default to <code>user_name/output_dir_name</code> with <em>output_dir_name</em> being the
name of <code>output_dir</code>.</p>
<p>Will default to the name of <code>output_dir</code>.`,name:"hub_model_id"},{anchor:"transformers.Seq2SeqTrainingArguments.hub_strategy",description:`<strong>hub_strategy</strong> (<code>str</code> or <code>HubStrategy</code>, <em>optional</em>, defaults to <code>&quot;every_save&quot;</code>) &#x2014;
Defines the scope of what is pushed to the Hub and when. Possible values are:</p>
<ul>
<li><code>&quot;end&quot;</code>: push the model, its configuration, the tokenizer (if passed along to the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>) and a
draft of a model card when the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.save_model">save_model()</a> method is called.</li>
<li><code>&quot;every_save&quot;</code>: push the model, its configuration, the tokenizer (if passed along to the <a href="/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer">Trainer</a>) and
a draft of a model card each time there is a model save. The pushes are asynchronous to not block
training, and in case the save are very frequent, a new push is only attempted if the previous one is
finished. A last push is made with the final model at the end of training.</li>
<li><code>&quot;checkpoint&quot;</code>: like <code>&quot;every_save&quot;</code> but the latest checkpoint is also pushed in a subfolder named
last-checkpoint, allowing you to resume training easily with
<code>trainer.train(resume_from_checkpoint=&quot;last-checkpoint&quot;)</code>.</li>
<li><code>&quot;all_checkpoints&quot;</code>: like <code>&quot;checkpoint&quot;</code> but all checkpoints are pushed like they appear in the output
folder (so you will get one checkpoint folder per folder in your final repository)</li>
</ul>`,name:"hub_strategy"},{anchor:"transformers.Seq2SeqTrainingArguments.hub_token",description:`<strong>hub_token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The token to use to push the model to the Hub. Will default to the token in the cache folder obtained with
<code>huggingface-cli login</code>.`,name:"hub_token"},{anchor:"transformers.Seq2SeqTrainingArguments.hub_private_repo",description:`<strong>hub_private_repo</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If True, the Hub repo will be set to private.`,name:"hub_private_repo"},{anchor:"transformers.Seq2SeqTrainingArguments.gradient_checkpointing",description:`<strong>gradient_checkpointing</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If True, use gradient checkpointing to save memory at the expense of slower backward pass.`,name:"gradient_checkpointing"},{anchor:"transformers.Seq2SeqTrainingArguments.include_inputs_for_metrics",description:`<strong>include_inputs_for_metrics</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the inputs will be passed to the <code>compute_metrics</code> function. This is intended for metrics
that need inputs, predictions and references for scoring calculation in Metric class.`,name:"include_inputs_for_metrics"},{anchor:"transformers.Seq2SeqTrainingArguments.auto_find_batch_size",description:`<strong>auto_find_batch_size</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to find a batch size that will fit into memory automatically through exponential decay, avoiding
CUDA Out-of-Memory errors. Requires accelerate to be installed (<code>pip install accelerate</code>)`,name:"auto_find_batch_size"},{anchor:"transformers.Seq2SeqTrainingArguments.full_determinism",description:`<strong>full_determinism</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.enable_full_determinism">enable_full_determinism()</a> is called instead of <a href="/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.set_seed">set_seed()</a> to ensure reproducible results in
distributed training`,name:"full_determinism"},{anchor:"transformers.Seq2SeqTrainingArguments.torchdynamo",description:`<strong>torchdynamo</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The token that is used to set the backend compiler for TorchDynamo. Possible choices are [&#x201C;eager&#x201D;,
&#x201C;nvfuser]. This is an experimental API and subject to change.`,name:"torchdynamo"},{anchor:"transformers.Seq2SeqTrainingArguments.ray_scope",description:`<strong>ray_scope</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;last&quot;</code>) &#x2014;
The scope to use when doing hyperparameter search with Ray. By default, <code>&quot;last&quot;</code> will be used. Ray will
then use the last checkpoint of all trials, compare those, and select the best one. However, other options
are also available. See the <a href="https://docs.ray.io/en/latest/tune/api_docs/analysis.html#ray.tune.ExperimentAnalysis.get_best_trial" rel="nofollow">Ray documentation</a> for
more options.`,name:"ray_scope"},{anchor:"transformers.Seq2SeqTrainingArguments.ddp_timeout",description:`<strong>ddp_timeout</strong> (<code>int</code>, <em>optional</em>, defaults to 1800) &#x2014;
The timeout for <code>torch.distributed.init_process_group</code> calls, used to avoid GPU socket timeouts when
performing slow operations in distributed runnings. Please refer the [PyTorch documentation]
(<a href="https://pytorch.org/docs/stable/distributed.html#torch.distributed.init_process_group" rel="nofollow">https://pytorch.org/docs/stable/distributed.html#torch.distributed.init_process_group</a>) for more
information.`,name:"ddp_timeout"},{anchor:"transformers.Seq2SeqTrainingArguments.use_mps_device",description:`<strong>use_mps_device</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use Apple Silicon chip based <code>mps</code> device.`,name:"use_mps_device"},{anchor:"transformers.Seq2SeqTrainingArguments.sortish_sampler",description:`<strong>sortish_sampler</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use a <em>sortish sampler</em> or not. Only possible if the underlying datasets are <em>Seq2SeqDataset</em>
for now but will become generally available in the near future.</p>
<p>It sorts the inputs according to lengths in order to minimize the padding size, with a bit of randomness
for the training set.`,name:"sortish_sampler"},{anchor:"transformers.Seq2SeqTrainingArguments.predict_with_generate",description:`<strong>predict_with_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use generate to calculate generative metrics (ROUGE, BLEU).`,name:"predict_with_generate"},{anchor:"transformers.Seq2SeqTrainingArguments.generation_max_length",description:`<strong>generation_max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The <code>max_length</code> to use on each evaluation loop when <code>predict_with_generate=True</code>. Will default to the
<code>max_length</code> value of the model configuration.`,name:"generation_max_length"},{anchor:"transformers.Seq2SeqTrainingArguments.generation_num_beams",description:`<strong>generation_num_beams</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The <code>num_beams</code> to use on each evaluation loop when <code>predict_with_generate=True</code>. Will default to the
<code>num_beams</code> value of the model configuration.`,name:"generation_num_beams"}],source:"https://github.com/huggingface/transformers/blob/vr_19907/src/transformers/training_args_seq2seq.py#L28"}}),_s=new Y({}),vs=new Y({}),bs=new O({props:{code:`[...]
logger = logging.getLogger(__name__)

# Setup logging
logging.basicConfig(
    format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
    datefmt="%m/%d/%Y %H:%M:%S",
    handlers=[logging.StreamHandler(sys.stdout)],
)

# set the main code and the modules it uses to the same log-level according to the node
log_level = training_args.get_process_log_level()
logger.setLevel(log_level)
datasets.utils.logging.set_verbosity(log_level)
transformers.utils.logging.set_verbosity(log_level)

trainer = Trainer(...)`,highlighted:`[...]
logger = logging.getLogger(__name__)

<span class="hljs-comment"># Setup logging</span>
logging.basicConfig(
    <span class="hljs-built_in">format</span>=<span class="hljs-string">&quot;%(asctime)s - %(levelname)s - %(name)s - %(message)s&quot;</span>,
    datefmt=<span class="hljs-string">&quot;%m/%d/%Y %H:%M:%S&quot;</span>,
    handlers=[logging.StreamHandler(sys.stdout)],
)

<span class="hljs-comment"># set the main code and the modules it uses to the same log-level according to the node</span>
log_level = training_args.get_process_log_level()
logger.setLevel(log_level)
datasets.utils.logging.set_verbosity(log_level)
transformers.utils.logging.set_verbosity(log_level)

trainer = Trainer(...)`}}),ys=new O({props:{code:"my_app.py ... --log_level warning --log_level_replica error",highlighted:"my_app.py ... --log_level warning --log_level_replica error"}}),ws=new O({props:{code:"my_app.py ... --log_level warning --log_level_replica error --log_on_each_node 0",highlighted:"my_app.py ... --log_level warning --log_level_replica error --log_on_each_node 0"}}),Ts=new O({props:{code:"my_app.py ... --log_level error --log_level_replica error --log_on_each_node 0",highlighted:"my_app.py ... --log_level error --log_level_replica error --log_on_each_node 0"}}),Es=new Y({}),xs=new Y({}),As=new O({props:{code:"python -m torch.distributed.launch --nproc_per_node=2  trainer-program.py ...",highlighted:"python -m torch.distributed.launch --nproc_per_node=2  trainer-program.py ..."}}),Ss=new O({props:{code:"accelerate launch --num_processes 2 trainer-program.py ...",highlighted:"accelerate launch --num_processes 2 trainer-program.py ..."}}),qs=new O({props:{code:"deepspeed --num_gpus 2 trainer-program.py ...",highlighted:"deepspeed --num_gpus 2 trainer-program.py ..."}}),Os=new O({props:{code:"CUDA_VISIBLE_DEVICES=0,2 python -m torch.distributed.launch trainer-program.py ...",highlighted:"CUDA_VISIBLE_DEVICES=0,2 python -m torch.distributed.launch trainer-program.py ..."}}),Cs=new O({props:{code:"CUDA_VISIBLE_DEVICES=2,0 python -m torch.distributed.launch trainer-program.py ...",highlighted:"CUDA_VISIBLE_DEVICES=2,0 python -m torch.distributed.launch trainer-program.py ..."}}),Us=new O({props:{code:"CUDA_VISIBLE_DEVICES=2,0 python trainer-program.py ...",highlighted:"CUDA_VISIBLE_DEVICES=2,0 python trainer-program.py ..."}}),Ns=new O({props:{code:"CUDA_VISIBLE_DEVICES= python trainer-program.py ...",highlighted:"CUDA_VISIBLE_DEVICES= python trainer-program.py ..."}}),zs=new O({props:{code:`export CUDA_VISIBLE_DEVICES=0,2
python -m torch.distributed.launch trainer-program.py ...`,highlighted:`<span class="hljs-built_in">export</span> CUDA_VISIBLE_DEVICES=0,2
python -m torch.distributed.launch trainer-program.py ...`}}),Ls=new O({props:{code:"export CUDA_DEVICE_ORDER=PCI_BUS_ID",highlighted:'<span class="hljs-built_in">export</span> CUDA_DEVICE_ORDER=PCI_BUS_ID'}}),Ws=new O({props:{code:"export CUDA_DEVICE_ORDER=FASTEST_FIRST",highlighted:'<span class="hljs-built_in">export</span> CUDA_DEVICE_ORDER=FASTEST_FIRST'}}),Gs=new O({props:{code:"export CUDA_VISIBLE_DEVICES=1,0",highlighted:'<span class="hljs-built_in">export</span> CUDA_VISIBLE_DEVICES=1,0'}}),Ms=new Y({}),Ys=new Y({}),Js=new O({props:{code:`pip install fairscale
pip install deepspeed`,highlighted:`pip install fairscale
pip install deepspeed`}}),Xs=new Y({}),Qs=new O({props:{code:"which nvcc",highlighted:'<span class="hljs-built_in">which</span> nvcc'}}),ti=new Y({}),oi=new O({props:{code:`/usr/local/cuda-10.2
/usr/local/cuda-11.0`,highlighted:`/usr/local/cuda-10.2
/usr/local/cuda-11.0`}}),ri=new O({props:{code:`echo $PATH
echo $LD_LIBRARY_PATH`,highlighted:`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$PATH</span>
<span class="hljs-built_in">echo</span> <span class="hljs-variable">$LD_LIBRARY_PATH</span>`}}),ai=new O({props:{code:`export PATH=/usr/local/cuda-10.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH`,highlighted:`<span class="hljs-built_in">export</span> PATH=/usr/local/cuda-10.2/bin:<span class="hljs-variable">$PATH</span>
<span class="hljs-built_in">export</span> LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:<span class="hljs-variable">$LD_LIBRARY_PATH</span>`}}),ni=new Y({}),si=new O({props:{code:`sudo ln -s /usr/bin/gcc-7  /usr/local/cuda-10.2/bin/gcc
sudo ln -s /usr/bin/g++-7  /usr/local/cuda-10.2/bin/g++`,highlighted:`sudo <span class="hljs-built_in">ln</span> -s /usr/bin/gcc-7  /usr/local/cuda-10.2/bin/gcc
sudo <span class="hljs-built_in">ln</span> -s /usr/bin/g++-7  /usr/local/cuda-10.2/bin/g++`}}),ii=new Y({}),ra=new gp({props:{warning:!0,$$slots:{default:[mM]},$$scope:{ctx:Z}}}),pi=new O({props:{code:"pip install fairscale",highlighted:"pip install fairscale"}}),mi=new O({props:{code:"pip install transformers[fairscale]",highlighted:"pip install transformers[fairscale]"}}),fi=new O({props:{code:"pip install fairscale --no-build-isolation .",highlighted:"pip install fairscale --no-build-isolation ."}}),gi=new O({props:{code:`git clone https://github.com/facebookresearch/fairscale/
cd fairscale
rm -r dist build
python setup.py bdist_wheel
pip uninstall -y fairscale
pip install dist/fairscale-*.whl`,highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/facebookresearch/fairscale/
<span class="hljs-built_in">cd</span> fairscale
<span class="hljs-built_in">rm</span> -r dist build
python setup.py bdist_wheel
pip uninstall -y fairscale
pip install dist/fairscale-*.whl`}}),vi=new O({props:{code:`pip uninstall -y fairscale; pip install fairscale --pre \\
-f https://download.pytorch.org/whl/nightly/cu110/torch_nightly \\
--no-cache --no-build-isolation`,highlighted:`pip uninstall -y fairscale; pip install fairscale --pre \\
-f https://download.pytorch.org/whl/nightly/cu110/torch_nightly \\
--no-cache --no-build-isolation`}}),bi=new O({props:{code:`pip install -v --disable-pip-version-check . \\
-f https://download.pytorch.org/whl/nightly/cu110/torch_nightly --pre`,highlighted:`pip install -v --disable-pip-version-check . \\
-f https://download.pytorch.org/whl/nightly/cu110/torch_nightly --pre`}}),Ti=new O({props:{code:`python -m torch.distributed.launch --nproc_per_node=2 examples/pytorch/translation/run_translation.py \\
--model_name_or_path t5-small --per_device_train_batch_size 1   \\
--output_dir output_dir --overwrite_output_dir \\
--do_train --max_train_samples 500 --num_train_epochs 1 \\
--dataset_name wmt16 --dataset_config "ro-en" \\
--source_lang en --target_lang ro \\
--fp16 --sharded_ddp simple`,highlighted:`python -m torch.distributed.launch --nproc_per_node=2 examples/pytorch/translation/run_translation.py \\
--model_name_or_path t5-small --per_device_train_batch_size 1   \\
--output_dir output_dir --overwrite_output_dir \\
--do_train --max_train_samples 500 --num_train_epochs 1 \\
--dataset_name wmt16 --dataset_config <span class="hljs-string">&quot;ro-en&quot;</span> \\
--source_lang en --target_lang ro \\
--fp16 --sharded_ddp simple`}}),ki=new O({props:{code:`python -m torch.distributed.launch --nproc_per_node=2 examples/pytorch/translation/run_translation.py \\
--model_name_or_path t5-small --per_device_train_batch_size 1   \\
--output_dir output_dir --overwrite_output_dir \\
--do_train --max_train_samples 500 --num_train_epochs 1 \\
--dataset_name wmt16 --dataset_config "ro-en" \\
--source_lang en --target_lang ro \\
--fp16 --sharded_ddp zero_dp_2`,highlighted:`python -m torch.distributed.launch --nproc_per_node=2 examples/pytorch/translation/run_translation.py \\
--model_name_or_path t5-small --per_device_train_batch_size 1   \\
--output_dir output_dir --overwrite_output_dir \\
--do_train --max_train_samples 500 --num_train_epochs 1 \\
--dataset_name wmt16 --dataset_config <span class="hljs-string">&quot;ro-en&quot;</span> \\
--source_lang en --target_lang ro \\
--fp16 --sharded_ddp zero_dp_2`}}),Pi=new Y({}),Mi=new Y({}),ha=new gp({props:{warning:!1,$$slots:{default:[hM]},$$scope:{ctx:Z}}}),Vi=new O({props:{code:`export TASK_NAME=mrpc

python examples/pytorch/text-classification/run_glue.py \\
  --model_name_or_path bert-base-cased \\
  --task_name $TASK_NAME \\
  --do_train \\
  --do_eval \\
  --max_seq_length 128 \\
  --per_device_train_batch_size 32 \\
  --learning_rate 2e-5 \\
  --num_train_epochs 3 \\
  --output_dir /tmp/$TASK_NAME/ \\
  --use_mps_device \\
  --overwrite_output_dir`,highlighted:`<span class="hljs-built_in">export</span> TASK_NAME=mrpc

python examples/pytorch/text-classification/run_glue.py \\
  --model_name_or_path bert-base-cased \\
  --task_name <span class="hljs-variable">$TASK_NAME</span> \\
  --do_train \\
  --do_eval \\
  --max_seq_length 128 \\
  --per_device_train_batch_size 32 \\
  --learning_rate 2e-5 \\
  --num_train_epochs 3 \\
  --output_dir /tmp/<span class="hljs-variable">$TASK_NAME</span>/ \\
  --use_mps_device \\
  --overwrite_output_dir`}}),{c(){T=n("meta"),D=l(),$=n("h1"),k=n("a"),L=n("span"),h(A.$$.fragment),S=l(),W=n("span"),fe=r("Trainer"),oe=l(),G=n("p"),se=r("The "),ie=n("a"),re=r("Trainer"),le=r(" class provides an API for feature-complete training in PyTorch for most standard use cases. It\u2019s used in most of the "),H=n("a"),Ze=r("example scripts"),ge=r("."),z=l(),I=n("p"),st=r("Before instantiating your "),ae=n("a"),it=r("Trainer"),lt=r(", create a "),_e=n("a"),Ia=r("TrainingArguments"),Ua=r(" to access all the points of customization during training."),Ke=l(),Pe=n("p"),Na=r("The API supports distributed training on multiple GPUs/TPUs, mixed precision through "),ve=n("a"),za=r("NVIDIA Apex"),Fa=r(" and Native AMP for PyTorch."),K=l(),B=n("p"),el=r("The "),be=n("a"),Xo=r("Trainer"),tl=r(" contains the basic training loop which supports the above features. To inject custom behavior you can subclass them and override the following methods:"),ro=l(),C=n("ul"),V=n("li"),Qo=n("strong"),ol=r("get_train_dataloader"),rl=r(" \u2014 Creates the training DataLoader."),al=l(),nl=n("li"),_p=n("strong"),A0=r("get_eval_dataloader"),P0=r(" \u2014 Creates the evaluation DataLoader."),D0=l(),sl=n("li"),vp=n("strong"),S0=r("get_test_dataloader"),q0=r(" \u2014 Creates the test DataLoader."),O0=l(),il=n("li"),bp=n("strong"),C0=r("log"),I0=r(" \u2014 Logs information on the various objects watching training."),U0=l(),dt=n("li"),yp=n("strong"),N0=r("create_optimizer_and_scheduler"),z0=r(` \u2014 Sets up the optimizer and learning rate scheduler if they were not passed at
init. Note, that you can also subclass or override the `),wp=n("code"),F0=r("create_optimizer"),L0=r(" and "),Tp=n("code"),R0=r("create_scheduler"),W0=r(` methods
separately.`),G0=l(),ll=n("li"),Ep=n("strong"),M0=r("create_optimizer"),j0=r(" \u2014 Sets up the optimizer if it wasn\u2019t passed at init."),H0=l(),dl=n("li"),$p=n("strong"),B0=r("create_scheduler"),V0=r(" \u2014 Sets up the learning rate scheduler if it wasn\u2019t passed at init."),Y0=l(),cl=n("li"),xp=n("strong"),Z0=r("compute_loss"),K0=r(" - Computes the loss on a batch of training inputs."),J0=l(),pl=n("li"),kp=n("strong"),X0=r("training_step"),Q0=r(" \u2014 Performs a training step."),ew=l(),ml=n("li"),Ap=n("strong"),tw=r("prediction_step"),ow=r(" \u2014 Performs an evaluation/test step."),rw=l(),hl=n("li"),Pp=n("strong"),aw=r("evaluate"),nw=r(" \u2014 Runs an evaluation loop and returns metrics."),sw=l(),ul=n("li"),Dp=n("strong"),iw=r("predict"),lw=r(" \u2014 Returns predictions (with metrics if labels are available) on a test set."),yv=l(),h(er.$$.fragment),wv=l(),tr=n("p"),dw=r("Here is an example of how to customize "),fl=n("a"),cw=r("Trainer"),pw=r(" to use a weighted loss (useful when you have an unbalanced training set):"),Tv=l(),h(La.$$.fragment),Ev=l(),ct=n("p"),mw=r("Another way to customize the training loop behavior for the PyTorch "),gl=n("a"),hw=r("Trainer"),uw=r(" is to use "),_l=n("a"),fw=r("callbacks"),gw=r(" that can inspect the training loop state (for progress reporting, logging on TensorBoard or other ML platforms\u2026) and take decisions (like early stopping)."),$v=l(),ao=n("h2"),or=n("a"),Sp=n("span"),h(Ra.$$.fragment),_w=l(),qp=n("span"),vw=r("Trainer"),xv=l(),b=n("div"),h(Wa.$$.fragment),bw=l(),Op=n("p"),yw=r("Trainer is a simple but feature-complete training and eval loop for PyTorch, optimized for \u{1F917} Transformers."),ww=l(),Cp=n("p"),Tw=r("Important attributes:"),Ew=l(),ye=n("ul"),rr=n("li"),Ip=n("strong"),$w=r("model"),xw=r(" \u2014 Always points to the core model. If using a transformers model, it will be a "),vl=n("a"),kw=r("PreTrainedModel"),Aw=r(`
subclass.`),Pw=l(),J=n("li"),Up=n("strong"),Dw=r("model_wrapped"),Sw=r(` \u2014 Always points to the most external model in case one or more other modules wrap the
original model. This is the model that should be used for the forward pass. For example, under `),Np=n("code"),qw=r("DeepSpeed"),Ow=r(`,
the inner model is wrapped in `),zp=n("code"),Cw=r("DeepSpeed"),Iw=r(" and then again in "),Fp=n("code"),Uw=r("torch.nn.DistributedDataParallel"),Nw=r(`. If the inner
model hasn\u2019t been wrapped, then `),Lp=n("code"),zw=r("self.model_wrapped"),Fw=r(" is the same as "),Rp=n("code"),Lw=r("self.model"),Rw=r("."),Ww=l(),bl=n("li"),Wp=n("strong"),Gw=r("is_model_parallel"),Mw=r(` \u2014 Whether or not a model has been switched to a model parallel mode (different from
data parallelism, this means some of the model layers are split on different GPUs).`),jw=l(),De=n("li"),Gp=n("strong"),Hw=r("place_model_on_device"),Bw=r(` \u2014 Whether or not to automatically place the model on the device - it will be set
to `),Mp=n("code"),Vw=r("False"),Yw=r(` if model parallel or deepspeed is used, or if the default
`),jp=n("code"),Zw=r("TrainingArguments.place_model_on_device"),Kw=r(" is overridden to return "),Hp=n("code"),Jw=r("False"),Xw=r(" ."),Qw=l(),Se=n("li"),Bp=n("strong"),eT=r("is_in_train"),tT=r(" \u2014 Whether or not a model is currently running "),Vp=n("code"),oT=r("train"),rT=r(" (e.g. when "),Yp=n("code"),aT=r("evaluate"),nT=r(` is called while
in `),Zp=n("code"),sT=r("train"),iT=r(")"),lT=l(),ar=n("div"),h(Ga.$$.fragment),dT=l(),Ma=n("p"),cT=r("Add a callback to the current list of "),Kp=n("code"),pT=r("~transformer.TrainerCallback"),mT=r("."),hT=l(),nr=n("div"),h(ja.$$.fragment),uT=l(),Ha=n("p"),fT=r("A helper wrapper that creates an appropriate context manager for "),Jp=n("code"),gT=r("autocast"),_T=r(` while feeding it the desired
arguments, depending on the situation.`),vT=l(),pt=n("div"),h(Ba.$$.fragment),bT=l(),Xp=n("p"),yT=r("How the loss is computed by Trainer. By default, all models return the loss in the first element."),wT=l(),Qp=n("p"),TT=r("Subclass and override for custom behavior."),ET=l(),sr=n("div"),h(Va.$$.fragment),$T=l(),em=n("p"),xT=r("A helper wrapper to group together context managers."),kT=l(),ir=n("div"),h(Ya.$$.fragment),AT=l(),Za=n("p"),PT=r("Creates a draft of a model card using the information available to the "),tm=n("code"),DT=r("Trainer"),ST=r("."),qT=l(),mt=n("div"),h(Ka.$$.fragment),OT=l(),om=n("p"),CT=r("Setup the optimizer."),IT=l(),Ja=n("p"),UT=r(`We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
Trainer\u2019s init through `),rm=n("code"),NT=r("optimizers"),zT=r(", or subclass and override this method in a subclass."),FT=l(),ht=n("div"),h(Xa.$$.fragment),LT=l(),am=n("p"),RT=r("Setup the optimizer and the learning rate scheduler."),WT=l(),Je=n("p"),GT=r(`We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
Trainer\u2019s init through `),nm=n("code"),MT=r("optimizers"),jT=r(", or subclass and override this method (or "),sm=n("code"),HT=r("create_optimizer"),BT=r(` and/or
`),im=n("code"),VT=r("create_scheduler"),YT=r(") in a subclass."),ZT=l(),lr=n("div"),h(Qa.$$.fragment),KT=l(),lm=n("p"),JT=r(`Setup the scheduler. The optimizer of the trainer must have been set up either before this method is called or
passed as an argument.`),XT=l(),qe=n("div"),h(en.$$.fragment),QT=l(),dm=n("p"),eE=r("Run evaluation and returns metrics."),tE=l(),tn=n("p"),oE=r(`The calling script will be responsible for providing a method to compute metrics, as they are task-dependent
(pass it to the init `),cm=n("code"),rE=r("compute_metrics"),aE=r(" argument)."),nE=l(),pm=n("p"),sE=r("You can also subclass and override this method to inject custom behavior."),iE=l(),ut=n("div"),h(on.$$.fragment),lE=l(),no=n("p"),dE=r("Prediction/evaluation loop, shared by "),mm=n("code"),cE=r("Trainer.evaluate()"),pE=r(" and "),hm=n("code"),mE=r("Trainer.predict()"),hE=r("."),uE=l(),um=n("p"),fE=r("Works both with or without labels."),gE=l(),dr=n("div"),h(rn.$$.fragment),_E=l(),an=n("p"),vE=r("For models that inherit from "),yl=n("a"),bE=r("PreTrainedModel"),yE=r(`, uses that method to compute the number of floating point
operations for every backward + forward pass. If using another model, either implement such a method in the
model or subclass and override this method.`),wE=l(),ft=n("div"),h(nn.$$.fragment),TE=l(),sn=n("p"),EE=r("Returns the evaluation "),fm=n("code"),$E=r("~torch.utils.data.DataLoader"),xE=r("."),kE=l(),gm=n("p"),AE=r("Subclass and override this method if you want to inject some custom behavior."),PE=l(),cr=n("div"),h(ln.$$.fragment),DE=l(),_m=n("p"),SE=r("Returns the optimizer class and optimizer parameters based on the training arguments."),qE=l(),gt=n("div"),h(dn.$$.fragment),OE=l(),cn=n("p"),CE=r("Returns the test "),vm=n("code"),IE=r("~torch.utils.data.DataLoader"),UE=r("."),NE=l(),bm=n("p"),zE=r("Subclass and override this method if you want to inject some custom behavior."),FE=l(),Oe=n("div"),h(pn.$$.fragment),LE=l(),mn=n("p"),RE=r("Returns the training "),ym=n("code"),WE=r("~torch.utils.data.DataLoader"),GE=r("."),ME=l(),so=n("p"),jE=r("Will use no sampler if "),wm=n("code"),HE=r("train_dataset"),BE=r(" does not implement "),Tm=n("code"),VE=r("__len__"),YE=r(`, a random sampler (adapted to distributed
training if necessary) otherwise.`),ZE=l(),Em=n("p"),KE=r("Subclass and override this method if you want to inject some custom behavior."),JE=l(),_t=n("div"),h(hn.$$.fragment),XE=l(),we=n("p"),QE=r("Launch an hyperparameter search using "),$m=n("code"),e4=r("optuna"),t4=r(" or "),xm=n("code"),o4=r("Ray Tune"),r4=r(" or "),km=n("code"),a4=r("SigOpt"),n4=r(`. The optimized quantity is determined
by `),Am=n("code"),s4=r("compute_objective"),i4=r(`, which defaults to a function returning the evaluation loss when no metric is provided,
the sum of all metrics otherwise.`),l4=l(),h(pr.$$.fragment),d4=l(),mr=n("div"),h(un.$$.fragment),c4=l(),fn=n("p"),p4=r("Initializes a git repo in "),Pm=n("code"),m4=r("self.args.hub_model_id"),h4=r("."),u4=l(),hr=n("div"),h(gn.$$.fragment),f4=l(),Dm=n("p"),g4=r(`Whether or not this process is the local (e.g., on one machine if training in a distributed fashion on several
machines) main process.`),_4=l(),ur=n("div"),h(_n.$$.fragment),v4=l(),vn=n("p"),b4=r(`Whether or not this process is the global main process (when training in a distributed fashion on several
machines, this is only going to be `),Sm=n("code"),y4=r("True"),w4=r(" for one process)."),T4=l(),vt=n("div"),h(bn.$$.fragment),E4=l(),yn=n("p"),$4=r("Log "),qm=n("code"),x4=r("logs"),k4=r(" on the various objects watching training."),A4=l(),Om=n("p"),P4=r("Subclass and override this method to inject custom behavior."),D4=l(),P=n("div"),h(wn.$$.fragment),S4=l(),Cm=n("p"),q4=r("Log metrics in a specially formatted way"),O4=l(),Im=n("p"),C4=r("Under distributed environment this is done only for a process with rank 0."),I4=l(),Um=n("p"),U4=r("Notes on memory reports:"),N4=l(),io=n("p"),z4=r("In order to get memory usage report you need to install "),Nm=n("code"),F4=r("psutil"),L4=r(". You can do that with "),zm=n("code"),R4=r("pip install psutil"),W4=r("."),G4=l(),h(fr.$$.fragment),M4=l(),Fm=n("p"),Lm=n("strong"),j4=r("Understanding the reports:"),H4=l(),Xe=n("ul"),Te=n("li"),B4=r("the first segment, e.g., "),Rm=n("code"),V4=r("train__"),Y4=r(", tells you which stage the metrics are for. Reports starting with "),Wm=n("code"),Z4=r("init_"),K4=r(`
will be added to the first stage that gets run. So that if only evaluation is run, the memory usage for the
`),Gm=n("code"),J4=r("__init__"),X4=r(" will be reported along with the "),Mm=n("code"),Q4=r("eval_"),e9=r(" metrics."),t9=l(),lo=n("li"),o9=r("the third segment, is either "),jm=n("code"),r9=r("cpu"),a9=r(" or "),Hm=n("code"),n9=r("gpu"),s9=r(`, tells you whether it\u2019s the general RAM or the gpu0 memory
metric.`),i9=l(),wl=n("li"),Bm=n("code"),l9=r("*_alloc_delta"),d9=r(` - is the difference in the used/allocated memory counter between the end and the start of the
stage - it can be negative if a function released more memory than it allocated.`),c9=l(),bt=n("li"),Vm=n("code"),p9=r("*_peaked_delta"),m9=r(` - is any extra memory that was consumed and then freed - relative to the current allocated
memory counter - it is never negative. When you look at the metrics of any stage you add up `),Ym=n("code"),h9=r("alloc_delta"),u9=r(` +
`),Zm=n("code"),f9=r("peaked_delta"),g9=r(" and you know how much memory was needed to complete that stage."),_9=l(),Km=n("p"),v9=r(`The reporting happens only for process of rank 0 and gpu 0 (if there is a gpu). Typically this is enough since the
main process does the bulk of work, but it could be not quite so if model parallel is used and then other GPUs may
use a different amount of gpu memory. This is also not the same under DataParallel where gpu0 may require much more
memory than the rest since it stores the gradient and optimizer states for all participating GPUS. Perhaps in the
future these reports will evolve to measure those too.`),b9=l(),Jm=n("p"),y9=r(`The CPU RAM metric measures RSS (Resident Set Size) includes both the memory which is unique to the process and the
memory shared with other processes. It is important to note that it does not include swapped out memory, so the
reports could be imprecise.`),w9=l(),Tn=n("p"),T9=r(`The CPU peak memory is measured using a sampling thread. Due to python\u2019s GIL it may miss some of the peak memory if
that thread didn\u2019t get a chance to run when the highest memory was used. Therefore this report can be less than
reality. Using `),Xm=n("code"),E9=r("tracemalloc"),$9=r(` would have reported the exact peak memory, but it doesn\u2019t report memory allocations
outside of python. So if some C++ CUDA extension allocated its own memory it won\u2019t be reported. And therefore it
was dropped in favor of the memory sampling approach, which reads the current process memory usage.`),x9=l(),Qe=n("p"),k9=r("The GPU allocated and peak memory reporting is done with "),Qm=n("code"),A9=r("torch.cuda.memory_allocated()"),P9=r(` and
`),eh=n("code"),D9=r("torch.cuda.max_memory_allocated()"),S9=r(`. This metric reports only \u201Cdeltas\u201D for pytorch-specific allocations, as
`),th=n("code"),q9=r("torch.cuda"),O9=r(` memory management system doesn\u2019t track any memory allocated outside of pytorch. For example, the very
first cuda call typically loads CUDA kernels, which may take from 0.5 to 2GB of GPU memory.`),C9=l(),ne=n("p"),I9=r("Note that this tracker doesn\u2019t account for memory allocations outside of "),Tl=n("a"),U9=r("Trainer"),N9=r("\u2019s "),oh=n("code"),z9=r("__init__"),F9=r(", "),rh=n("code"),L9=r("train"),R9=r(`,
`),ah=n("code"),W9=r("evaluate"),G9=r(" and "),nh=n("code"),M9=r("predict"),j9=r(" calls."),H9=l(),U=n("p"),B9=r("Because "),sh=n("code"),V9=r("evaluation"),Y9=r(" calls may happen during "),ih=n("code"),Z9=r("train"),K9=r(`, we can\u2019t handle nested invocations because
`),lh=n("code"),J9=r("torch.cuda.max_memory_allocated"),X9=r(" is a single counter, so if it gets reset by a nested eval call, "),dh=n("code"),Q9=r("train"),e$=r(`\u2019s tracker
will report incorrect info. If this `),En=n("a"),t$=r("pytorch issue"),o$=r(` gets resolved
it will be possible to change this class to be re-entrant. Until then we will only track the outer level of
`),ch=n("code"),r$=r("train"),a$=r(", "),ph=n("code"),n$=r("evaluate"),s$=r(" and "),mh=n("code"),i$=r("predict"),l$=r(" methods. Which means that if "),hh=n("code"),d$=r("eval"),c$=r(" is called during "),uh=n("code"),p$=r("train"),m$=r(`, it\u2019s the latter
that will account for its memory usage and that of the former.`),h$=l(),Ee=n("p"),u$=r("This also means that if any other tool that is used along the "),El=n("a"),f$=r("Trainer"),g$=r(` calls
`),fh=n("code"),_$=r("torch.cuda.reset_peak_memory_stats"),v$=r(", the gpu peak memory stats could be invalid. And the "),$l=n("a"),b$=r("Trainer"),y$=r(` will disrupt
the normal behavior of any such tools that rely on calling `),gh=n("code"),w$=r("torch.cuda.reset_peak_memory_stats"),T$=r(" themselves."),E$=l(),_h=n("p"),$$=r("For best performance you may want to consider turning the memory profiling off for production runs."),x$=l(),gr=n("div"),h($n.$$.fragment),k$=l(),vh=n("p"),A$=r("Reformat Trainer metrics values to a human-readable format"),P$=l(),_r=n("div"),h(xn.$$.fragment),D$=l(),kn=n("p"),S$=r("Helper to get number of samples in a "),bh=n("code"),q$=r("~torch.utils.data.DataLoader"),O$=r(` by accessing its dataset. When
dataloader.dataset does not exist or has no length, estimates as best it can`),C$=l(),yt=n("div"),h(An.$$.fragment),I$=l(),Pn=n("p"),U$=r("Remove a callback from the current list of "),yh=n("code"),N$=r("~transformer.TrainerCallback"),z$=r(" and returns it."),F$=l(),Dn=n("p"),L$=r("If the callback is not found, returns "),wh=n("code"),R$=r("None"),W$=r(" (and no error is raised)."),G$=l(),X=n("div"),h(Sn.$$.fragment),M$=l(),Th=n("p"),j$=r("Run prediction and returns predictions and potential metrics."),H$=l(),qn=n("p"),B$=r(`Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
will also return metrics, like in `),Eh=n("code"),V$=r("evaluate()"),Y$=r("."),Z$=l(),h(vr.$$.fragment),K$=l(),On=n("p"),J$=r("Returns: "),$h=n("em"),X$=r("NamedTuple"),Q$=r(" A namedtuple with the following keys:"),e3=l(),co=n("ul"),po=n("li"),t3=r("predictions ("),xh=n("code"),o3=r("np.ndarray"),r3=r("): The predictions on "),kh=n("code"),a3=r("test_dataset"),n3=r("."),s3=l(),mo=n("li"),i3=r("label_ids ("),Ah=n("code"),l3=r("np.ndarray"),d3=r(", "),Ph=n("em"),c3=r("optional"),p3=r("): The labels (if the dataset contained some)."),m3=l(),ho=n("li"),h3=r("metrics ("),Dh=n("code"),u3=r("Dict[str, float]"),f3=r(", "),Sh=n("em"),g3=r("optional"),_3=r(`): The potential dictionary of metrics (if the dataset contained
labels).`),v3=l(),wt=n("div"),h(Cn.$$.fragment),b3=l(),uo=n("p"),y3=r("Prediction/evaluation loop, shared by "),qh=n("code"),w3=r("Trainer.evaluate()"),T3=r(" and "),Oh=n("code"),E3=r("Trainer.predict()"),$3=r("."),x3=l(),Ch=n("p"),k3=r("Works both with or without labels."),A3=l(),Tt=n("div"),h(In.$$.fragment),P3=l(),fo=n("p"),D3=r("Perform an evaluation step on "),Ih=n("code"),S3=r("model"),q3=r(" using "),Uh=n("code"),O3=r("inputs"),C3=r("."),I3=l(),Nh=n("p"),U3=r("Subclass and override to inject custom behavior."),N3=l(),br=n("div"),h(Un.$$.fragment),z3=l(),et=n("p"),F3=r("Upload "),zh=n("em"),L3=r("self.model"),R3=r(" and "),Fh=n("em"),W3=r("self.tokenizer"),G3=r(" to the \u{1F917} model hub on the repo "),Lh=n("em"),M3=r("self.args.hub_model_id"),j3=r("."),H3=l(),yr=n("div"),h(Nn.$$.fragment),B3=l(),zn=n("p"),V3=r("Remove a callback from the current list of "),Rh=n("code"),Y3=r("~transformer.TrainerCallback"),Z3=r("."),K3=l(),Ce=n("div"),h(Fn.$$.fragment),J3=l(),Ln=n("p"),X3=r("Save metrics into a json file for that split, e.g. "),Wh=n("code"),Q3=r("train_results.json"),ex=r("."),tx=l(),Gh=n("p"),ox=r("Under distributed environment this is done only for a process with rank 0."),rx=l(),Rn=n("p"),ax=r("To understand the metrics please read the docstring of "),xl=n("a"),nx=r("log_metrics()"),sx=r(`. The only difference is that raw
unformatted numbers are saved in the current method.`),ix=l(),Et=n("div"),h(Wn.$$.fragment),lx=l(),Gn=n("p"),dx=r("Will save the model, so you can reload it using "),Mh=n("code"),cx=r("from_pretrained()"),px=r("."),mx=l(),jh=n("p"),hx=r("Will only save from the main process."),ux=l(),$t=n("div"),h(Mn.$$.fragment),fx=l(),Hh=n("p"),gx=r("Saves the Trainer state, since Trainer.save_model saves only the tokenizer with the model"),_x=l(),Bh=n("p"),vx=r("Under distributed environment this is done only for a process with rank 0."),bx=l(),wr=n("div"),h(jn.$$.fragment),yx=l(),Hn=n("p"),wx=r("A helper wrapper that creates an appropriate context manager for "),Vh=n("code"),Tx=r("torchdynamo"),Ex=r("."),$x=l(),Tr=n("div"),h(Bn.$$.fragment),xx=l(),Yh=n("p"),kx=r("Main training entry point."),Ax=l(),xt=n("div"),h(Vn.$$.fragment),Px=l(),Zh=n("p"),Dx=r("Perform a training step on a batch of inputs."),Sx=l(),Kh=n("p"),qx=r("Subclass and override to inject custom behavior."),kv=l(),go=n("h2"),Er=n("a"),Jh=n("span"),h(Yn.$$.fragment),Ox=l(),Xh=n("span"),Cx=r("Seq2SeqTrainer"),Av=l(),tt=n("div"),h(Zn.$$.fragment),Ix=l(),Ie=n("div"),h(Kn.$$.fragment),Ux=l(),Qh=n("p"),Nx=r("Run evaluation and returns metrics."),zx=l(),Jn=n("p"),Fx=r(`The calling script will be responsible for providing a method to compute metrics, as they are task-dependent
(pass it to the init `),eu=n("code"),Lx=r("compute_metrics"),Rx=r(" argument)."),Wx=l(),tu=n("p"),Gx=r("You can also subclass and override this method to inject custom behavior."),Mx=l(),Q=n("div"),h(Xn.$$.fragment),jx=l(),ou=n("p"),Hx=r("Run prediction and returns predictions and potential metrics."),Bx=l(),Qn=n("p"),Vx=r(`Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
will also return metrics, like in `),ru=n("code"),Yx=r("evaluate()"),Zx=r("."),Kx=l(),h($r.$$.fragment),Jx=l(),es=n("p"),Xx=r("Returns: "),au=n("em"),Qx=r("NamedTuple"),ek=r(" A namedtuple with the following keys:"),tk=l(),_o=n("ul"),vo=n("li"),ok=r("predictions ("),nu=n("code"),rk=r("np.ndarray"),ak=r("): The predictions on "),su=n("code"),nk=r("test_dataset"),sk=r("."),ik=l(),bo=n("li"),lk=r("label_ids ("),iu=n("code"),dk=r("np.ndarray"),ck=r(", "),lu=n("em"),pk=r("optional"),mk=r("): The labels (if the dataset contained some)."),hk=l(),yo=n("li"),uk=r("metrics ("),du=n("code"),fk=r("Dict[str, float]"),gk=r(", "),cu=n("em"),_k=r("optional"),vk=r(`): The potential dictionary of metrics (if the dataset contained
labels).`),Pv=l(),wo=n("h2"),xr=n("a"),pu=n("span"),h(ts.$$.fragment),bk=l(),mu=n("span"),yk=r("TrainingArguments"),Dv=l(),F=n("div"),h(os.$$.fragment),wk=l(),rs=n("p"),Tk=r("TrainingArguments is the subset of the arguments we use in our example scripts "),hu=n("strong"),Ek=r(`which relate to the training loop
itself`),$k=r("."),xk=l(),To=n("p"),kk=r("Using "),kl=n("a"),Ak=r("HfArgumentParser"),Pk=r(` we can turn this class into
`),as=n("a"),Dk=r("argparse"),Sk=r(` arguments that can be specified on the
command line.`),qk=l(),de=n("div"),h(ns.$$.fragment),Ok=l(),uu=n("p"),Ck=r(`Returns the log level to be used depending on whether this process is the main process of node 0, main process
of node non-0, or a non-main process.`),Ik=l(),Eo=n("p"),Uk=r("For the main process the log level defaults to "),fu=n("code"),Nk=r("logging.INFO"),zk=r(" unless overridden by "),gu=n("code"),Fk=r("log_level"),Lk=r(" argument."),Rk=l(),$o=n("p"),Wk=r("For the replica processes the log level defaults to "),_u=n("code"),Gk=r("logging.WARNING"),Mk=r(" unless overridden by "),vu=n("code"),jk=r("log_level_replica"),Hk=r(`
argument.`),Bk=l(),ss=n("p"),Vk=r("The choice between the main and replica process settings is made according to the return value of "),bu=n("code"),Yk=r("should_log"),Zk=r("."),Kk=l(),kr=n("div"),h(is.$$.fragment),Jk=l(),yu=n("p"),Xk=r("Get number of steps used for a linear warmup."),Qk=l(),kt=n("div"),h(ls.$$.fragment),e5=l(),wu=n("p"),t5=r(`A context manager for torch distributed environment where on needs to do something on the main process, while
blocking replicas, and when it\u2019s finished releasing the replicas.`),o5=l(),xo=n("p"),r5=r("One such use is for "),Tu=n("code"),a5=r("datasets"),n5=r("\u2019s "),Eu=n("code"),s5=r("map"),i5=r(` feature which to be efficient should be run once on the main process,
which upon completion saves a cached version of results and which then automatically gets loaded by the
replicas.`),l5=l(),Ar=n("div"),h(ds.$$.fragment),d5=l(),cs=n("p"),c5=r("Serializes this instance while replace "),$u=n("code"),p5=r("Enum"),m5=r(` by their values (for JSON serialization support). It obfuscates
the token values by removing their value.`),h5=l(),Pr=n("div"),h(ps.$$.fragment),u5=l(),xu=n("p"),f5=r("Serializes this instance to a JSON string."),g5=l(),Dr=n("div"),h(ms.$$.fragment),_5=l(),ku=n("p"),v5=r("Sanitized serialization to use with TensorBoard\u2019s hparams"),Sv=l(),ko=n("h2"),Sr=n("a"),Au=n("span"),h(hs.$$.fragment),b5=l(),Pu=n("span"),y5=r("Seq2SeqTrainingArguments"),qv=l(),ot=n("div"),h(us.$$.fragment),w5=l(),fs=n("p"),T5=r("TrainingArguments is the subset of the arguments we use in our example scripts "),Du=n("strong"),E5=r(`which relate to the training loop
itself`),$5=r("."),x5=l(),Ao=n("p"),k5=r("Using "),Al=n("a"),A5=r("HfArgumentParser"),P5=r(` we can turn this class into
`),gs=n("a"),D5=r("argparse"),S5=r(` arguments that can be specified on the
command line.`),Ov=l(),Po=n("h2"),qr=n("a"),Su=n("span"),h(_s.$$.fragment),q5=l(),qu=n("span"),O5=r("Checkpoints"),Cv=l(),ce=n("p"),C5=r("By default, "),Pl=n("a"),I5=r("Trainer"),U5=r(" will save all checkpoints in the "),Ou=n("code"),N5=r("output_dir"),z5=r(` you set in the
`),Dl=n("a"),F5=r("TrainingArguments"),L5=r(" you are using. Those will go in subfolder named "),Cu=n("code"),R5=r("checkpoint-xxx"),W5=r(` with xxx
being the step at which the training was at.`),Iv=l(),Or=n("p"),G5=r("Resuming training from a checkpoint can be done when calling "),Sl=n("a"),M5=r("Trainer.train()"),j5=r(" with either:"),Uv=l(),Cr=n("ul"),ql=n("li"),Iu=n("code"),H5=r("resume_from_checkpoint=True"),B5=r(" which will resume training from the latest checkpoint"),V5=l(),Ol=n("li"),Uu=n("code"),Y5=r("resume_from_checkpoint=checkpoint_dir"),Z5=r(` which will resume training from the specific checkpoint in the directory
passed.`),Nv=l(),Ue=n("p"),K5=r("In addition, you can easily save your checkpoints on the Model Hub when using "),Nu=n("code"),J5=r("push_to_hub=True"),X5=r(`. By default, all
the models saved in intermediate checkpoints are saved in different commits, but not the optimizer state. You can adapt
the `),zu=n("code"),Q5=r("hub-strategy"),e6=r(" value of your "),Cl=n("a"),t6=r("TrainingArguments"),o6=r(" to either:"),zv=l(),Ir=n("ul"),Ur=n("li"),Fu=n("code"),r6=r('"checkpoint"'),a6=r(`: the latest checkpoint is also pushed in a subfolder named last-checkpoint, allowing you to
resume training easily with `),Lu=n("code"),n6=r('trainer.train(resume_from_checkpoint="output_dir/last-checkpoint")'),s6=r("."),i6=l(),Il=n("li"),Ru=n("code"),l6=r('"all_checkpoints"'),d6=r(`: all checkpoints are pushed like they appear in the output folder (so you will get one
checkpoint folder per folder in your final repository)`),Fv=l(),Do=n("h2"),Nr=n("a"),Wu=n("span"),h(vs.$$.fragment),c6=l(),Gu=n("span"),p6=r("Logging"),Lv=l(),Ne=n("p"),m6=r("By default "),Ul=n("a"),h6=r("Trainer"),u6=r(" will use "),Mu=n("code"),f6=r("logging.INFO"),g6=r(" for the main process and "),ju=n("code"),_6=r("logging.WARNING"),v6=r(" for the replicas if any."),Rv=l(),At=n("p"),b6=r("These defaults can be overridden to use any of the 5 "),Hu=n("code"),y6=r("logging"),w6=r(" levels with "),Nl=n("a"),T6=r("TrainingArguments"),E6=r(`\u2019s
arguments:`),Wv=l(),zr=n("ul"),zl=n("li"),Bu=n("code"),$6=r("log_level"),x6=r(" - for the main process"),k6=l(),Fl=n("li"),Vu=n("code"),A6=r("log_level_replica"),P6=r(" - for the replicas"),Gv=l(),ze=n("p"),D6=r("Further, if "),Ll=n("a"),S6=r("TrainingArguments"),q6=r("\u2019s "),Yu=n("code"),O6=r("log_on_each_node"),C6=r(" is set to "),Zu=n("code"),I6=r("False"),U6=r(` only the main node will
use the log level settings for its main process, all other nodes will use the log level settings for replicas.`),Mv=l(),ee=n("p"),N6=r("Note that "),Rl=n("a"),z6=r("Trainer"),F6=r(" is going to set "),Ku=n("code"),L6=r("transformers"),R6=r(`\u2019s log level separately for each node in its
`),Ju=n("code"),W6=r("Trainer.__init__()"),G6=r(`. So you may want to set this sooner (see the next example) if you tap into other
`),Xu=n("code"),M6=r("transformers"),j6=r(" functionality before creating the "),Wl=n("a"),H6=r("Trainer"),B6=r(" object."),jv=l(),Gl=n("p"),V6=r("Here is an example of how this can be used in an application:"),Hv=l(),h(bs.$$.fragment),Bv=l(),Ml=n("p"),Y6=r(`And then if you only want to see warnings on the main node and all other nodes to not print any most likely duplicated
warnings you could run it as:`),Vv=l(),h(ys.$$.fragment),Yv=l(),jl=n("p"),Z6=r(`In the multi-node environment if you also don\u2019t want the logs to repeat for each node\u2019s main process, you will want to
change the above to:`),Zv=l(),h(ws.$$.fragment),Kv=l(),Hl=n("p"),K6=r(`and then only the main process of the first node will log at the \u201Cwarning\u201D level, and all other processes on the main
node and all processes on other nodes will log at the \u201Cerror\u201D level.`),Jv=l(),Bl=n("p"),J6=r("If you need your application to be as quiet as possible you could do:"),Xv=l(),h(Ts.$$.fragment),Qv=l(),Fr=n("p"),X6=r("(add "),Qu=n("code"),Q6=r("--log_on_each_node 0"),e7=r(" if on multi-node environment)"),e1=l(),So=n("h2"),Lr=n("a"),ef=n("span"),h(Es.$$.fragment),t7=l(),tf=n("span"),o7=r("Randomness"),t1=l(),pe=n("p"),r7=r("When resuming from a checkpoint generated by "),Vl=n("a"),a7=r("Trainer"),n7=r(` all efforts are made to restore the
`),of=n("em"),s7=r("python"),i7=r(", "),rf=n("em"),l7=r("numpy"),d7=r(" and "),af=n("em"),c7=r("pytorch"),p7=r(` RNG states to the same states as they were at the moment of saving that checkpoint,
which should make the \u201Cstop and resume\u201D style of training as close as possible to non-stop training.`),o1=l(),Pt=n("p"),m7=r(`However, due to various default non-deterministic pytorch settings this might not fully work. If you want full
determinism please refer to `),$s=n("a"),h7=r("Controlling sources of randomness"),u7=r(`. As explained in the document, that some of those settings
that make things deterministic (.e.g., `),nf=n("code"),f7=r("torch.backends.cudnn.deterministic"),g7=r(`) may slow things down, therefore this
can\u2019t be done by default, but you can enable those yourself if needed.`),r1=l(),qo=n("h2"),Rr=n("a"),sf=n("span"),h(xs.$$.fragment),_7=l(),lf=n("span"),v7=r("Specific GPUs Selection"),a1=l(),Yl=n("p"),b7=r("Let\u2019s discuss how you can tell your program which GPUs are to be used and in what order."),n1=l(),Wr=n("p"),y7=r("When using "),ks=n("a"),df=n("code"),w7=r("DistributedDataParallel"),T7=r(" to use only a subset of your GPUs, you simply specify the number of GPUs to use. For example, if you have 4 GPUs, but you wish to use the first 2 you can do:"),s1=l(),h(As.$$.fragment),i1=l(),Dt=n("p"),E7=r("if you have either "),Ps=n("a"),cf=n("code"),$7=r("accelerate"),x7=r(" or "),Ds=n("a"),pf=n("code"),k7=r("deepspeed"),A7=r(" installed you can also accomplish the same by using one of:"),l1=l(),h(Ss.$$.fragment),d1=l(),h(qs.$$.fragment),c1=l(),Gr=n("p"),P7=r("You don\u2019t need to use the Accelerate or "),Zl=n("a"),D7=r("the Deepspeed integration"),S7=r(" features to use these launchers."),p1=l(),Kl=n("p"),q7=r("Until now you were able to tell the program how many GPUs to use. Now let\u2019s discuss how to select specific GPUs and control their order."),m1=l(),Jl=n("p"),O7=r("The following environment variables help you control which GPUs to use and their order."),h1=l(),Xl=n("p"),mf=n("strong"),hf=n("code"),C7=r("CUDA_VISIBLE_DEVICES"),u1=l(),Mr=n("p"),I7=r("If you have multiple GPUs and you\u2019d like to use only 1 or a few of those GPUs, set the environment variable "),uf=n("code"),U7=r("CUDA_VISIBLE_DEVICES"),N7=r(" to a list of the GPUs to be used."),f1=l(),Ql=n("p"),z7=r("For example, let\u2019s say you have 4 GPUs: 0, 1, 2 and 3. To run only on the physical GPUs 0 and 2, you can do:"),g1=l(),h(Os.$$.fragment),_1=l(),St=n("p"),F7=r("So now pytorch will see only 2 GPUs, where your physical GPUs 0 and 2 are mapped to "),ff=n("code"),L7=r("cuda:0"),R7=r(" and "),gf=n("code"),W7=r("cuda:1"),G7=r(" correspondingly."),v1=l(),ed=n("p"),M7=r("You can even change their order:"),b1=l(),h(Cs.$$.fragment),y1=l(),qt=n("p"),j7=r("Here your physical GPUs 0 and 2 are mapped to "),_f=n("code"),H7=r("cuda:1"),B7=r(" and "),vf=n("code"),V7=r("cuda:0"),Y7=r(" correspondingly."),w1=l(),Ot=n("p"),Z7=r("The above examples were all for "),bf=n("code"),K7=r("DistributedDataParallel"),J7=r(" use pattern, but the same method works for "),Is=n("a"),yf=n("code"),X7=r("DataParallel"),Q7=r(" as well:"),T1=l(),h(Us.$$.fragment),E1=l(),td=n("p"),eA=r("To emulate an environment without GPUs simply set this environment variable to an empty value like so:"),$1=l(),h(Ns.$$.fragment),x1=l(),od=n("p"),tA=r("As with any environment variable you can, of course, export those instead of adding these to the command line, as in:"),k1=l(),h(zs.$$.fragment),A1=l(),rd=n("p"),oA=r("but this approach can be confusing since you may forget you set up the environment variable earlier and not understand why the wrong GPUs are used. Therefore, it\u2019s a common practice to set the environment variable just for a specific run on the same command line as it\u2019s shown in most examples of this section."),P1=l(),ad=n("p"),wf=n("strong"),Tf=n("code"),rA=r("CUDA_DEVICE_ORDER"),D1=l(),jr=n("p"),aA=r("There is an additional environment variable "),Ef=n("code"),nA=r("CUDA_DEVICE_ORDER"),sA=r(" that controls how the physical devices are ordered. The two choices are:"),S1=l(),nd=n("ol"),Fs=n("li"),iA=r("ordered by PCIe bus IDs (matches "),$f=n("code"),lA=r("nvidia-smi"),dA=r("\u2019s order) - this is the default."),q1=l(),h(Ls.$$.fragment),O1=l(),Rs=n("ol"),xf=n("li"),cA=r("ordered by GPU compute capabilities"),C1=l(),h(Ws.$$.fragment),I1=l(),Ct=n("p"),pA=r("Most of the time you don\u2019t need to care about this environment variable, but it\u2019s very helpful if you have a lopsided setup where you have an old and a new GPUs physically inserted in such a way so that the slow older card appears to be first. One way to fix that is to swap the cards. But if you can\u2019t swap the cards (e.g., if the cooling of the devices gets impacted) then setting "),kf=n("code"),mA=r("CUDA_DEVICE_ORDER=FASTEST_FIRST"),hA=r(" will always put the newer faster card first. It\u2019ll be somewhat confusing though since "),Af=n("code"),uA=r("nvidia-smi"),fA=r(" will still report them in the PCIe order."),U1=l(),sd=n("p"),gA=r("The other solution to swapping the order is to use:"),N1=l(),h(Gs.$$.fragment),z1=l(),id=n("p"),_A=r("In this example we are working with just 2 GPUs, but of course the same would apply to as many GPUs as your computer has."),F1=l(),Hr=n("p"),vA=r("Also if you do set this environment variable it\u2019s the best to set it in your "),Pf=n("code"),bA=r("~/.bashrc"),yA=r(" file or some other startup config file and forget about it."),L1=l(),Oo=n("h2"),Br=n("a"),Df=n("span"),h(Ms.$$.fragment),wA=l(),Sf=n("span"),TA=r("Trainer Integrations"),R1=l(),Vr=n("p"),EA=r("The "),ld=n("a"),$A=r("Trainer"),xA=r(` has been extended to support libraries that may dramatically improve your training
time and fit much bigger models.`),W1=l(),me=n("p"),kA=r("Currently it supports third party solutions, "),js=n("a"),AA=r("DeepSpeed"),PA=r(", "),Hs=n("a"),DA=r("PyTorch FSDP"),SA=r(" and "),Bs=n("a"),qA=r("FairScale"),OA=r(", which implement parts of the paper "),Vs=n("a"),CA=r(`ZeRO: Memory Optimizations
Toward Training Trillion Parameter Models, by Samyam Rajbhandari, Jeff Rasley, Olatunji Ruwase, Yuxiong He`),IA=r("."),G1=l(),Yr=n("p"),UA=r("This provided support is new and experimental as of this writing. While the support for DeepSpeed and PyTorch FSDP is active and we welcome issues around it, we don\u2019t support the FairScale integration anymore since it has been integrated in PyTorch main (see the "),dd=n("a"),NA=r("PyTorch FSDP integration"),zA=r(")"),M1=l(),cd=n("a"),j1=l(),Co=n("h3"),Zr=n("a"),qf=n("span"),h(Ys.$$.fragment),FA=l(),Of=n("span"),LA=r("CUDA Extension Installation Notes"),H1=l(),pd=n("p"),RA=r("As of this writing, both FairScale and Deepspeed require compilation of CUDA C++ code, before they can be used."),B1=l(),It=n("p"),WA=r("While all installation issues should be dealt with through the corresponding GitHub Issues of "),Zs=n("a"),GA=r("FairScale"),MA=r(" and "),Ks=n("a"),jA=r("Deepspeed"),HA=r(`, there are a few common issues that one may encounter while building
any PyTorch extension that needs to build CUDA extensions.`),V1=l(),md=n("p"),BA=r("Therefore, if you encounter a CUDA-related build issue while doing one of the following or both:"),Y1=l(),h(Js.$$.fragment),Z1=l(),hd=n("p"),VA=r("please, read the following notes first."),K1=l(),Ut=n("p"),YA=r("In these notes we give examples for what to do when "),Cf=n("code"),ZA=r("pytorch"),KA=r(" has been built with CUDA "),If=n("code"),JA=r("10.2"),XA=r(`. If your situation is
different remember to adjust the version number to the one you are after.`),J1=l(),Io=n("h4"),Kr=n("a"),Uf=n("span"),h(Xs.$$.fragment),QA=l(),Nf=n("span"),e8=r("Possible problem #1"),X1=l(),ud=n("p"),t8=r(`While, Pytorch comes with its own CUDA toolkit, to build these two projects you must have an identical version of CUDA
installed system-wide.`),Q1=l(),Fe=n("p"),o8=r("For example, if you installed "),zf=n("code"),r8=r("pytorch"),a8=r(" with "),Ff=n("code"),n8=r("cudatoolkit==10.2"),s8=r(` in the Python environment, you also need to have
CUDA `),Lf=n("code"),i8=r("10.2"),l8=r(" installed system-wide."),eb=l(),Nt=n("p"),d8=r("The exact location may vary from system to system, but "),Rf=n("code"),c8=r("/usr/local/cuda-10.2"),p8=r(` is the most common location on many
Unix systems. When CUDA is correctly set up and added to the `),Wf=n("code"),m8=r("PATH"),h8=r(` environment variable, one can find the
installation location by doing:`),tb=l(),h(Qs.$$.fragment),ob=l(),Jr=n("p"),u8=r(`If you don\u2019t have CUDA installed system-wide, install it first. You will find the instructions by using your favorite
search engine. For example, if you\u2019re on Ubuntu you may want to search for: `),ei=n("a"),f8=r("ubuntu cuda 10.2 install"),g8=r("."),rb=l(),Uo=n("h4"),Xr=n("a"),Gf=n("span"),h(ti.$$.fragment),_8=l(),Mf=n("span"),v8=r("Possible problem #2"),ab=l(),fd=n("p"),b8=r(`Another possible common problem is that you may have more than one CUDA toolkit installed system-wide. For example you
may have:`),nb=l(),h(oi.$$.fragment),sb=l(),zt=n("p"),y8=r("Now, in this situation you need to make sure that your "),jf=n("code"),w8=r("PATH"),T8=r(" and "),Hf=n("code"),E8=r("LD_LIBRARY_PATH"),$8=r(` environment variables contain
the correct paths to the desired CUDA version. Typically, package installers will set these to contain whatever the
last version was installed. If you encounter the problem, where the package build fails because it can\u2019t find the right
CUDA version despite you having it installed system-wide, it means that you need to adjust the 2 aforementioned
environment variables.`),ib=l(),gd=n("p"),x8=r("First, you may look at their contents:"),lb=l(),h(ri.$$.fragment),db=l(),_d=n("p"),k8=r("so you get an idea of what is inside."),cb=l(),Qr=n("p"),A8=r("It\u2019s possible that "),Bf=n("code"),P8=r("LD_LIBRARY_PATH"),D8=r(" is empty."),pb=l(),rt=n("p"),Vf=n("code"),S8=r("PATH"),q8=r(" lists the locations of where executables can be found and "),Yf=n("code"),O8=r("LD_LIBRARY_PATH"),C8=r(` is for where shared libraries
are to looked for. In both cases, earlier entries have priority over the later ones. `),Zf=n("code"),I8=r(":"),U8=r(` is used to separate multiple
entries.`),mb=l(),vd=n("p"),N8=r(`Now, to tell the build program where to find the specific CUDA toolkit, insert the desired paths to be listed first by
doing:`),hb=l(),h(ai.$$.fragment),ub=l(),bd=n("p"),z8=r("Note that we aren\u2019t overwriting the existing values, but prepending instead."),fb=l(),Le=n("p"),F8=r(`Of course, adjust the version number, the full path if need be. Check that the directories you assign actually do
exist. `),Kf=n("code"),L8=r("lib64"),R8=r(" sub-directory is where the various CUDA "),Jf=n("code"),W8=r(".so"),G8=r(" objects, like "),Xf=n("code"),M8=r("libcudart.so"),j8=r(` reside, it\u2019s unlikely
that your system will have it named differently, but if it is adjust it to reflect your reality.`),gb=l(),No=n("h4"),ea=n("a"),Qf=n("span"),h(ni.$$.fragment),H8=l(),eg=n("span"),B8=r("Possible problem #3"),_b=l(),Ft=n("p"),V8=r("Some older CUDA versions may refuse to build with newer compilers. For example, you my have "),tg=n("code"),Y8=r("gcc-9"),Z8=r(` but it wants
`),og=n("code"),K8=r("gcc-7"),J8=r("."),vb=l(),yd=n("p"),X8=r("There are various ways to go about it."),bb=l(),wd=n("p"),Q8=r("If you can install the latest CUDA toolkit it typically should support the newer compiler."),yb=l(),ta=n("p"),eP=r(`Alternatively, you could install the lower version of the compiler in addition to the one you already have, or you may
already have it but it\u2019s not the default one, so the build system can\u2019t see it. If you have `),rg=n("code"),tP=r("gcc-7"),oP=r(` installed but the
build system complains it can\u2019t find it, the following might do the trick:`),wb=l(),h(si.$$.fragment),Tb=l(),M=n("p"),rP=r("Here, we are making a symlink to "),ag=n("code"),aP=r("gcc-7"),nP=r(" from "),ng=n("code"),sP=r("/usr/local/cuda-10.2/bin/gcc"),iP=r(` and since
`),sg=n("code"),lP=r("/usr/local/cuda-10.2/bin/"),dP=r(" should be in the "),ig=n("code"),cP=r("PATH"),pP=r(` environment variable (see the previous problem\u2019s solution), it
should find `),lg=n("code"),mP=r("gcc-7"),hP=r(" (and "),dg=n("code"),uP=r("g++7"),fP=r(") and then the build will succeed."),Eb=l(),Td=n("p"),gP=r("As always make sure to edit the paths in the example to match your situation."),$b=l(),zo=n("h3"),oa=n("a"),cg=n("span"),h(ii.$$.fragment),_P=l(),pg=n("span"),vP=r("FairScale"),xb=l(),h(ra.$$.fragment),kb=l(),Re=n("p"),bP=r("By integrating "),li=n("a"),yP=r("FairScale"),wP=r(" the "),Ed=n("a"),TP=r("Trainer"),EP=r(`
provides support for the following features from `),di=n("a"),$P=r("the ZeRO paper"),xP=r(":"),Ab=l(),We=n("ol"),mg=n("li"),kP=r("Optimizer State Sharding"),AP=l(),hg=n("li"),PP=r("Gradient Sharding"),DP=l(),ug=n("li"),SP=r("Model Parameters Sharding (new and very experimental)"),qP=l(),fg=n("li"),OP=r("CPU offload (new and very experimental)"),Pb=l(),$d=n("p"),CP=r("You will need at least two GPUs to use this feature."),Db=l(),ci=n("p"),gg=n("strong"),IP=r("Installation"),UP=r(":"),Sb=l(),xd=n("p"),NP=r("Install the library via pypi:"),qb=l(),h(pi.$$.fragment),Ob=l(),Lt=n("p"),zP=r("or via "),_g=n("code"),FP=r("transformers"),LP=r("\u2019 "),vg=n("code"),RP=r("extras"),WP=r(":"),Cb=l(),h(mi.$$.fragment),Ib=l(),Rt=n("p"),GP=r("(available starting from "),bg=n("code"),MP=r("transformers==4.6.0"),jP=r(") or find more details on "),hi=n("a"),HP=r("the FairScale\u2019s GitHub page"),BP=r("."),Ub=l(),aa=n("p"),VP=r("If you\u2019re still struggling with the build, first make sure to read "),kd=n("a"),YP=r("CUDA Extension Installation Notes"),ZP=r("."),Nb=l(),Ad=n("p"),KP=r("If it\u2019s still not resolved the build issue, here are a few more ideas."),zb=l(),ui=n("p"),yg=n("code"),JP=r("fairscale"),XP=r(` seems to have an issue with the recently introduced by pip build isolation feature. If you have a problem
with it, you may want to try one of:`),Fb=l(),h(fi.$$.fragment),Lb=l(),Pd=n("p"),QP=r("or:"),Rb=l(),h(gi.$$.fragment),Wb=l(),_i=n("p"),wg=n("code"),eD=r("fairscale"),tD=r(" also has issues with building against pytorch-nightly, so if you use it you may have to try one of:"),Gb=l(),h(vi.$$.fragment),Mb=l(),Dd=n("p"),oD=r("or:"),jb=l(),h(bi.$$.fragment),Hb=l(),Sd=n("p"),rD=r("Of course, adjust the urls to match the cuda version you use."),Bb=l(),na=n("p"),aD=r(`If after trying everything suggested you still encounter build issues, please, proceed with the GitHub Issue of
`),yi=n("a"),nD=r("FairScale"),sD=r("."),Vb=l(),wi=n("p"),Tg=n("strong"),iD=r("Usage"),lD=r(":"),Yb=l(),Wt=n("p"),dD=r("To use the first version of Sharded data-parallelism, add "),Eg=n("code"),cD=r("--sharded_ddp simple"),pD=r(` to the command line arguments, and
make sure you have added the distributed launcher `),$g=n("code"),mD=r("-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),hD=r(" if you haven\u2019t been using it already."),Zb=l(),sa=n("p"),uD=r("For example here is how you could use it for "),xg=n("code"),fD=r("run_translation.py"),gD=r(" with 2 GPUs:"),Kb=l(),h(Ti.$$.fragment),Jb=l(),qd=n("p"),_D=r("Notes:"),Xb=l(),Ge=n("ul"),kg=n("li"),vD=r("This feature requires distributed training (so multiple GPUs)."),bD=l(),Ag=n("li"),yD=r("It is not implemented for TPUs."),wD=l(),Ei=n("li"),TD=r("It works with "),Pg=n("code"),ED=r("--fp16"),$D=r(" too, to make things even faster."),xD=l(),$i=n("li"),kD=r("One of the main benefits of enabling "),Dg=n("code"),AD=r("--sharded_ddp simple"),PD=r(` is that it uses a lot less GPU memory, so you should be
able to use significantly larger batch sizes using the same hardware (e.g. 3x and even bigger) which should lead to
significantly shorter training time.`),Qb=l(),xi=n("ol"),at=n("li"),DD=r("To use the second version of Sharded data-parallelism, add "),Sg=n("code"),SD=r("--sharded_ddp zero_dp_2"),qD=r(" or "),qg=n("code"),OD=r("--sharded_ddp zero_dp_3"),CD=r(" to the command line arguments, and make sure you have added the distributed launcher "),Og=n("code"),ID=r("-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),UD=r(" if you haven\u2019t been using it already."),ey=l(),ia=n("p"),ND=r("For example here is how you could use it for "),Cg=n("code"),zD=r("run_translation.py"),FD=r(" with 2 GPUs:"),ty=l(),h(ki.$$.fragment),oy=l(),Fo=n("p"),Ig=n("code"),LD=r("zero_dp_2"),RD=r(" is an optimized version of the simple wrapper, while "),Ug=n("code"),WD=r("zero_dp_3"),GD=r(` fully shards model weights,
gradients and optimizer states.`),ry=l(),Gt=n("p"),MD=r("Both are compatible with adding "),Ng=n("code"),jD=r("cpu_offload"),HD=r(" to enable ZeRO-offload (activate it like this: "),zg=n("code"),BD=r('--sharded_ddp "zero_dp_2 cpu_offload"'),VD=r(")."),ay=l(),Od=n("p"),YD=r("Notes:"),ny=l(),he=n("ul"),Fg=n("li"),ZD=r("This feature requires distributed training (so multiple GPUs)."),KD=l(),Lg=n("li"),JD=r("It is not implemented for TPUs."),XD=l(),Ai=n("li"),QD=r("It works with "),Rg=n("code"),eS=r("--fp16"),tS=r(" too, to make things even faster."),oS=l(),Lo=n("li"),rS=r("The "),Wg=n("code"),aS=r("cpu_offload"),nS=r(" additional option requires "),Gg=n("code"),sS=r("--fp16"),iS=r("."),lS=l(),Mg=n("li"),dS=r(`This is an area of active development, so make sure you have a source install of fairscale to use this feature as
some bugs you encounter may have been fixed there already.`),sy=l(),Cd=n("p"),cS=r("Known caveats:"),iy=l(),la=n("ul"),Ro=n("li"),pS=r("This feature is incompatible with "),jg=n("code"),mS=r("--predict_with_generate"),hS=r(" in the "),Hg=n("em"),uS=r("run_translation.py"),fS=r(" script."),gS=l(),$e=n("li"),_S=r("Using "),Bg=n("code"),vS=r("--sharded_ddp zero_dp_3"),bS=r(` requires wrapping each layer of the model in the special container
`),Vg=n("code"),yS=r("FullyShardedDataParallelism"),wS=r(" of fairscale. It should be used with the option "),Yg=n("code"),TS=r("auto_wrap"),ES=r(` if you are not
doing this yourself: `),Zg=n("code"),$S=r('--sharded_ddp "zero_dp_3 auto_wrap"'),xS=r("."),ly=l(),Wo=n("h3"),da=n("a"),Kg=n("span"),h(Pi.$$.fragment),kS=l(),Jg=n("span"),AS=r("PyTorch Fully Sharded Data parallel"),dy=l(),ca=n("p"),PS=r(`To accelerate training huge models on larger batch sizes, we can use a fully sharded data parallel model.
This type of data parallel paradigm enables fitting more data and larger models by sharding the optimizer states, gradients and parameters.
To read more about it and the benefits, check out the `),Di=n("a"),DS=r("Fully Sharded Data Parallel blog"),SS=r(`.
We have integrated the latest PyTorch\u2019s Fully Sharded Data Parallel (FSDP) training feature.
All you need to do is enable it through the config.`),cy=l(),Si=n("p"),Xg=n("strong"),qS=r("Required PyTorch version for FSDP support"),OS=r(`: PyTorch Nightly (or 1.12.0 if you read this after it has been released)
as the model saving with FSDP activated is only available with recent fixes.`),py=l(),qi=n("p"),Qg=n("strong"),CS=r("Usage"),IS=r(":"),my=l(),te=n("ul"),e_=n("li"),Oi=n("p"),US=r(`Make sure you have added the distributed launcher
`),t_=n("code"),NS=r("-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),zS=r(" if you haven\u2019t been using it already."),FS=l(),Ci=n("li"),Id=n("p"),o_=n("strong"),LS=r("Sharding Strategy"),RS=r(":"),WS=l(),Go=n("ul"),Ii=n("li"),GS=r(`FULL_SHARD : Shards optimizer states + gradients + model parameters across data parallel workers/GPUs.
For this, add `),r_=n("code"),MS=r("--fsdp full_shard"),jS=r(" to the command line arguments."),HS=l(),Ui=n("li"),BS=r(`SHARD_GRAD_OP : Shards optimizer states + gradients across data parallel workers/GPUs.
For this, add `),a_=n("code"),VS=r("--fsdp shard_grad_op"),YS=r(" to the command line arguments."),ZS=l(),Ni=n("li"),KS=r("NO_SHARD : No sharding. For this, add "),n_=n("code"),JS=r("--fsdp no_shard"),XS=r(" to the command line arguments."),QS=l(),s_=n("li"),Mo=n("p"),eq=r(`To offload the parameters and gradients to the CPU,
add `),i_=n("code"),tq=r('--fsdp "full_shard offload"'),oq=r(" or "),l_=n("code"),rq=r('--fsdp "shard_grad_op offload"'),aq=r(" to the command line arguments."),nq=l(),d_=n("li"),nt=n("p"),sq=r("To automatically recursively wrap layers with FSDP using "),c_=n("code"),iq=r("default_auto_wrap_policy"),lq=r(`,
add `),p_=n("code"),dq=r('--fsdp "full_shard auto_wrap"'),cq=r(" or "),m_=n("code"),pq=r('--fsdp "shard_grad_op auto_wrap"'),mq=r(" to the command line arguments."),hq=l(),h_=n("li"),jo=n("p"),uq=r(`To enable both CPU offloading and auto wrapping,
add `),u_=n("code"),fq=r('--fsdp "full_shard offload auto_wrap"'),gq=r(" or "),f_=n("code"),_q=r('--fsdp "shard_grad_op offload auto_wrap"'),vq=r(" to the command line arguments."),bq=l(),zi=n("li"),g_=n("p"),yq=r("If auto wrapping is enabled, you can either use transformer based auto wrap policy or size based auto wrap policy."),wq=l(),Fi=n("ul"),xe=n("li"),Tq=r("For transformer based auto wrap policy, please add "),__=n("code"),Eq=r("--fsdp_transformer_layer_cls_to_wrap <value>"),$q=r(` to command line arguments.
This specifies the transformer layer class name (case-sensitive) to wrap ,e.g, `),v_=n("code"),xq=r("BertLayer"),kq=r(", "),b_=n("code"),Aq=r("GPTJBlock"),Pq=r(", "),y_=n("code"),Dq=r("T5Block"),Sq=r(` \u2026
This is important because submodules that share weights (e.g., embedding layer) should not end up in different FSDP wrapped units.
Using this policy, wrapping happens for each block containing Multi-Head Attention followed by couple of MLP layers.
Remaining layers including the shared embeddings are conviniently wrapped in same outermost FSDP unit.
Therefore, use this for transformer based models.`),qq=l(),Li=n("li"),Oq=r("For size based auto wrap policy, please add "),w_=n("code"),Cq=r("--fsdp_min_num_params <number>"),Iq=r(` to command line arguments.
It specifies FSDP\u2019s minimum number of parameters for auto wrapping.`),hy=l(),Ud=n("p"),T_=n("strong"),Uq=r("Few caveats to be aware of"),uy=l(),pa=n("ul"),Ri=n("li"),Nq=r(`Mixed precision is currently not supported with FSDP as we wait for PyTorch to fix support for it.
More details in this `),Wi=n("a"),zq=r("issues"),Fq=r("."),Lq=l(),Ho=n("li"),Rq=r(`FSDP currently doesn\u2019t support multiple parameter groups.
More details mentioned in this `),Gi=n("a"),Wq=r("issue"),Gq=r(`
(`),E_=n("code"),Mq=r("The original model parameters' .grads are not set, meaning that they cannot be optimized separately (which is why we cannot support multiple parameter groups)"),jq=r(")."),fy=l(),Bo=n("h3"),ma=n("a"),$_=n("span"),h(Mi.$$.fragment),Hq=l(),x_=n("span"),Bq=r("Using Trainer for accelerated PyTorch Training on Mac"),gy=l(),Me=n("p"),Vq=r(`With PyTorch v1.12 release, developers and researchers can take advantage of Apple silicon GPUs for significantly faster model training.
This unlocks the ability to perform machine learning workflows like prototyping and fine-tuning locally, right on Mac.
Apple\u2019s Metal Performance Shaders (MPS) as a backend for PyTorch enables this and can be used via the new `),k_=n("code"),Yq=r('"mps"'),Zq=r(` device.
This will map computational graphs and primitives on the MPS Graph framework and tuned kernels provided by MPS.
For more information please refer official documents `),ji=n("a"),Kq=r("Introducing Accelerated PyTorch Training on Mac"),Jq=r(`
and `),Hi=n("a"),Xq=r("MPS BACKEND"),Qq=r("."),_y=l(),h(ha.$$.fragment),vy=l(),Nd=n("p"),A_=n("strong"),eO=r("Benefits of Training and Inference using Apple Silicon Chips"),by=l(),Mt=n("ol"),P_=n("li"),tO=r("Enables users to train larger networks or batch sizes locally"),oO=l(),D_=n("li"),rO=r(`Reduces data retrieval latency and provides the GPU with direct access to the full memory store due to unified memory architecture.
Therefore, improving end-to-end performance.`),aO=l(),S_=n("li"),nO=r("Reduces costs associated with cloud-based development or the need for additional local GPUs."),yy=l(),Vo=n("p"),q_=n("strong"),sO=r("Pre-requisites"),iO=r(`: To install torch with mps support,
please follow this nice medium article `),Bi=n("a"),lO=r("GPU-Acceleration Comes to PyTorch on M1 Macs"),dO=r("."),wy=l(),Yo=n("p"),O_=n("strong"),cO=r("Usage"),pO=r(`:
User has to just pass `),C_=n("code"),mO=r("--use_mps_device"),hO=r(` argument.
For example, you can run the offical Glue text classififcation task (from the root folder) using Apple Silicon GPU with below command:`),Ty=l(),h(Vi.$$.fragment),Ey=l(),zd=n("p"),I_=n("strong"),uO=r("A few caveats to be aware of"),$y=l(),ua=n("ol"),Yi=n("li"),fO=r(`Some PyTorch operations have not been implemented in mps and will throw an error.
One way to get around that is to set the environment variable `),U_=n("code"),gO=r("PYTORCH_ENABLE_MPS_FALLBACK=1"),_O=r(`,
which will fallback to CPU for these operations. It still throws a UserWarning however.`),vO=l(),ke=n("li"),bO=r("Distributed setups "),N_=n("code"),yO=r("gloo"),wO=r(" and "),z_=n("code"),TO=r("nccl"),EO=r(" are not working with "),F_=n("code"),$O=r("mps"),xO=r(` device.
This means that currently only single GPU of `),L_=n("code"),kO=r("mps"),AO=r(" device type can be used."),xy=l(),jt=n("p"),PO=r("Finally, please, remember that, \u{1F917} "),R_=n("code"),DO=r("Trainer"),SO=r(` only integrates MPS backend, therefore if you
have any problems or questions with regards to MPS backend usage, please,
file an issue with `),Zi=n("a"),qO=r("PyTorch GitHub"),OO=r("."),ky=l(),Fd=n("p"),CO=r("Sections that were moved:"),Ay=l(),w=n("p"),IO=r("[ "),Ld=n("a"),UO=r("DeepSpeed"),W_=n("a"),NO=r(`
| `),Rd=n("a"),zO=r("Installation"),G_=n("a"),FO=r(`
| `),Wd=n("a"),LO=r("Deployment with multiple GPUs"),M_=n("a"),RO=r(`
| `),Gd=n("a"),WO=r("Deployment with one GPU"),j_=n("a"),GO=r(`
| `),Md=n("a"),MO=r("Deployment in Notebooks"),H_=n("a"),jO=r(`
| `),jd=n("a"),HO=r("Configuration"),B_=n("a"),BO=r(`
| `),Hd=n("a"),VO=r("Passing Configuration"),V_=n("a"),YO=r(`
| `),Bd=n("a"),ZO=r("Shared Configuration"),Y_=n("a"),KO=r(`
| `),Vd=n("a"),JO=r("ZeRO"),Z_=n("a"),XO=r(`
| `),Yd=n("a"),QO=r("ZeRO-2 Config"),K_=n("a"),eC=r(`
| `),Zd=n("a"),tC=r("ZeRO-3 Config"),J_=n("a"),oC=r(`
| `),Kd=n("a"),rC=r("NVMe Support"),X_=n("a"),aC=r(`
| `),Jd=n("a"),nC=r("ZeRO-2 vs ZeRO-3 Performance"),Q_=n("a"),sC=r(`
| `),Xd=n("a"),iC=r("ZeRO-2 Example"),ev=n("a"),lC=r(`
| `),Qd=n("a"),dC=r("ZeRO-3 Example"),tv=n("a"),cC=r(`
| `),ec=n("a"),pC=r("Optimizer"),ov=n("a"),mC=r(`
| `),tc=n("a"),hC=r("Scheduler"),rv=n("a"),uC=r(`
| `),oc=n("a"),fC=r("fp32 Precision"),av=n("a"),gC=r(`
| `),rc=n("a"),_C=r("Automatic Mixed Precision"),nv=n("a"),vC=r(`
| `),ac=n("a"),bC=r("Batch Size"),sv=n("a"),yC=r(`
| `),nc=n("a"),wC=r("Gradient Accumulation"),iv=n("a"),TC=r(`
| `),sc=n("a"),EC=r("Gradient Clipping"),lv=n("a"),$C=r(`
| `),ic=n("a"),xC=r("Getting The Model Weights Out"),dv=n("a"),kC=r(`
]`),this.h()},l(t){const c=rM('[data-svelte="svelte-1phssyn"]',document.head);T=s(c,"META",{name:!0,content:!0}),c.forEach(o),D=d(t),$=s(t,"H1",{class:!0});var Ki=i($);k=s(Ki,"A",{id:!0,class:!0,href:!0});var cv=i(k);L=s(cv,"SPAN",{});var pv=i(L);u(A.$$.fragment,pv),pv.forEach(o),cv.forEach(o),S=d(Ki),W=s(Ki,"SPAN",{});var mv=i(W);fe=a(mv,"Trainer"),mv.forEach(o),Ki.forEach(o),oe=d(t),G=s(t,"P",{});var Zo=i(G);se=a(Zo,"The "),ie=s(Zo,"A",{href:!0});var hv=i(ie);re=a(hv,"Trainer"),hv.forEach(o),le=a(Zo," class provides an API for feature-complete training in PyTorch for most standard use cases. It\u2019s used in most of the "),H=s(Zo,"A",{href:!0,rel:!0});var uv=i(H);Ze=a(uv,"example scripts"),uv.forEach(o),ge=a(Zo,"."),Zo.forEach(o),z=d(t),I=s(t,"P",{});var lc=i(I);st=a(lc,"Before instantiating your "),ae=s(lc,"A",{href:!0});var XC=i(ae);it=a(XC,"Trainer"),XC.forEach(o),lt=a(lc,", create a "),_e=s(lc,"A",{href:!0});var QC=i(_e);Ia=a(QC,"TrainingArguments"),QC.forEach(o),Ua=a(lc," to access all the points of customization during training."),lc.forEach(o),Ke=d(t),Pe=s(t,"P",{});var Dy=i(Pe);Na=a(Dy,"The API supports distributed training on multiple GPUs/TPUs, mixed precision through "),ve=s(Dy,"A",{href:!0,rel:!0});var eI=i(ve);za=a(eI,"NVIDIA Apex"),eI.forEach(o),Fa=a(Dy," and Native AMP for PyTorch."),Dy.forEach(o),K=d(t),B=s(t,"P",{});var Sy=i(B);el=a(Sy,"The "),be=s(Sy,"A",{href:!0});var tI=i(be);Xo=a(tI,"Trainer"),tI.forEach(o),tl=a(Sy," contains the basic training loop which supports the above features. To inject custom behavior you can subclass them and override the following methods:"),Sy.forEach(o),ro=d(t),C=s(t,"UL",{});var N=i(C);V=s(N,"LI",{});var AC=i(V);Qo=s(AC,"STRONG",{});var oI=i(Qo);ol=a(oI,"get_train_dataloader"),oI.forEach(o),rl=a(AC," \u2014 Creates the training DataLoader."),AC.forEach(o),al=d(N),nl=s(N,"LI",{});var PC=i(nl);_p=s(PC,"STRONG",{});var rI=i(_p);A0=a(rI,"get_eval_dataloader"),rI.forEach(o),P0=a(PC," \u2014 Creates the evaluation DataLoader."),PC.forEach(o),D0=d(N),sl=s(N,"LI",{});var DC=i(sl);vp=s(DC,"STRONG",{});var aI=i(vp);S0=a(aI,"get_test_dataloader"),aI.forEach(o),q0=a(DC," \u2014 Creates the test DataLoader."),DC.forEach(o),O0=d(N),il=s(N,"LI",{});var SC=i(il);bp=s(SC,"STRONG",{});var nI=i(bp);C0=a(nI,"log"),nI.forEach(o),I0=a(SC," \u2014 Logs information on the various objects watching training."),SC.forEach(o),U0=d(N),dt=s(N,"LI",{});var Ji=i(dt);yp=s(Ji,"STRONG",{});var sI=i(yp);N0=a(sI,"create_optimizer_and_scheduler"),sI.forEach(o),z0=a(Ji,` \u2014 Sets up the optimizer and learning rate scheduler if they were not passed at
init. Note, that you can also subclass or override the `),wp=s(Ji,"CODE",{});var iI=i(wp);F0=a(iI,"create_optimizer"),iI.forEach(o),L0=a(Ji," and "),Tp=s(Ji,"CODE",{});var lI=i(Tp);R0=a(lI,"create_scheduler"),lI.forEach(o),W0=a(Ji,` methods
separately.`),Ji.forEach(o),G0=d(N),ll=s(N,"LI",{});var qC=i(ll);Ep=s(qC,"STRONG",{});var dI=i(Ep);M0=a(dI,"create_optimizer"),dI.forEach(o),j0=a(qC," \u2014 Sets up the optimizer if it wasn\u2019t passed at init."),qC.forEach(o),H0=d(N),dl=s(N,"LI",{});var OC=i(dl);$p=s(OC,"STRONG",{});var cI=i($p);B0=a(cI,"create_scheduler"),cI.forEach(o),V0=a(OC," \u2014 Sets up the learning rate scheduler if it wasn\u2019t passed at init."),OC.forEach(o),Y0=d(N),cl=s(N,"LI",{});var CC=i(cl);xp=s(CC,"STRONG",{});var pI=i(xp);Z0=a(pI,"compute_loss"),pI.forEach(o),K0=a(CC," - Computes the loss on a batch of training inputs."),CC.forEach(o),J0=d(N),pl=s(N,"LI",{});var IC=i(pl);kp=s(IC,"STRONG",{});var mI=i(kp);X0=a(mI,"training_step"),mI.forEach(o),Q0=a(IC," \u2014 Performs a training step."),IC.forEach(o),ew=d(N),ml=s(N,"LI",{});var UC=i(ml);Ap=s(UC,"STRONG",{});var hI=i(Ap);tw=a(hI,"prediction_step"),hI.forEach(o),ow=a(UC," \u2014 Performs an evaluation/test step."),UC.forEach(o),rw=d(N),hl=s(N,"LI",{});var NC=i(hl);Pp=s(NC,"STRONG",{});var uI=i(Pp);aw=a(uI,"evaluate"),uI.forEach(o),nw=a(NC," \u2014 Runs an evaluation loop and returns metrics."),NC.forEach(o),sw=d(N),ul=s(N,"LI",{});var zC=i(ul);Dp=s(zC,"STRONG",{});var fI=i(Dp);iw=a(fI,"predict"),fI.forEach(o),lw=a(zC," \u2014 Returns predictions (with metrics if labels are available) on a test set."),zC.forEach(o),N.forEach(o),yv=d(t),u(er.$$.fragment,t),wv=d(t),tr=s(t,"P",{});var qy=i(tr);dw=a(qy,"Here is an example of how to customize "),fl=s(qy,"A",{href:!0});var gI=i(fl);cw=a(gI,"Trainer"),gI.forEach(o),pw=a(qy," to use a weighted loss (useful when you have an unbalanced training set):"),qy.forEach(o),Tv=d(t),u(La.$$.fragment,t),Ev=d(t),ct=s(t,"P",{});var dc=i(ct);mw=a(dc,"Another way to customize the training loop behavior for the PyTorch "),gl=s(dc,"A",{href:!0});var _I=i(gl);hw=a(_I,"Trainer"),_I.forEach(o),uw=a(dc," is to use "),_l=s(dc,"A",{href:!0});var vI=i(_l);fw=a(vI,"callbacks"),vI.forEach(o),gw=a(dc," that can inspect the training loop state (for progress reporting, logging on TensorBoard or other ML platforms\u2026) and take decisions (like early stopping)."),dc.forEach(o),$v=d(t),ao=s(t,"H2",{class:!0});var Oy=i(ao);or=s(Oy,"A",{id:!0,class:!0,href:!0});var bI=i(or);Sp=s(bI,"SPAN",{});var yI=i(Sp);u(Ra.$$.fragment,yI),yI.forEach(o),bI.forEach(o),_w=d(Oy),qp=s(Oy,"SPAN",{});var wI=i(qp);vw=a(wI,"Trainer"),wI.forEach(o),Oy.forEach(o),xv=d(t),b=s(t,"DIV",{class:!0});var y=i(b);u(Wa.$$.fragment,y),bw=d(y),Op=s(y,"P",{});var TI=i(Op);yw=a(TI,"Trainer is a simple but feature-complete training and eval loop for PyTorch, optimized for \u{1F917} Transformers."),TI.forEach(o),ww=d(y),Cp=s(y,"P",{});var EI=i(Cp);Tw=a(EI,"Important attributes:"),EI.forEach(o),Ew=d(y),ye=s(y,"UL",{});var Ht=i(ye);rr=s(Ht,"LI",{});var fv=i(rr);Ip=s(fv,"STRONG",{});var $I=i(Ip);$w=a($I,"model"),$I.forEach(o),xw=a(fv," \u2014 Always points to the core model. If using a transformers model, it will be a "),vl=s(fv,"A",{href:!0});var xI=i(vl);kw=a(xI,"PreTrainedModel"),xI.forEach(o),Aw=a(fv,`
subclass.`),fv.forEach(o),Pw=d(Ht),J=s(Ht,"LI",{});var Ae=i(J);Up=s(Ae,"STRONG",{});var kI=i(Up);Dw=a(kI,"model_wrapped"),kI.forEach(o),Sw=a(Ae,` \u2014 Always points to the most external model in case one or more other modules wrap the
original model. This is the model that should be used for the forward pass. For example, under `),Np=s(Ae,"CODE",{});var AI=i(Np);qw=a(AI,"DeepSpeed"),AI.forEach(o),Ow=a(Ae,`,
the inner model is wrapped in `),zp=s(Ae,"CODE",{});var PI=i(zp);Cw=a(PI,"DeepSpeed"),PI.forEach(o),Iw=a(Ae," and then again in "),Fp=s(Ae,"CODE",{});var DI=i(Fp);Uw=a(DI,"torch.nn.DistributedDataParallel"),DI.forEach(o),Nw=a(Ae,`. If the inner
model hasn\u2019t been wrapped, then `),Lp=s(Ae,"CODE",{});var SI=i(Lp);zw=a(SI,"self.model_wrapped"),SI.forEach(o),Fw=a(Ae," is the same as "),Rp=s(Ae,"CODE",{});var qI=i(Rp);Lw=a(qI,"self.model"),qI.forEach(o),Rw=a(Ae,"."),Ae.forEach(o),Ww=d(Ht),bl=s(Ht,"LI",{});var FC=i(bl);Wp=s(FC,"STRONG",{});var OI=i(Wp);Gw=a(OI,"is_model_parallel"),OI.forEach(o),Mw=a(FC,` \u2014 Whether or not a model has been switched to a model parallel mode (different from
data parallelism, this means some of the model layers are split on different GPUs).`),FC.forEach(o),jw=d(Ht),De=s(Ht,"LI",{});var Ko=i(De);Gp=s(Ko,"STRONG",{});var CI=i(Gp);Hw=a(CI,"place_model_on_device"),CI.forEach(o),Bw=a(Ko,` \u2014 Whether or not to automatically place the model on the device - it will be set
to `),Mp=s(Ko,"CODE",{});var II=i(Mp);Vw=a(II,"False"),II.forEach(o),Yw=a(Ko,` if model parallel or deepspeed is used, or if the default
`),jp=s(Ko,"CODE",{});var UI=i(jp);Zw=a(UI,"TrainingArguments.place_model_on_device"),UI.forEach(o),Kw=a(Ko," is overridden to return "),Hp=s(Ko,"CODE",{});var NI=i(Hp);Jw=a(NI,"False"),NI.forEach(o),Xw=a(Ko," ."),Ko.forEach(o),Qw=d(Ht),Se=s(Ht,"LI",{});var Jo=i(Se);Bp=s(Jo,"STRONG",{});var zI=i(Bp);eT=a(zI,"is_in_train"),zI.forEach(o),tT=a(Jo," \u2014 Whether or not a model is currently running "),Vp=s(Jo,"CODE",{});var FI=i(Vp);oT=a(FI,"train"),FI.forEach(o),rT=a(Jo," (e.g. when "),Yp=s(Jo,"CODE",{});var LI=i(Yp);aT=a(LI,"evaluate"),LI.forEach(o),nT=a(Jo,` is called while
in `),Zp=s(Jo,"CODE",{});var RI=i(Zp);sT=a(RI,"train"),RI.forEach(o),iT=a(Jo,")"),Jo.forEach(o),Ht.forEach(o),lT=d(y),ar=s(y,"DIV",{class:!0});var Cy=i(ar);u(Ga.$$.fragment,Cy),dT=d(Cy),Ma=s(Cy,"P",{});var Iy=i(Ma);cT=a(Iy,"Add a callback to the current list of "),Kp=s(Iy,"CODE",{});var WI=i(Kp);pT=a(WI,"~transformer.TrainerCallback"),WI.forEach(o),mT=a(Iy,"."),Iy.forEach(o),Cy.forEach(o),hT=d(y),nr=s(y,"DIV",{class:!0});var Uy=i(nr);u(ja.$$.fragment,Uy),uT=d(Uy),Ha=s(Uy,"P",{});var Ny=i(Ha);fT=a(Ny,"A helper wrapper that creates an appropriate context manager for "),Jp=s(Ny,"CODE",{});var GI=i(Jp);gT=a(GI,"autocast"),GI.forEach(o),_T=a(Ny,` while feeding it the desired
arguments, depending on the situation.`),Ny.forEach(o),Uy.forEach(o),vT=d(y),pt=s(y,"DIV",{class:!0});var cc=i(pt);u(Ba.$$.fragment,cc),bT=d(cc),Xp=s(cc,"P",{});var MI=i(Xp);yT=a(MI,"How the loss is computed by Trainer. By default, all models return the loss in the first element."),MI.forEach(o),wT=d(cc),Qp=s(cc,"P",{});var jI=i(Qp);TT=a(jI,"Subclass and override for custom behavior."),jI.forEach(o),cc.forEach(o),ET=d(y),sr=s(y,"DIV",{class:!0});var zy=i(sr);u(Va.$$.fragment,zy),$T=d(zy),em=s(zy,"P",{});var HI=i(em);xT=a(HI,"A helper wrapper to group together context managers."),HI.forEach(o),zy.forEach(o),kT=d(y),ir=s(y,"DIV",{class:!0});var Fy=i(ir);u(Ya.$$.fragment,Fy),AT=d(Fy),Za=s(Fy,"P",{});var Ly=i(Za);PT=a(Ly,"Creates a draft of a model card using the information available to the "),tm=s(Ly,"CODE",{});var BI=i(tm);DT=a(BI,"Trainer"),BI.forEach(o),ST=a(Ly,"."),Ly.forEach(o),Fy.forEach(o),qT=d(y),mt=s(y,"DIV",{class:!0});var pc=i(mt);u(Ka.$$.fragment,pc),OT=d(pc),om=s(pc,"P",{});var VI=i(om);CT=a(VI,"Setup the optimizer."),VI.forEach(o),IT=d(pc),Ja=s(pc,"P",{});var Ry=i(Ja);UT=a(Ry,`We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
Trainer\u2019s init through `),rm=s(Ry,"CODE",{});var YI=i(rm);NT=a(YI,"optimizers"),YI.forEach(o),zT=a(Ry,", or subclass and override this method in a subclass."),Ry.forEach(o),pc.forEach(o),FT=d(y),ht=s(y,"DIV",{class:!0});var mc=i(ht);u(Xa.$$.fragment,mc),LT=d(mc),am=s(mc,"P",{});var ZI=i(am);RT=a(ZI,"Setup the optimizer and the learning rate scheduler."),ZI.forEach(o),WT=d(mc),Je=s(mc,"P",{});var fa=i(Je);GT=a(fa,`We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
Trainer\u2019s init through `),nm=s(fa,"CODE",{});var KI=i(nm);MT=a(KI,"optimizers"),KI.forEach(o),jT=a(fa,", or subclass and override this method (or "),sm=s(fa,"CODE",{});var JI=i(sm);HT=a(JI,"create_optimizer"),JI.forEach(o),BT=a(fa,` and/or
`),im=s(fa,"CODE",{});var XI=i(im);VT=a(XI,"create_scheduler"),XI.forEach(o),YT=a(fa,") in a subclass."),fa.forEach(o),mc.forEach(o),ZT=d(y),lr=s(y,"DIV",{class:!0});var Wy=i(lr);u(Qa.$$.fragment,Wy),KT=d(Wy),lm=s(Wy,"P",{});var QI=i(lm);JT=a(QI,`Setup the scheduler. The optimizer of the trainer must have been set up either before this method is called or
passed as an argument.`),QI.forEach(o),Wy.forEach(o),XT=d(y),qe=s(y,"DIV",{class:!0});var ga=i(qe);u(en.$$.fragment,ga),QT=d(ga),dm=s(ga,"P",{});var eU=i(dm);eE=a(eU,"Run evaluation and returns metrics."),eU.forEach(o),tE=d(ga),tn=s(ga,"P",{});var Gy=i(tn);oE=a(Gy,`The calling script will be responsible for providing a method to compute metrics, as they are task-dependent
(pass it to the init `),cm=s(Gy,"CODE",{});var tU=i(cm);rE=a(tU,"compute_metrics"),tU.forEach(o),aE=a(Gy," argument)."),Gy.forEach(o),nE=d(ga),pm=s(ga,"P",{});var oU=i(pm);sE=a(oU,"You can also subclass and override this method to inject custom behavior."),oU.forEach(o),ga.forEach(o),iE=d(y),ut=s(y,"DIV",{class:!0});var hc=i(ut);u(on.$$.fragment,hc),lE=d(hc),no=s(hc,"P",{});var uc=i(no);dE=a(uc,"Prediction/evaluation loop, shared by "),mm=s(uc,"CODE",{});var rU=i(mm);cE=a(rU,"Trainer.evaluate()"),rU.forEach(o),pE=a(uc," and "),hm=s(uc,"CODE",{});var aU=i(hm);mE=a(aU,"Trainer.predict()"),aU.forEach(o),hE=a(uc,"."),uc.forEach(o),uE=d(hc),um=s(hc,"P",{});var nU=i(um);fE=a(nU,"Works both with or without labels."),nU.forEach(o),hc.forEach(o),gE=d(y),dr=s(y,"DIV",{class:!0});var My=i(dr);u(rn.$$.fragment,My),_E=d(My),an=s(My,"P",{});var jy=i(an);vE=a(jy,"For models that inherit from "),yl=s(jy,"A",{href:!0});var sU=i(yl);bE=a(sU,"PreTrainedModel"),sU.forEach(o),yE=a(jy,`, uses that method to compute the number of floating point
operations for every backward + forward pass. If using another model, either implement such a method in the
model or subclass and override this method.`),jy.forEach(o),My.forEach(o),wE=d(y),ft=s(y,"DIV",{class:!0});var fc=i(ft);u(nn.$$.fragment,fc),TE=d(fc),sn=s(fc,"P",{});var Hy=i(sn);EE=a(Hy,"Returns the evaluation "),fm=s(Hy,"CODE",{});var iU=i(fm);$E=a(iU,"~torch.utils.data.DataLoader"),iU.forEach(o),xE=a(Hy,"."),Hy.forEach(o),kE=d(fc),gm=s(fc,"P",{});var lU=i(gm);AE=a(lU,"Subclass and override this method if you want to inject some custom behavior."),lU.forEach(o),fc.forEach(o),PE=d(y),cr=s(y,"DIV",{class:!0});var By=i(cr);u(ln.$$.fragment,By),DE=d(By),_m=s(By,"P",{});var dU=i(_m);SE=a(dU,"Returns the optimizer class and optimizer parameters based on the training arguments."),dU.forEach(o),By.forEach(o),qE=d(y),gt=s(y,"DIV",{class:!0});var gc=i(gt);u(dn.$$.fragment,gc),OE=d(gc),cn=s(gc,"P",{});var Vy=i(cn);CE=a(Vy,"Returns the test "),vm=s(Vy,"CODE",{});var cU=i(vm);IE=a(cU,"~torch.utils.data.DataLoader"),cU.forEach(o),UE=a(Vy,"."),Vy.forEach(o),NE=d(gc),bm=s(gc,"P",{});var pU=i(bm);zE=a(pU,"Subclass and override this method if you want to inject some custom behavior."),pU.forEach(o),gc.forEach(o),FE=d(y),Oe=s(y,"DIV",{class:!0});var _a=i(Oe);u(pn.$$.fragment,_a),LE=d(_a),mn=s(_a,"P",{});var Yy=i(mn);RE=a(Yy,"Returns the training "),ym=s(Yy,"CODE",{});var mU=i(ym);WE=a(mU,"~torch.utils.data.DataLoader"),mU.forEach(o),GE=a(Yy,"."),Yy.forEach(o),ME=d(_a),so=s(_a,"P",{});var _c=i(so);jE=a(_c,"Will use no sampler if "),wm=s(_c,"CODE",{});var hU=i(wm);HE=a(hU,"train_dataset"),hU.forEach(o),BE=a(_c," does not implement "),Tm=s(_c,"CODE",{});var uU=i(Tm);VE=a(uU,"__len__"),uU.forEach(o),YE=a(_c,`, a random sampler (adapted to distributed
training if necessary) otherwise.`),_c.forEach(o),ZE=d(_a),Em=s(_a,"P",{});var fU=i(Em);KE=a(fU,"Subclass and override this method if you want to inject some custom behavior."),fU.forEach(o),_a.forEach(o),JE=d(y),_t=s(y,"DIV",{class:!0});var vc=i(_t);u(hn.$$.fragment,vc),XE=d(vc),we=s(vc,"P",{});var Bt=i(we);QE=a(Bt,"Launch an hyperparameter search using "),$m=s(Bt,"CODE",{});var gU=i($m);e4=a(gU,"optuna"),gU.forEach(o),t4=a(Bt," or "),xm=s(Bt,"CODE",{});var _U=i(xm);o4=a(_U,"Ray Tune"),_U.forEach(o),r4=a(Bt," or "),km=s(Bt,"CODE",{});var vU=i(km);a4=a(vU,"SigOpt"),vU.forEach(o),n4=a(Bt,`. The optimized quantity is determined
by `),Am=s(Bt,"CODE",{});var bU=i(Am);s4=a(bU,"compute_objective"),bU.forEach(o),i4=a(Bt,`, which defaults to a function returning the evaluation loss when no metric is provided,
the sum of all metrics otherwise.`),Bt.forEach(o),l4=d(vc),u(pr.$$.fragment,vc),vc.forEach(o),d4=d(y),mr=s(y,"DIV",{class:!0});var Zy=i(mr);u(un.$$.fragment,Zy),c4=d(Zy),fn=s(Zy,"P",{});var Ky=i(fn);p4=a(Ky,"Initializes a git repo in "),Pm=s(Ky,"CODE",{});var yU=i(Pm);m4=a(yU,"self.args.hub_model_id"),yU.forEach(o),h4=a(Ky,"."),Ky.forEach(o),Zy.forEach(o),u4=d(y),hr=s(y,"DIV",{class:!0});var Jy=i(hr);u(gn.$$.fragment,Jy),f4=d(Jy),Dm=s(Jy,"P",{});var wU=i(Dm);g4=a(wU,`Whether or not this process is the local (e.g., on one machine if training in a distributed fashion on several
machines) main process.`),wU.forEach(o),Jy.forEach(o),_4=d(y),ur=s(y,"DIV",{class:!0});var Xy=i(ur);u(_n.$$.fragment,Xy),v4=d(Xy),vn=s(Xy,"P",{});var Qy=i(vn);b4=a(Qy,`Whether or not this process is the global main process (when training in a distributed fashion on several
machines, this is only going to be `),Sm=s(Qy,"CODE",{});var TU=i(Sm);y4=a(TU,"True"),TU.forEach(o),w4=a(Qy," for one process)."),Qy.forEach(o),Xy.forEach(o),T4=d(y),vt=s(y,"DIV",{class:!0});var bc=i(vt);u(bn.$$.fragment,bc),E4=d(bc),yn=s(bc,"P",{});var e2=i(yn);$4=a(e2,"Log "),qm=s(e2,"CODE",{});var EU=i(qm);x4=a(EU,"logs"),EU.forEach(o),k4=a(e2," on the various objects watching training."),e2.forEach(o),A4=d(bc),Om=s(bc,"P",{});var $U=i(Om);P4=a($U,"Subclass and override this method to inject custom behavior."),$U.forEach(o),bc.forEach(o),D4=d(y),P=s(y,"DIV",{class:!0});var q=i(P);u(wn.$$.fragment,q),S4=d(q),Cm=s(q,"P",{});var xU=i(Cm);q4=a(xU,"Log metrics in a specially formatted way"),xU.forEach(o),O4=d(q),Im=s(q,"P",{});var kU=i(Im);C4=a(kU,"Under distributed environment this is done only for a process with rank 0."),kU.forEach(o),I4=d(q),Um=s(q,"P",{});var AU=i(Um);U4=a(AU,"Notes on memory reports:"),AU.forEach(o),N4=d(q),io=s(q,"P",{});var yc=i(io);z4=a(yc,"In order to get memory usage report you need to install "),Nm=s(yc,"CODE",{});var PU=i(Nm);F4=a(PU,"psutil"),PU.forEach(o),L4=a(yc,". You can do that with "),zm=s(yc,"CODE",{});var DU=i(zm);R4=a(DU,"pip install psutil"),DU.forEach(o),W4=a(yc,"."),yc.forEach(o),G4=d(q),u(fr.$$.fragment,q),M4=d(q),Fm=s(q,"P",{});var SU=i(Fm);Lm=s(SU,"STRONG",{});var qU=i(Lm);j4=a(qU,"Understanding the reports:"),qU.forEach(o),SU.forEach(o),H4=d(q),Xe=s(q,"UL",{});var va=i(Xe);Te=s(va,"LI",{});var Vt=i(Te);B4=a(Vt,"the first segment, e.g., "),Rm=s(Vt,"CODE",{});var OU=i(Rm);V4=a(OU,"train__"),OU.forEach(o),Y4=a(Vt,", tells you which stage the metrics are for. Reports starting with "),Wm=s(Vt,"CODE",{});var CU=i(Wm);Z4=a(CU,"init_"),CU.forEach(o),K4=a(Vt,`
will be added to the first stage that gets run. So that if only evaluation is run, the memory usage for the
`),Gm=s(Vt,"CODE",{});var IU=i(Gm);J4=a(IU,"__init__"),IU.forEach(o),X4=a(Vt," will be reported along with the "),Mm=s(Vt,"CODE",{});var UU=i(Mm);Q4=a(UU,"eval_"),UU.forEach(o),e9=a(Vt," metrics."),Vt.forEach(o),t9=d(va),lo=s(va,"LI",{});var wc=i(lo);o9=a(wc,"the third segment, is either "),jm=s(wc,"CODE",{});var NU=i(jm);r9=a(NU,"cpu"),NU.forEach(o),a9=a(wc," or "),Hm=s(wc,"CODE",{});var zU=i(Hm);n9=a(zU,"gpu"),zU.forEach(o),s9=a(wc,`, tells you whether it\u2019s the general RAM or the gpu0 memory
metric.`),wc.forEach(o),i9=d(va),wl=s(va,"LI",{});var LC=i(wl);Bm=s(LC,"CODE",{});var FU=i(Bm);l9=a(FU,"*_alloc_delta"),FU.forEach(o),d9=a(LC,` - is the difference in the used/allocated memory counter between the end and the start of the
stage - it can be negative if a function released more memory than it allocated.`),LC.forEach(o),c9=d(va),bt=s(va,"LI",{});var Xi=i(bt);Vm=s(Xi,"CODE",{});var LU=i(Vm);p9=a(LU,"*_peaked_delta"),LU.forEach(o),m9=a(Xi,` - is any extra memory that was consumed and then freed - relative to the current allocated
memory counter - it is never negative. When you look at the metrics of any stage you add up `),Ym=s(Xi,"CODE",{});var RU=i(Ym);h9=a(RU,"alloc_delta"),RU.forEach(o),u9=a(Xi,` +
`),Zm=s(Xi,"CODE",{});var WU=i(Zm);f9=a(WU,"peaked_delta"),WU.forEach(o),g9=a(Xi," and you know how much memory was needed to complete that stage."),Xi.forEach(o),va.forEach(o),_9=d(q),Km=s(q,"P",{});var GU=i(Km);v9=a(GU,`The reporting happens only for process of rank 0 and gpu 0 (if there is a gpu). Typically this is enough since the
main process does the bulk of work, but it could be not quite so if model parallel is used and then other GPUs may
use a different amount of gpu memory. This is also not the same under DataParallel where gpu0 may require much more
memory than the rest since it stores the gradient and optimizer states for all participating GPUS. Perhaps in the
future these reports will evolve to measure those too.`),GU.forEach(o),b9=d(q),Jm=s(q,"P",{});var MU=i(Jm);y9=a(MU,`The CPU RAM metric measures RSS (Resident Set Size) includes both the memory which is unique to the process and the
memory shared with other processes. It is important to note that it does not include swapped out memory, so the
reports could be imprecise.`),MU.forEach(o),w9=d(q),Tn=s(q,"P",{});var t2=i(Tn);T9=a(t2,`The CPU peak memory is measured using a sampling thread. Due to python\u2019s GIL it may miss some of the peak memory if
that thread didn\u2019t get a chance to run when the highest memory was used. Therefore this report can be less than
reality. Using `),Xm=s(t2,"CODE",{});var jU=i(Xm);E9=a(jU,"tracemalloc"),jU.forEach(o),$9=a(t2,` would have reported the exact peak memory, but it doesn\u2019t report memory allocations
outside of python. So if some C++ CUDA extension allocated its own memory it won\u2019t be reported. And therefore it
was dropped in favor of the memory sampling approach, which reads the current process memory usage.`),t2.forEach(o),x9=d(q),Qe=s(q,"P",{});var ba=i(Qe);k9=a(ba,"The GPU allocated and peak memory reporting is done with "),Qm=s(ba,"CODE",{});var HU=i(Qm);A9=a(HU,"torch.cuda.memory_allocated()"),HU.forEach(o),P9=a(ba,` and
`),eh=s(ba,"CODE",{});var BU=i(eh);D9=a(BU,"torch.cuda.max_memory_allocated()"),BU.forEach(o),S9=a(ba,`. This metric reports only \u201Cdeltas\u201D for pytorch-specific allocations, as
`),th=s(ba,"CODE",{});var VU=i(th);q9=a(VU,"torch.cuda"),VU.forEach(o),O9=a(ba,` memory management system doesn\u2019t track any memory allocated outside of pytorch. For example, the very
first cuda call typically loads CUDA kernels, which may take from 0.5 to 2GB of GPU memory.`),ba.forEach(o),C9=d(q),ne=s(q,"P",{});var je=i(ne);I9=a(je,"Note that this tracker doesn\u2019t account for memory allocations outside of "),Tl=s(je,"A",{href:!0});var YU=i(Tl);U9=a(YU,"Trainer"),YU.forEach(o),N9=a(je,"\u2019s "),oh=s(je,"CODE",{});var ZU=i(oh);z9=a(ZU,"__init__"),ZU.forEach(o),F9=a(je,", "),rh=s(je,"CODE",{});var KU=i(rh);L9=a(KU,"train"),KU.forEach(o),R9=a(je,`,
`),ah=s(je,"CODE",{});var JU=i(ah);W9=a(JU,"evaluate"),JU.forEach(o),G9=a(je," and "),nh=s(je,"CODE",{});var XU=i(nh);M9=a(XU,"predict"),XU.forEach(o),j9=a(je," calls."),je.forEach(o),H9=d(q),U=s(q,"P",{});var R=i(U);B9=a(R,"Because "),sh=s(R,"CODE",{});var QU=i(sh);V9=a(QU,"evaluation"),QU.forEach(o),Y9=a(R," calls may happen during "),ih=s(R,"CODE",{});var eN=i(ih);Z9=a(eN,"train"),eN.forEach(o),K9=a(R,`, we can\u2019t handle nested invocations because
`),lh=s(R,"CODE",{});var tN=i(lh);J9=a(tN,"torch.cuda.max_memory_allocated"),tN.forEach(o),X9=a(R," is a single counter, so if it gets reset by a nested eval call, "),dh=s(R,"CODE",{});var oN=i(dh);Q9=a(oN,"train"),oN.forEach(o),e$=a(R,`\u2019s tracker
will report incorrect info. If this `),En=s(R,"A",{href:!0,rel:!0});var rN=i(En);t$=a(rN,"pytorch issue"),rN.forEach(o),o$=a(R,` gets resolved
it will be possible to change this class to be re-entrant. Until then we will only track the outer level of
`),ch=s(R,"CODE",{});var aN=i(ch);r$=a(aN,"train"),aN.forEach(o),a$=a(R,", "),ph=s(R,"CODE",{});var nN=i(ph);n$=a(nN,"evaluate"),nN.forEach(o),s$=a(R," and "),mh=s(R,"CODE",{});var sN=i(mh);i$=a(sN,"predict"),sN.forEach(o),l$=a(R," methods. Which means that if "),hh=s(R,"CODE",{});var iN=i(hh);d$=a(iN,"eval"),iN.forEach(o),c$=a(R," is called during "),uh=s(R,"CODE",{});var lN=i(uh);p$=a(lN,"train"),lN.forEach(o),m$=a(R,`, it\u2019s the latter
that will account for its memory usage and that of the former.`),R.forEach(o),h$=d(q),Ee=s(q,"P",{});var Yt=i(Ee);u$=a(Yt,"This also means that if any other tool that is used along the "),El=s(Yt,"A",{href:!0});var dN=i(El);f$=a(dN,"Trainer"),dN.forEach(o),g$=a(Yt,` calls
`),fh=s(Yt,"CODE",{});var cN=i(fh);_$=a(cN,"torch.cuda.reset_peak_memory_stats"),cN.forEach(o),v$=a(Yt,", the gpu peak memory stats could be invalid. And the "),$l=s(Yt,"A",{href:!0});var pN=i($l);b$=a(pN,"Trainer"),pN.forEach(o),y$=a(Yt,` will disrupt
the normal behavior of any such tools that rely on calling `),gh=s(Yt,"CODE",{});var mN=i(gh);w$=a(mN,"torch.cuda.reset_peak_memory_stats"),mN.forEach(o),T$=a(Yt," themselves."),Yt.forEach(o),E$=d(q),_h=s(q,"P",{});var hN=i(_h);$$=a(hN,"For best performance you may want to consider turning the memory profiling off for production runs."),hN.forEach(o),q.forEach(o),x$=d(y),gr=s(y,"DIV",{class:!0});var o2=i(gr);u($n.$$.fragment,o2),k$=d(o2),vh=s(o2,"P",{});var uN=i(vh);A$=a(uN,"Reformat Trainer metrics values to a human-readable format"),uN.forEach(o),o2.forEach(o),P$=d(y),_r=s(y,"DIV",{class:!0});var r2=i(_r);u(xn.$$.fragment,r2),D$=d(r2),kn=s(r2,"P",{});var a2=i(kn);S$=a(a2,"Helper to get number of samples in a "),bh=s(a2,"CODE",{});var fN=i(bh);q$=a(fN,"~torch.utils.data.DataLoader"),fN.forEach(o),O$=a(a2,` by accessing its dataset. When
dataloader.dataset does not exist or has no length, estimates as best it can`),a2.forEach(o),r2.forEach(o),C$=d(y),yt=s(y,"DIV",{class:!0});var Tc=i(yt);u(An.$$.fragment,Tc),I$=d(Tc),Pn=s(Tc,"P",{});var n2=i(Pn);U$=a(n2,"Remove a callback from the current list of "),yh=s(n2,"CODE",{});var gN=i(yh);N$=a(gN,"~transformer.TrainerCallback"),gN.forEach(o),z$=a(n2," and returns it."),n2.forEach(o),F$=d(Tc),Dn=s(Tc,"P",{});var s2=i(Dn);L$=a(s2,"If the callback is not found, returns "),wh=s(s2,"CODE",{});var _N=i(wh);R$=a(_N,"None"),_N.forEach(o),W$=a(s2," (and no error is raised)."),s2.forEach(o),Tc.forEach(o),G$=d(y),X=s(y,"DIV",{class:!0});var He=i(X);u(Sn.$$.fragment,He),M$=d(He),Th=s(He,"P",{});var vN=i(Th);j$=a(vN,"Run prediction and returns predictions and potential metrics."),vN.forEach(o),H$=d(He),qn=s(He,"P",{});var i2=i(qn);B$=a(i2,`Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
will also return metrics, like in `),Eh=s(i2,"CODE",{});var bN=i(Eh);V$=a(bN,"evaluate()"),bN.forEach(o),Y$=a(i2,"."),i2.forEach(o),Z$=d(He),u(vr.$$.fragment,He),K$=d(He),On=s(He,"P",{});var l2=i(On);J$=a(l2,"Returns: "),$h=s(l2,"EM",{});var yN=i($h);X$=a(yN,"NamedTuple"),yN.forEach(o),Q$=a(l2," A namedtuple with the following keys:"),l2.forEach(o),e3=d(He),co=s(He,"UL",{});var Ec=i(co);po=s(Ec,"LI",{});var $c=i(po);t3=a($c,"predictions ("),xh=s($c,"CODE",{});var wN=i(xh);o3=a(wN,"np.ndarray"),wN.forEach(o),r3=a($c,"): The predictions on "),kh=s($c,"CODE",{});var TN=i(kh);a3=a(TN,"test_dataset"),TN.forEach(o),n3=a($c,"."),$c.forEach(o),s3=d(Ec),mo=s(Ec,"LI",{});var xc=i(mo);i3=a(xc,"label_ids ("),Ah=s(xc,"CODE",{});var EN=i(Ah);l3=a(EN,"np.ndarray"),EN.forEach(o),d3=a(xc,", "),Ph=s(xc,"EM",{});var $N=i(Ph);c3=a($N,"optional"),$N.forEach(o),p3=a(xc,"): The labels (if the dataset contained some)."),xc.forEach(o),m3=d(Ec),ho=s(Ec,"LI",{});var kc=i(ho);h3=a(kc,"metrics ("),Dh=s(kc,"CODE",{});var xN=i(Dh);u3=a(xN,"Dict[str, float]"),xN.forEach(o),f3=a(kc,", "),Sh=s(kc,"EM",{});var kN=i(Sh);g3=a(kN,"optional"),kN.forEach(o),_3=a(kc,`): The potential dictionary of metrics (if the dataset contained
labels).`),kc.forEach(o),Ec.forEach(o),He.forEach(o),v3=d(y),wt=s(y,"DIV",{class:!0});var Ac=i(wt);u(Cn.$$.fragment,Ac),b3=d(Ac),uo=s(Ac,"P",{});var Pc=i(uo);y3=a(Pc,"Prediction/evaluation loop, shared by "),qh=s(Pc,"CODE",{});var AN=i(qh);w3=a(AN,"Trainer.evaluate()"),AN.forEach(o),T3=a(Pc," and "),Oh=s(Pc,"CODE",{});var PN=i(Oh);E3=a(PN,"Trainer.predict()"),PN.forEach(o),$3=a(Pc,"."),Pc.forEach(o),x3=d(Ac),Ch=s(Ac,"P",{});var DN=i(Ch);k3=a(DN,"Works both with or without labels."),DN.forEach(o),Ac.forEach(o),A3=d(y),Tt=s(y,"DIV",{class:!0});var Dc=i(Tt);u(In.$$.fragment,Dc),P3=d(Dc),fo=s(Dc,"P",{});var Sc=i(fo);D3=a(Sc,"Perform an evaluation step on "),Ih=s(Sc,"CODE",{});var SN=i(Ih);S3=a(SN,"model"),SN.forEach(o),q3=a(Sc," using "),Uh=s(Sc,"CODE",{});var qN=i(Uh);O3=a(qN,"inputs"),qN.forEach(o),C3=a(Sc,"."),Sc.forEach(o),I3=d(Dc),Nh=s(Dc,"P",{});var ON=i(Nh);U3=a(ON,"Subclass and override to inject custom behavior."),ON.forEach(o),Dc.forEach(o),N3=d(y),br=s(y,"DIV",{class:!0});var d2=i(br);u(Un.$$.fragment,d2),z3=d(d2),et=s(d2,"P",{});var ya=i(et);F3=a(ya,"Upload "),zh=s(ya,"EM",{});var CN=i(zh);L3=a(CN,"self.model"),CN.forEach(o),R3=a(ya," and "),Fh=s(ya,"EM",{});var IN=i(Fh);W3=a(IN,"self.tokenizer"),IN.forEach(o),G3=a(ya," to the \u{1F917} model hub on the repo "),Lh=s(ya,"EM",{});var UN=i(Lh);M3=a(UN,"self.args.hub_model_id"),UN.forEach(o),j3=a(ya,"."),ya.forEach(o),d2.forEach(o),H3=d(y),yr=s(y,"DIV",{class:!0});var c2=i(yr);u(Nn.$$.fragment,c2),B3=d(c2),zn=s(c2,"P",{});var p2=i(zn);V3=a(p2,"Remove a callback from the current list of "),Rh=s(p2,"CODE",{});var NN=i(Rh);Y3=a(NN,"~transformer.TrainerCallback"),NN.forEach(o),Z3=a(p2,"."),p2.forEach(o),c2.forEach(o),K3=d(y),Ce=s(y,"DIV",{class:!0});var wa=i(Ce);u(Fn.$$.fragment,wa),J3=d(wa),Ln=s(wa,"P",{});var m2=i(Ln);X3=a(m2,"Save metrics into a json file for that split, e.g. "),Wh=s(m2,"CODE",{});var zN=i(Wh);Q3=a(zN,"train_results.json"),zN.forEach(o),ex=a(m2,"."),m2.forEach(o),tx=d(wa),Gh=s(wa,"P",{});var FN=i(Gh);ox=a(FN,"Under distributed environment this is done only for a process with rank 0."),FN.forEach(o),rx=d(wa),Rn=s(wa,"P",{});var h2=i(Rn);ax=a(h2,"To understand the metrics please read the docstring of "),xl=s(h2,"A",{href:!0});var LN=i(xl);nx=a(LN,"log_metrics()"),LN.forEach(o),sx=a(h2,`. The only difference is that raw
unformatted numbers are saved in the current method.`),h2.forEach(o),wa.forEach(o),ix=d(y),Et=s(y,"DIV",{class:!0});var qc=i(Et);u(Wn.$$.fragment,qc),lx=d(qc),Gn=s(qc,"P",{});var u2=i(Gn);dx=a(u2,"Will save the model, so you can reload it using "),Mh=s(u2,"CODE",{});var RN=i(Mh);cx=a(RN,"from_pretrained()"),RN.forEach(o),px=a(u2,"."),u2.forEach(o),mx=d(qc),jh=s(qc,"P",{});var WN=i(jh);hx=a(WN,"Will only save from the main process."),WN.forEach(o),qc.forEach(o),ux=d(y),$t=s(y,"DIV",{class:!0});var Oc=i($t);u(Mn.$$.fragment,Oc),fx=d(Oc),Hh=s(Oc,"P",{});var GN=i(Hh);gx=a(GN,"Saves the Trainer state, since Trainer.save_model saves only the tokenizer with the model"),GN.forEach(o),_x=d(Oc),Bh=s(Oc,"P",{});var MN=i(Bh);vx=a(MN,"Under distributed environment this is done only for a process with rank 0."),MN.forEach(o),Oc.forEach(o),bx=d(y),wr=s(y,"DIV",{class:!0});var f2=i(wr);u(jn.$$.fragment,f2),yx=d(f2),Hn=s(f2,"P",{});var g2=i(Hn);wx=a(g2,"A helper wrapper that creates an appropriate context manager for "),Vh=s(g2,"CODE",{});var jN=i(Vh);Tx=a(jN,"torchdynamo"),jN.forEach(o),Ex=a(g2,"."),g2.forEach(o),f2.forEach(o),$x=d(y),Tr=s(y,"DIV",{class:!0});var _2=i(Tr);u(Bn.$$.fragment,_2),xx=d(_2),Yh=s(_2,"P",{});var HN=i(Yh);kx=a(HN,"Main training entry point."),HN.forEach(o),_2.forEach(o),Ax=d(y),xt=s(y,"DIV",{class:!0});var Cc=i(xt);u(Vn.$$.fragment,Cc),Px=d(Cc),Zh=s(Cc,"P",{});var BN=i(Zh);Dx=a(BN,"Perform a training step on a batch of inputs."),BN.forEach(o),Sx=d(Cc),Kh=s(Cc,"P",{});var VN=i(Kh);qx=a(VN,"Subclass and override to inject custom behavior."),VN.forEach(o),Cc.forEach(o),y.forEach(o),kv=d(t),go=s(t,"H2",{class:!0});var v2=i(go);Er=s(v2,"A",{id:!0,class:!0,href:!0});var YN=i(Er);Jh=s(YN,"SPAN",{});var ZN=i(Jh);u(Yn.$$.fragment,ZN),ZN.forEach(o),YN.forEach(o),Ox=d(v2),Xh=s(v2,"SPAN",{});var KN=i(Xh);Cx=a(KN,"Seq2SeqTrainer"),KN.forEach(o),v2.forEach(o),Av=d(t),tt=s(t,"DIV",{class:!0});var Ic=i(tt);u(Zn.$$.fragment,Ic),Ix=d(Ic),Ie=s(Ic,"DIV",{class:!0});var Ta=i(Ie);u(Kn.$$.fragment,Ta),Ux=d(Ta),Qh=s(Ta,"P",{});var JN=i(Qh);Nx=a(JN,"Run evaluation and returns metrics."),JN.forEach(o),zx=d(Ta),Jn=s(Ta,"P",{});var b2=i(Jn);Fx=a(b2,`The calling script will be responsible for providing a method to compute metrics, as they are task-dependent
(pass it to the init `),eu=s(b2,"CODE",{});var XN=i(eu);Lx=a(XN,"compute_metrics"),XN.forEach(o),Rx=a(b2," argument)."),b2.forEach(o),Wx=d(Ta),tu=s(Ta,"P",{});var QN=i(tu);Gx=a(QN,"You can also subclass and override this method to inject custom behavior."),QN.forEach(o),Ta.forEach(o),Mx=d(Ic),Q=s(Ic,"DIV",{class:!0});var Be=i(Q);u(Xn.$$.fragment,Be),jx=d(Be),ou=s(Be,"P",{});var ez=i(ou);Hx=a(ez,"Run prediction and returns predictions and potential metrics."),ez.forEach(o),Bx=d(Be),Qn=s(Be,"P",{});var y2=i(Qn);Vx=a(y2,`Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method
will also return metrics, like in `),ru=s(y2,"CODE",{});var tz=i(ru);Yx=a(tz,"evaluate()"),tz.forEach(o),Zx=a(y2,"."),y2.forEach(o),Kx=d(Be),u($r.$$.fragment,Be),Jx=d(Be),es=s(Be,"P",{});var w2=i(es);Xx=a(w2,"Returns: "),au=s(w2,"EM",{});var oz=i(au);Qx=a(oz,"NamedTuple"),oz.forEach(o),ek=a(w2," A namedtuple with the following keys:"),w2.forEach(o),tk=d(Be),_o=s(Be,"UL",{});var Uc=i(_o);vo=s(Uc,"LI",{});var Nc=i(vo);ok=a(Nc,"predictions ("),nu=s(Nc,"CODE",{});var rz=i(nu);rk=a(rz,"np.ndarray"),rz.forEach(o),ak=a(Nc,"): The predictions on "),su=s(Nc,"CODE",{});var az=i(su);nk=a(az,"test_dataset"),az.forEach(o),sk=a(Nc,"."),Nc.forEach(o),ik=d(Uc),bo=s(Uc,"LI",{});var zc=i(bo);lk=a(zc,"label_ids ("),iu=s(zc,"CODE",{});var nz=i(iu);dk=a(nz,"np.ndarray"),nz.forEach(o),ck=a(zc,", "),lu=s(zc,"EM",{});var sz=i(lu);pk=a(sz,"optional"),sz.forEach(o),mk=a(zc,"): The labels (if the dataset contained some)."),zc.forEach(o),hk=d(Uc),yo=s(Uc,"LI",{});var Fc=i(yo);uk=a(Fc,"metrics ("),du=s(Fc,"CODE",{});var iz=i(du);fk=a(iz,"Dict[str, float]"),iz.forEach(o),gk=a(Fc,", "),cu=s(Fc,"EM",{});var lz=i(cu);_k=a(lz,"optional"),lz.forEach(o),vk=a(Fc,`): The potential dictionary of metrics (if the dataset contained
labels).`),Fc.forEach(o),Uc.forEach(o),Be.forEach(o),Ic.forEach(o),Pv=d(t),wo=s(t,"H2",{class:!0});var T2=i(wo);xr=s(T2,"A",{id:!0,class:!0,href:!0});var dz=i(xr);pu=s(dz,"SPAN",{});var cz=i(pu);u(ts.$$.fragment,cz),cz.forEach(o),dz.forEach(o),bk=d(T2),mu=s(T2,"SPAN",{});var pz=i(mu);yk=a(pz,"TrainingArguments"),pz.forEach(o),T2.forEach(o),Dv=d(t),F=s(t,"DIV",{class:!0});var j=i(F);u(os.$$.fragment,j),wk=d(j),rs=s(j,"P",{});var E2=i(rs);Tk=a(E2,"TrainingArguments is the subset of the arguments we use in our example scripts "),hu=s(E2,"STRONG",{});var mz=i(hu);Ek=a(mz,`which relate to the training loop
itself`),mz.forEach(o),$k=a(E2,"."),E2.forEach(o),xk=d(j),To=s(j,"P",{});var Lc=i(To);kk=a(Lc,"Using "),kl=s(Lc,"A",{href:!0});var hz=i(kl);Ak=a(hz,"HfArgumentParser"),hz.forEach(o),Pk=a(Lc,` we can turn this class into
`),as=s(Lc,"A",{href:!0,rel:!0});var uz=i(as);Dk=a(uz,"argparse"),uz.forEach(o),Sk=a(Lc,` arguments that can be specified on the
command line.`),Lc.forEach(o),qk=d(j),de=s(j,"DIV",{class:!0});var Zt=i(de);u(ns.$$.fragment,Zt),Ok=d(Zt),uu=s(Zt,"P",{});var fz=i(uu);Ck=a(fz,`Returns the log level to be used depending on whether this process is the main process of node 0, main process
of node non-0, or a non-main process.`),fz.forEach(o),Ik=d(Zt),Eo=s(Zt,"P",{});var Rc=i(Eo);Uk=a(Rc,"For the main process the log level defaults to "),fu=s(Rc,"CODE",{});var gz=i(fu);Nk=a(gz,"logging.INFO"),gz.forEach(o),zk=a(Rc," unless overridden by "),gu=s(Rc,"CODE",{});var _z=i(gu);Fk=a(_z,"log_level"),_z.forEach(o),Lk=a(Rc," argument."),Rc.forEach(o),Rk=d(Zt),$o=s(Zt,"P",{});var Wc=i($o);Wk=a(Wc,"For the replica processes the log level defaults to "),_u=s(Wc,"CODE",{});var vz=i(_u);Gk=a(vz,"logging.WARNING"),vz.forEach(o),Mk=a(Wc," unless overridden by "),vu=s(Wc,"CODE",{});var bz=i(vu);jk=a(bz,"log_level_replica"),bz.forEach(o),Hk=a(Wc,`
argument.`),Wc.forEach(o),Bk=d(Zt),ss=s(Zt,"P",{});var $2=i(ss);Vk=a($2,"The choice between the main and replica process settings is made according to the return value of "),bu=s($2,"CODE",{});var yz=i(bu);Yk=a(yz,"should_log"),yz.forEach(o),Zk=a($2,"."),$2.forEach(o),Zt.forEach(o),Kk=d(j),kr=s(j,"DIV",{class:!0});var x2=i(kr);u(is.$$.fragment,x2),Jk=d(x2),yu=s(x2,"P",{});var wz=i(yu);Xk=a(wz,"Get number of steps used for a linear warmup."),wz.forEach(o),x2.forEach(o),Qk=d(j),kt=s(j,"DIV",{class:!0});var Gc=i(kt);u(ls.$$.fragment,Gc),e5=d(Gc),wu=s(Gc,"P",{});var Tz=i(wu);t5=a(Tz,`A context manager for torch distributed environment where on needs to do something on the main process, while
blocking replicas, and when it\u2019s finished releasing the replicas.`),Tz.forEach(o),o5=d(Gc),xo=s(Gc,"P",{});var Mc=i(xo);r5=a(Mc,"One such use is for "),Tu=s(Mc,"CODE",{});var Ez=i(Tu);a5=a(Ez,"datasets"),Ez.forEach(o),n5=a(Mc,"\u2019s "),Eu=s(Mc,"CODE",{});var $z=i(Eu);s5=a($z,"map"),$z.forEach(o),i5=a(Mc,` feature which to be efficient should be run once on the main process,
which upon completion saves a cached version of results and which then automatically gets loaded by the
replicas.`),Mc.forEach(o),Gc.forEach(o),l5=d(j),Ar=s(j,"DIV",{class:!0});var k2=i(Ar);u(ds.$$.fragment,k2),d5=d(k2),cs=s(k2,"P",{});var A2=i(cs);c5=a(A2,"Serializes this instance while replace "),$u=s(A2,"CODE",{});var xz=i($u);p5=a(xz,"Enum"),xz.forEach(o),m5=a(A2,` by their values (for JSON serialization support). It obfuscates
the token values by removing their value.`),A2.forEach(o),k2.forEach(o),h5=d(j),Pr=s(j,"DIV",{class:!0});var P2=i(Pr);u(ps.$$.fragment,P2),u5=d(P2),xu=s(P2,"P",{});var kz=i(xu);f5=a(kz,"Serializes this instance to a JSON string."),kz.forEach(o),P2.forEach(o),g5=d(j),Dr=s(j,"DIV",{class:!0});var D2=i(Dr);u(ms.$$.fragment,D2),_5=d(D2),ku=s(D2,"P",{});var Az=i(ku);v5=a(Az,"Sanitized serialization to use with TensorBoard\u2019s hparams"),Az.forEach(o),D2.forEach(o),j.forEach(o),Sv=d(t),ko=s(t,"H2",{class:!0});var S2=i(ko);Sr=s(S2,"A",{id:!0,class:!0,href:!0});var Pz=i(Sr);Au=s(Pz,"SPAN",{});var Dz=i(Au);u(hs.$$.fragment,Dz),Dz.forEach(o),Pz.forEach(o),b5=d(S2),Pu=s(S2,"SPAN",{});var Sz=i(Pu);y5=a(Sz,"Seq2SeqTrainingArguments"),Sz.forEach(o),S2.forEach(o),qv=d(t),ot=s(t,"DIV",{class:!0});var jc=i(ot);u(us.$$.fragment,jc),w5=d(jc),fs=s(jc,"P",{});var q2=i(fs);T5=a(q2,"TrainingArguments is the subset of the arguments we use in our example scripts "),Du=s(q2,"STRONG",{});var qz=i(Du);E5=a(qz,`which relate to the training loop
itself`),qz.forEach(o),$5=a(q2,"."),q2.forEach(o),x5=d(jc),Ao=s(jc,"P",{});var Hc=i(Ao);k5=a(Hc,"Using "),Al=s(Hc,"A",{href:!0});var Oz=i(Al);A5=a(Oz,"HfArgumentParser"),Oz.forEach(o),P5=a(Hc,` we can turn this class into
`),gs=s(Hc,"A",{href:!0,rel:!0});var Cz=i(gs);D5=a(Cz,"argparse"),Cz.forEach(o),S5=a(Hc,` arguments that can be specified on the
command line.`),Hc.forEach(o),jc.forEach(o),Ov=d(t),Po=s(t,"H2",{class:!0});var O2=i(Po);qr=s(O2,"A",{id:!0,class:!0,href:!0});var Iz=i(qr);Su=s(Iz,"SPAN",{});var Uz=i(Su);u(_s.$$.fragment,Uz),Uz.forEach(o),Iz.forEach(o),q5=d(O2),qu=s(O2,"SPAN",{});var Nz=i(qu);O5=a(Nz,"Checkpoints"),Nz.forEach(o),O2.forEach(o),Cv=d(t),ce=s(t,"P",{});var Kt=i(ce);C5=a(Kt,"By default, "),Pl=s(Kt,"A",{href:!0});var zz=i(Pl);I5=a(zz,"Trainer"),zz.forEach(o),U5=a(Kt," will save all checkpoints in the "),Ou=s(Kt,"CODE",{});var Fz=i(Ou);N5=a(Fz,"output_dir"),Fz.forEach(o),z5=a(Kt,` you set in the
`),Dl=s(Kt,"A",{href:!0});var Lz=i(Dl);F5=a(Lz,"TrainingArguments"),Lz.forEach(o),L5=a(Kt," you are using. Those will go in subfolder named "),Cu=s(Kt,"CODE",{});var Rz=i(Cu);R5=a(Rz,"checkpoint-xxx"),Rz.forEach(o),W5=a(Kt,` with xxx
being the step at which the training was at.`),Kt.forEach(o),Iv=d(t),Or=s(t,"P",{});var C2=i(Or);G5=a(C2,"Resuming training from a checkpoint can be done when calling "),Sl=s(C2,"A",{href:!0});var Wz=i(Sl);M5=a(Wz,"Trainer.train()"),Wz.forEach(o),j5=a(C2," with either:"),C2.forEach(o),Uv=d(t),Cr=s(t,"UL",{});var I2=i(Cr);ql=s(I2,"LI",{});var RC=i(ql);Iu=s(RC,"CODE",{});var Gz=i(Iu);H5=a(Gz,"resume_from_checkpoint=True"),Gz.forEach(o),B5=a(RC," which will resume training from the latest checkpoint"),RC.forEach(o),V5=d(I2),Ol=s(I2,"LI",{});var WC=i(Ol);Uu=s(WC,"CODE",{});var Mz=i(Uu);Y5=a(Mz,"resume_from_checkpoint=checkpoint_dir"),Mz.forEach(o),Z5=a(WC,` which will resume training from the specific checkpoint in the directory
passed.`),WC.forEach(o),I2.forEach(o),Nv=d(t),Ue=s(t,"P",{});var Ea=i(Ue);K5=a(Ea,"In addition, you can easily save your checkpoints on the Model Hub when using "),Nu=s(Ea,"CODE",{});var jz=i(Nu);J5=a(jz,"push_to_hub=True"),jz.forEach(o),X5=a(Ea,`. By default, all
the models saved in intermediate checkpoints are saved in different commits, but not the optimizer state. You can adapt
the `),zu=s(Ea,"CODE",{});var Hz=i(zu);Q5=a(Hz,"hub-strategy"),Hz.forEach(o),e6=a(Ea," value of your "),Cl=s(Ea,"A",{href:!0});var Bz=i(Cl);t6=a(Bz,"TrainingArguments"),Bz.forEach(o),o6=a(Ea," to either:"),Ea.forEach(o),zv=d(t),Ir=s(t,"UL",{});var U2=i(Ir);Ur=s(U2,"LI",{});var gv=i(Ur);Fu=s(gv,"CODE",{});var Vz=i(Fu);r6=a(Vz,'"checkpoint"'),Vz.forEach(o),a6=a(gv,`: the latest checkpoint is also pushed in a subfolder named last-checkpoint, allowing you to
resume training easily with `),Lu=s(gv,"CODE",{});var Yz=i(Lu);n6=a(Yz,'trainer.train(resume_from_checkpoint="output_dir/last-checkpoint")'),Yz.forEach(o),s6=a(gv,"."),gv.forEach(o),i6=d(U2),Il=s(U2,"LI",{});var GC=i(Il);Ru=s(GC,"CODE",{});var Zz=i(Ru);l6=a(Zz,'"all_checkpoints"'),Zz.forEach(o),d6=a(GC,`: all checkpoints are pushed like they appear in the output folder (so you will get one
checkpoint folder per folder in your final repository)`),GC.forEach(o),U2.forEach(o),Fv=d(t),Do=s(t,"H2",{class:!0});var N2=i(Do);Nr=s(N2,"A",{id:!0,class:!0,href:!0});var Kz=i(Nr);Wu=s(Kz,"SPAN",{});var Jz=i(Wu);u(vs.$$.fragment,Jz),Jz.forEach(o),Kz.forEach(o),c6=d(N2),Gu=s(N2,"SPAN",{});var Xz=i(Gu);p6=a(Xz,"Logging"),Xz.forEach(o),N2.forEach(o),Lv=d(t),Ne=s(t,"P",{});var $a=i(Ne);m6=a($a,"By default "),Ul=s($a,"A",{href:!0});var Qz=i(Ul);h6=a(Qz,"Trainer"),Qz.forEach(o),u6=a($a," will use "),Mu=s($a,"CODE",{});var eF=i(Mu);f6=a(eF,"logging.INFO"),eF.forEach(o),g6=a($a," for the main process and "),ju=s($a,"CODE",{});var tF=i(ju);_6=a(tF,"logging.WARNING"),tF.forEach(o),v6=a($a," for the replicas if any."),$a.forEach(o),Rv=d(t),At=s(t,"P",{});var Bc=i(At);b6=a(Bc,"These defaults can be overridden to use any of the 5 "),Hu=s(Bc,"CODE",{});var oF=i(Hu);y6=a(oF,"logging"),oF.forEach(o),w6=a(Bc," levels with "),Nl=s(Bc,"A",{href:!0});var rF=i(Nl);T6=a(rF,"TrainingArguments"),rF.forEach(o),E6=a(Bc,`\u2019s
arguments:`),Bc.forEach(o),Wv=d(t),zr=s(t,"UL",{});var z2=i(zr);zl=s(z2,"LI",{});var MC=i(zl);Bu=s(MC,"CODE",{});var aF=i(Bu);$6=a(aF,"log_level"),aF.forEach(o),x6=a(MC," - for the main process"),MC.forEach(o),k6=d(z2),Fl=s(z2,"LI",{});var jC=i(Fl);Vu=s(jC,"CODE",{});var nF=i(Vu);A6=a(nF,"log_level_replica"),nF.forEach(o),P6=a(jC," - for the replicas"),jC.forEach(o),z2.forEach(o),Gv=d(t),ze=s(t,"P",{});var xa=i(ze);D6=a(xa,"Further, if "),Ll=s(xa,"A",{href:!0});var sF=i(Ll);S6=a(sF,"TrainingArguments"),sF.forEach(o),q6=a(xa,"\u2019s "),Yu=s(xa,"CODE",{});var iF=i(Yu);O6=a(iF,"log_on_each_node"),iF.forEach(o),C6=a(xa," is set to "),Zu=s(xa,"CODE",{});var lF=i(Zu);I6=a(lF,"False"),lF.forEach(o),U6=a(xa,` only the main node will
use the log level settings for its main process, all other nodes will use the log level settings for replicas.`),xa.forEach(o),Mv=d(t),ee=s(t,"P",{});var Ve=i(ee);N6=a(Ve,"Note that "),Rl=s(Ve,"A",{href:!0});var dF=i(Rl);z6=a(dF,"Trainer"),dF.forEach(o),F6=a(Ve," is going to set "),Ku=s(Ve,"CODE",{});var cF=i(Ku);L6=a(cF,"transformers"),cF.forEach(o),R6=a(Ve,`\u2019s log level separately for each node in its
`),Ju=s(Ve,"CODE",{});var pF=i(Ju);W6=a(pF,"Trainer.__init__()"),pF.forEach(o),G6=a(Ve,`. So you may want to set this sooner (see the next example) if you tap into other
`),Xu=s(Ve,"CODE",{});var mF=i(Xu);M6=a(mF,"transformers"),mF.forEach(o),j6=a(Ve," functionality before creating the "),Wl=s(Ve,"A",{href:!0});var hF=i(Wl);H6=a(hF,"Trainer"),hF.forEach(o),B6=a(Ve," object."),Ve.forEach(o),jv=d(t),Gl=s(t,"P",{});var uF=i(Gl);V6=a(uF,"Here is an example of how this can be used in an application:"),uF.forEach(o),Hv=d(t),u(bs.$$.fragment,t),Bv=d(t),Ml=s(t,"P",{});var fF=i(Ml);Y6=a(fF,`And then if you only want to see warnings on the main node and all other nodes to not print any most likely duplicated
warnings you could run it as:`),fF.forEach(o),Vv=d(t),u(ys.$$.fragment,t),Yv=d(t),jl=s(t,"P",{});var gF=i(jl);Z6=a(gF,`In the multi-node environment if you also don\u2019t want the logs to repeat for each node\u2019s main process, you will want to
change the above to:`),gF.forEach(o),Zv=d(t),u(ws.$$.fragment,t),Kv=d(t),Hl=s(t,"P",{});var _F=i(Hl);K6=a(_F,`and then only the main process of the first node will log at the \u201Cwarning\u201D level, and all other processes on the main
node and all processes on other nodes will log at the \u201Cerror\u201D level.`),_F.forEach(o),Jv=d(t),Bl=s(t,"P",{});var vF=i(Bl);J6=a(vF,"If you need your application to be as quiet as possible you could do:"),vF.forEach(o),Xv=d(t),u(Ts.$$.fragment,t),Qv=d(t),Fr=s(t,"P",{});var F2=i(Fr);X6=a(F2,"(add "),Qu=s(F2,"CODE",{});var bF=i(Qu);Q6=a(bF,"--log_on_each_node 0"),bF.forEach(o),e7=a(F2," if on multi-node environment)"),F2.forEach(o),e1=d(t),So=s(t,"H2",{class:!0});var L2=i(So);Lr=s(L2,"A",{id:!0,class:!0,href:!0});var yF=i(Lr);ef=s(yF,"SPAN",{});var wF=i(ef);u(Es.$$.fragment,wF),wF.forEach(o),yF.forEach(o),t7=d(L2),tf=s(L2,"SPAN",{});var TF=i(tf);o7=a(TF,"Randomness"),TF.forEach(o),L2.forEach(o),t1=d(t),pe=s(t,"P",{});var Jt=i(pe);r7=a(Jt,"When resuming from a checkpoint generated by "),Vl=s(Jt,"A",{href:!0});var EF=i(Vl);a7=a(EF,"Trainer"),EF.forEach(o),n7=a(Jt,` all efforts are made to restore the
`),of=s(Jt,"EM",{});var $F=i(of);s7=a($F,"python"),$F.forEach(o),i7=a(Jt,", "),rf=s(Jt,"EM",{});var xF=i(rf);l7=a(xF,"numpy"),xF.forEach(o),d7=a(Jt," and "),af=s(Jt,"EM",{});var kF=i(af);c7=a(kF,"pytorch"),kF.forEach(o),p7=a(Jt,` RNG states to the same states as they were at the moment of saving that checkpoint,
which should make the \u201Cstop and resume\u201D style of training as close as possible to non-stop training.`),Jt.forEach(o),o1=d(t),Pt=s(t,"P",{});var Vc=i(Pt);m7=a(Vc,`However, due to various default non-deterministic pytorch settings this might not fully work. If you want full
determinism please refer to `),$s=s(Vc,"A",{href:!0,rel:!0});var AF=i($s);h7=a(AF,"Controlling sources of randomness"),AF.forEach(o),u7=a(Vc,`. As explained in the document, that some of those settings
that make things deterministic (.e.g., `),nf=s(Vc,"CODE",{});var PF=i(nf);f7=a(PF,"torch.backends.cudnn.deterministic"),PF.forEach(o),g7=a(Vc,`) may slow things down, therefore this
can\u2019t be done by default, but you can enable those yourself if needed.`),Vc.forEach(o),r1=d(t),qo=s(t,"H2",{class:!0});var R2=i(qo);Rr=s(R2,"A",{id:!0,class:!0,href:!0});var DF=i(Rr);sf=s(DF,"SPAN",{});var SF=i(sf);u(xs.$$.fragment,SF),SF.forEach(o),DF.forEach(o),_7=d(R2),lf=s(R2,"SPAN",{});var qF=i(lf);v7=a(qF,"Specific GPUs Selection"),qF.forEach(o),R2.forEach(o),a1=d(t),Yl=s(t,"P",{});var OF=i(Yl);b7=a(OF,"Let\u2019s discuss how you can tell your program which GPUs are to be used and in what order."),OF.forEach(o),n1=d(t),Wr=s(t,"P",{});var W2=i(Wr);y7=a(W2,"When using "),ks=s(W2,"A",{href:!0,rel:!0});var CF=i(ks);df=s(CF,"CODE",{});var IF=i(df);w7=a(IF,"DistributedDataParallel"),IF.forEach(o),CF.forEach(o),T7=a(W2," to use only a subset of your GPUs, you simply specify the number of GPUs to use. For example, if you have 4 GPUs, but you wish to use the first 2 you can do:"),W2.forEach(o),s1=d(t),u(As.$$.fragment,t),i1=d(t),Dt=s(t,"P",{});var Yc=i(Dt);E7=a(Yc,"if you have either "),Ps=s(Yc,"A",{href:!0,rel:!0});var UF=i(Ps);cf=s(UF,"CODE",{});var NF=i(cf);$7=a(NF,"accelerate"),NF.forEach(o),UF.forEach(o),x7=a(Yc," or "),Ds=s(Yc,"A",{href:!0,rel:!0});var zF=i(Ds);pf=s(zF,"CODE",{});var FF=i(pf);k7=a(FF,"deepspeed"),FF.forEach(o),zF.forEach(o),A7=a(Yc," installed you can also accomplish the same by using one of:"),Yc.forEach(o),l1=d(t),u(Ss.$$.fragment,t),d1=d(t),u(qs.$$.fragment,t),c1=d(t),Gr=s(t,"P",{});var G2=i(Gr);P7=a(G2,"You don\u2019t need to use the Accelerate or "),Zl=s(G2,"A",{href:!0});var LF=i(Zl);D7=a(LF,"the Deepspeed integration"),LF.forEach(o),S7=a(G2," features to use these launchers."),G2.forEach(o),p1=d(t),Kl=s(t,"P",{});var RF=i(Kl);q7=a(RF,"Until now you were able to tell the program how many GPUs to use. Now let\u2019s discuss how to select specific GPUs and control their order."),RF.forEach(o),m1=d(t),Jl=s(t,"P",{});var WF=i(Jl);O7=a(WF,"The following environment variables help you control which GPUs to use and their order."),WF.forEach(o),h1=d(t),Xl=s(t,"P",{});var GF=i(Xl);mf=s(GF,"STRONG",{});var MF=i(mf);hf=s(MF,"CODE",{});var jF=i(hf);C7=a(jF,"CUDA_VISIBLE_DEVICES"),jF.forEach(o),MF.forEach(o),GF.forEach(o),u1=d(t),Mr=s(t,"P",{});var M2=i(Mr);I7=a(M2,"If you have multiple GPUs and you\u2019d like to use only 1 or a few of those GPUs, set the environment variable "),uf=s(M2,"CODE",{});var HF=i(uf);U7=a(HF,"CUDA_VISIBLE_DEVICES"),HF.forEach(o),N7=a(M2," to a list of the GPUs to be used."),M2.forEach(o),f1=d(t),Ql=s(t,"P",{});var BF=i(Ql);z7=a(BF,"For example, let\u2019s say you have 4 GPUs: 0, 1, 2 and 3. To run only on the physical GPUs 0 and 2, you can do:"),BF.forEach(o),g1=d(t),u(Os.$$.fragment,t),_1=d(t),St=s(t,"P",{});var Zc=i(St);F7=a(Zc,"So now pytorch will see only 2 GPUs, where your physical GPUs 0 and 2 are mapped to "),ff=s(Zc,"CODE",{});var VF=i(ff);L7=a(VF,"cuda:0"),VF.forEach(o),R7=a(Zc," and "),gf=s(Zc,"CODE",{});var YF=i(gf);W7=a(YF,"cuda:1"),YF.forEach(o),G7=a(Zc," correspondingly."),Zc.forEach(o),v1=d(t),ed=s(t,"P",{});var ZF=i(ed);M7=a(ZF,"You can even change their order:"),ZF.forEach(o),b1=d(t),u(Cs.$$.fragment,t),y1=d(t),qt=s(t,"P",{});var Kc=i(qt);j7=a(Kc,"Here your physical GPUs 0 and 2 are mapped to "),_f=s(Kc,"CODE",{});var KF=i(_f);H7=a(KF,"cuda:1"),KF.forEach(o),B7=a(Kc," and "),vf=s(Kc,"CODE",{});var JF=i(vf);V7=a(JF,"cuda:0"),JF.forEach(o),Y7=a(Kc," correspondingly."),Kc.forEach(o),w1=d(t),Ot=s(t,"P",{});var Jc=i(Ot);Z7=a(Jc,"The above examples were all for "),bf=s(Jc,"CODE",{});var XF=i(bf);K7=a(XF,"DistributedDataParallel"),XF.forEach(o),J7=a(Jc," use pattern, but the same method works for "),Is=s(Jc,"A",{href:!0,rel:!0});var QF=i(Is);yf=s(QF,"CODE",{});var eL=i(yf);X7=a(eL,"DataParallel"),eL.forEach(o),QF.forEach(o),Q7=a(Jc," as well:"),Jc.forEach(o),T1=d(t),u(Us.$$.fragment,t),E1=d(t),td=s(t,"P",{});var tL=i(td);eA=a(tL,"To emulate an environment without GPUs simply set this environment variable to an empty value like so:"),tL.forEach(o),$1=d(t),u(Ns.$$.fragment,t),x1=d(t),od=s(t,"P",{});var oL=i(od);tA=a(oL,"As with any environment variable you can, of course, export those instead of adding these to the command line, as in:"),oL.forEach(o),k1=d(t),u(zs.$$.fragment,t),A1=d(t),rd=s(t,"P",{});var rL=i(rd);oA=a(rL,"but this approach can be confusing since you may forget you set up the environment variable earlier and not understand why the wrong GPUs are used. Therefore, it\u2019s a common practice to set the environment variable just for a specific run on the same command line as it\u2019s shown in most examples of this section."),rL.forEach(o),P1=d(t),ad=s(t,"P",{});var aL=i(ad);wf=s(aL,"STRONG",{});var nL=i(wf);Tf=s(nL,"CODE",{});var sL=i(Tf);rA=a(sL,"CUDA_DEVICE_ORDER"),sL.forEach(o),nL.forEach(o),aL.forEach(o),D1=d(t),jr=s(t,"P",{});var j2=i(jr);aA=a(j2,"There is an additional environment variable "),Ef=s(j2,"CODE",{});var iL=i(Ef);nA=a(iL,"CUDA_DEVICE_ORDER"),iL.forEach(o),sA=a(j2," that controls how the physical devices are ordered. The two choices are:"),j2.forEach(o),S1=d(t),nd=s(t,"OL",{});var lL=i(nd);Fs=s(lL,"LI",{});var H2=i(Fs);iA=a(H2,"ordered by PCIe bus IDs (matches "),$f=s(H2,"CODE",{});var dL=i($f);lA=a(dL,"nvidia-smi"),dL.forEach(o),dA=a(H2,"\u2019s order) - this is the default."),H2.forEach(o),lL.forEach(o),q1=d(t),u(Ls.$$.fragment,t),O1=d(t),Rs=s(t,"OL",{start:!0});var cL=i(Rs);xf=s(cL,"LI",{});var pL=i(xf);cA=a(pL,"ordered by GPU compute capabilities"),pL.forEach(o),cL.forEach(o),C1=d(t),u(Ws.$$.fragment,t),I1=d(t),Ct=s(t,"P",{});var Xc=i(Ct);pA=a(Xc,"Most of the time you don\u2019t need to care about this environment variable, but it\u2019s very helpful if you have a lopsided setup where you have an old and a new GPUs physically inserted in such a way so that the slow older card appears to be first. One way to fix that is to swap the cards. But if you can\u2019t swap the cards (e.g., if the cooling of the devices gets impacted) then setting "),kf=s(Xc,"CODE",{});var mL=i(kf);mA=a(mL,"CUDA_DEVICE_ORDER=FASTEST_FIRST"),mL.forEach(o),hA=a(Xc," will always put the newer faster card first. It\u2019ll be somewhat confusing though since "),Af=s(Xc,"CODE",{});var hL=i(Af);uA=a(hL,"nvidia-smi"),hL.forEach(o),fA=a(Xc," will still report them in the PCIe order."),Xc.forEach(o),U1=d(t),sd=s(t,"P",{});var uL=i(sd);gA=a(uL,"The other solution to swapping the order is to use:"),uL.forEach(o),N1=d(t),u(Gs.$$.fragment,t),z1=d(t),id=s(t,"P",{});var fL=i(id);_A=a(fL,"In this example we are working with just 2 GPUs, but of course the same would apply to as many GPUs as your computer has."),fL.forEach(o),F1=d(t),Hr=s(t,"P",{});var B2=i(Hr);vA=a(B2,"Also if you do set this environment variable it\u2019s the best to set it in your "),Pf=s(B2,"CODE",{});var gL=i(Pf);bA=a(gL,"~/.bashrc"),gL.forEach(o),yA=a(B2," file or some other startup config file and forget about it."),B2.forEach(o),L1=d(t),Oo=s(t,"H2",{class:!0});var V2=i(Oo);Br=s(V2,"A",{id:!0,class:!0,href:!0});var _L=i(Br);Df=s(_L,"SPAN",{});var vL=i(Df);u(Ms.$$.fragment,vL),vL.forEach(o),_L.forEach(o),wA=d(V2),Sf=s(V2,"SPAN",{});var bL=i(Sf);TA=a(bL,"Trainer Integrations"),bL.forEach(o),V2.forEach(o),R1=d(t),Vr=s(t,"P",{});var Y2=i(Vr);EA=a(Y2,"The "),ld=s(Y2,"A",{href:!0});var yL=i(ld);$A=a(yL,"Trainer"),yL.forEach(o),xA=a(Y2,` has been extended to support libraries that may dramatically improve your training
time and fit much bigger models.`),Y2.forEach(o),W1=d(t),me=s(t,"P",{});var Xt=i(me);kA=a(Xt,"Currently it supports third party solutions, "),js=s(Xt,"A",{href:!0,rel:!0});var wL=i(js);AA=a(wL,"DeepSpeed"),wL.forEach(o),PA=a(Xt,", "),Hs=s(Xt,"A",{href:!0,rel:!0});var TL=i(Hs);DA=a(TL,"PyTorch FSDP"),TL.forEach(o),SA=a(Xt," and "),Bs=s(Xt,"A",{href:!0,rel:!0});var EL=i(Bs);qA=a(EL,"FairScale"),EL.forEach(o),OA=a(Xt,", which implement parts of the paper "),Vs=s(Xt,"A",{href:!0,rel:!0});var $L=i(Vs);CA=a($L,`ZeRO: Memory Optimizations
Toward Training Trillion Parameter Models, by Samyam Rajbhandari, Jeff Rasley, Olatunji Ruwase, Yuxiong He`),$L.forEach(o),IA=a(Xt,"."),Xt.forEach(o),G1=d(t),Yr=s(t,"P",{});var Z2=i(Yr);UA=a(Z2,"This provided support is new and experimental as of this writing. While the support for DeepSpeed and PyTorch FSDP is active and we welcome issues around it, we don\u2019t support the FairScale integration anymore since it has been integrated in PyTorch main (see the "),dd=s(Z2,"A",{href:!0});var xL=i(dd);NA=a(xL,"PyTorch FSDP integration"),xL.forEach(o),zA=a(Z2,")"),Z2.forEach(o),M1=d(t),cd=s(t,"A",{id:!0}),i(cd).forEach(o),j1=d(t),Co=s(t,"H3",{class:!0});var K2=i(Co);Zr=s(K2,"A",{id:!0,class:!0,href:!0});var kL=i(Zr);qf=s(kL,"SPAN",{});var AL=i(qf);u(Ys.$$.fragment,AL),AL.forEach(o),kL.forEach(o),FA=d(K2),Of=s(K2,"SPAN",{});var PL=i(Of);LA=a(PL,"CUDA Extension Installation Notes"),PL.forEach(o),K2.forEach(o),H1=d(t),pd=s(t,"P",{});var DL=i(pd);RA=a(DL,"As of this writing, both FairScale and Deepspeed require compilation of CUDA C++ code, before they can be used."),DL.forEach(o),B1=d(t),It=s(t,"P",{});var Qc=i(It);WA=a(Qc,"While all installation issues should be dealt with through the corresponding GitHub Issues of "),Zs=s(Qc,"A",{href:!0,rel:!0});var SL=i(Zs);GA=a(SL,"FairScale"),SL.forEach(o),MA=a(Qc," and "),Ks=s(Qc,"A",{href:!0,rel:!0});var qL=i(Ks);jA=a(qL,"Deepspeed"),qL.forEach(o),HA=a(Qc,`, there are a few common issues that one may encounter while building
any PyTorch extension that needs to build CUDA extensions.`),Qc.forEach(o),V1=d(t),md=s(t,"P",{});var OL=i(md);BA=a(OL,"Therefore, if you encounter a CUDA-related build issue while doing one of the following or both:"),OL.forEach(o),Y1=d(t),u(Js.$$.fragment,t),Z1=d(t),hd=s(t,"P",{});var CL=i(hd);VA=a(CL,"please, read the following notes first."),CL.forEach(o),K1=d(t),Ut=s(t,"P",{});var ep=i(Ut);YA=a(ep,"In these notes we give examples for what to do when "),Cf=s(ep,"CODE",{});var IL=i(Cf);ZA=a(IL,"pytorch"),IL.forEach(o),KA=a(ep," has been built with CUDA "),If=s(ep,"CODE",{});var UL=i(If);JA=a(UL,"10.2"),UL.forEach(o),XA=a(ep,`. If your situation is
different remember to adjust the version number to the one you are after.`),ep.forEach(o),J1=d(t),Io=s(t,"H4",{class:!0});var J2=i(Io);Kr=s(J2,"A",{id:!0,class:!0,href:!0});var NL=i(Kr);Uf=s(NL,"SPAN",{});var zL=i(Uf);u(Xs.$$.fragment,zL),zL.forEach(o),NL.forEach(o),QA=d(J2),Nf=s(J2,"SPAN",{});var FL=i(Nf);e8=a(FL,"Possible problem #1"),FL.forEach(o),J2.forEach(o),X1=d(t),ud=s(t,"P",{});var LL=i(ud);t8=a(LL,`While, Pytorch comes with its own CUDA toolkit, to build these two projects you must have an identical version of CUDA
installed system-wide.`),LL.forEach(o),Q1=d(t),Fe=s(t,"P",{});var ka=i(Fe);o8=a(ka,"For example, if you installed "),zf=s(ka,"CODE",{});var RL=i(zf);r8=a(RL,"pytorch"),RL.forEach(o),a8=a(ka," with "),Ff=s(ka,"CODE",{});var WL=i(Ff);n8=a(WL,"cudatoolkit==10.2"),WL.forEach(o),s8=a(ka,` in the Python environment, you also need to have
CUDA `),Lf=s(ka,"CODE",{});var GL=i(Lf);i8=a(GL,"10.2"),GL.forEach(o),l8=a(ka," installed system-wide."),ka.forEach(o),eb=d(t),Nt=s(t,"P",{});var tp=i(Nt);d8=a(tp,"The exact location may vary from system to system, but "),Rf=s(tp,"CODE",{});var ML=i(Rf);c8=a(ML,"/usr/local/cuda-10.2"),ML.forEach(o),p8=a(tp,` is the most common location on many
Unix systems. When CUDA is correctly set up and added to the `),Wf=s(tp,"CODE",{});var jL=i(Wf);m8=a(jL,"PATH"),jL.forEach(o),h8=a(tp,` environment variable, one can find the
installation location by doing:`),tp.forEach(o),tb=d(t),u(Qs.$$.fragment,t),ob=d(t),Jr=s(t,"P",{});var X2=i(Jr);u8=a(X2,`If you don\u2019t have CUDA installed system-wide, install it first. You will find the instructions by using your favorite
search engine. For example, if you\u2019re on Ubuntu you may want to search for: `),ei=s(X2,"A",{href:!0,rel:!0});var HL=i(ei);f8=a(HL,"ubuntu cuda 10.2 install"),HL.forEach(o),g8=a(X2,"."),X2.forEach(o),rb=d(t),Uo=s(t,"H4",{class:!0});var Q2=i(Uo);Xr=s(Q2,"A",{id:!0,class:!0,href:!0});var BL=i(Xr);Gf=s(BL,"SPAN",{});var VL=i(Gf);u(ti.$$.fragment,VL),VL.forEach(o),BL.forEach(o),_8=d(Q2),Mf=s(Q2,"SPAN",{});var YL=i(Mf);v8=a(YL,"Possible problem #2"),YL.forEach(o),Q2.forEach(o),ab=d(t),fd=s(t,"P",{});var ZL=i(fd);b8=a(ZL,`Another possible common problem is that you may have more than one CUDA toolkit installed system-wide. For example you
may have:`),ZL.forEach(o),nb=d(t),u(oi.$$.fragment,t),sb=d(t),zt=s(t,"P",{});var op=i(zt);y8=a(op,"Now, in this situation you need to make sure that your "),jf=s(op,"CODE",{});var KL=i(jf);w8=a(KL,"PATH"),KL.forEach(o),T8=a(op," and "),Hf=s(op,"CODE",{});var JL=i(Hf);E8=a(JL,"LD_LIBRARY_PATH"),JL.forEach(o),$8=a(op,` environment variables contain
the correct paths to the desired CUDA version. Typically, package installers will set these to contain whatever the
last version was installed. If you encounter the problem, where the package build fails because it can\u2019t find the right
CUDA version despite you having it installed system-wide, it means that you need to adjust the 2 aforementioned
environment variables.`),op.forEach(o),ib=d(t),gd=s(t,"P",{});var XL=i(gd);x8=a(XL,"First, you may look at their contents:"),XL.forEach(o),lb=d(t),u(ri.$$.fragment,t),db=d(t),_d=s(t,"P",{});var QL=i(_d);k8=a(QL,"so you get an idea of what is inside."),QL.forEach(o),cb=d(t),Qr=s(t,"P",{});var e0=i(Qr);A8=a(e0,"It\u2019s possible that "),Bf=s(e0,"CODE",{});var eR=i(Bf);P8=a(eR,"LD_LIBRARY_PATH"),eR.forEach(o),D8=a(e0," is empty."),e0.forEach(o),pb=d(t),rt=s(t,"P",{});var Qi=i(rt);Vf=s(Qi,"CODE",{});var tR=i(Vf);S8=a(tR,"PATH"),tR.forEach(o),q8=a(Qi," lists the locations of where executables can be found and "),Yf=s(Qi,"CODE",{});var oR=i(Yf);O8=a(oR,"LD_LIBRARY_PATH"),oR.forEach(o),C8=a(Qi,` is for where shared libraries
are to looked for. In both cases, earlier entries have priority over the later ones. `),Zf=s(Qi,"CODE",{});var rR=i(Zf);I8=a(rR,":"),rR.forEach(o),U8=a(Qi,` is used to separate multiple
entries.`),Qi.forEach(o),mb=d(t),vd=s(t,"P",{});var aR=i(vd);N8=a(aR,`Now, to tell the build program where to find the specific CUDA toolkit, insert the desired paths to be listed first by
doing:`),aR.forEach(o),hb=d(t),u(ai.$$.fragment,t),ub=d(t),bd=s(t,"P",{});var nR=i(bd);z8=a(nR,"Note that we aren\u2019t overwriting the existing values, but prepending instead."),nR.forEach(o),fb=d(t),Le=s(t,"P",{});var Aa=i(Le);F8=a(Aa,`Of course, adjust the version number, the full path if need be. Check that the directories you assign actually do
exist. `),Kf=s(Aa,"CODE",{});var sR=i(Kf);L8=a(sR,"lib64"),sR.forEach(o),R8=a(Aa," sub-directory is where the various CUDA "),Jf=s(Aa,"CODE",{});var iR=i(Jf);W8=a(iR,".so"),iR.forEach(o),G8=a(Aa," objects, like "),Xf=s(Aa,"CODE",{});var lR=i(Xf);M8=a(lR,"libcudart.so"),lR.forEach(o),j8=a(Aa,` reside, it\u2019s unlikely
that your system will have it named differently, but if it is adjust it to reflect your reality.`),Aa.forEach(o),gb=d(t),No=s(t,"H4",{class:!0});var t0=i(No);ea=s(t0,"A",{id:!0,class:!0,href:!0});var dR=i(ea);Qf=s(dR,"SPAN",{});var cR=i(Qf);u(ni.$$.fragment,cR),cR.forEach(o),dR.forEach(o),H8=d(t0),eg=s(t0,"SPAN",{});var pR=i(eg);B8=a(pR,"Possible problem #3"),pR.forEach(o),t0.forEach(o),_b=d(t),Ft=s(t,"P",{});var rp=i(Ft);V8=a(rp,"Some older CUDA versions may refuse to build with newer compilers. For example, you my have "),tg=s(rp,"CODE",{});var mR=i(tg);Y8=a(mR,"gcc-9"),mR.forEach(o),Z8=a(rp,` but it wants
`),og=s(rp,"CODE",{});var hR=i(og);K8=a(hR,"gcc-7"),hR.forEach(o),J8=a(rp,"."),rp.forEach(o),vb=d(t),yd=s(t,"P",{});var uR=i(yd);X8=a(uR,"There are various ways to go about it."),uR.forEach(o),bb=d(t),wd=s(t,"P",{});var fR=i(wd);Q8=a(fR,"If you can install the latest CUDA toolkit it typically should support the newer compiler."),fR.forEach(o),yb=d(t),ta=s(t,"P",{});var o0=i(ta);eP=a(o0,`Alternatively, you could install the lower version of the compiler in addition to the one you already have, or you may
already have it but it\u2019s not the default one, so the build system can\u2019t see it. If you have `),rg=s(o0,"CODE",{});var gR=i(rg);tP=a(gR,"gcc-7"),gR.forEach(o),oP=a(o0,` installed but the
build system complains it can\u2019t find it, the following might do the trick:`),o0.forEach(o),wb=d(t),u(si.$$.fragment,t),Tb=d(t),M=s(t,"P",{});var ue=i(M);rP=a(ue,"Here, we are making a symlink to "),ag=s(ue,"CODE",{});var _R=i(ag);aP=a(_R,"gcc-7"),_R.forEach(o),nP=a(ue," from "),ng=s(ue,"CODE",{});var vR=i(ng);sP=a(vR,"/usr/local/cuda-10.2/bin/gcc"),vR.forEach(o),iP=a(ue,` and since
`),sg=s(ue,"CODE",{});var bR=i(sg);lP=a(bR,"/usr/local/cuda-10.2/bin/"),bR.forEach(o),dP=a(ue," should be in the "),ig=s(ue,"CODE",{});var yR=i(ig);cP=a(yR,"PATH"),yR.forEach(o),pP=a(ue,` environment variable (see the previous problem\u2019s solution), it
should find `),lg=s(ue,"CODE",{});var wR=i(lg);mP=a(wR,"gcc-7"),wR.forEach(o),hP=a(ue," (and "),dg=s(ue,"CODE",{});var TR=i(dg);uP=a(TR,"g++7"),TR.forEach(o),fP=a(ue,") and then the build will succeed."),ue.forEach(o),Eb=d(t),Td=s(t,"P",{});var ER=i(Td);gP=a(ER,"As always make sure to edit the paths in the example to match your situation."),ER.forEach(o),$b=d(t),zo=s(t,"H3",{class:!0});var r0=i(zo);oa=s(r0,"A",{id:!0,class:!0,href:!0});var $R=i(oa);cg=s($R,"SPAN",{});var xR=i(cg);u(ii.$$.fragment,xR),xR.forEach(o),$R.forEach(o),_P=d(r0),pg=s(r0,"SPAN",{});var kR=i(pg);vP=a(kR,"FairScale"),kR.forEach(o),r0.forEach(o),xb=d(t),u(ra.$$.fragment,t),kb=d(t),Re=s(t,"P",{});var Pa=i(Re);bP=a(Pa,"By integrating "),li=s(Pa,"A",{href:!0,rel:!0});var AR=i(li);yP=a(AR,"FairScale"),AR.forEach(o),wP=a(Pa," the "),Ed=s(Pa,"A",{href:!0});var PR=i(Ed);TP=a(PR,"Trainer"),PR.forEach(o),EP=a(Pa,`
provides support for the following features from `),di=s(Pa,"A",{href:!0,rel:!0});var DR=i(di);$P=a(DR,"the ZeRO paper"),DR.forEach(o),xP=a(Pa,":"),Pa.forEach(o),Ab=d(t),We=s(t,"OL",{});var Da=i(We);mg=s(Da,"LI",{});var SR=i(mg);kP=a(SR,"Optimizer State Sharding"),SR.forEach(o),AP=d(Da),hg=s(Da,"LI",{});var qR=i(hg);PP=a(qR,"Gradient Sharding"),qR.forEach(o),DP=d(Da),ug=s(Da,"LI",{});var OR=i(ug);SP=a(OR,"Model Parameters Sharding (new and very experimental)"),OR.forEach(o),qP=d(Da),fg=s(Da,"LI",{});var CR=i(fg);OP=a(CR,"CPU offload (new and very experimental)"),CR.forEach(o),Da.forEach(o),Pb=d(t),$d=s(t,"P",{});var IR=i($d);CP=a(IR,"You will need at least two GPUs to use this feature."),IR.forEach(o),Db=d(t),ci=s(t,"P",{});var HC=i(ci);gg=s(HC,"STRONG",{});var UR=i(gg);IP=a(UR,"Installation"),UR.forEach(o),UP=a(HC,":"),HC.forEach(o),Sb=d(t),xd=s(t,"P",{});var NR=i(xd);NP=a(NR,"Install the library via pypi:"),NR.forEach(o),qb=d(t),u(pi.$$.fragment,t),Ob=d(t),Lt=s(t,"P",{});var ap=i(Lt);zP=a(ap,"or via "),_g=s(ap,"CODE",{});var zR=i(_g);FP=a(zR,"transformers"),zR.forEach(o),LP=a(ap,"\u2019 "),vg=s(ap,"CODE",{});var FR=i(vg);RP=a(FR,"extras"),FR.forEach(o),WP=a(ap,":"),ap.forEach(o),Cb=d(t),u(mi.$$.fragment,t),Ib=d(t),Rt=s(t,"P",{});var np=i(Rt);GP=a(np,"(available starting from "),bg=s(np,"CODE",{});var LR=i(bg);MP=a(LR,"transformers==4.6.0"),LR.forEach(o),jP=a(np,") or find more details on "),hi=s(np,"A",{href:!0,rel:!0});var RR=i(hi);HP=a(RR,"the FairScale\u2019s GitHub page"),RR.forEach(o),BP=a(np,"."),np.forEach(o),Ub=d(t),aa=s(t,"P",{});var a0=i(aa);VP=a(a0,"If you\u2019re still struggling with the build, first make sure to read "),kd=s(a0,"A",{href:!0});var WR=i(kd);YP=a(WR,"CUDA Extension Installation Notes"),WR.forEach(o),ZP=a(a0,"."),a0.forEach(o),Nb=d(t),Ad=s(t,"P",{});var GR=i(Ad);KP=a(GR,"If it\u2019s still not resolved the build issue, here are a few more ideas."),GR.forEach(o),zb=d(t),ui=s(t,"P",{});var BC=i(ui);yg=s(BC,"CODE",{});var MR=i(yg);JP=a(MR,"fairscale"),MR.forEach(o),XP=a(BC,` seems to have an issue with the recently introduced by pip build isolation feature. If you have a problem
with it, you may want to try one of:`),BC.forEach(o),Fb=d(t),u(fi.$$.fragment,t),Lb=d(t),Pd=s(t,"P",{});var jR=i(Pd);QP=a(jR,"or:"),jR.forEach(o),Rb=d(t),u(gi.$$.fragment,t),Wb=d(t),_i=s(t,"P",{});var VC=i(_i);wg=s(VC,"CODE",{});var HR=i(wg);eD=a(HR,"fairscale"),HR.forEach(o),tD=a(VC," also has issues with building against pytorch-nightly, so if you use it you may have to try one of:"),VC.forEach(o),Gb=d(t),u(vi.$$.fragment,t),Mb=d(t),Dd=s(t,"P",{});var BR=i(Dd);oD=a(BR,"or:"),BR.forEach(o),jb=d(t),u(bi.$$.fragment,t),Hb=d(t),Sd=s(t,"P",{});var VR=i(Sd);rD=a(VR,"Of course, adjust the urls to match the cuda version you use."),VR.forEach(o),Bb=d(t),na=s(t,"P",{});var n0=i(na);aD=a(n0,`If after trying everything suggested you still encounter build issues, please, proceed with the GitHub Issue of
`),yi=s(n0,"A",{href:!0,rel:!0});var YR=i(yi);nD=a(YR,"FairScale"),YR.forEach(o),sD=a(n0,"."),n0.forEach(o),Vb=d(t),wi=s(t,"P",{});var YC=i(wi);Tg=s(YC,"STRONG",{});var ZR=i(Tg);iD=a(ZR,"Usage"),ZR.forEach(o),lD=a(YC,":"),YC.forEach(o),Yb=d(t),Wt=s(t,"P",{});var sp=i(Wt);dD=a(sp,"To use the first version of Sharded data-parallelism, add "),Eg=s(sp,"CODE",{});var KR=i(Eg);cD=a(KR,"--sharded_ddp simple"),KR.forEach(o),pD=a(sp,` to the command line arguments, and
make sure you have added the distributed launcher `),$g=s(sp,"CODE",{});var JR=i($g);mD=a(JR,"-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),JR.forEach(o),hD=a(sp," if you haven\u2019t been using it already."),sp.forEach(o),Zb=d(t),sa=s(t,"P",{});var s0=i(sa);uD=a(s0,"For example here is how you could use it for "),xg=s(s0,"CODE",{});var XR=i(xg);fD=a(XR,"run_translation.py"),XR.forEach(o),gD=a(s0," with 2 GPUs:"),s0.forEach(o),Kb=d(t),u(Ti.$$.fragment,t),Jb=d(t),qd=s(t,"P",{});var QR=i(qd);_D=a(QR,"Notes:"),QR.forEach(o),Xb=d(t),Ge=s(t,"UL",{});var Sa=i(Ge);kg=s(Sa,"LI",{});var eW=i(kg);vD=a(eW,"This feature requires distributed training (so multiple GPUs)."),eW.forEach(o),bD=d(Sa),Ag=s(Sa,"LI",{});var tW=i(Ag);yD=a(tW,"It is not implemented for TPUs."),tW.forEach(o),wD=d(Sa),Ei=s(Sa,"LI",{});var i0=i(Ei);TD=a(i0,"It works with "),Pg=s(i0,"CODE",{});var oW=i(Pg);ED=a(oW,"--fp16"),oW.forEach(o),$D=a(i0," too, to make things even faster."),i0.forEach(o),xD=d(Sa),$i=s(Sa,"LI",{});var l0=i($i);kD=a(l0,"One of the main benefits of enabling "),Dg=s(l0,"CODE",{});var rW=i(Dg);AD=a(rW,"--sharded_ddp simple"),rW.forEach(o),PD=a(l0,` is that it uses a lot less GPU memory, so you should be
able to use significantly larger batch sizes using the same hardware (e.g. 3x and even bigger) which should lead to
significantly shorter training time.`),l0.forEach(o),Sa.forEach(o),Qb=d(t),xi=s(t,"OL",{start:!0});var aW=i(xi);at=s(aW,"LI",{});var qa=i(at);DD=a(qa,"To use the second version of Sharded data-parallelism, add "),Sg=s(qa,"CODE",{});var nW=i(Sg);SD=a(nW,"--sharded_ddp zero_dp_2"),nW.forEach(o),qD=a(qa," or "),qg=s(qa,"CODE",{});var sW=i(qg);OD=a(sW,"--sharded_ddp zero_dp_3"),sW.forEach(o),CD=a(qa," to the command line arguments, and make sure you have added the distributed launcher "),Og=s(qa,"CODE",{});var iW=i(Og);ID=a(iW,"-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),iW.forEach(o),UD=a(qa," if you haven\u2019t been using it already."),qa.forEach(o),aW.forEach(o),ey=d(t),ia=s(t,"P",{});var d0=i(ia);ND=a(d0,"For example here is how you could use it for "),Cg=s(d0,"CODE",{});var lW=i(Cg);zD=a(lW,"run_translation.py"),lW.forEach(o),FD=a(d0," with 2 GPUs:"),d0.forEach(o),ty=d(t),u(ki.$$.fragment,t),oy=d(t),Fo=s(t,"P",{});var _v=i(Fo);Ig=s(_v,"CODE",{});var dW=i(Ig);LD=a(dW,"zero_dp_2"),dW.forEach(o),RD=a(_v," is an optimized version of the simple wrapper, while "),Ug=s(_v,"CODE",{});var cW=i(Ug);WD=a(cW,"zero_dp_3"),cW.forEach(o),GD=a(_v,` fully shards model weights,
gradients and optimizer states.`),_v.forEach(o),ry=d(t),Gt=s(t,"P",{});var ip=i(Gt);MD=a(ip,"Both are compatible with adding "),Ng=s(ip,"CODE",{});var pW=i(Ng);jD=a(pW,"cpu_offload"),pW.forEach(o),HD=a(ip," to enable ZeRO-offload (activate it like this: "),zg=s(ip,"CODE",{});var mW=i(zg);BD=a(mW,'--sharded_ddp "zero_dp_2 cpu_offload"'),mW.forEach(o),VD=a(ip,")."),ip.forEach(o),ay=d(t),Od=s(t,"P",{});var hW=i(Od);YD=a(hW,"Notes:"),hW.forEach(o),ny=d(t),he=s(t,"UL",{});var Qt=i(he);Fg=s(Qt,"LI",{});var uW=i(Fg);ZD=a(uW,"This feature requires distributed training (so multiple GPUs)."),uW.forEach(o),KD=d(Qt),Lg=s(Qt,"LI",{});var fW=i(Lg);JD=a(fW,"It is not implemented for TPUs."),fW.forEach(o),XD=d(Qt),Ai=s(Qt,"LI",{});var c0=i(Ai);QD=a(c0,"It works with "),Rg=s(c0,"CODE",{});var gW=i(Rg);eS=a(gW,"--fp16"),gW.forEach(o),tS=a(c0," too, to make things even faster."),c0.forEach(o),oS=d(Qt),Lo=s(Qt,"LI",{});var lp=i(Lo);rS=a(lp,"The "),Wg=s(lp,"CODE",{});var _W=i(Wg);aS=a(_W,"cpu_offload"),_W.forEach(o),nS=a(lp," additional option requires "),Gg=s(lp,"CODE",{});var vW=i(Gg);sS=a(vW,"--fp16"),vW.forEach(o),iS=a(lp,"."),lp.forEach(o),lS=d(Qt),Mg=s(Qt,"LI",{});var bW=i(Mg);dS=a(bW,`This is an area of active development, so make sure you have a source install of fairscale to use this feature as
some bugs you encounter may have been fixed there already.`),bW.forEach(o),Qt.forEach(o),sy=d(t),Cd=s(t,"P",{});var yW=i(Cd);cS=a(yW,"Known caveats:"),yW.forEach(o),iy=d(t),la=s(t,"UL",{});var p0=i(la);Ro=s(p0,"LI",{});var dp=i(Ro);pS=a(dp,"This feature is incompatible with "),jg=s(dp,"CODE",{});var wW=i(jg);mS=a(wW,"--predict_with_generate"),wW.forEach(o),hS=a(dp," in the "),Hg=s(dp,"EM",{});var TW=i(Hg);uS=a(TW,"run_translation.py"),TW.forEach(o),fS=a(dp," script."),dp.forEach(o),gS=d(p0),$e=s(p0,"LI",{});var eo=i($e);_S=a(eo,"Using "),Bg=s(eo,"CODE",{});var EW=i(Bg);vS=a(EW,"--sharded_ddp zero_dp_3"),EW.forEach(o),bS=a(eo,` requires wrapping each layer of the model in the special container
`),Vg=s(eo,"CODE",{});var $W=i(Vg);yS=a($W,"FullyShardedDataParallelism"),$W.forEach(o),wS=a(eo," of fairscale. It should be used with the option "),Yg=s(eo,"CODE",{});var xW=i(Yg);TS=a(xW,"auto_wrap"),xW.forEach(o),ES=a(eo,` if you are not
doing this yourself: `),Zg=s(eo,"CODE",{});var kW=i(Zg);$S=a(kW,'--sharded_ddp "zero_dp_3 auto_wrap"'),kW.forEach(o),xS=a(eo,"."),eo.forEach(o),p0.forEach(o),ly=d(t),Wo=s(t,"H3",{class:!0});var m0=i(Wo);da=s(m0,"A",{id:!0,class:!0,href:!0});var AW=i(da);Kg=s(AW,"SPAN",{});var PW=i(Kg);u(Pi.$$.fragment,PW),PW.forEach(o),AW.forEach(o),kS=d(m0),Jg=s(m0,"SPAN",{});var DW=i(Jg);AS=a(DW,"PyTorch Fully Sharded Data parallel"),DW.forEach(o),m0.forEach(o),dy=d(t),ca=s(t,"P",{});var h0=i(ca);PS=a(h0,`To accelerate training huge models on larger batch sizes, we can use a fully sharded data parallel model.
This type of data parallel paradigm enables fitting more data and larger models by sharding the optimizer states, gradients and parameters.
To read more about it and the benefits, check out the `),Di=s(h0,"A",{href:!0,rel:!0});var SW=i(Di);DS=a(SW,"Fully Sharded Data Parallel blog"),SW.forEach(o),SS=a(h0,`.
We have integrated the latest PyTorch\u2019s Fully Sharded Data Parallel (FSDP) training feature.
All you need to do is enable it through the config.`),h0.forEach(o),cy=d(t),Si=s(t,"P",{});var ZC=i(Si);Xg=s(ZC,"STRONG",{});var qW=i(Xg);qS=a(qW,"Required PyTorch version for FSDP support"),qW.forEach(o),OS=a(ZC,`: PyTorch Nightly (or 1.12.0 if you read this after it has been released)
as the model saving with FSDP activated is only available with recent fixes.`),ZC.forEach(o),py=d(t),qi=s(t,"P",{});var KC=i(qi);Qg=s(KC,"STRONG",{});var OW=i(Qg);CS=a(OW,"Usage"),OW.forEach(o),IS=a(KC,":"),KC.forEach(o),my=d(t),te=s(t,"UL",{});var Ye=i(te);e_=s(Ye,"LI",{});var CW=i(e_);Oi=s(CW,"P",{});var u0=i(Oi);US=a(u0,`Make sure you have added the distributed launcher
`),t_=s(u0,"CODE",{});var IW=i(t_);NS=a(IW,"-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE"),IW.forEach(o),zS=a(u0," if you haven\u2019t been using it already."),u0.forEach(o),CW.forEach(o),FS=d(Ye),Ci=s(Ye,"LI",{});var f0=i(Ci);Id=s(f0,"P",{});var JC=i(Id);o_=s(JC,"STRONG",{});var UW=i(o_);LS=a(UW,"Sharding Strategy"),UW.forEach(o),RS=a(JC,":"),JC.forEach(o),WS=d(f0),Go=s(f0,"UL",{});var cp=i(Go);Ii=s(cp,"LI",{});var g0=i(Ii);GS=a(g0,`FULL_SHARD : Shards optimizer states + gradients + model parameters across data parallel workers/GPUs.
For this, add `),r_=s(g0,"CODE",{});var NW=i(r_);MS=a(NW,"--fsdp full_shard"),NW.forEach(o),jS=a(g0," to the command line arguments."),g0.forEach(o),HS=d(cp),Ui=s(cp,"LI",{});var _0=i(Ui);BS=a(_0,`SHARD_GRAD_OP : Shards optimizer states + gradients across data parallel workers/GPUs.
For this, add `),a_=s(_0,"CODE",{});var zW=i(a_);VS=a(zW,"--fsdp shard_grad_op"),zW.forEach(o),YS=a(_0," to the command line arguments."),_0.forEach(o),ZS=d(cp),Ni=s(cp,"LI",{});var v0=i(Ni);KS=a(v0,"NO_SHARD : No sharding. For this, add "),n_=s(v0,"CODE",{});var FW=i(n_);JS=a(FW,"--fsdp no_shard"),FW.forEach(o),XS=a(v0," to the command line arguments."),v0.forEach(o),cp.forEach(o),f0.forEach(o),QS=d(Ye),s_=s(Ye,"LI",{});var LW=i(s_);Mo=s(LW,"P",{});var pp=i(Mo);eq=a(pp,`To offload the parameters and gradients to the CPU,
add `),i_=s(pp,"CODE",{});var RW=i(i_);tq=a(RW,'--fsdp "full_shard offload"'),RW.forEach(o),oq=a(pp," or "),l_=s(pp,"CODE",{});var WW=i(l_);rq=a(WW,'--fsdp "shard_grad_op offload"'),WW.forEach(o),aq=a(pp," to the command line arguments."),pp.forEach(o),LW.forEach(o),nq=d(Ye),d_=s(Ye,"LI",{});var GW=i(d_);nt=s(GW,"P",{});var Oa=i(nt);sq=a(Oa,"To automatically recursively wrap layers with FSDP using "),c_=s(Oa,"CODE",{});var MW=i(c_);iq=a(MW,"default_auto_wrap_policy"),MW.forEach(o),lq=a(Oa,`,
add `),p_=s(Oa,"CODE",{});var jW=i(p_);dq=a(jW,'--fsdp "full_shard auto_wrap"'),jW.forEach(o),cq=a(Oa," or "),m_=s(Oa,"CODE",{});var HW=i(m_);pq=a(HW,'--fsdp "shard_grad_op auto_wrap"'),HW.forEach(o),mq=a(Oa," to the command line arguments."),Oa.forEach(o),GW.forEach(o),hq=d(Ye),h_=s(Ye,"LI",{});var BW=i(h_);jo=s(BW,"P",{});var mp=i(jo);uq=a(mp,`To enable both CPU offloading and auto wrapping,
add `),u_=s(mp,"CODE",{});var VW=i(u_);fq=a(VW,'--fsdp "full_shard offload auto_wrap"'),VW.forEach(o),gq=a(mp," or "),f_=s(mp,"CODE",{});var YW=i(f_);_q=a(YW,'--fsdp "shard_grad_op offload auto_wrap"'),YW.forEach(o),vq=a(mp," to the command line arguments."),mp.forEach(o),BW.forEach(o),bq=d(Ye),zi=s(Ye,"LI",{});var b0=i(zi);g_=s(b0,"P",{});var ZW=i(g_);yq=a(ZW,"If auto wrapping is enabled, you can either use transformer based auto wrap policy or size based auto wrap policy."),ZW.forEach(o),wq=d(b0),Fi=s(b0,"UL",{});var y0=i(Fi);xe=s(y0,"LI",{});var to=i(xe);Tq=a(to,"For transformer based auto wrap policy, please add "),__=s(to,"CODE",{});var KW=i(__);Eq=a(KW,"--fsdp_transformer_layer_cls_to_wrap <value>"),KW.forEach(o),$q=a(to,` to command line arguments.
This specifies the transformer layer class name (case-sensitive) to wrap ,e.g, `),v_=s(to,"CODE",{});var JW=i(v_);xq=a(JW,"BertLayer"),JW.forEach(o),kq=a(to,", "),b_=s(to,"CODE",{});var XW=i(b_);Aq=a(XW,"GPTJBlock"),XW.forEach(o),Pq=a(to,", "),y_=s(to,"CODE",{});var QW=i(y_);Dq=a(QW,"T5Block"),QW.forEach(o),Sq=a(to,` \u2026
This is important because submodules that share weights (e.g., embedding layer) should not end up in different FSDP wrapped units.
Using this policy, wrapping happens for each block containing Multi-Head Attention followed by couple of MLP layers.
Remaining layers including the shared embeddings are conviniently wrapped in same outermost FSDP unit.
Therefore, use this for transformer based models.`),to.forEach(o),qq=d(y0),Li=s(y0,"LI",{});var w0=i(Li);Oq=a(w0,"For size based auto wrap policy, please add "),w_=s(w0,"CODE",{});var eG=i(w_);Cq=a(eG,"--fsdp_min_num_params <number>"),eG.forEach(o),Iq=a(w0,` to command line arguments.
It specifies FSDP\u2019s minimum number of parameters for auto wrapping.`),w0.forEach(o),y0.forEach(o),b0.forEach(o),Ye.forEach(o),hy=d(t),Ud=s(t,"P",{});var tG=i(Ud);T_=s(tG,"STRONG",{});var oG=i(T_);Uq=a(oG,"Few caveats to be aware of"),oG.forEach(o),tG.forEach(o),uy=d(t),pa=s(t,"UL",{});var T0=i(pa);Ri=s(T0,"LI",{});var E0=i(Ri);Nq=a(E0,`Mixed precision is currently not supported with FSDP as we wait for PyTorch to fix support for it.
More details in this `),Wi=s(E0,"A",{href:!0,rel:!0});var rG=i(Wi);zq=a(rG,"issues"),rG.forEach(o),Fq=a(E0,"."),E0.forEach(o),Lq=d(T0),Ho=s(T0,"LI",{});var hp=i(Ho);Rq=a(hp,`FSDP currently doesn\u2019t support multiple parameter groups.
More details mentioned in this `),Gi=s(hp,"A",{href:!0,rel:!0});var aG=i(Gi);Wq=a(aG,"issue"),aG.forEach(o),Gq=a(hp,`
(`),E_=s(hp,"CODE",{});var nG=i(E_);Mq=a(nG,"The original model parameters' .grads are not set, meaning that they cannot be optimized separately (which is why we cannot support multiple parameter groups)"),nG.forEach(o),jq=a(hp,")."),hp.forEach(o),T0.forEach(o),fy=d(t),Bo=s(t,"H3",{class:!0});var $0=i(Bo);ma=s($0,"A",{id:!0,class:!0,href:!0});var sG=i(ma);$_=s(sG,"SPAN",{});var iG=i($_);u(Mi.$$.fragment,iG),iG.forEach(o),sG.forEach(o),Hq=d($0),x_=s($0,"SPAN",{});var lG=i(x_);Bq=a(lG,"Using Trainer for accelerated PyTorch Training on Mac"),lG.forEach(o),$0.forEach(o),gy=d(t),Me=s(t,"P",{});var Ca=i(Me);Vq=a(Ca,`With PyTorch v1.12 release, developers and researchers can take advantage of Apple silicon GPUs for significantly faster model training.
This unlocks the ability to perform machine learning workflows like prototyping and fine-tuning locally, right on Mac.
Apple\u2019s Metal Performance Shaders (MPS) as a backend for PyTorch enables this and can be used via the new `),k_=s(Ca,"CODE",{});var dG=i(k_);Yq=a(dG,'"mps"'),dG.forEach(o),Zq=a(Ca,` device.
This will map computational graphs and primitives on the MPS Graph framework and tuned kernels provided by MPS.
For more information please refer official documents `),ji=s(Ca,"A",{href:!0,rel:!0});var cG=i(ji);Kq=a(cG,"Introducing Accelerated PyTorch Training on Mac"),cG.forEach(o),Jq=a(Ca,`
and `),Hi=s(Ca,"A",{href:!0,rel:!0});var pG=i(Hi);Xq=a(pG,"MPS BACKEND"),pG.forEach(o),Qq=a(Ca,"."),Ca.forEach(o),_y=d(t),u(ha.$$.fragment,t),vy=d(t),Nd=s(t,"P",{});var mG=i(Nd);A_=s(mG,"STRONG",{});var hG=i(A_);eO=a(hG,"Benefits of Training and Inference using Apple Silicon Chips"),hG.forEach(o),mG.forEach(o),by=d(t),Mt=s(t,"OL",{});var up=i(Mt);P_=s(up,"LI",{});var uG=i(P_);tO=a(uG,"Enables users to train larger networks or batch sizes locally"),uG.forEach(o),oO=d(up),D_=s(up,"LI",{});var fG=i(D_);rO=a(fG,`Reduces data retrieval latency and provides the GPU with direct access to the full memory store due to unified memory architecture.
Therefore, improving end-to-end performance.`),fG.forEach(o),aO=d(up),S_=s(up,"LI",{});var gG=i(S_);nO=a(gG,"Reduces costs associated with cloud-based development or the need for additional local GPUs."),gG.forEach(o),up.forEach(o),yy=d(t),Vo=s(t,"P",{});var vv=i(Vo);q_=s(vv,"STRONG",{});var _G=i(q_);sO=a(_G,"Pre-requisites"),_G.forEach(o),iO=a(vv,`: To install torch with mps support,
please follow this nice medium article `),Bi=s(vv,"A",{href:!0,rel:!0});var vG=i(Bi);lO=a(vG,"GPU-Acceleration Comes to PyTorch on M1 Macs"),vG.forEach(o),dO=a(vv,"."),vv.forEach(o),wy=d(t),Yo=s(t,"P",{});var bv=i(Yo);O_=s(bv,"STRONG",{});var bG=i(O_);cO=a(bG,"Usage"),bG.forEach(o),pO=a(bv,`:
User has to just pass `),C_=s(bv,"CODE",{});var yG=i(C_);mO=a(yG,"--use_mps_device"),yG.forEach(o),hO=a(bv,` argument.
For example, you can run the offical Glue text classififcation task (from the root folder) using Apple Silicon GPU with below command:`),bv.forEach(o),Ty=d(t),u(Vi.$$.fragment,t),Ey=d(t),zd=s(t,"P",{});var wG=i(zd);I_=s(wG,"STRONG",{});var TG=i(I_);uO=a(TG,"A few caveats to be aware of"),TG.forEach(o),wG.forEach(o),$y=d(t),ua=s(t,"OL",{});var x0=i(ua);Yi=s(x0,"LI",{});var k0=i(Yi);fO=a(k0,`Some PyTorch operations have not been implemented in mps and will throw an error.
One way to get around that is to set the environment variable `),U_=s(k0,"CODE",{});var EG=i(U_);gO=a(EG,"PYTORCH_ENABLE_MPS_FALLBACK=1"),EG.forEach(o),_O=a(k0,`,
which will fallback to CPU for these operations. It still throws a UserWarning however.`),k0.forEach(o),vO=d(x0),ke=s(x0,"LI",{});var oo=i(ke);bO=a(oo,"Distributed setups "),N_=s(oo,"CODE",{});var $G=i(N_);yO=a($G,"gloo"),$G.forEach(o),wO=a(oo," and "),z_=s(oo,"CODE",{});var xG=i(z_);TO=a(xG,"nccl"),xG.forEach(o),EO=a(oo," are not working with "),F_=s(oo,"CODE",{});var kG=i(F_);$O=a(kG,"mps"),kG.forEach(o),xO=a(oo,` device.
This means that currently only single GPU of `),L_=s(oo,"CODE",{});var AG=i(L_);kO=a(AG,"mps"),AG.forEach(o),AO=a(oo," device type can be used."),oo.forEach(o),x0.forEach(o),xy=d(t),jt=s(t,"P",{});var fp=i(jt);PO=a(fp,"Finally, please, remember that, \u{1F917} "),R_=s(fp,"CODE",{});var PG=i(R_);DO=a(PG,"Trainer"),PG.forEach(o),SO=a(fp,` only integrates MPS backend, therefore if you
have any problems or questions with regards to MPS backend usage, please,
file an issue with `),Zi=s(fp,"A",{href:!0,rel:!0});var DG=i(Zi);qO=a(DG,"PyTorch GitHub"),DG.forEach(o),OO=a(fp,"."),fp.forEach(o),ky=d(t),Fd=s(t,"P",{});var SG=i(Fd);CO=a(SG,"Sections that were moved:"),SG.forEach(o),Ay=d(t),w=s(t,"P",{});var E=i(w);IO=a(E,"[ "),Ld=s(E,"A",{href:!0});var qG=i(Ld);UO=a(qG,"DeepSpeed"),qG.forEach(o),W_=s(E,"A",{id:!0}),i(W_).forEach(o),NO=a(E,`
| `),Rd=s(E,"A",{href:!0});var OG=i(Rd);zO=a(OG,"Installation"),OG.forEach(o),G_=s(E,"A",{id:!0}),i(G_).forEach(o),FO=a(E,`
| `),Wd=s(E,"A",{href:!0});var CG=i(Wd);LO=a(CG,"Deployment with multiple GPUs"),CG.forEach(o),M_=s(E,"A",{id:!0}),i(M_).forEach(o),RO=a(E,`
| `),Gd=s(E,"A",{href:!0});var IG=i(Gd);WO=a(IG,"Deployment with one GPU"),IG.forEach(o),j_=s(E,"A",{id:!0}),i(j_).forEach(o),GO=a(E,`
| `),Md=s(E,"A",{href:!0});var UG=i(Md);MO=a(UG,"Deployment in Notebooks"),UG.forEach(o),H_=s(E,"A",{id:!0}),i(H_).forEach(o),jO=a(E,`
| `),jd=s(E,"A",{href:!0});var NG=i(jd);HO=a(NG,"Configuration"),NG.forEach(o),B_=s(E,"A",{id:!0}),i(B_).forEach(o),BO=a(E,`
| `),Hd=s(E,"A",{href:!0});var zG=i(Hd);VO=a(zG,"Passing Configuration"),zG.forEach(o),V_=s(E,"A",{id:!0}),i(V_).forEach(o),YO=a(E,`
| `),Bd=s(E,"A",{href:!0});var FG=i(Bd);ZO=a(FG,"Shared Configuration"),FG.forEach(o),Y_=s(E,"A",{id:!0}),i(Y_).forEach(o),KO=a(E,`
| `),Vd=s(E,"A",{href:!0});var LG=i(Vd);JO=a(LG,"ZeRO"),LG.forEach(o),Z_=s(E,"A",{id:!0}),i(Z_).forEach(o),XO=a(E,`
| `),Yd=s(E,"A",{href:!0});var RG=i(Yd);QO=a(RG,"ZeRO-2 Config"),RG.forEach(o),K_=s(E,"A",{id:!0}),i(K_).forEach(o),eC=a(E,`
| `),Zd=s(E,"A",{href:!0});var WG=i(Zd);tC=a(WG,"ZeRO-3 Config"),WG.forEach(o),J_=s(E,"A",{id:!0}),i(J_).forEach(o),oC=a(E,`
| `),Kd=s(E,"A",{href:!0});var GG=i(Kd);rC=a(GG,"NVMe Support"),GG.forEach(o),X_=s(E,"A",{id:!0}),i(X_).forEach(o),aC=a(E,`
| `),Jd=s(E,"A",{href:!0});var MG=i(Jd);nC=a(MG,"ZeRO-2 vs ZeRO-3 Performance"),MG.forEach(o),Q_=s(E,"A",{id:!0}),i(Q_).forEach(o),sC=a(E,`
| `),Xd=s(E,"A",{href:!0});var jG=i(Xd);iC=a(jG,"ZeRO-2 Example"),jG.forEach(o),ev=s(E,"A",{id:!0}),i(ev).forEach(o),lC=a(E,`
| `),Qd=s(E,"A",{href:!0});var HG=i(Qd);dC=a(HG,"ZeRO-3 Example"),HG.forEach(o),tv=s(E,"A",{id:!0}),i(tv).forEach(o),cC=a(E,`
| `),ec=s(E,"A",{href:!0});var BG=i(ec);pC=a(BG,"Optimizer"),BG.forEach(o),ov=s(E,"A",{id:!0}),i(ov).forEach(o),mC=a(E,`
| `),tc=s(E,"A",{href:!0});var VG=i(tc);hC=a(VG,"Scheduler"),VG.forEach(o),rv=s(E,"A",{id:!0}),i(rv).forEach(o),uC=a(E,`
| `),oc=s(E,"A",{href:!0});var YG=i(oc);fC=a(YG,"fp32 Precision"),YG.forEach(o),av=s(E,"A",{id:!0}),i(av).forEach(o),gC=a(E,`
| `),rc=s(E,"A",{href:!0});var ZG=i(rc);_C=a(ZG,"Automatic Mixed Precision"),ZG.forEach(o),nv=s(E,"A",{id:!0}),i(nv).forEach(o),vC=a(E,`
| `),ac=s(E,"A",{href:!0});var KG=i(ac);bC=a(KG,"Batch Size"),KG.forEach(o),sv=s(E,"A",{id:!0}),i(sv).forEach(o),yC=a(E,`
| `),nc=s(E,"A",{href:!0});var JG=i(nc);wC=a(JG,"Gradient Accumulation"),JG.forEach(o),iv=s(E,"A",{id:!0}),i(iv).forEach(o),TC=a(E,`
| `),sc=s(E,"A",{href:!0});var XG=i(sc);EC=a(XG,"Gradient Clipping"),XG.forEach(o),lv=s(E,"A",{id:!0}),i(lv).forEach(o),$C=a(E,`
| `),ic=s(E,"A",{href:!0});var QG=i(ic);xC=a(QG,"Getting The Model Weights Out"),QG.forEach(o),dv=s(E,"A",{id:!0}),i(dv).forEach(o),kC=a(E,`
]`),E.forEach(o),this.h()},h(){m(T,"name","hf:doc:metadata"),m(T,"content",JSON.stringify(fM)),m(k,"id","trainer"),m(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"),m(k,"href","#trainer"),m($,"class","relative group"),m(ie,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(H,"href","https://github.com/huggingface/transformers/tree/main/examples"),m(H,"rel","nofollow"),m(ae,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(_e,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(ve,"href","https://github.com/NVIDIA/apex"),m(ve,"rel","nofollow"),m(be,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(fl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(gl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(_l,"href","callback"),m(or,"id","transformers.Trainer"),m(or,"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"),m(or,"href","#transformers.Trainer"),m(ao,"class","relative group"),m(vl,"href","/docs/transformers/pr_19907/en/main_classes/model#transformers.PreTrainedModel"),m(ar,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(nr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(pt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(sr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ir,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(mt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ht,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(lr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(qe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ut,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(yl,"href","/docs/transformers/pr_19907/en/main_classes/model#transformers.PreTrainedModel"),m(dr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ft,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(cr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(_t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(mr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(hr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ur,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(vt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Tl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(En,"href","https://github.com/pytorch/pytorch/issues/16266"),m(En,"rel","nofollow"),m(El,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m($l,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(gr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(_r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(yt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(wt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(br,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(yr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.log_metrics"),m(Ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Et,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m($t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(wr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Tr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Er,"id","transformers.Seq2SeqTrainer"),m(Er,"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"),m(Er,"href","#transformers.Seq2SeqTrainer"),m(go,"class","relative group"),m(Ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xr,"id","transformers.TrainingArguments"),m(xr,"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"),m(xr,"href","#transformers.TrainingArguments"),m(wo,"class","relative group"),m(kl,"href","/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.HfArgumentParser"),m(as,"href","https://docs.python.org/3/library/argparse#module-argparse"),m(as,"rel","nofollow"),m(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(kr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(kt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ar,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Pr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Dr,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Sr,"id","transformers.Seq2SeqTrainingArguments"),m(Sr,"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"),m(Sr,"href","#transformers.Seq2SeqTrainingArguments"),m(ko,"class","relative group"),m(Al,"href","/docs/transformers/pr_19907/en/internal/trainer_utils#transformers.HfArgumentParser"),m(gs,"href","https://docs.python.org/3/library/argparse#module-argparse"),m(gs,"rel","nofollow"),m(ot,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(qr,"id","checkpoints"),m(qr,"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"),m(qr,"href","#checkpoints"),m(Po,"class","relative group"),m(Pl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(Dl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(Sl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer.train"),m(Cl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(Nr,"id","logging"),m(Nr,"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"),m(Nr,"href","#logging"),m(Do,"class","relative group"),m(Ul,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(Nl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(Ll,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.TrainingArguments"),m(Rl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(Wl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(Lr,"id","randomness"),m(Lr,"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"),m(Lr,"href","#randomness"),m(So,"class","relative group"),m(Vl,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m($s,"href","https://pytorch.org/docs/stable/notes/randomness"),m($s,"rel","nofollow"),m(Rr,"id","specific-gpus-selection"),m(Rr,"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"),m(Rr,"href","#specific-gpus-selection"),m(qo,"class","relative group"),m(ks,"href","https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html"),m(ks,"rel","nofollow"),m(Ps,"href","https://github.com/huggingface/accelerate"),m(Ps,"rel","nofollow"),m(Ds,"href","https://github.com/microsoft/DeepSpeed"),m(Ds,"rel","nofollow"),m(Zl,"href","Deepspeed"),m(Is,"href","https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html"),m(Is,"rel","nofollow"),m(Rs,"start","2"),m(Br,"id","trainer-integrations"),m(Br,"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"),m(Br,"href","#trainer-integrations"),m(Oo,"class","relative group"),m(ld,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(js,"href","https://github.com/microsoft/DeepSpeed"),m(js,"rel","nofollow"),m(Hs,"href","https://pytorch.org/docs/stable/fsdp.html"),m(Hs,"rel","nofollow"),m(Bs,"href","https://github.com/facebookresearch/fairscale/"),m(Bs,"rel","nofollow"),m(Vs,"href","https://arxiv.org/abs/1910.02054"),m(Vs,"rel","nofollow"),m(dd,"href","#pytorch-fully-sharded-data-parallel"),m(cd,"id","zero-install-notes"),m(Zr,"id","cuda-extension-installation-notes"),m(Zr,"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"),m(Zr,"href","#cuda-extension-installation-notes"),m(Co,"class","relative group"),m(Zs,"href","https://github.com/facebookresearch/fairscale/issues"),m(Zs,"rel","nofollow"),m(Ks,"href","https://github.com/microsoft/DeepSpeed/issues"),m(Ks,"rel","nofollow"),m(Kr,"id","possible-problem-1"),m(Kr,"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"),m(Kr,"href","#possible-problem-1"),m(Io,"class","relative group"),m(ei,"href","https://www.google.com/search?q=ubuntu+cuda+10.2+install"),m(ei,"rel","nofollow"),m(Xr,"id","possible-problem-2"),m(Xr,"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"),m(Xr,"href","#possible-problem-2"),m(Uo,"class","relative group"),m(ea,"id","possible-problem-3"),m(ea,"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"),m(ea,"href","#possible-problem-3"),m(No,"class","relative group"),m(oa,"id","fairscale"),m(oa,"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"),m(oa,"href","#fairscale"),m(zo,"class","relative group"),m(li,"href","https://github.com/facebookresearch/fairscale/"),m(li,"rel","nofollow"),m(Ed,"href","/docs/transformers/pr_19907/en/main_classes/trainer#transformers.Trainer"),m(di,"href","https://arxiv.org/abs/1910.02054"),m(di,"rel","nofollow"),m(hi,"href","https://github.com/facebookresearch/fairscale/#installation"),m(hi,"rel","nofollow"),m(kd,"href","#zero-install-notes"),m(yi,"href","https://github.com/facebookresearch/fairscale/issues"),m(yi,"rel","nofollow"),m(xi,"start","3"),m(da,"id","pytorch-fully-sharded-data-parallel"),m(da,"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"),m(da,"href","#pytorch-fully-sharded-data-parallel"),m(Wo,"class","relative group"),m(Di,"href","https://pytorch.org/blog/introducing-pytorch-fully-sharded-data-parallel-api/"),m(Di,"rel","nofollow"),m(Wi,"href","https://github.com/pytorch/pytorch/issues/75676"),m(Wi,"rel","nofollow"),m(Gi,"href","https://github.com/pytorch/pytorch/issues/76501"),m(Gi,"rel","nofollow"),m(ma,"id","using-trainer-for-accelerated-pytorch-training-on-mac"),m(ma,"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"),m(ma,"href","#using-trainer-for-accelerated-pytorch-training-on-mac"),m(Bo,"class","relative group"),m(ji,"href","https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/"),m(ji,"rel","nofollow"),m(Hi,"href","https://pytorch.org/docs/stable/notes/mps.html"),m(Hi,"rel","nofollow"),m(Bi,"href","https://medium.com/towards-data-science/gpu-acceleration-comes-to-pytorch-on-m1-macs-195c399efcc1"),m(Bi,"rel","nofollow"),m(Zi,"href","https://github.com/pytorch/pytorch/issues"),m(Zi,"rel","nofollow"),m(Ld,"href","./deepspeed#deepspeed-trainer-integration"),m(W_,"id","deepspeed"),m(Rd,"href","./deepspeed#deepspeed-installation"),m(G_,"id","installation"),m(Wd,"href","./deepspeed#deepspeed-multi-gpu"),m(M_,"id","deployment-with-multiple-gpus"),m(Gd,"href","./deepspeed#deepspeed-one-gpu"),m(j_,"id","deployment-with-one-gpu"),m(Md,"href","./deepspeed#deepspeed-notebook"),m(H_,"id","deployment-in-notebooks"),m(jd,"href","./deepspeed#deepspeed-config"),m(B_,"id","configuration"),m(Hd,"href","./deepspeed#deepspeed-config-passing"),m(V_,"id","passing-configuration"),m(Bd,"href","./deepspeed#deepspeed-config-shared"),m(Y_,"id","shared-configuration"),m(Vd,"href","./deepspeed#deepspeed-zero"),m(Z_,"id","zero"),m(Yd,"href","./deepspeed#deepspeed-zero2-config"),m(K_,"id","zero-2-config"),m(Zd,"href","./deepspeed#deepspeed-zero3-config"),m(J_,"id","zero-3-config"),m(Kd,"href","./deepspeed#deepspeed-nvme"),m(X_,"id","nvme-support"),m(Jd,"href","./deepspeed#deepspeed-zero2-zero3-performance"),m(Q_,"id","zero-2-vs-zero-3-performance"),m(Xd,"href","./deepspeed#deepspeed-zero2-example"),m(ev,"id","zero-2-example"),m(Qd,"href","./deepspeed#deepspeed-zero3-example"),m(tv,"id","zero-3-example"),m(ec,"href","./deepspeed#deepspeed-optimizer"),m(ov,"id","optimizer"),m(tc,"href","./deepspeed#deepspeed-scheduler"),m(rv,"id","scheduler"),m(oc,"href","./deepspeed#deepspeed-fp32"),m(av,"id","fp32-precision"),m(rc,"href","./deepspeed#deepspeed-amp"),m(nv,"id","automatic-mixed-precision"),m(ac,"href","./deepspeed#deepspeed-bs"),m(sv,"id","batch-size"),m(nc,"href","./deepspeed#deepspeed-grad-acc"),m(iv,"id","gradient-accumulation"),m(sc,"href","./deepspeed#deepspeed-grad-clip"),m(lv,"id","gradient-clipping"),m(ic,"href","./deepspeed#deepspeed-weight-extraction"),m(dv,"id","getting-the-model-weights-out")},m(t,c){e(document.head,T),p(t,D,c),p(t,$,c),e($,k),e(k,L),f(A,L,null),e($,S),e($,W),e(W,fe),p(t,oe,c),p(t,G,c),e(G,se),e(G,ie),e(ie,re),e(G,le),e(G,H),e(H,Ze),e(G,ge),p(t,z,c),p(t,I,c),e(I,st),e(I,ae),e(ae,it),e(I,lt),e(I,_e),e(_e,Ia),e(I,Ua),p(t,Ke,c),p(t,Pe,c),e(Pe,Na),e(Pe,ve),e(ve,za),e(Pe,Fa),p(t,K,c),p(t,B,c),e(B,el),e(B,be),e(be,Xo),e(B,tl),p(t,ro,c),p(t,C,c),e(C,V),e(V,Qo),e(Qo,ol),e(V,rl),e(C,al),e(C,nl),e(nl,_p),e(_p,A0),e(nl,P0),e(C,D0),e(C,sl),e(sl,vp),e(vp,S0),e(sl,q0),e(C,O0),e(C,il),e(il,bp),e(bp,C0),e(il,I0),e(C,U0),e(C,dt),e(dt,yp),e(yp,N0),e(dt,z0),e(dt,wp),e(wp,F0),e(dt,L0),e(dt,Tp),e(Tp,R0),e(dt,W0),e(C,G0),e(C,ll),e(ll,Ep),e(Ep,M0),e(ll,j0),e(C,H0),e(C,dl),e(dl,$p),e($p,B0),e(dl,V0),e(C,Y0),e(C,cl),e(cl,xp),e(xp,Z0),e(cl,K0),e(C,J0),e(C,pl),e(pl,kp),e(kp,X0),e(pl,Q0),e(C,ew),e(C,ml),e(ml,Ap),e(Ap,tw),e(ml,ow),e(C,rw),e(C,hl),e(hl,Pp),e(Pp,aw),e(hl,nw),e(C,sw),e(C,ul),e(ul,Dp),e(Dp,iw),e(ul,lw),p(t,yv,c),f(er,t,c),p(t,wv,c),p(t,tr,c),e(tr,dw),e(tr,fl),e(fl,cw),e(tr,pw),p(t,Tv,c),f(La,t,c),p(t,Ev,c),p(t,ct,c),e(ct,mw),e(ct,gl),e(gl,hw),e(ct,uw),e(ct,_l),e(_l,fw),e(ct,gw),p(t,$v,c),p(t,ao,c),e(ao,or),e(or,Sp),f(Ra,Sp,null),e(ao,_w),e(ao,qp),e(qp,vw),p(t,xv,c),p(t,b,c),f(Wa,b,null),e(b,bw),e(b,Op),e(Op,yw),e(b,ww),e(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ht,am),e(am,RT),e(ht,WT),e(ht,Je),e(Je,GT),e(Je,nm),e(nm,MT),e(Je,jT),e(Je,sm),e(sm,HT),e(Je,BT),e(Je,im),e(im,VT),e(Je,YT),e(b,ZT),e(b,lr),f(Qa,lr,null),e(lr,KT),e(lr,lm),e(lm,JT),e(b,XT),e(b,qe),f(en,qe,null),e(qe,QT),e(qe,dm),e(dm,eE),e(qe,tE),e(qe,tn),e(tn,oE),e(tn,cm),e(cm,rE),e(tn,aE),e(qe,nE),e(qe,pm),e(pm,sE),e(b,iE),e(b,ut),f(on,ut,null),e(ut,lE),e(ut,no),e(no,dE),e(no,mm),e(mm,cE),e(no,pE),e(no,hm),e(hm,mE),e(no,hE),e(ut,uE),e(ut,um),e(um,fE),e(b,gE),e(b,dr),f(rn,dr,null),e(dr,_E),e(dr,an),e(an,vE),e(an,yl),e(yl,bE),e(an,yE),e(b,wE),e(b,ft),f(nn,ft,null),e(ft,TE),e(ft,sn),e(sn,EE),e(sn,fm),e(fm,$E),e(sn,xE),e(ft,kE),e(ft,gm),e(gm,AE),e(b,PE),e(b,cr),f(ln,cr,null),e(cr,DE),e(cr,_m),e(_m,SE),e(b,qE),e(b,gt),f(dn,gt,null),e(gt,OE),e(gt,cn),e(cn,CE),e(cn,vm),e(vm,IE),e(cn,UE),e(gt,NE),e(gt,bm),e(bm,zE),e(b,FE),e(b,Oe),f(pn,Oe,null),e(Oe,LE),e(Oe,mn),e(mn,RE),e(mn,ym),e(ym,WE),e(mn,GE),e(Oe,ME),e(Oe,so),e(so,jE),e(so,wm),e(wm,HE),e(so,BE),e(so,Tm),e(Tm,VE),e(so,YE),e(Oe,ZE),e(Oe,Em),e(Em,KE),e(b,JE),e(b,_t),f(hn,_t,null),e(_t,XE),e(_t,we),e(we,QE),e(we,$m),e($m,e4),e(we,t4),e(we,xm),e(xm,o4),e(we,r4),e(we,km),e(km,a4),e(we,n4),e(we,Am),e(Am,s4),e(we,i4),e(_t,l4),f(pr,_t,null),e(b,d4),e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Qe,th),e(th,q9),e(Qe,O9),e(P,C9),e(P,ne),e(ne,I9),e(ne,Tl),e(Tl,U9),e(ne,N9),e(ne,oh),e(oh,z9),e(ne,F9),e(ne,rh),e(rh,L9),e(ne,R9),e(ne,ah),e(ah,W9),e(ne,G9),e(ne,nh),e(nh,M9),e(ne,j9),e(P,H9),e(P,U),e(U,B9),e(U,sh),e(sh,V9),e(U,Y9),e(U,ih),e(ih,Z9),e(U,K9),e(U,lh),e(lh,J9),e(U,X9),e(U,dh),e(dh,Q9),e(U,e$),e(U,En),e(En,t$),e(U,o$),e(U,ch),e(ch,r$),e(U,a$),e(U,ph),e(ph,n$),e(U,s$),e(U,mh),e(mh,i$),e(U,l$),e(U,hh),e(hh,d$),e(U,c$),e(U,uh),e(uh,p$),e(U,m$),e(P,h$),e(P,Ee),e(Ee,u$),e(Ee,El),e(El,f$),e(Ee,g$),e(Ee,fh),e(fh,_$),e(Ee,v$),e(Ee,$l),e($l,b$),e(Ee,y$),e(Ee,gh),e(gh,w$),e(Ee,T$),e(P,E$),e(P,_h),e(_h,$$),e(b,x$),e(b,gr),f($n,gr,null),e(gr,k$),e(gr,vh),e(vh,A$),e(b,P$),e(b,_r),f(xn,_r,null),e(_r,D$),e(_r,kn),e(kn,S$),e(kn,bh),e(bh,q$),e(kn,O$),e(b,C$),e(b,yt),f(An,yt,null),e(yt,I$),e(yt,Pn),e(Pn,U$),e(Pn,yh),e(yh,N$),e(Pn,z$),e(yt,F$),e(yt,Dn),e(Dn,L$),e(Dn,wh),e(wh,R$),e(Dn,W$),e(b,G$),e(b,X),f(Sn,X,null),e(X,M$),e(X,Th),e(Th,j$),e(X,H$),e(X,qn),e(qn,B$),e(qn,Eh),e(Eh,V$),e(qn,Y$),e(X,Z$),f(vr,X,null),e(X,K$),e(X,On),e(On,J$),e(On,$h),e($h,X$),e(On,Q$),e(X,e3),e(X,co),e(co,po),e(po,t3),e(po,xh),e(xh,o3),e(po,r3),e(po,kh),e(kh,a3),e(po,n3),e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gd,WO),e(w,j_),e(w,GO),e(w,Md),e(Md,MO),e(w,H_),e(w,jO),e(w,jd),e(jd,HO),e(w,B_),e(w,BO),e(w,Hd),e(Hd,VO),e(w,V_),e(w,YO),e(w,Bd),e(Bd,ZO),e(w,Y_),e(w,KO),e(w,Vd),e(Vd,JO),e(w,Z_),e(w,XO),e(w,Yd),e(Yd,QO),e(w,K_),e(w,eC),e(w,Zd),e(Zd,tC),e(w,J_),e(w,oC),e(w,Kd),e(Kd,rC),e(w,X_),e(w,aC),e(w,Jd),e(Jd,nC),e(w,Q_),e(w,sC),e(w,Xd),e(Xd,iC),e(w,ev),e(w,lC),e(w,Qd),e(Qd,dC),e(w,tv),e(w,cC),e(w,ec),e(ec,pC),e(w,ov),e(w,mC),e(w,tc),e(tc,hC),e(w,rv),e(w,uC),e(w,oc),e(oc,fC),e(w,av),e(w,gC),e(w,rc),e(rc,_C),e(w,nv),e(w,vC),e(w,ac),e(ac,bC),e(w,sv),e(w,yC),e(w,nc),e(nc,wC),e(w,iv),e(w,TC),e(w,sc),e(sc,EC),e(w,lv),e(w,$C),e(w,ic),e(ic,xC),e(w,dv),e(w,kC),Py=!0},p(t,[c]){const Ki={};c&2&&(Ki.$$scope={dirty:c,ctx:t}),er.$set(Ki);const cv={};c&2&&(cv.$$scope={dirty:c,ctx:t}),pr.$set(cv);const pv={};c&2&&(pv.$$scope={dirty:c,ctx:t}),fr.$set(pv);const mv={};c&2&&(mv.$$scope={dirty:c,ctx:t}),vr.$set(mv);const Zo={};c&2&&(Zo.$$scope={dirty:c,ctx:t}),$r.$set(Zo);const hv={};c&2&&(hv.$$scope={dirty:c,ctx:t}),ra.$set(hv);const uv={};c&2&&(uv.$$scope={dirty:c,ctx:t}),ha.$set(uv)},i(t){Py||(g(A.$$.fragment,t),g(er.$$.fragment,t),g(La.$$.fragment,t),g(Ra.$$.fragment,t),g(Wa.$$.fragment,t),g(Ga.$$.fragment,t),g(ja.$$.fragment,t),g(Ba.$$.fragment,t),g(Va.$$.fragment,t),g(Ya.$$.fragment,t),g(Ka.$$.fragment,t),g(Xa.$$.fragment,t),g(Qa.$$.fragment,t),g(en.$$.fragment,t),g(on.$$.fragment,t),g(rn.$$.fragment,t),g(nn.$$.fragment,t),g(ln.$$.fragment,t),g(dn.$$.fragment,t),g(pn.$$.fragment,t),g(hn.$$.fragment,t),g(pr.$$.fragment,t),g(un.$$.fragment,t),g(gn.$$.fragment,t),g(_n.$$.fragment,t),g(bn.$$.fragment,t),g(wn.$$.fragment,t),g(fr.$$.fragment,t),g($n.$$.fragment,t),g(xn.$$.fragment,t),g(An.$$.fragment,t),g(Sn.$$.fragment,t),g(vr.$$.fragment,t),g(Cn.$$.fragment,t),g(In.$$.fragment,t),g(Un.$$.fragment,t),g(Nn.$$.fragment,t),g(Fn.$$.fragment,t),g(Wn.$$.fragment,t),g(Mn.$$.fragment,t),g(jn.$$.fragment,t),g(Bn.$$.fragment,t),g(Vn.$$.fragment,t),g(Yn.$$.fragment,t),g(Zn.$$.fragment,t),g(Kn.$$.fragment,t),g(Xn.$$.fragment,t),g($r.$$.fragment,t),g(ts.$$.fragment,t),g(os.$$.fragment,t),g(ns.$$.fragment,t),g(is.$$.fragment,t),g(ls.$$.fragment,t),g(ds.$$.fragment,t),g(ps.$$.fragment,t),g(ms.$$.fragment,t),g(hs.$$.fragment,t),g(us.$$.fragment,t),g(_s.$$.fragment,t),g(vs.$$.fragment,t),g(bs.$$.fragment,t),g(ys.$$.fragment,t),g(ws.$$.fragment,t),g(Ts.$$.fragment,t),g(Es.$$.fragment,t),g(xs.$$.fragment,t),g(As.$$.fragment,t),g(Ss.$$.fragment,t),g(qs.$$.fragment,t),g(Os.$$.fragment,t),g(Cs.$$.fragment,t),g(Us.$$.fragment,t),g(Ns.$$.fragment,t),g(zs.$$.fragment,t),g(Ls.$$.fragment,t),g(Ws.$$.fragment,t),g(Gs.$$.fragment,t),g(Ms.$$.fragment,t),g(Ys.$$.fragment,t),g(Js.$$.fragment,t),g(Xs.$$.fragment,t),g(Qs.$$.fragment,t),g(ti.$$.fragment,t),g(oi.$$.fragment,t),g(ri.$$.fragment,t),g(ai.$$.fragment,t),g(ni.$$.fragment,t),g(si.$$.fragment,t),g(ii.$$.fragment,t),g(ra.$$.fragment,t),g(pi.$$.fragment,t),g(mi.$$.fragment,t),g(fi.$$.fragment,t),g(gi.$$.fragment,t),g(vi.$$.fragment,t),g(bi.$$.fragment,t),g(Ti.$$.fragment,t),g(ki.$$.fragment,t),g(Pi.$$.fragment,t),g(Mi.$$.fragment,t),g(ha.$$.fragment,t),g(Vi.$$.fragment,t),Py=!0)},o(t){_(A.$$.fragment,t),_(er.$$.fragment,t),_(La.$$.fragment,t),_(Ra.$$.fragment,t),_(Wa.$$.fragment,t),_(Ga.$$.fragment,t),_(ja.$$.fragment,t),_(Ba.$$.fragment,t),_(Va.$$.fragment,t),_(Ya.$$.fragment,t),_(Ka.$$.fragment,t),_(Xa.$$.fragment,t),_(Qa.$$.fragment,t),_(en.$$.fragment,t),_(on.$$.fragment,t),_(rn.$$.fragment,t),_(nn.$$.fragment,t),_(ln.$$.fragment,t),_(dn.$$.fragment,t),_(pn.$$.fragment,t),_(hn.$$.fragment,t),_(pr.$$.fragment,t),_(un.$$.fragment,t),_(gn.$$.fragment,t),_(_n.$$.fragment,t),_(bn.$$.fragment,t),_(wn.$$.fragment,t),_(fr.$$.fragment,t),_($n.$$.fragment,t),_(xn.$$.fragment,t),_(An.$$.fragment,t),_(Sn.$$.fragment,t),_(vr.$$.fragment,t),_(Cn.$$.fragment,t),_(In.$$.fragment,t),_(Un.$$.fragment,t),_(Nn.$$.fragment,t),_(Fn.$$.fragment,t),_(Wn.$$.fragment,t),_(Mn.$$.fragment,t),_(jn.$$.fragment,t),_(Bn.$$.fragment,t),_(Vn.$$.fragment,t),_(Yn.$$.fragment,t),_(Zn.$$.fragment,t),_(Kn.$$.fragment,t),_(Xn.$$.fragment,t),_($r.$$.fragment,t),_(ts.$$.fragment,t),_(os.$$.fragment,t),_(ns.$$.fragment,t),_(is.$$.fragment,t),_(ls.$$.fragment,t),_(ds.$$.fragment,t),_(ps.$$.fragment,t),_(ms.$$.fragment,t),_(hs.$$.fragment,t),_(us.$$.fragment,t),_(_s.$$.fragment,t),_(vs.$$.fragment,t),_(bs.$$.fragment,t),_(ys.$$.fragment,t),_(ws.$$.fragment,t),_(Ts.$$.fragment,t),_(Es.$$.fragment,t),_(xs.$$.fragment,t),_(As.$$.fragment,t),_(Ss.$$.fragment,t),_(qs.$$.fragment,t),_(Os.$$.fragment,t),_(Cs.$$.fragment,t),_(Us.$$.fragment,t),_(Ns.$$.fragment,t),_(zs.$$.fragment,t),_(Ls.$$.fragment,t),_(Ws.$$.fragment,t),_(Gs.$$.fragment,t),_(Ms.$$.fragment,t),_(Ys.$$.fragment,t),_(Js.$$.fragment,t),_(Xs.$$.fragment,t),_(Qs.$$.fragment,t),_(ti.$$.fragment,t),_(oi.$$.fragment,t),_(ri.$$.fragment,t),_(ai.$$.fragment,t),_(ni.$$.fragment,t),_(si.$$.fragment,t),_(ii.$$.fragment,t),_(ra.$$.fragment,t),_(pi.$$.fragment,t),_(mi.$$.fragment,t),_(fi.$$.fragment,t),_(gi.$$.fragment,t),_(vi.$$.fragment,t),_(bi.$$.fragment,t),_(Ti.$$.fragment,t),_(ki.$$.fragment,t),_(Pi.$$.fragment,t),_(Mi.$$.fragment,t),_(ha.$$.fragment,t),_(Vi.$$.fragment,t),Py=!1},d(t){o(T),t&&o(D),t&&o($),v(A),t&&o(oe),t&&o(G),t&&o(z),t&&o(I),t&&o(Ke),t&&o(Pe),t&&o(K),t&&o(B),t&&o(ro),t&&o(C),t&&o(yv),v(er,t),t&&o(wv),t&&o(tr),t&&o(Tv),v(La,t),t&&o(Ev),t&&o(ct),t&&o($v),t&&o(ao),v(Ra),t&&o(xv),t&&o(b),v(Wa),v(Ga),v(ja),v(Ba),v(Va),v(Ya),v(Ka),v(Xa),v(Qa),v(en),v(on),v(rn),v(nn),v(ln),v(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(y1),t&&o(qt),t&&o(w1),t&&o(Ot),t&&o(T1),v(Us,t),t&&o(E1),t&&o(td),t&&o($1),v(Ns,t),t&&o(x1),t&&o(od),t&&o(k1),v(zs,t),t&&o(A1),t&&o(rd),t&&o(P1),t&&o(ad),t&&o(D1),t&&o(jr),t&&o(S1),t&&o(nd),t&&o(q1),v(Ls,t),t&&o(O1),t&&o(Rs),t&&o(C1),v(Ws,t),t&&o(I1),t&&o(Ct),t&&o(U1),t&&o(sd),t&&o(N1),v(Gs,t),t&&o(z1),t&&o(id),t&&o(F1),t&&o(Hr),t&&o(L1),t&&o(Oo),v(Ms),t&&o(R1),t&&o(Vr),t&&o(W1),t&&o(me),t&&o(G1),t&&o(Yr),t&&o(M1),t&&o(cd),t&&o(j1),t&&o(Co),v(Ys),t&&o(H1),t&&o(pd),t&&o(B1),t&&o(It),t&&o(V1),t&&o(md),t&&o(Y1),v(Js,t),t&&o(Z1),t&&o(hd),t&&o(K1),t&&o(Ut),t&&o(J1),t&&o(Io),v(Xs),t&&o(X1),t&&o(ud),t&&o(Q1),t&&o(Fe),t&&o(eb),t&&o(Nt),t&&o(tb),v(Qs,t),t&&o(ob),t&&o(Jr),t&&o(rb),t&&o(Uo),v(ti),t&&o(ab),t&&o(fd),t&&o(nb),v(oi,t),t&&o(sb),t&&o(zt),t&&o(ib),t&&o(gd),t&&o(lb),v(ri,t),t&&o(db),t&&o(_d),t&&o(cb),t&&o(Qr),t&&o(pb),t&&o(rt),t&&o(mb),t&&o(vd),t&&o(hb),v(ai,t),t&&o(ub),t&&o(bd),t&&o(fb),t&&o(Le),t&&o(gb),t&&o(No),v(ni),t&&o(_b),t&&o(Ft),t&&o(vb),t&&o(yd),t&&o(bb),t&&o(wd),t&&o(yb),t&&o(ta),t&&o(wb),v(si,t),t&&o(Tb),t&&o(M),t&&o(Eb),t&&o(Td),t&&o($b),t&&o(zo),v(ii),t&&o(xb),v(ra,t),t&&o(kb),t&&o(Re),t&&o(Ab),t&&o(We),t&&o(Pb),t&&o($d),t&&o(Db),t&&o(ci),t&&o(Sb),t&&o(xd),t&&o(qb),v(pi,t),t&&o(Ob),t&&o(Lt),t&&o(Cb),v(mi,t),t&&o(Ib),t&&o(Rt),t&&o(Ub),t&&o(aa),t&&o(Nb),t&&o(Ad),t&&o(zb),t&&o(ui),t&&o(Fb),v(fi,t),t&&o(Lb),t&&o(Pd),t&&o(Rb),v(gi,t),t&&o(Wb),t&&o(_i),t&&o(Gb),v(vi,t),t&&o(Mb),t&&o(Dd),t&&o(jb),v(bi,t),t&&o(Hb),t&&o(Sd),t&&o(Bb),t&&o(na),t&&o(Vb),t&&o(wi),t&&o(Yb),t&&o(Wt),t&&o(Zb),t&&o(sa),t&&o(Kb),v(Ti,t),t&&o(Jb),t&&o(qd),t&&o(Xb),t&&o(Ge),t&&o(Qb),t&&o(xi),t&&o(ey),t&&o(ia),t&&o(ty),v(ki,t),t&&o(oy),t&&o(Fo),t&&o(ry),t&&o(Gt),t&&o(ay),t&&o(Od),t&&o(ny),t&&o(he),t&&o(sy),t&&o(Cd),t&&o(iy),t&&o(la),t&&o(ly),t&&o(Wo),v(Pi),t&&o(dy),t&&o(ca),t&&o(cy),t&&o(Si),t&&o(py),t&&o(qi),t&&o(my),t&&o(te),t&&o(hy),t&&o(Ud),t&&o(uy),t&&o(pa),t&&o(fy),t&&o(Bo),v(Mi),t&&o(gy),t&&o(Me),t&&o(_y),v(ha,t),t&&o(vy),t&&o(Nd),t&&o(by),t&&o(Mt),t&&o(yy),t&&o(Vo),t&&o(wy),t&&o(Yo),t&&o(Ty),v(Vi,t),t&&o(Ey),t&&o(zd),t&&o($y),t&&o(ua),t&&o(xy),t&&o(jt),t&&o(ky),t&&o(Fd),t&&o(Ay),t&&o(w)}}}const fM={local:"trainer",sections:[{local:"transformers.Trainer",title:"Trainer"},{local:"transformers.Seq2SeqTrainer",title:"Seq2SeqTrainer"},{local:"transformers.TrainingArguments",title:"TrainingArguments"},{local:"transformers.Seq2SeqTrainingArguments",title:"Seq2SeqTrainingArguments"},{local:"checkpoints",title:"Checkpoints"},{local:"logging",title:"Logging"},{local:"randomness",title:"Randomness"},{local:"specific-gpus-selection",title:"Specific GPUs Selection"},{local:"trainer-integrations",sections:[{local:"cuda-extension-installation-notes",sections:[{local:"possible-problem-1",title:"Possible problem #1"},{local:"possible-problem-2",title:"Possible problem #2"},{local:"possible-problem-3",title:"Possible problem #3"}],title:"CUDA Extension Installation Notes"},{local:"fairscale",title:"FairScale"},{local:"pytorch-fully-sharded-data-parallel",title:"PyTorch Fully Sharded Data parallel"},{local:"using-trainer-for-accelerated-pytorch-training-on-mac",title:"Using Trainer for accelerated PyTorch Training on Mac "}],title:"Trainer Integrations"}],title:"Trainer"};function gM(Z){return aM(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class EM extends eM{constructor(T){super();tM(this,T,gM,uM,oM,{})}}export{EM as default,fM as metadata};
