import{s as hl,o as Tl}from"../chunks/scheduler.defa9a21.js";import{S as bl,i as fl,g as r,s,r as c,A as Ul,h as i,f as t,c as n,j as wl,u as o,x as p,k as Jl,y as gl,a,v as M,d as m,t as d,w as y,m as Il,n as _l}from"../chunks/index.fe795e71.js";import{T as kl}from"../chunks/Tip.179eb360.js";import{C as u}from"../chunks/CodeBlock.204b6c34.js";import{H as re,E as Al}from"../chunks/getInferenceSnippets.2234a8dd.js";function Bl(ie){let j;return{c(){j=Il(`Trackers built in Accelerate will automatically execute on the correct process, 
  so if a tracker is only meant to be ran on the main process it will do so 
  automatically.`)},l(w){j=_l(w,`Trackers built in Accelerate will automatically execute on the correct process, 
  so if a tracker is only meant to be ran on the main process it will do so 
  automatically.`)},m(w,h){a(w,j,h)},d(w){w&&t(j)}}}function Cl(ie){let j,w,h,ce,T,oe,b,Ke=`There are a large number of experiment tracking APIs available, however getting them all to work in a multi-processing environment can oftentimes be complex.
Accelerate provides a general tracking API that can be used to log useful items during your script through <code>Accelerator.log()</code>`,pe,f,Me,U,Pe="Currently <code>Accelerate</code> supports eight trackers out-of-the-box:",me,g,De="<li>TensorBoard</li> <li>WandB</li> <li>Trackio</li> <li>CometML</li> <li>Aim</li> <li>MLFlow</li> <li>ClearML</li> <li>DVCLive</li>",de,I,Oe="To use any of them, pass in the selected type(s) to the <code>log_with</code> parameter in <code>Accelerate</code>:",ye,_,je,k,el="At the start of your experiment <code>Accelerator.init_trackers()</code> should be used to setup your project, and potentially add any experiment hyperparameters to be logged:",ue,A,we,B,ll=`When you are ready to log any data, <code>Accelerator.log()</code> should be used.
A <code>step</code> can also be passed in to correlate the data with a particular step in the training loop.`,Je,C,he,$,tl='Once you’ve finished training, make sure to run <a href="/docs/accelerate/v1.10.1/en/package_reference/accelerator#accelerate.Accelerator.end_training">Accelerator.end_training()</a> so that all the trackers can run their finish functionalities if they have any.',Te,Z,be,G,al="A full example is below:",fe,v,Ue,W,sl=`If a tracker requires a directory to save data to, such as <code>TensorBoard</code>, then pass the directory path to <code>project_dir</code>. The <code>project_dir</code> parameter is useful
when there are other configurations to be combined with in the <a href="/docs/accelerate/v1.10.1/en/package_reference/utilities#accelerate.utils.ProjectConfiguration">ProjectConfiguration</a> data class. For example, you can save the TensorBoard data to <code>project_dir</code> and everything else can be logged in the <code>logging_dir</code> parameter of [<code>~utils.ProjectConfiguration</code>:`,ge,X,Ie,Y,_e,R,nl=`To implement a new tracker to be used in <code>Accelerator</code>, a new one can be made through implementing the <code>GeneralTracker</code> class.
Every tracker must implement three functions and have three properties:`,ke,V,rl="<li><p><code>__init__</code>:</p> <ul><li>Should store a <code>run_name</code> and initialize the tracker API of the integrated library.</li> <li>If a tracker stores their data locally (such as TensorBoard), a <code>logging_dir</code> parameter can be added.</li></ul></li> <li><p><code>store_init_configuration</code>:</p> <ul><li>Should take in a <code>values</code> dictionary and store them as a one-time experiment configuration</li></ul></li> <li><p><code>log</code>:</p> <ul><li>Should take in a <code>values</code> dictionary and a <code>step</code>, and should log them to the run</li></ul></li> <li><p><code>name</code> (<code>str</code>):</p> <ul><li>A unique string name for the tracker, such as <code>&quot;wandb&quot;</code> for the wandb tracker.</li> <li>This will be used for interacting with this tracker specifically</li></ul></li> <li><p><code>requires_logging_directory</code> (<code>bool</code>):</p> <ul><li>Whether a <code>logging_dir</code> is needed for this particular tracker and if it uses one.</li></ul></li> <li><p><code>tracker</code>:</p> <ul><li>This should be implemented as a <code>@property</code> function</li> <li>Should return the internal tracking mechanism the library uses, such as the <code>run</code> object for <code>wandb</code>.</li></ul></li>",Ae,N,il='Each method should also utilize the <a href="/docs/accelerate/v1.10.1/en/package_reference/state#accelerate.PartialState">state.PartialState</a> class if the logger should only be executed on the main process for instance.',Be,Q,cl=`A brief example can be seen below with an integration with Weights and Biases, containing only the relevant information and logging just on
the main process:`,Ce,E,$e,F,ol=`When you are ready to build your <code>Accelerator</code> object, pass in an <strong>instance</strong> of your tracker to <code>Accelerator.log_with</code> to have it automatically
be used with the API:`,Ze,H,Ge,x,pl="These also can be mixed with existing trackers, including with <code>&quot;all&quot;</code>:",ve,S,We,z,Xe,q,Ml=`If some custom interactions with a tracker might be wanted directly, you can quickly access one using the
<a href="/docs/accelerate/v1.10.1/en/package_reference/accelerator#accelerate.Accelerator.get_tracker">Accelerator.get_tracker()</a> method. Just pass in the string corresponding to a tracker’s <code>.name</code> attribute
and it will return that tracker on the main process.`,Ye,L,ml="This example shows doing so with wandb:",Re,K,Ve,P,dl="From there you can interact with <code>wandb</code>’s <code>run</code> object like normal:",Ne,D,Qe,J,Ee,O,yl=`If you want to truly remove Accelerate’s wrapping entirely, you can
achieve the same outcome with:`,Fe,ee,He,le,xe,te,jl="If a library has an API that does not follow a strict <code>.log</code> with an overall dictionary such as Neptune.AI, logging can be done manually under an <code>if accelerator.is_main_process</code> statement:",Se,ae,ze,se,qe,ne,Le;return T=new re({props:{title:"Experiment trackers",local:"experiment-trackers",headingTag:"h1"}}),f=new re({props:{title:"Integrated Trackers",local:"integrated-trackers",headingTag:"h2"}}),_=new u({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQWZyb20lMjBhY2NlbGVyYXRlLnV0aWxzJTIwaW1wb3J0JTIwTG9nZ2VyVHlwZSUwQSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IobG9nX3dpdGglM0QlMjJhbGwlMjIpJTIwJTIwJTIzJTIwRm9yJTIwYWxsJTIwYXZhaWxhYmxlJTIwdHJhY2tlcnMlMjBpbiUyMHRoZSUyMGVudmlyb25tZW50JTBBYWNjZWxlcmF0b3IlMjAlM0QlMjBBY2NlbGVyYXRvcihsb2dfd2l0aCUzRCUyMndhbmRiJTIyKSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IobG9nX3dpdGglM0QlNUIlMjJ3YW5kYiUyMiUyQyUyMExvZ2dlclR5cGUuVEVOU09SQk9BUkQlNUQp",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator
<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> LoggerType

accelerator = Accelerator(log_with=<span class="hljs-string">&quot;all&quot;</span>)  <span class="hljs-comment"># For all available trackers in the environment</span>
accelerator = Accelerator(log_with=<span class="hljs-string">&quot;wandb&quot;</span>)
accelerator = Accelerator(log_with=[<span class="hljs-string">&quot;wandb&quot;</span>, LoggerType.TENSORBOARD])`,wrap:!1}}),A=new u({props:{code:"aHBzJTIwJTNEJTIwJTdCJTIybnVtX2l0ZXJhdGlvbnMlMjIlM0ElMjA1JTJDJTIwJTIybGVhcm5pbmdfcmF0ZSUyMiUzQSUyMDFlLTIlN0QlMEFhY2NlbGVyYXRvci5pbml0X3RyYWNrZXJzKCUyMm15X3Byb2plY3QlMjIlMkMlMjBjb25maWclM0RocHMp",highlighted:`hps = {<span class="hljs-string">&quot;num_iterations&quot;</span>: <span class="hljs-number">5</span>, <span class="hljs-string">&quot;learning_rate&quot;</span>: <span class="hljs-number">1e-2</span>}
accelerator.init_trackers(<span class="hljs-string">&quot;my_project&quot;</span>, config=hps)`,wrap:!1}}),C=new u({props:{code:"YWNjZWxlcmF0b3IubG9nKCU3QiUyMnRyYWluX2xvc3MlMjIlM0ElMjAxLjEyJTJDJTIwJTIydmFsaWRfbG9zcyUyMiUzQSUyMDAuOCU3RCUyQyUyMHN0ZXAlM0QxKQ==",highlighted:'accelerator.log({<span class="hljs-string">&quot;train_loss&quot;</span>: <span class="hljs-number">1.12</span>, <span class="hljs-string">&quot;valid_loss&quot;</span>: <span class="hljs-number">0.8</span>}, step=<span class="hljs-number">1</span>)',wrap:!1}}),Z=new u({props:{code:"YWNjZWxlcmF0b3IuZW5kX3RyYWluaW5nKCk=",highlighted:"accelerator.end_training()",wrap:!1}}),v=new u({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUwQWFjY2VsZXJhdG9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HMlMjAlM0QlMjBpbnB1dHMudG8oZGV2aWNlKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRhcmdldHMlMjAlM0QlMjB0YXJnZXRzLnRvKGRldmljZSklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbXlfbW9kZWwoaW5wdXRzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvc3MlMjAlM0QlMjBteV9sb3NzX2Z1bmN0aW9uKG91dHB1dHMlMkMlMjB0YXJnZXRzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjY2VsZXJhdG9yLmJhY2t3YXJkKGxvc3MpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbXlfb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjY2VsZXJhdG9yLmxvZyglN0IlMjJ0cmFpbmluZ19sb3NzJTIyJTNBJTIwbG9zcyU3RCUyQyUyMHN0ZXAlM0RzdGVwKSUwQWFjY2VsZXJhdG9yLmVuZF90cmFpbmluZygp",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

accelerator = Accelerator(log_with=<span class="hljs-string">&quot;all&quot;</span>)
config = {
    <span class="hljs-string">&quot;num_iterations&quot;</span>: <span class="hljs-number">5</span>,
    <span class="hljs-string">&quot;learning_rate&quot;</span>: <span class="hljs-number">1e-2</span>,
    <span class="hljs-string">&quot;loss_function&quot;</span>: <span class="hljs-built_in">str</span>(my_loss_function),
}

accelerator.init_trackers(<span class="hljs-string">&quot;example_project&quot;</span>, config=config)

my_model, my_optimizer, my_training_dataloader = accelerator.prepare(my_model, my_optimizer, my_training_dataloader)
device = accelerator.device
my_model.to(device)

<span class="hljs-keyword">for</span> iteration <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(config[<span class="hljs-string">&quot;num_iterations&quot;</span>]):
    <span class="hljs-keyword">for</span> step, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(my_training_dataloader):
        my_optimizer.zero_grad()
        inputs, targets = batch
        inputs = inputs.to(device)
        targets = targets.to(device)
        outputs = my_model(inputs)
        loss = my_loss_function(outputs, targets)
        accelerator.backward(loss)
        my_optimizer.step()
        accelerator.log({<span class="hljs-string">&quot;training_loss&quot;</span>: loss}, step=step)
accelerator.end_training()`,wrap:!1}}),X=new u({props:{code:"YWNjZWxlcmF0b3IlMjAlM0QlMjBBY2NlbGVyYXRvcihsb2dfd2l0aCUzRCUyMnRlbnNvcmJvYXJkJTIyJTJDJTIwcHJvamVjdF9kaXIlM0QlMjIuJTIyKSUwQSUwQSUyMyUyMHVzZSUyMHdpdGglMjBQcm9qZWN0Q29uZmlndXJhdGlvbiUwQWNvbmZpZyUyMCUzRCUyMFByb2plY3RDb25maWd1cmF0aW9uKHByb2plY3RfZGlyJTNEJTIyLiUyMiUyQyUyMGxvZ2dpbmdfZGlyJTNEJTIyYW5vdGhlciUyRmRpcmVjdG9yeSUyMiklMEFhY2NlbGVyYXRvciUyMCUzRCUyMEFjY2VsZXJhdG9yKGxvZ193aXRoJTNEJTIydGVuc29yYm9hcmQlMjIlMkMlMjBwcm9qZWN0X2NvbmZpZyUzRGNvbmZpZyk=",highlighted:`accelerator = Accelerator(log_with=<span class="hljs-string">&quot;tensorboard&quot;</span>, project_dir=<span class="hljs-string">&quot;.&quot;</span>)

<span class="hljs-comment"># use with ProjectConfiguration</span>
config = ProjectConfiguration(project_dir=<span class="hljs-string">&quot;.&quot;</span>, logging_dir=<span class="hljs-string">&quot;another/directory&quot;</span>)
accelerator = Accelerator(log_with=<span class="hljs-string">&quot;tensorboard&quot;</span>, project_config=config)`,wrap:!1}}),Y=new re({props:{title:"Implementing Custom Trackers",local:"implementing-custom-trackers",headingTag:"h2"}}),E=new u({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudHJhY2tpbmclMjBpbXBvcnQlMjBHZW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bGYlMkMlMjB2YWx1ZXMlM0ElMjBkaWN0JTJDJTIwc3RlcCUzQSUyME9wdGlvbmFsJTVCaW50JTVEJTIwJTNEJTIwTm9uZSklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB3YW5kYi5sb2codmFsdWVzJTJDJTIwc3RlcCUzRHN0ZXAp",highlighted:`<span class="hljs-keyword">from</span> accelerate.tracking <span class="hljs-keyword">import</span> GeneralTracker, on_main_process
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>

<span class="hljs-keyword">import</span> wandb


<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyCustomTracker</span>(<span class="hljs-title class_ inherited__">GeneralTracker</span>):
    name = <span class="hljs-string">&quot;wandb&quot;</span>
    requires_logging_directory = <span class="hljs-literal">False</span>

<span class="hljs-meta">    @on_main_process</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, run_name: <span class="hljs-built_in">str</span></span>):
        self.run_name = run_name
        run = wandb.init(self.run_name)

<span class="hljs-meta">    @property</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">tracker</span>(<span class="hljs-params">self</span>):
        <span class="hljs-keyword">return</span> self.run.run

<span class="hljs-meta">    @on_main_process</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">store_init_configuration</span>(<span class="hljs-params">self, values: <span class="hljs-built_in">dict</span></span>):
        wandb.config(values)

<span class="hljs-meta">    @on_main_process</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">log</span>(<span class="hljs-params">self, values: <span class="hljs-built_in">dict</span>, step: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span></span>):
        wandb.log(values, step=step)`,wrap:!1}}),H=new u({props:{code:"dHJhY2tlciUyMCUzRCUyME15Q3VzdG9tVHJhY2tlciglMjJzb21lX3J1bl9uYW1lJTIyKSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IobG9nX3dpdGglM0R0cmFja2VyKQ==",highlighted:`tracker = MyCustomTracker(<span class="hljs-string">&quot;some_run_name&quot;</span>)
accelerator = Accelerator(log_with=tracker)`,wrap:!1}}),S=new u({props:{code:"dHJhY2tlciUyMCUzRCUyME15Q3VzdG9tVHJhY2tlciglMjJzb21lX3J1bl9uYW1lJTIyKSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IobG9nX3dpdGglM0QlNUJ0cmFja2VyJTJDJTIwJTIyYWxsJTIyJTVEKQ==",highlighted:`tracker = MyCustomTracker(<span class="hljs-string">&quot;some_run_name&quot;</span>)
accelerator = Accelerator(log_with=[tracker, <span class="hljs-string">&quot;all&quot;</span>])`,wrap:!1}}),z=new re({props:{title:"Accessing the internal tracker",local:"accessing-the-internal-tracker",headingTag:"h2"}}),K=new u({props:{code:"d2FuZGJfdHJhY2tlciUyMCUzRCUyMGFjY2VsZXJhdG9yLmdldF90cmFja2VyKCUyMndhbmRiJTIyKQ==",highlighted:'wandb_tracker = accelerator.get_tracker(<span class="hljs-string">&quot;wandb&quot;</span>)',wrap:!1}}),D=new u({props:{code:"d2FuZGJfdHJhY2tlci5sb2dfYXJ0aWZhY3Qoc29tZV9hcnRpZmFjdF90b19sb2cp",highlighted:"wandb_tracker.log_artifact(some_artifact_to_log)",wrap:!1}}),J=new kl({props:{$$slots:{default:[Bl]},$$scope:{ctx:ie}}}),ee=new u({props:{code:"d2FuZGJfdHJhY2tlciUyMCUzRCUyMGFjY2VsZXJhdG9yLmdldF90cmFja2VyKCUyMndhbmRiJTIyJTJDJTIwdW53cmFwJTNEVHJ1ZSklMEFpZiUyMGFjY2VsZXJhdG9yLmlzX21haW5fcHJvY2VzcyUzQSUwQSUyMCUyMCUyMCUyMHdhbmRiX3RyYWNrZXIubG9nX2FydGlmYWN0KHNvbWVfYXJ0aWZhY3RfdG9fbG9nKQ==",highlighted:`wandb_tracker = accelerator.get_tracker(<span class="hljs-string">&quot;wandb&quot;</span>, unwrap=<span class="hljs-literal">True</span>)
<span class="hljs-keyword">if</span> accelerator.is_main_process:
    wandb_tracker.log_artifact(some_artifact_to_log)`,wrap:!1}}),le=new re({props:{title:"When a wrapper cannot work",local:"when-a-wrapper-cannot-work",headingTag:"h2"}}),ae=new u({props:{code:"JTIwJTIwZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUyQiUyMGltcG9ydCUyMG5lcHR1bmUlMEElMEElMjAlMjBhY2NlbGVyYXRvciUyMCUzRCUyMEFjY2VsZXJhdG9yKCklMEElMkIlMjBydW4lMjAlM0QlMjBuZXB0dW5lLmluaXRfcnVuKC4uLiklMEElMEElMjAlMjBteV9tb2RlbCUyQyUyMG15X29wdGltaXplciUyQyUyMG15X3RyYWluaW5nX2RhdGFsb2FkZXIlMjAlM0QlMjBhY2NlbGVyYXRlLnByZXBhcmUobXlfbW9kZWwlMkMlMjBteV9vcHRpbWl6ZXIlMkMlMjBteV90cmFpbmluZ19kYXRhbG9hZGVyKSUwQSUyMCUyMGRldmljZSUyMCUzRCUyMGFjY2VsZXJhdG9yLmRldmljZSUwQSUyMCUyMG15X21vZGVsLnRvKGRldmljZSklMEElMEElMjAlMjBmb3IlMjBpdGVyYXRpb24lMjBpbiUyMGNvbmZpZyU1QiUyMm51bV9pdGVyYXRpb25zJTIyJTVEJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMG15X3RyYWluaW5nX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBteV9vcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnB1dHMlMkMlMjB0YXJnZXRzJTIwJTNEJTIwYmF0Y2glMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjBpbnB1dHMudG8oZGV2aWNlKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRhcmdldHMlMjAlM0QlMjB0YXJnZXRzLnRvKGRldmljZSklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbXlfbW9kZWwoaW5wdXRzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvc3MlMjAlM0QlMjBteV9sb3NzX2Z1bmN0aW9uKG91dHB1dHMlMkMlMjB0YXJnZXRzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRvdGFsX2xvc3MlMjAlMkIlM0QlMjBsb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWNjZWxlcmF0b3IuYmFja3dhcmQobG9zcyklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBteV9vcHRpbWl6ZXIuc3RlcCgpJTBBJTJCJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWYlMjBhY2NlbGVyYXRvci5pc19tYWluX3Byb2Nlc3MlM0ElMEElMkIlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBydW4lNUIlMjJsb2dzJTJGdHJhaW5pbmclMkZiYXRjaCUyRmxvc3MlMjIlNUQubG9nKGxvc3Mp",highlighted:`  from accelerate import Accelerator
<span class="hljs-addition">+ import neptune</span>

  accelerator = Accelerator()
<span class="hljs-addition">+ run = neptune.init_run(...)</span>

  my_model, my_optimizer, my_training_dataloader = accelerate.prepare(my_model, my_optimizer, my_training_dataloader)
  device = accelerator.device
  my_model.to(device)

  for iteration in config[&quot;num_iterations&quot;]:
      for batch in my_training_dataloader:
          my_optimizer.zero_grad()
          inputs, targets = batch
          inputs = inputs.to(device)
          targets = targets.to(device)
          outputs = my_model(inputs)
          loss = my_loss_function(outputs, targets)
          total_loss += loss
          accelerator.backward(loss)
          my_optimizer.step()
<span class="hljs-addition">+         if accelerator.is_main_process:</span>
<span class="hljs-addition">+             run[&quot;logs/training/batch/loss&quot;].log(loss)</span>`,wrap:!1}}),se=new Al({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/usage_guides/tracking.md"}}),{c(){j=r("meta"),w=s(),h=r("p"),ce=s(),c(T.$$.fragment),oe=s(),b=r("p"),b.innerHTML=Ke,pe=s(),c(f.$$.fragment),Me=s(),U=r("p"),U.innerHTML=Pe,me=s(),g=r("ul"),g.innerHTML=De,de=s(),I=r("p"),I.innerHTML=Oe,ye=s(),c(_.$$.fragment),je=s(),k=r("p"),k.innerHTML=el,ue=s(),c(A.$$.fragment),we=s(),B=r("p"),B.innerHTML=ll,Je=s(),c(C.$$.fragment),he=s(),$=r("p"),$.innerHTML=tl,Te=s(),c(Z.$$.fragment),be=s(),G=r("p"),G.textContent=al,fe=s(),c(v.$$.fragment),Ue=s(),W=r("p"),W.innerHTML=sl,ge=s(),c(X.$$.fragment),Ie=s(),c(Y.$$.fragment),_e=s(),R=r("p"),R.innerHTML=nl,ke=s(),V=r("ul"),V.innerHTML=rl,Ae=s(),N=r("p"),N.innerHTML=il,Be=s(),Q=r("p"),Q.textContent=cl,Ce=s(),c(E.$$.fragment),$e=s(),F=r("p"),F.innerHTML=ol,Ze=s(),c(H.$$.fragment),Ge=s(),x=r("p"),x.innerHTML=pl,ve=s(),c(S.$$.fragment),We=s(),c(z.$$.fragment),Xe=s(),q=r("p"),q.innerHTML=Ml,Ye=s(),L=r("p"),L.textContent=ml,Re=s(),c(K.$$.fragment),Ve=s(),P=r("p"),P.innerHTML=dl,Ne=s(),c(D.$$.fragment),Qe=s(),c(J.$$.fragment),Ee=s(),O=r("p"),O.textContent=yl,Fe=s(),c(ee.$$.fragment),He=s(),c(le.$$.fragment),xe=s(),te=r("p"),te.innerHTML=jl,Se=s(),c(ae.$$.fragment),ze=s(),c(se.$$.fragment),qe=s(),ne=r("p"),this.h()},l(e){const l=Ul("svelte-u9bgzb",document.head);j=i(l,"META",{name:!0,content:!0}),l.forEach(t),w=n(e),h=i(e,"P",{}),wl(h).forEach(t),ce=n(e),o(T.$$.fragment,e),oe=n(e),b=i(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-bw1s2g"&&(b.innerHTML=Ke),pe=n(e),o(f.$$.fragment,e),Me=n(e),U=i(e,"P",{"data-svelte-h":!0}),p(U)!=="svelte-153ccmy"&&(U.innerHTML=Pe),me=n(e),g=i(e,"UL",{"data-svelte-h":!0}),p(g)!=="svelte-1717u44"&&(g.innerHTML=De),de=n(e),I=i(e,"P",{"data-svelte-h":!0}),p(I)!=="svelte-1s812u7"&&(I.innerHTML=Oe),ye=n(e),o(_.$$.fragment,e),je=n(e),k=i(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-1myr0m3"&&(k.innerHTML=el),ue=n(e),o(A.$$.fragment,e),we=n(e),B=i(e,"P",{"data-svelte-h":!0}),p(B)!=="svelte-1eivltl"&&(B.innerHTML=ll),Je=n(e),o(C.$$.fragment,e),he=n(e),$=i(e,"P",{"data-svelte-h":!0}),p($)!=="svelte-tnwpta"&&($.innerHTML=tl),Te=n(e),o(Z.$$.fragment,e),be=n(e),G=i(e,"P",{"data-svelte-h":!0}),p(G)!=="svelte-14biqpt"&&(G.textContent=al),fe=n(e),o(v.$$.fragment,e),Ue=n(e),W=i(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-lkd44c"&&(W.innerHTML=sl),ge=n(e),o(X.$$.fragment,e),Ie=n(e),o(Y.$$.fragment,e),_e=n(e),R=i(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-rvhb9m"&&(R.innerHTML=nl),ke=n(e),V=i(e,"UL",{"data-svelte-h":!0}),p(V)!=="svelte-bz1vgf"&&(V.innerHTML=rl),Ae=n(e),N=i(e,"P",{"data-svelte-h":!0}),p(N)!=="svelte-1rcidn3"&&(N.innerHTML=il),Be=n(e),Q=i(e,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-1e80qmi"&&(Q.textContent=cl),Ce=n(e),o(E.$$.fragment,e),$e=n(e),F=i(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-19lwbk8"&&(F.innerHTML=ol),Ze=n(e),o(H.$$.fragment,e),Ge=n(e),x=i(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-13imq9d"&&(x.innerHTML=pl),ve=n(e),o(S.$$.fragment,e),We=n(e),o(z.$$.fragment,e),Xe=n(e),q=i(e,"P",{"data-svelte-h":!0}),p(q)!=="svelte-jp9up7"&&(q.innerHTML=Ml),Ye=n(e),L=i(e,"P",{"data-svelte-h":!0}),p(L)!=="svelte-bsc6i9"&&(L.textContent=ml),Re=n(e),o(K.$$.fragment,e),Ve=n(e),P=i(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-gdcdqr"&&(P.innerHTML=dl),Ne=n(e),o(D.$$.fragment,e),Qe=n(e),o(J.$$.fragment,e),Ee=n(e),O=i(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-8mhpnh"&&(O.textContent=yl),Fe=n(e),o(ee.$$.fragment,e),He=n(e),o(le.$$.fragment,e),xe=n(e),te=i(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-e74pz9"&&(te.innerHTML=jl),Se=n(e),o(ae.$$.fragment,e),ze=n(e),o(se.$$.fragment,e),qe=n(e),ne=i(e,"P",{}),wl(ne).forEach(t),this.h()},h(){Jl(j,"name","hf:doc:metadata"),Jl(j,"content",$l)},m(e,l){gl(document.head,j),a(e,w,l),a(e,h,l),a(e,ce,l),M(T,e,l),a(e,oe,l),a(e,b,l),a(e,pe,l),M(f,e,l),a(e,Me,l),a(e,U,l),a(e,me,l),a(e,g,l),a(e,de,l),a(e,I,l),a(e,ye,l),M(_,e,l),a(e,je,l),a(e,k,l),a(e,ue,l),M(A,e,l),a(e,we,l),a(e,B,l),a(e,Je,l),M(C,e,l),a(e,he,l),a(e,$,l),a(e,Te,l),M(Z,e,l),a(e,be,l),a(e,G,l),a(e,fe,l),M(v,e,l),a(e,Ue,l),a(e,W,l),a(e,ge,l),M(X,e,l),a(e,Ie,l),M(Y,e,l),a(e,_e,l),a(e,R,l),a(e,ke,l),a(e,V,l),a(e,Ae,l),a(e,N,l),a(e,Be,l),a(e,Q,l),a(e,Ce,l),M(E,e,l),a(e,$e,l),a(e,F,l),a(e,Ze,l),M(H,e,l),a(e,Ge,l),a(e,x,l),a(e,ve,l),M(S,e,l),a(e,We,l),M(z,e,l),a(e,Xe,l),a(e,q,l),a(e,Ye,l),a(e,L,l),a(e,Re,l),M(K,e,l),a(e,Ve,l),a(e,P,l),a(e,Ne,l),M(D,e,l),a(e,Qe,l),M(J,e,l),a(e,Ee,l),a(e,O,l),a(e,Fe,l),M(ee,e,l),a(e,He,l),M(le,e,l),a(e,xe,l),a(e,te,l),a(e,Se,l),M(ae,e,l),a(e,ze,l),M(se,e,l),a(e,qe,l),a(e,ne,l),Le=!0},p(e,[l]){const ul={};l&2&&(ul.$$scope={dirty:l,ctx:e}),J.$set(ul)},i(e){Le||(m(T.$$.fragment,e),m(f.$$.fragment,e),m(_.$$.fragment,e),m(A.$$.fragment,e),m(C.$$.fragment,e),m(Z.$$.fragment,e),m(v.$$.fragment,e),m(X.$$.fragment,e),m(Y.$$.fragment,e),m(E.$$.fragment,e),m(H.$$.fragment,e),m(S.$$.fragment,e),m(z.$$.fragment,e),m(K.$$.fragment,e),m(D.$$.fragment,e),m(J.$$.fragment,e),m(ee.$$.fragment,e),m(le.$$.fragment,e),m(ae.$$.fragment,e),m(se.$$.fragment,e),Le=!0)},o(e){d(T.$$.fragment,e),d(f.$$.fragment,e),d(_.$$.fragment,e),d(A.$$.fragment,e),d(C.$$.fragment,e),d(Z.$$.fragment,e),d(v.$$.fragment,e),d(X.$$.fragment,e),d(Y.$$.fragment,e),d(E.$$.fragment,e),d(H.$$.fragment,e),d(S.$$.fragment,e),d(z.$$.fragment,e),d(K.$$.fragment,e),d(D.$$.fragment,e),d(J.$$.fragment,e),d(ee.$$.fragment,e),d(le.$$.fragment,e),d(ae.$$.fragment,e),d(se.$$.fragment,e),Le=!1},d(e){e&&(t(w),t(h),t(ce),t(oe),t(b),t(pe),t(Me),t(U),t(me),t(g),t(de),t(I),t(ye),t(je),t(k),t(ue),t(we),t(B),t(Je),t(he),t($),t(Te),t(be),t(G),t(fe),t(Ue),t(W),t(ge),t(Ie),t(_e),t(R),t(ke),t(V),t(Ae),t(N),t(Be),t(Q),t(Ce),t($e),t(F),t(Ze),t(Ge),t(x),t(ve),t(We),t(Xe),t(q),t(Ye),t(L),t(Re),t(Ve),t(P),t(Ne),t(Qe),t(Ee),t(O),t(Fe),t(He),t(xe),t(te),t(Se),t(ze),t(qe),t(ne)),t(j),y(T,e),y(f,e),y(_,e),y(A,e),y(C,e),y(Z,e),y(v,e),y(X,e),y(Y,e),y(E,e),y(H,e),y(S,e),y(z,e),y(K,e),y(D,e),y(J,e),y(ee,e),y(le,e),y(ae,e),y(se,e)}}}const $l='{"title":"Experiment trackers","local":"experiment-trackers","sections":[{"title":"Integrated Trackers","local":"integrated-trackers","sections":[],"depth":2},{"title":"Implementing Custom Trackers","local":"implementing-custom-trackers","sections":[],"depth":2},{"title":"Accessing the internal tracker","local":"accessing-the-internal-tracker","sections":[],"depth":2},{"title":"When a wrapper cannot work","local":"when-a-wrapper-cannot-work","sections":[],"depth":2}],"depth":1}';function Zl(ie){return Tl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Rl extends bl{constructor(j){super(),fl(this,j,Zl,Cl,hl,{})}}export{Rl as component};
