import{s as qt,o as Ot,n as Ft}from"../chunks/scheduler.defa9a21.js";import{S as Nt,i as Wt,g as n,s as o,r as i,A as Et,h as c,f as a,c as r,j as w,u as h,x as f,k as x,y as s,a as l,v as p,d as m,t as u,w as g}from"../chunks/index.fe795e71.js";import{T as Ct}from"../chunks/Tip.179eb360.js";import{D as k}from"../chunks/Docstring.90d6fe5c.js";import{H as N,E as Bt}from"../chunks/getInferenceSnippets.2234a8dd.js";function Gt(ce){let d,L=`<code>BatchSampler</code>s with varying batch sizes are not enabled by default. To enable this behaviour, set <code>even_batches</code>
equal to <code>False</code>`;return{c(){d=n("p"),d.innerHTML=L},l(_){d=c(_,"P",{"data-svelte-h":!0}),f(d)!=="svelte-11uxp6"&&(d.innerHTML=L)},m(_,M){l(_,d,M)},p:Ft,d(_){_&&a(d)}}}function Ut(ce){let d,L=`<code>BatchSampler</code>s with varying batch sizes are not enabled by default. To enable this behaviour, set <code>even_batches</code>
equal to <code>False</code>`;return{c(){d=n("p"),d.innerHTML=L},l(_){d=c(_,"P",{"data-svelte-h":!0}),f(d)!=="svelte-11uxp6"&&(d.innerHTML=L)},m(_,M){l(_,d,M)},p:Ft,d(_){_&&a(d)}}}function Vt(ce){let d,L,_,M,W,Se,E,_t=`The internal classes Accelerate uses to prepare objects for distributed training
when calling <a href="/docs/accelerate/v1.10.1/en/package_reference/accelerator#accelerate.Accelerator.prepare">prepare()</a>.`,ke,B,Ae,v,G,Ke,le,bt="Wraps a PyTorch <code>DataLoader</code> to generate batches for one of the processes only.",Qe,de,vt=`Depending on the value of the <code>drop_last</code> attribute of the <code>dataloader</code> passed, it will either stop the iteration
at the first batch that would be too small / not present on all processes or loop with indices from the beginning.`,Ye,H,Ie,A,U,Ze,ie,$t=`Creates a <code>torch.utils.data.DataLoader</code> that will efficiently skip the first <code>num_batches</code>. Should not be used if
the original dataloader is a <code>StatefulDataLoader</code>.`,Me,V,He,T,R,et,he,yt=`Wraps a PyTorch <code>BatchSampler</code> to generate batches for one of the processes only. Instances of this class will
always yield a number of batches that is a round multiple of <code>num_processes</code> and that all have the same size.
Depending on the value of the <code>drop_last</code> attribute of the batch sampler passed, it will either stop the iteration
at the first batch that would be too small / not present on all processes or loop with indices from the beginning.`,tt,P,Pe,j,Ce,I,X,at,pe,wt=`Wraps a PyTorch <code>IterableDataset</code> to generate samples for one of the processes only. Instances of this class will
always yield a number of samples that is a round multiple of the actual batch size (depending of the value of
<code>split_batches</code>, this is either <code>batch_size</code> or <code>batch_size x num_processes</code>). Depending on the value of the
<code>drop_last</code> attribute of the batch sampler passed, it will either stop the iteration at the first batch that would
be too small or loop with indices from the beginning.`,Fe,J,qe,$,K,ot,me,xt="Subclass of <code>DataLoaderAdapter</code> that will deal with device placement and current distributed setup.",rt,ue,Tt="<strong>Available attributes:</strong>",st,ge,zt=`<li><p><strong>total_batch_size</strong> (<code>int</code>) — Total batch size of the dataloader across all processes.
Equal to the original batch size when <code>split_batches=True</code>; otherwise the original batch size * the total
number of processes</p></li> <li><p><strong>total_dataset_length</strong> (<code>int</code>) — Total length of the inner dataset across all processes.</p></li>`,Oe,Q,Ne,y,Y,nt,fe,Dt=`Subclass of <code>DataLoaderAdapter</code> that will iterate and preprocess on process 0 only, then dispatch on each process
their part of the batch.`,ct,_e,Lt="<strong>Available attributes:</strong>",lt,be,St=`<li><p><strong>total_batch_size</strong> (<code>int</code>) — Total batch size of the dataloader across all processes.
Equal to the original batch size when <code>split_batches=True</code>; otherwise the original batch size * the total
number of processes</p></li> <li><p><strong>total_dataset_length</strong> (<code>int</code>) — Total length of the inner dataset across all processes.</p></li>`,We,Z,Ee,b,ee,dt,ve,kt="Internal wrapper around a torch optimizer.",it,$e,At=`Conditionally will perform <code>step</code> and <code>zero_grad</code> if gradients should be synchronized when performing gradient
accumulation.`,ht,C,te,pt,ye,It="Sets the optimizer to “eval” mode. Useful for optimizers like <code>schedule_free</code>",mt,F,ae,ut,we,Mt="Sets the optimizer to “train” mode. Useful for optimizers like <code>schedule_free</code>",Be,oe,Ge,z,re,gt,xe,Ht=`A wrapper around a learning rate scheduler that will only step when the optimizer(s) have a training step. Useful
to avoid making a scheduler step too fast when gradients went overflow and there was no training step (in mixed
precision training)`,ft,Te,Pt=`When performing gradient accumulation scheduler lengths should not be changed accordingly, Accelerate will always
step the scheduler to account for it.`,Ue,se,Ve,Le,Re;return W=new N({props:{title:"DataLoaders, Optimizers, and Schedulers",local:"dataloaders-optimizers-and-schedulers",headingTag:"h1"}}),B=new N({props:{title:"DataLoader utilities",local:"accelerate.data_loader.prepare_data_loader",headingTag:"h2"}}),G=new k({props:{name:"accelerate.data_loader.prepare_data_loader",anchor:"accelerate.data_loader.prepare_data_loader",parameters:[{name:"dataloader",val:": DataLoader"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"num_processes",val:": typing.Optional[int] = None"},{name:"process_index",val:": typing.Optional[int] = None"},{name:"split_batches",val:": bool = False"},{name:"put_on_device",val:": bool = False"},{name:"rng_types",val:": typing.Optional[list[typing.Union[str, accelerate.utils.dataclasses.RNGType]]] = None"},{name:"dispatch_batches",val:": typing.Optional[bool] = None"},{name:"even_batches",val:": bool = True"},{name:"slice_fn_for_dispatch",val:": typing.Optional[typing.Callable] = None"},{name:"use_seedable_sampler",val:": bool = False"},{name:"data_seed",val:": typing.Optional[int] = None"},{name:"non_blocking",val:": bool = False"},{name:"use_stateful_dataloader",val:": bool = False"},{name:"torch_device_mesh",val:" = None"}],parametersDescription:[{anchor:"accelerate.data_loader.prepare_data_loader.dataloader",description:`<strong>dataloader</strong> (<code>torch.utils.data.dataloader.DataLoader</code>) &#x2014;
The data loader to split across several devices.`,name:"dataloader"},{anchor:"accelerate.data_loader.prepare_data_loader.device",description:`<strong>device</strong> (<code>torch.device</code>) &#x2014;
The target device for the returned <code>DataLoader</code>.`,name:"device"},{anchor:"accelerate.data_loader.prepare_data_loader.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of processes running concurrently. Will default to the value given by <a href="/docs/accelerate/v1.10.1/en/package_reference/state#accelerate.PartialState">PartialState</a>.`,name:"num_processes"},{anchor:"accelerate.data_loader.prepare_data_loader.process_index",description:`<strong>process_index</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The index of the current process. Will default to the value given by <a href="/docs/accelerate/v1.10.1/en/package_reference/state#accelerate.PartialState">PartialState</a>.`,name:"process_index"},{anchor:"accelerate.data_loader.prepare_data_loader.split_batches",description:`<strong>split_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the resulting <code>DataLoader</code> should split the batches of the original data loader across devices or
yield full batches (in which case it will yield batches starting at the <code>process_index</code>-th and advancing of
<code>num_processes</code> batches at each iteration).</p>
<p>Another way to see this is that the observed batch size will be the same as the initial <code>dataloader</code> if
this option is set to <code>True</code>, the batch size of the initial <code>dataloader</code> multiplied by <code>num_processes</code>
otherwise.</p>
<p>Setting this option to <code>True</code> requires that the batch size of the <code>dataloader</code> is a round multiple of
<code>batch_size</code>.`,name:"split_batches"},{anchor:"accelerate.data_loader.prepare_data_loader.put_on_device",description:`<strong>put_on_device</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to put the batches on <code>device</code> (only works if the batches are nested list, tuples or
dictionaries of tensors).`,name:"put_on_device"},{anchor:"accelerate.data_loader.prepare_data_loader.rng_types",description:`<strong>rng_types</strong> (list of <code>str</code> or <a href="/docs/accelerate/v1.10.1/en/package_reference/utilities#accelerate.utils.RNGType">RNGType</a>) &#x2014;
The list of random number generators to synchronize at the beginning of each iteration. Should be one or
several of:</p>
<ul>
<li><code>&quot;torch&quot;</code>: the base torch random number generator</li>
<li><code>&quot;cuda&quot;</code>: the CUDA random number generator (GPU only)</li>
<li><code>&quot;xla&quot;</code>: the XLA random number generator (TPU only)</li>
<li><code>&quot;generator&quot;</code>: the <code>torch.Generator</code> of the sampler (or batch sampler if there is no sampler in your
dataloader) or of the iterable dataset (if it exists) if the underlying dataset is of that type.</li>
</ul>`,name:"rng_types"},{anchor:"accelerate.data_loader.prepare_data_loader.dispatch_batches",description:`<strong>dispatch_batches</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the dataloader prepared is only iterated through on the main process and then the batches
are split and broadcast to each process. Will default to <code>True</code> when the underlying dataset is an
<code>IterableDataset</code>, <code>False</code> otherwise.`,name:"dispatch_batches"},{anchor:"accelerate.data_loader.prepare_data_loader.even_batches",description:`<strong>even_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If set to <code>True</code>, in cases where the total batch size across all processes does not exactly divide the
dataset, samples at the start of the dataset will be duplicated so the batch can be divided equally among
all workers.`,name:"even_batches"},{anchor:"accelerate.data_loader.prepare_data_loader.slice_fn_for_dispatch",description:"<strong>slice_fn_for_dispatch</strong> (<code>Callable</code>, <em>optional</em><code>) -- If passed, this function will be used to slice tensors across </code>num_processes<code>. Will default to [slice_tensors()](/docs/accelerate/v1.10.1/en/package_reference/utilities#accelerate.utils.slice_tensors). This argument is used only when </code>dispatch_batches<code>is set to</code>True` and will be\nignored otherwise.",name:"slice_fn_for_dispatch"},{anchor:"accelerate.data_loader.prepare_data_loader.use_seedable_sampler",description:`<strong>use_seedable_sampler</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use the <code>SeedableRandomSampler</code> instead of a <code>RandomSampler</code> for better
reproducability. Comes at a cost of potentially different performances due to different shuffling
algorithms but ensures results will be the <em>exact</em> same. Should be paired with <code>set_seed()</code> at every
<code>self.set_epoch</code>`,name:"use_seedable_sampler"},{anchor:"accelerate.data_loader.prepare_data_loader.data_seed",description:`<strong>data_seed</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The seed to use for the underlying generator when using <code>use_seedable_sampler</code>. If <code>None</code>, the generator
will use the current default seed from torch.`,name:"data_seed"},{anchor:"accelerate.data_loader.prepare_data_loader.non_blocking",description:`<strong>non_blocking</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If set to <code>True</code>, dataloader will utilize non-blocking host-to-device transfers. If the dataloader has
<code>pin_memory</code> set to <code>True</code>, this will help to increase overlap between data transfer and computations.`,name:"non_blocking"},{anchor:"accelerate.data_loader.prepare_data_loader.use_stateful_dataloader",description:`<strong>use_stateful_dataloader</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
&#x201C;If set to true, the dataloader prepared by the Accelerator will be backed by &#x201D;
&#x201D;<a href="https://github.com/pytorch/data/tree/main/torchdata/stateful_dataloader" rel="nofollow">torchdata.StatefulDataLoader</a>.
This requires <code>torchdata</code> version 0.8.0 or higher that supports StatefulDataLoader to be installed.&#x201D;`,name:"use_stateful_dataloader"},{anchor:"accelerate.data_loader.prepare_data_loader.torch_device_mesh",description:`<strong>torch_device_mesh</strong> (<code>torch.distributed.DeviceMesh</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
PyTorch device mesh.`,name:"torch_device_mesh"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L996",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A new data loader that will yield the portion of the batches</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.utils.data.dataloader.DataLoader</code></p>
`}}),H=new Ct({props:{warning:!0,$$slots:{default:[Gt]},$$scope:{ctx:ce}}}),U=new k({props:{name:"accelerate.skip_first_batches",anchor:"accelerate.skip_first_batches",parameters:[{name:"dataloader",val:""},{name:"num_batches",val:" = 0"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L1375"}}),V=new N({props:{title:"BatchSamplerShard",local:"accelerate.data_loader.BatchSamplerShard",headingTag:"h2"}}),R=new k({props:{name:"class accelerate.data_loader.BatchSamplerShard",anchor:"accelerate.data_loader.BatchSamplerShard",parameters:[{name:"batch_sampler",val:": BatchSampler"},{name:"num_processes",val:": int = 1"},{name:"process_index",val:": int = 0"},{name:"split_batches",val:": bool = False"},{name:"even_batches",val:": bool = True"}],parametersDescription:[{anchor:"accelerate.data_loader.BatchSamplerShard.batch_sampler",description:`<strong>batch_sampler</strong> (<code>torch.utils.data.sampler.BatchSampler</code>) &#x2014;
The batch sampler to split in several shards.`,name:"batch_sampler"},{anchor:"accelerate.data_loader.BatchSamplerShard.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of processes running concurrently.`,name:"num_processes"},{anchor:"accelerate.data_loader.BatchSamplerShard.process_index",description:`<strong>process_index</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The index of the current process.`,name:"process_index"},{anchor:"accelerate.data_loader.BatchSamplerShard.split_batches",description:`<strong>split_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the shards should be created by splitting a batch to give a piece of it on each process, or by
yielding different full batches on each process.</p>
<p>On two processes with a sampler of <code>[[0, 1, 2, 3], [4, 5, 6, 7]]</code>, this will result in:</p>
<ul>
<li>the sampler on process 0 to yield <code>[0, 1, 2, 3]</code> and the sampler on process 1 to yield <code>[4, 5, 6, 7]</code> if
this argument is set to <code>False</code>.</li>
<li>the sampler on process 0 to yield <code>[0, 1]</code> then <code>[4, 5]</code> and the sampler on process 1 to yield <code>[2, 3]</code>
then <code>[6, 7]</code> if this argument is set to <code>True</code>.</li>
</ul>`,name:"split_batches"},{anchor:"accelerate.data_loader.BatchSamplerShard.even_batches",description:`<strong>even_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to loop back at the beginning of the sampler when the number of samples is not a round
multiple of (original batch size / number of processes).`,name:"even_batches"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L110"}}),P=new Ct({props:{warning:!0,$$slots:{default:[Ut]},$$scope:{ctx:ce}}}),j=new N({props:{title:"IterableDatasetShard",local:"accelerate.data_loader.IterableDatasetShard",headingTag:"h2"}}),X=new k({props:{name:"class accelerate.data_loader.IterableDatasetShard",anchor:"accelerate.data_loader.IterableDatasetShard",parameters:[{name:"dataset",val:": IterableDataset"},{name:"batch_size",val:": int = 1"},{name:"drop_last",val:": bool = False"},{name:"num_processes",val:": int = 1"},{name:"process_index",val:": int = 0"},{name:"split_batches",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.data_loader.IterableDatasetShard.dataset",description:`<strong>dataset</strong> (<code>torch.utils.data.dataset.IterableDataset</code>) &#x2014;
The batch sampler to split in several shards.`,name:"dataset"},{anchor:"accelerate.data_loader.IterableDatasetShard.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The size of the batches per shard (if <code>split_batches=False</code>) or the size of the batches (if
<code>split_batches=True</code>).`,name:"batch_size"},{anchor:"accelerate.data_loader.IterableDatasetShard.drop_last",description:`<strong>drop_last</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to drop the last incomplete batch or complete the last batches by using the samples from the
beginning.`,name:"drop_last"},{anchor:"accelerate.data_loader.IterableDatasetShard.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of processes running concurrently.`,name:"num_processes"},{anchor:"accelerate.data_loader.IterableDatasetShard.process_index",description:`<strong>process_index</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The index of the current process.`,name:"process_index"},{anchor:"accelerate.data_loader.IterableDatasetShard.split_batches",description:`<strong>split_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the shards should be created by splitting a batch to give a piece of it on each process, or by
yielding different full batches on each process.</p>
<p>On two processes with an iterable dataset yielding of <code>[0, 1, 2, 3, 4, 5, 6, 7]</code>, this will result in:</p>
<ul>
<li>the shard on process 0 to yield <code>[0, 1, 2, 3]</code> and the shard on process 1 to yield <code>[4, 5, 6, 7]</code> if this
argument is set to <code>False</code>.</li>
<li>the shard on process 0 to yield <code>[0, 1, 4, 5]</code> and the sampler on process 1 to yield <code>[2, 3, 6, 7]</code> if
this argument is set to <code>True</code>.</li>
</ul>`,name:"split_batches"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L266"}}),J=new N({props:{title:"DataLoaderShard",local:"accelerate.data_loader.DataLoaderShard",headingTag:"h2"}}),K=new k({props:{name:"class accelerate.data_loader.DataLoaderShard",anchor:"accelerate.data_loader.DataLoaderShard",parameters:[{name:"dataset",val:""},{name:"device",val:" = None"},{name:"rng_types",val:" = None"},{name:"synchronized_generator",val:" = None"},{name:"skip_batches",val:" = 0"},{name:"use_stateful_dataloader",val:" = False"},{name:"_drop_last",val:": bool = False"},{name:"_non_blocking",val:": bool = False"},{name:"torch_device_mesh",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"accelerate.data_loader.DataLoaderShard.dataset",description:`<strong>dataset</strong> (<code>torch.utils.data.dataset.Dataset</code>) &#x2014;
The dataset to use to build this dataloader.`,name:"dataset"},{anchor:"accelerate.data_loader.DataLoaderShard.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>) &#x2014;
If passed, the device to put all batches on.`,name:"device"},{anchor:"accelerate.data_loader.DataLoaderShard.rng_types",description:`<strong>rng_types</strong> (list of <code>str</code> or <a href="/docs/accelerate/v1.10.1/en/package_reference/utilities#accelerate.utils.RNGType">RNGType</a>) &#x2014;
The list of random number generators to synchronize at the beginning of each iteration. Should be one or
several of:</p>
<ul>
<li><code>&quot;torch&quot;</code>: the base torch random number generator</li>
<li><code>&quot;cuda&quot;</code>: the CUDA random number generator (GPU only)</li>
<li><code>&quot;xla&quot;</code>: the XLA random number generator (TPU only)</li>
<li><code>&quot;generator&quot;</code>: an optional <code>torch.Generator</code></li>
</ul>`,name:"rng_types"},{anchor:"accelerate.data_loader.DataLoaderShard.synchronized_generator",description:`<strong>synchronized_generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator to keep synchronized across processes.`,name:"synchronized_generator"},{anchor:"accelerate.data_loader.DataLoaderShard.skip_batches",description:`<strong>skip_batches</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of batches to skip at the beginning.`,name:"skip_batches"},{anchor:"accelerate.data_loader.DataLoaderShard.use_stateful_dataloader",description:`<strong>use_stateful_dataloader</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to have this class adapt <code>StatefulDataLoader</code> from <code>torchdata</code> instead of the regular <code>DataLoader</code>.`,name:"use_stateful_dataloader"},{anchor:"accelerate.data_loader.DataLoaderShard.*kwargs",description:`*<strong>*kwargs</strong> (additional keyword arguments, <em>optional</em>) &#x2014;
All other keyword arguments to pass to the regular <code>DataLoader</code> initialization.`,name:"*kwargs"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L500"}}),Q=new N({props:{title:"DataLoaderDispatcher",local:"accelerate.data_loader.DataLoaderDispatcher",headingTag:"h2"}}),Y=new k({props:{name:"class accelerate.data_loader.DataLoaderDispatcher",anchor:"accelerate.data_loader.DataLoaderDispatcher",parameters:[{name:"dataset",val:""},{name:"split_batches",val:": bool = False"},{name:"skip_batches",val:" = 0"},{name:"use_stateful_dataloader",val:" = False"},{name:"_drop_last",val:": bool = False"},{name:"_non_blocking",val:": bool = False"},{name:"slice_fn",val:" = None"},{name:"torch_device_mesh",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"accelerate.data_loader.DataLoaderDispatcher.split_batches",description:`<strong>split_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the resulting <code>DataLoader</code> should split the batches of the original data loader across devices or
yield full batches (in which case it will yield batches starting at the <code>process_index</code>-th and advancing of
<code>num_processes</code> batches at each iteration). Another way to see this is that the observed batch size will be
the same as the initial <code>dataloader</code> if this option is set to <code>True</code>, the batch size of the initial
<code>dataloader</code> multiplied by <code>num_processes</code> otherwise. Setting this option to <code>True</code> requires that the batch
size of the <code>dataloader</code> is a round multiple of <code>batch_size</code>.`,name:"split_batches"},{anchor:"accelerate.data_loader.DataLoaderDispatcher.skip_batches",description:`<strong>skip_batches</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of batches to skip at the beginning of an iteration.`,name:"skip_batches"},{anchor:"accelerate.data_loader.DataLoaderDispatcher.use_stateful_dataloader",description:`<strong>use_stateful_dataloader</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to have this class adapt <code>StatefulDataLoader</code> from <code>torchdata</code> instead of the regular <code>DataLoader</code>.`,name:"use_stateful_dataloader"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/data_loader.py#L704"}}),Z=new N({props:{title:"AcceleratedOptimizer",local:"accelerate.optimizer.AcceleratedOptimizer",headingTag:"h2"}}),ee=new k({props:{name:"class accelerate.optimizer.AcceleratedOptimizer",anchor:"accelerate.optimizer.AcceleratedOptimizer",parameters:[{name:"optimizer",val:""},{name:"device_placement",val:" = True"},{name:"scaler",val:" = None"}],parametersDescription:[{anchor:"accelerate.optimizer.AcceleratedOptimizer.optimizer",description:`<strong>optimizer</strong> (<code>torch.optim.optimizer.Optimizer</code>) &#x2014;
The optimizer to wrap.`,name:"optimizer"},{anchor:"accelerate.optimizer.AcceleratedOptimizer.device_placement",description:`<strong>device_placement</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the optimizer should handle device placement. If so, it will place the state dictionary of
<code>optimizer</code> on the right device.`,name:"device_placement"},{anchor:"accelerate.optimizer.AcceleratedOptimizer.scaler",description:`<strong>scaler</strong> (<code>torch.amp.GradScaler</code> or <code>torch.cuda.amp.GradScaler</code>, <em>optional</em>) &#x2014;
The scaler to use in the step function if training with mixed precision.`,name:"scaler"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/optimizer.py#L38"}}),te=new k({props:{name:"eval",anchor:"accelerate.optimizer.AcceleratedOptimizer.eval",parameters:[],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/optimizer.py#L138"}}),ae=new k({props:{name:"train",anchor:"accelerate.optimizer.AcceleratedOptimizer.train",parameters:[],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/optimizer.py#L124"}}),oe=new N({props:{title:"AcceleratedScheduler",local:"accelerate.scheduler.AcceleratedScheduler",headingTag:"h2"}}),re=new k({props:{name:"class accelerate.scheduler.AcceleratedScheduler",anchor:"accelerate.scheduler.AcceleratedScheduler",parameters:[{name:"scheduler",val:""},{name:"optimizers",val:""},{name:"step_with_optimizer",val:": bool = True"},{name:"split_batches",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.scheduler.AcceleratedScheduler.scheduler",description:`<strong>scheduler</strong> (<code>torch.optim.lr_scheduler._LRScheduler</code>) &#x2014;
The scheduler to wrap.`,name:"scheduler"},{anchor:"accelerate.scheduler.AcceleratedScheduler.optimizers",description:`<strong>optimizers</strong> (one or a list of <code>torch.optim.Optimizer</code>) &#x2014;
The optimizers used.`,name:"optimizers"},{anchor:"accelerate.scheduler.AcceleratedScheduler.step_with_optimizer",description:`<strong>step_with_optimizer</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the scheduler should be stepped at each optimizer step.`,name:"step_with_optimizer"},{anchor:"accelerate.scheduler.AcceleratedScheduler.split_batches",description:`<strong>split_batches</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the dataloaders split one batch across the different processes (so batch size is the same
regardless of the number of processes) or create batches on each process (so batch size is the original
batch size multiplied by the number of processes).`,name:"split_batches"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/scheduler.py#L25"}}),se=new Bt({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/torch_wrappers.md"}}),{c(){d=n("meta"),L=o(),_=n("p"),M=o(),i(W.$$.fragment),Se=o(),E=n("p"),E.innerHTML=_t,ke=o(),i(B.$$.fragment),Ae=o(),v=n("div"),i(G.$$.fragment),Ke=o(),le=n("p"),le.innerHTML=bt,Qe=o(),de=n("p"),de.innerHTML=vt,Ye=o(),i(H.$$.fragment),Ie=o(),A=n("div"),i(U.$$.fragment),Ze=o(),ie=n("p"),ie.innerHTML=$t,Me=o(),i(V.$$.fragment),He=o(),T=n("div"),i(R.$$.fragment),et=o(),he=n("p"),he.innerHTML=yt,tt=o(),i(P.$$.fragment),Pe=o(),i(j.$$.fragment),Ce=o(),I=n("div"),i(X.$$.fragment),at=o(),pe=n("p"),pe.innerHTML=wt,Fe=o(),i(J.$$.fragment),qe=o(),$=n("div"),i(K.$$.fragment),ot=o(),me=n("p"),me.innerHTML=xt,rt=o(),ue=n("p"),ue.innerHTML=Tt,st=o(),ge=n("ul"),ge.innerHTML=zt,Oe=o(),i(Q.$$.fragment),Ne=o(),y=n("div"),i(Y.$$.fragment),nt=o(),fe=n("p"),fe.innerHTML=Dt,ct=o(),_e=n("p"),_e.innerHTML=Lt,lt=o(),be=n("ul"),be.innerHTML=St,We=o(),i(Z.$$.fragment),Ee=o(),b=n("div"),i(ee.$$.fragment),dt=o(),ve=n("p"),ve.textContent=kt,it=o(),$e=n("p"),$e.innerHTML=At,ht=o(),C=n("div"),i(te.$$.fragment),pt=o(),ye=n("p"),ye.innerHTML=It,mt=o(),F=n("div"),i(ae.$$.fragment),ut=o(),we=n("p"),we.innerHTML=Mt,Be=o(),i(oe.$$.fragment),Ge=o(),z=n("div"),i(re.$$.fragment),gt=o(),xe=n("p"),xe.textContent=Ht,ft=o(),Te=n("p"),Te.textContent=Pt,Ue=o(),i(se.$$.fragment),Ve=o(),Le=n("p"),this.h()},l(e){const t=Et("svelte-u9bgzb",document.head);d=c(t,"META",{name:!0,content:!0}),t.forEach(a),L=r(e),_=c(e,"P",{}),w(_).forEach(a),M=r(e),h(W.$$.fragment,e),Se=r(e),E=c(e,"P",{"data-svelte-h":!0}),f(E)!=="svelte-gm7jyf"&&(E.innerHTML=_t),ke=r(e),h(B.$$.fragment,e),Ae=r(e),v=c(e,"DIV",{class:!0});var D=w(v);h(G.$$.fragment,D),Ke=r(D),le=c(D,"P",{"data-svelte-h":!0}),f(le)!=="svelte-18lxf6z"&&(le.innerHTML=bt),Qe=r(D),de=c(D,"P",{"data-svelte-h":!0}),f(de)!=="svelte-15utu04"&&(de.innerHTML=vt),Ye=r(D),h(H.$$.fragment,D),D.forEach(a),Ie=r(e),A=c(e,"DIV",{class:!0});var ne=w(A);h(U.$$.fragment,ne),Ze=r(ne),ie=c(ne,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-1j74yzt"&&(ie.innerHTML=$t),ne.forEach(a),Me=r(e),h(V.$$.fragment,e),He=r(e),T=c(e,"DIV",{class:!0});var ze=w(T);h(R.$$.fragment,ze),et=r(ze),he=c(ze,"P",{"data-svelte-h":!0}),f(he)!=="svelte-1d4wgd"&&(he.innerHTML=yt),tt=r(ze),h(P.$$.fragment,ze),ze.forEach(a),Pe=r(e),h(j.$$.fragment,e),Ce=r(e),I=c(e,"DIV",{class:!0});var je=w(I);h(X.$$.fragment,je),at=r(je),pe=c(je,"P",{"data-svelte-h":!0}),f(pe)!=="svelte-1t48as2"&&(pe.innerHTML=wt),je.forEach(a),Fe=r(e),h(J.$$.fragment,e),qe=r(e),$=c(e,"DIV",{class:!0});var q=w($);h(K.$$.fragment,q),ot=r(q),me=c(q,"P",{"data-svelte-h":!0}),f(me)!=="svelte-1gl2w6s"&&(me.innerHTML=xt),rt=r(q),ue=c(q,"P",{"data-svelte-h":!0}),f(ue)!=="svelte-17v1xbv"&&(ue.innerHTML=Tt),st=r(q),ge=c(q,"UL",{"data-svelte-h":!0}),f(ge)!=="svelte-ixpwl0"&&(ge.innerHTML=zt),q.forEach(a),Oe=r(e),h(Q.$$.fragment,e),Ne=r(e),y=c(e,"DIV",{class:!0});var O=w(y);h(Y.$$.fragment,O),nt=r(O),fe=c(O,"P",{"data-svelte-h":!0}),f(fe)!=="svelte-1mjzhu7"&&(fe.innerHTML=Dt),ct=r(O),_e=c(O,"P",{"data-svelte-h":!0}),f(_e)!=="svelte-17v1xbv"&&(_e.innerHTML=Lt),lt=r(O),be=c(O,"UL",{"data-svelte-h":!0}),f(be)!=="svelte-ixpwl0"&&(be.innerHTML=St),O.forEach(a),We=r(e),h(Z.$$.fragment,e),Ee=r(e),b=c(e,"DIV",{class:!0});var S=w(b);h(ee.$$.fragment,S),dt=r(S),ve=c(S,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-1kknwnf"&&(ve.textContent=kt),it=r(S),$e=c(S,"P",{"data-svelte-h":!0}),f($e)!=="svelte-vsq67w"&&($e.innerHTML=At),ht=r(S),C=c(S,"DIV",{class:!0});var Xe=w(C);h(te.$$.fragment,Xe),pt=r(Xe),ye=c(Xe,"P",{"data-svelte-h":!0}),f(ye)!=="svelte-2k0jq3"&&(ye.innerHTML=It),Xe.forEach(a),mt=r(S),F=c(S,"DIV",{class:!0});var Je=w(F);h(ae.$$.fragment,Je),ut=r(Je),we=c(Je,"P",{"data-svelte-h":!0}),f(we)!=="svelte-2n5ee9"&&(we.innerHTML=Mt),Je.forEach(a),S.forEach(a),Be=r(e),h(oe.$$.fragment,e),Ge=r(e),z=c(e,"DIV",{class:!0});var De=w(z);h(re.$$.fragment,De),gt=r(De),xe=c(De,"P",{"data-svelte-h":!0}),f(xe)!=="svelte-ebdman"&&(xe.textContent=Ht),ft=r(De),Te=c(De,"P",{"data-svelte-h":!0}),f(Te)!=="svelte-1g111ye"&&(Te.textContent=Pt),De.forEach(a),Ue=r(e),h(se.$$.fragment,e),Ve=r(e),Le=c(e,"P",{}),w(Le).forEach(a),this.h()},h(){x(d,"name","hf:doc:metadata"),x(d,"content",Rt),x(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){s(document.head,d),l(e,L,t),l(e,_,t),l(e,M,t),p(W,e,t),l(e,Se,t),l(e,E,t),l(e,ke,t),p(B,e,t),l(e,Ae,t),l(e,v,t),p(G,v,null),s(v,Ke),s(v,le),s(v,Qe),s(v,de),s(v,Ye),p(H,v,null),l(e,Ie,t),l(e,A,t),p(U,A,null),s(A,Ze),s(A,ie),l(e,Me,t),p(V,e,t),l(e,He,t),l(e,T,t),p(R,T,null),s(T,et),s(T,he),s(T,tt),p(P,T,null),l(e,Pe,t),p(j,e,t),l(e,Ce,t),l(e,I,t),p(X,I,null),s(I,at),s(I,pe),l(e,Fe,t),p(J,e,t),l(e,qe,t),l(e,$,t),p(K,$,null),s($,ot),s($,me),s($,rt),s($,ue),s($,st),s($,ge),l(e,Oe,t),p(Q,e,t),l(e,Ne,t),l(e,y,t),p(Y,y,null),s(y,nt),s(y,fe),s(y,ct),s(y,_e),s(y,lt),s(y,be),l(e,We,t),p(Z,e,t),l(e,Ee,t),l(e,b,t),p(ee,b,null),s(b,dt),s(b,ve),s(b,it),s(b,$e),s(b,ht),s(b,C),p(te,C,null),s(C,pt),s(C,ye),s(b,mt),s(b,F),p(ae,F,null),s(F,ut),s(F,we),l(e,Be,t),p(oe,e,t),l(e,Ge,t),l(e,z,t),p(re,z,null),s(z,gt),s(z,xe),s(z,ft),s(z,Te),l(e,Ue,t),p(se,e,t),l(e,Ve,t),l(e,Le,t),Re=!0},p(e,[t]){const D={};t&2&&(D.$$scope={dirty:t,ctx:e}),H.$set(D);const ne={};t&2&&(ne.$$scope={dirty:t,ctx:e}),P.$set(ne)},i(e){Re||(m(W.$$.fragment,e),m(B.$$.fragment,e),m(G.$$.fragment,e),m(H.$$.fragment,e),m(U.$$.fragment,e),m(V.$$.fragment,e),m(R.$$.fragment,e),m(P.$$.fragment,e),m(j.$$.fragment,e),m(X.$$.fragment,e),m(J.$$.fragment,e),m(K.$$.fragment,e),m(Q.$$.fragment,e),m(Y.$$.fragment,e),m(Z.$$.fragment,e),m(ee.$$.fragment,e),m(te.$$.fragment,e),m(ae.$$.fragment,e),m(oe.$$.fragment,e),m(re.$$.fragment,e),m(se.$$.fragment,e),Re=!0)},o(e){u(W.$$.fragment,e),u(B.$$.fragment,e),u(G.$$.fragment,e),u(H.$$.fragment,e),u(U.$$.fragment,e),u(V.$$.fragment,e),u(R.$$.fragment,e),u(P.$$.fragment,e),u(j.$$.fragment,e),u(X.$$.fragment,e),u(J.$$.fragment,e),u(K.$$.fragment,e),u(Q.$$.fragment,e),u(Y.$$.fragment,e),u(Z.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(ae.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),u(se.$$.fragment,e),Re=!1},d(e){e&&(a(L),a(_),a(M),a(Se),a(E),a(ke),a(Ae),a(v),a(Ie),a(A),a(Me),a(He),a(T),a(Pe),a(Ce),a(I),a(Fe),a(qe),a($),a(Oe),a(Ne),a(y),a(We),a(Ee),a(b),a(Be),a(Ge),a(z),a(Ue),a(Ve),a(Le)),a(d),g(W,e),g(B,e),g(G),g(H),g(U),g(V,e),g(R),g(P),g(j,e),g(X),g(J,e),g(K),g(Q,e),g(Y),g(Z,e),g(ee),g(te),g(ae),g(oe,e),g(re),g(se,e)}}}const Rt='{"title":"DataLoaders, Optimizers, and Schedulers","local":"dataloaders-optimizers-and-schedulers","sections":[{"title":"DataLoader utilities","local":"accelerate.data_loader.prepare_data_loader","sections":[],"depth":2},{"title":"BatchSamplerShard","local":"accelerate.data_loader.BatchSamplerShard","sections":[],"depth":2},{"title":"IterableDatasetShard","local":"accelerate.data_loader.IterableDatasetShard","sections":[],"depth":2},{"title":"DataLoaderShard","local":"accelerate.data_loader.DataLoaderShard","sections":[],"depth":2},{"title":"DataLoaderDispatcher","local":"accelerate.data_loader.DataLoaderDispatcher","sections":[],"depth":2},{"title":"AcceleratedOptimizer","local":"accelerate.optimizer.AcceleratedOptimizer","sections":[],"depth":2},{"title":"AcceleratedScheduler","local":"accelerate.scheduler.AcceleratedScheduler","sections":[],"depth":2}],"depth":1}';function jt(ce){return Ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zt extends Nt{constructor(d){super(),Wt(this,d,jt,Vt,qt,{})}}export{Zt as component};
