import{s as vo,o as Go,n as S}from"../chunks/scheduler.25b97de1.js";import{S as Wo,i as Ro,g as m,s as M,r as J,A as zo,h as u,f as t,c as r,j as _o,u as d,x as T,k as Zo,y as ko,a as l,v as w,d as f,t as U,w as j,m as qo,n as Xo}from"../chunks/index.d9030fc9.js";import{T as Me}from"../chunks/Tip.baa67368.js";import{C as v}from"../chunks/CodeBlock.e6cd0d95.js";import{H as X,E as No}from"../chunks/EditOnGithub.91d95064.js";import{H as ie,a as Y}from"../chunks/HfOption.1e589c90.js";function Vo(g){let a,c='If you’re having difficulties installing DeepSpeed, check the <a href="../debugging#deepspeed-cuda-installation">DeepSpeed CUDA installation</a> guide. While DeepSpeed has a pip installable PyPI package, it is highly recommended to <a href="https://www.deepspeed.ai/tutorials/advanced-install/#install-deepspeed-from-source" rel="nofollow">install it from source</a> to best match your hardware and to support certain features, like 1-bit Adam, which aren’t available in the PyPI distribution.';return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1cityiq"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function So(g){let a,c;return a=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRlZXBzcGVlZA==",highlighted:"pip install deepspeed",wrap:!1}}),{c(){J(a.$$.fragment)},l(n){d(a.$$.fragment,n)},m(n,p){w(a,n,p),c=!0},p:S,i(n){c||(f(a.$$.fragment,n),c=!0)},o(n){U(a.$$.fragment,n),c=!1},d(n){j(a,n)}}}function Qo(g){let a,c;return a=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1QmRlZXBzcGVlZCU1RA==",highlighted:"pip install transformers[deepspeed]",wrap:!1}}),{c(){J(a.$$.fragment)},l(n){d(a.$$.fragment,n)},m(n,p){w(a,n,p),c=!0},p:S,i(n){c||(f(a.$$.fragment,n),c=!0)},o(n){U(a.$$.fragment,n),c=!1},d(n){j(a,n)}}}function Eo(g){let a,c,n,p;return a=new Y({props:{id:"install",option:"PyPI",$$slots:{default:[So]},$$scope:{ctx:g}}}),n=new Y({props:{id:"install",option:"Transformers",$$slots:{default:[Qo]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function Ho(g){let a,c='Find a complete list of DeepSpeed configuration options on the <a href="https://www.deepspeed.ai/docs/config-json/" rel="nofollow">DeepSpeed Configuration JSON</a> reference. You can also find more practical examples of various DeepSpeed configuration examples on the <a href="https://github.com/microsoft/DeepSpeedExamples" rel="nofollow">DeepSpeedExamples</a> repository or the main <a href="https://github.com/microsoft/DeepSpeed" rel="nofollow">DeepSpeed</a> repository. To quickly find specific examples, you can:',n,p,o;return p=new v({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZtaWNyb3NvZnQlMkZEZWVwU3BlZWRFeGFtcGxlcyUwQWNkJTIwRGVlcFNwZWVkRXhhbXBsZXMlMEFmaW5kJTIwLiUyMC1uYW1lJTIwJypqc29uJyUwQSUyMyUyMGZpbmQlMjBleGFtcGxlcyUyMHdpdGglMjB0aGUlMjBMYW1iJTIwb3B0aW1pemVyJTBBZ3JlcCUyMC1pJTIwTGFtYiUyMCUyNChmaW5kJTIwLiUyMC1uYW1lJTIwJypqc29uJyk=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/microsoft/DeepSpeedExamples
<span class="hljs-built_in">cd</span> DeepSpeedExamples
find . -name <span class="hljs-string">&#x27;*json&#x27;</span>
<span class="hljs-comment"># find examples with the Lamb optimizer</span>
grep -i Lamb $(find . -name <span class="hljs-string">&#x27;*json&#x27;</span>)`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-a4z01l"&&(a.innerHTML=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function xo(g){let a,c;return a=new v({props:{code:"VHJhaW5pbmdBcmd1bWVudHMoLi4uJTJDJTIwZGVlcHNwZWVkJTNEJTIycGF0aCUyRnRvJTJGZGVlcHNwZWVkX2NvbmZpZy5qc29uJTIyKQ==",highlighted:'TrainingArguments(..., deepspeed=<span class="hljs-string">&quot;path/to/deepspeed_config.json&quot;</span>)',wrap:!1}}),{c(){J(a.$$.fragment)},l(n){d(a.$$.fragment,n)},m(n,p){w(a,n,p),c=!0},p:S,i(n){c||(f(a.$$.fragment,n),c=!0)},o(n){U(a.$$.fragment,n),c=!1},d(n){j(a,n)}}}function Yo(g){let a,c;return a=new v({props:{code:"ZHNfY29uZmlnX2RpY3QlMjAlM0QlMjBkaWN0KHNjaGVkdWxlciUzRHNjaGVkdWxlcl9wYXJhbXMlMkMlMjBvcHRpbWl6ZXIlM0RvcHRpbWl6ZXJfcGFyYW1zKSUwQWFyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyguLi4lMkMlMjBkZWVwc3BlZWQlM0Rkc19jb25maWdfZGljdCklMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lcihtb2RlbCUyQyUyMGFyZ3MlMkMlMjAuLi4p",highlighted:`ds_config_dict = <span class="hljs-built_in">dict</span>(scheduler=scheduler_params, optimizer=optimizer_params)
args = TrainingArguments(..., deepspeed=ds_config_dict)
trainer = Trainer(model, args, ...)`,wrap:!1}}),{c(){J(a.$$.fragment)},l(n){d(a.$$.fragment,n)},m(n,p){w(a,n,p),c=!0},p:S,i(n){c||(f(a.$$.fragment,n),c=!0)},o(n){U(a.$$.fragment,n),c=!1},d(n){j(a,n)}}}function Fo(g){let a,c,n,p;return a=new Y({props:{id:"pass-config",option:"path to file",$$slots:{default:[xo]},$$scope:{ctx:g}}}),n=new Y({props:{id:"pass-config",option:"nested dict",$$slots:{default:[Yo]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function Lo(g){let a;return{c(){a=qo("DeepSpeed doesn’t validate parameter names and any typos fallback on the parameter's default setting. You can watch the DeepSpeed engine startup log messages to see what values it is going to use.")},l(c){a=Xo(c,"DeepSpeed doesn’t validate parameter names and any typos fallback on the parameter's default setting. You can watch the DeepSpeed engine startup log messages to see what values it is going to use.")},m(c,n){l(c,a,n)},d(c){c&&t(a)}}}function Do(g){let a,c="ZeRO-1 shards the optimizer states across GPUs, and you can expect a tiny speed up. The ZeRO-1 config can be setup like this:",n,p,o;return p=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyemVyb19vcHRpbWl6YXRpb24lMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZSUyMiUzQSUyMDElMEElMjAlMjAlMjAlMjAlN0QlMEElN0Q=",highlighted:`{
    <span class="hljs-attr">&quot;zero_optimization&quot;:</span> {
        <span class="hljs-attr">&quot;stage&quot;:</span> <span class="hljs-number">1</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.textContent=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-hkpv8b"&&(a.textContent=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function Po(g){let a,c="ZeRO-2 shards the optimizer and gradients across GPUs. This stage is primarily used for training since its features are not relevant to inference. Some important parameters to configure for better performance include:",n,p,o="<li><code>offload_optimizer</code> should be enabled to reduce GPU memory usage.</li> <li><code>overlap_comm</code> when set to <code>true</code> trades off increased GPU memory usage to lower allreduce latency. This feature uses 4.5x the <code>allgather_bucket_size</code> and <code>reduce_bucket_size</code> values. In this example, they’re set to <code>5e8</code> which means it requires 9GB of GPU memory. If your GPU memory is 8GB or less, you should reduce <code>overlap_comm</code> to lower the memory requirements and prevent an out-of-memory (OOM) error.</li> <li><code>allgather_bucket_size</code> and <code>reduce_bucket_size</code> trade off available GPU memory for communication speed. The smaller their values, the slower communication is and the more GPU memory is available. You can balance, for example, whether a bigger batch size is more important than a slightly slower training time.</li> <li><code>round_robin_gradients</code> is available in DeepSpeed 0.4.4 for CPU offloading. It parallelizes gradient copying to CPU memory among ranks by fine-grained gradient partitioning. Performance benefit grows with gradient accumulation steps (more copying between optimizer steps) or GPU count (increased parallelism).</li>",i,y,b;return y=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyemVyb19vcHRpbWl6YXRpb24lMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZSUyMiUzQSUyMDIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJvZmZsb2FkX29wdGltaXplciUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmRldmljZSUyMiUzQSUyMCUyMmNwdSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBpbl9tZW1vcnklMjIlM0ElMjB0cnVlJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYWxsZ2F0aGVyX3BhcnRpdGlvbnMlMjIlM0ElMjB0cnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYWxsZ2F0aGVyX2J1Y2tldF9zaXplJTIyJTNBJTIwNWU4JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyb3ZlcmxhcF9jb21tJTIyJTNBJTIwdHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJlZHVjZV9zY2F0dGVyJTIyJTNBJTIwdHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJlZHVjZV9idWNrZXRfc2l6ZSUyMiUzQSUyMDVlOCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbnRpZ3VvdXNfZ3JhZGllbnRzJTIyJTNBJTIwdHJ1ZSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvdW5kX3JvYmluX2dyYWRpZW50cyUyMiUzQSUyMHRydWUlMEElMjAlMjAlMjAlMjAlN0QlMEElN0Q=",highlighted:`{
    <span class="hljs-attr">&quot;zero_optimization&quot;:</span> {
        <span class="hljs-attr">&quot;stage&quot;:</span> <span class="hljs-number">2</span>,
        <span class="hljs-attr">&quot;offload_optimizer&quot;:</span> {
            <span class="hljs-attr">&quot;device&quot;:</span> <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-attr">&quot;pin_memory&quot;:</span> <span class="hljs-literal">true</span>
        },
        <span class="hljs-attr">&quot;allgather_partitions&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;allgather_bucket_size&quot;:</span> <span class="hljs-number">5e8</span>,
        <span class="hljs-attr">&quot;overlap_comm&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;reduce_scatter&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;reduce_bucket_size&quot;:</span> <span class="hljs-number">5e8</span>,
        <span class="hljs-attr">&quot;contiguous_gradients&quot;:</span> <span class="hljs-literal">true</span>
        <span class="hljs-attr">&quot;round_robin_gradients&quot;:</span> <span class="hljs-literal">true</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.textContent=c,n=M(),p=m("ul"),p.innerHTML=o,i=M(),J(y.$$.fragment)},l(I){a=u(I,"P",{"data-svelte-h":!0}),T(a)!=="svelte-19reu34"&&(a.textContent=c),n=r(I),p=u(I,"UL",{"data-svelte-h":!0}),T(p)!=="svelte-1ji2a0e"&&(p.innerHTML=o),i=r(I),d(y.$$.fragment,I)},m(I,B){l(I,a,B),l(I,n,B),l(I,p,B),l(I,i,B),w(y,I,B),b=!0},p:S,i(I){b||(f(y.$$.fragment,I),b=!0)},o(I){U(y.$$.fragment,I),b=!1},d(I){I&&(t(a),t(n),t(p),t(i)),j(y,I)}}}function Oo(g){let a,c='For more information about initializing large models with ZeRO-3 and accessing the parameters, take a look at the <a href="https://deepspeed.readthedocs.io/en/latest/zero3.html#constructing-massive-models" rel="nofollow">Constructing Massive Models</a> and <a href="https://deepspeed.readthedocs.io/en/latest/zero3.html#gathering-parameters" rel="nofollow">Gathering Parameters</a> guides.';return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-14c3i1p"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function Ko(g){let a,c="ZeRO-3 shards the optimizer, gradient, and parameters across GPUs. Unlike ZeRO-2, ZeRO-3 can also be used for inference, in addition to training, because it allows large models to be loaded on multiple GPUs. Some important parameters to configure include:",n,p,o='<li><p><code>device: &quot;cpu&quot;</code> can help if you’re running out of GPU memory and if you have free CPU memory available. This allows offloading model parameters to the CPU.</p></li> <li><p><code>pin_memory: true</code> can improve throughput, but less memory becomes available for other processes because the pinned memory is reserved for the specific process that requested it and it’s typically accessed much faster than normal CPU memory.</p></li> <li><p><code>stage3_max_live_parameters</code> is the upper limit on how many full parameters you want to keep on the GPU at any given time. Reduce this value if you encounter an OOM error.</p></li> <li><p><code>stage3_max_reuse_distance</code> is a value for determining when a parameter is used again in the future, and it helps decide whether to throw the parameter away or to keep it. If the parameter is going to be reused (if the value is less than <code>stage3_max_reuse_distance</code>), then it is kept to reduce communication overhead. This is super helpful when activation checkpointing is enabled and you want to keep the parameter in the forward recompute until the backward pass. But reduce this value if you encounter an OOM error.</p></li> <li><p><code>stage3_gather_16bit_weights_on_model_save</code> consolidates fp16 weights when a model is saved. For large models and multiple GPUs, this is expensive in terms of memory and speed. You should enable it if you’re planning on resuming training.</p></li> <li><p><code>sub_group_size</code> controls which parameters are updated during the optimizer step. Parameters are grouped into buckets of <code>sub_group_size</code> and each bucket is updated one at a time. When used with NVMe offload, <code>sub_group_size</code> determines when model states are moved in and out of CPU memory from during the optimization step. This prevents running out of CPU memory for extremely large models. <code>sub_group_size</code> can be left to its default value if you aren’t using NVMe offload, but you may want to change it if you:</p> <ol><li>Run into an OOM error during the optimizer step. In this case, reduce <code>sub_group_size</code> to reduce memory usage of the temporary buffers.</li> <li>The optimizer step is taking a really long time. In this case, increase <code>sub_group_size</code> to improve bandwidth utilization as a result of increased data buffers.</li></ol></li> <li><p><code>reduce_bucket_size</code>, <code>stage3_prefetch_bucket_size</code>, and <code>stage3_param_persistence_threshold</code> are dependent on a model’s hidden size. It is recommended to set these values to <code>auto</code> and allow the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> to automatically assign the values.</p></li>',i,y,b,I,B='You can use the <a href="https://deepspeed.readthedocs.io/en/latest/zero3.html#deepspeed.zero.Init" rel="nofollow"><code>deepspeed.zero.Init</code></a> context manager to initialize a model faster:',W,G,R,h,_='For pretrained models, the DeepSped config file needs to have <code>is_deepspeed_zero3_enabled: true</code> setup in <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> and it needs a ZeRO configuration enabled. The <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> object must be created <strong>before</strong> calling the model <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>.',q,N,Z,A,V='You’ll need ZeRO-3 if the fp16 weights don’t fit on a single GPU. If you’re able to load fp16 weights, then make sure you specify <code>torch_dtype=torch.float16</code> in <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>.',H,D,P='Another consideration for ZeRO-3 is if you have multiple GPUs, no single GPU has all the parameters unless it’s the parameters for the currently executing layer. To access all parameters from all the layers at once, such as loading pretrained model weights in <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>, one layer is loaded at a time and immediately partitioned to all GPUs. This is because for very large models, it isn’t possible to load the weights on one GPU and then distribute them across the other GPUs due to memory limitations.',F,x,K="If you encounter a model parameter weight that looks like the following, where <code>tensor([1.])</code> or the parameter size is 1 instead of a larger multi-dimensional shape, this means the parameter is partitioned and this is a ZeRO-3 placeholder.",ee,Q,te,E,O;return y=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyemVyb19vcHRpbWl6YXRpb24lMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZSUyMiUzQSUyMDMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJvZmZsb2FkX29wdGltaXplciUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmRldmljZSUyMiUzQSUyMCUyMmNwdSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBpbl9tZW1vcnklMjIlM0ElMjB0cnVlJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyb2ZmbG9hZF9wYXJhbSUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmRldmljZSUyMiUzQSUyMCUyMmNwdSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBpbl9tZW1vcnklMjIlM0ElMjB0cnVlJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyb3ZlcmxhcF9jb21tJTIyJTNBJTIwdHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbnRpZ3VvdXNfZ3JhZGllbnRzJTIyJTNBJTIwdHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN1Yl9ncm91cF9zaXplJTIyJTNBJTIwMWU5JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycmVkdWNlX2J1Y2tldF9zaXplJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWdlM19wcmVmZXRjaF9idWNrZXRfc2l6ZSUyMiUzQSUyMCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZTNfcGFyYW1fcGVyc2lzdGVuY2VfdGhyZXNob2xkJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWdlM19tYXhfbGl2ZV9wYXJhbWV0ZXJzJTIyJTNBJTIwMWU5JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhZ2UzX21heF9yZXVzZV9kaXN0YW5jZSUyMiUzQSUyMDFlOSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWdlM19nYXRoZXJfMTZiaXRfd2VpZ2h0c19vbl9tb2RlbF9zYXZlJTIyJTNBJTIwdHJ1ZSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`{
    <span class="hljs-attr">&quot;zero_optimization&quot;:</span> {
        <span class="hljs-attr">&quot;stage&quot;:</span> <span class="hljs-number">3</span>,
        <span class="hljs-attr">&quot;offload_optimizer&quot;:</span> {
            <span class="hljs-attr">&quot;device&quot;:</span> <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-attr">&quot;pin_memory&quot;:</span> <span class="hljs-literal">true</span>
        },
        <span class="hljs-attr">&quot;offload_param&quot;:</span> {
            <span class="hljs-attr">&quot;device&quot;:</span> <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-attr">&quot;pin_memory&quot;:</span> <span class="hljs-literal">true</span>
        },
        <span class="hljs-attr">&quot;overlap_comm&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;contiguous_gradients&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;sub_group_size&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;reduce_bucket_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_prefetch_bucket_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_param_persistence_threshold&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_max_live_parameters&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;stage3_max_reuse_distance&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;stage3_gather_16bit_weights_on_model_save&quot;:</span> <span class="hljs-literal">true</span>
    }
}`,wrap:!1}}),G=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFQ1Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTIwVDVDb25maWclMEFpbXBvcnQlMjBkZWVwc3BlZWQlMEElMEF3aXRoJTIwZGVlcHNwZWVkLnplcm8uSW5pdCgpJTNBJTBBJTIwJTIwJTIwJTIwY29uZmlnJTIwJTNEJTIwVDVDb25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS10NSUyRnQ1LXNtYWxsJTIyKSUwQSUyMCUyMCUyMCUyMG1vZGVsJTIwJTNEJTIwVDVGb3JDb25kaXRpb25hbEdlbmVyYXRpb24oY29uZmlnKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> T5ForConditionalGeneration, T5Config
<span class="hljs-keyword">import</span> deepspeed

<span class="hljs-keyword">with</span> deepspeed.zero.Init():
    config = T5Config.from_pretrained(<span class="hljs-string">&quot;google-t5/t5-small&quot;</span>)
    model = T5ForConditionalGeneration(config)`,wrap:!1}}),N=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUyQyUyMFRyYWluZXIlMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyguLi4lMkMlMjBkZWVwc3BlZWQlM0Rkc19jb25maWcpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS10NSUyRnQ1LXNtYWxsJTIyKSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKG1vZGVsJTNEbW9kZWwlMkMlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUyMC4uLik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, Trainer, TrainingArguments

training_args = TrainingArguments(..., deepspeed=ds_config)
model = AutoModel.from_pretrained(<span class="hljs-string">&quot;google-t5/t5-small&quot;</span>)
trainer = Trainer(model=model, args=training_args, ...)`,wrap:!1}}),Q=new v({props:{code:"dGVuc29yKCU1QjEuMCU1RCUyQyUyMGRldmljZSUzRCUyMmN1ZGElM0EwJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwcmVxdWlyZXNfZ3JhZCUzRFRydWUp",highlighted:'tensor([<span class="hljs-number">1.0</span>], device=<span class="hljs-string">&quot;cuda:0&quot;</span>, dtype=torch.float16, requires_grad=<span class="hljs-literal">True</span>)',wrap:!1}}),E=new Me({props:{$$slots:{default:[Oo]},$$scope:{ctx:g}}}),{c(){a=m("p"),a.textContent=c,n=M(),p=m("ul"),p.innerHTML=o,i=M(),J(y.$$.fragment),b=M(),I=m("p"),I.innerHTML=B,W=M(),J(G.$$.fragment),R=M(),h=m("p"),h.innerHTML=_,q=M(),J(N.$$.fragment),Z=M(),A=m("p"),A.innerHTML=V,H=M(),D=m("p"),D.innerHTML=P,F=M(),x=m("p"),x.innerHTML=K,ee=M(),J(Q.$$.fragment),te=M(),J(E.$$.fragment)},l($){a=u($,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1xly99k"&&(a.textContent=c),n=r($),p=u($,"UL",{"data-svelte-h":!0}),T(p)!=="svelte-108uxb6"&&(p.innerHTML=o),i=r($),d(y.$$.fragment,$),b=r($),I=u($,"P",{"data-svelte-h":!0}),T(I)!=="svelte-19jrhyn"&&(I.innerHTML=B),W=r($),d(G.$$.fragment,$),R=r($),h=u($,"P",{"data-svelte-h":!0}),T(h)!=="svelte-101ae6u"&&(h.innerHTML=_),q=r($),d(N.$$.fragment,$),Z=r($),A=u($,"P",{"data-svelte-h":!0}),T(A)!=="svelte-zcr9px"&&(A.innerHTML=V),H=r($),D=u($,"P",{"data-svelte-h":!0}),T(D)!=="svelte-1cn8zz5"&&(D.innerHTML=P),F=r($),x=u($,"P",{"data-svelte-h":!0}),T(x)!=="svelte-1t077r5"&&(x.innerHTML=K),ee=r($),d(Q.$$.fragment,$),te=r($),d(E.$$.fragment,$)},m($,k){l($,a,k),l($,n,k),l($,p,k),l($,i,k),w(y,$,k),l($,b,k),l($,I,k),l($,W,k),w(G,$,k),l($,R,k),l($,h,k),l($,q,k),w(N,$,k),l($,Z,k),l($,A,k),l($,H,k),l($,D,k),l($,F,k),l($,x,k),l($,ee,k),w(Q,$,k),l($,te,k),w(E,$,k),O=!0},p($,k){const se={};k&2&&(se.$$scope={dirty:k,ctx:$}),E.$set(se)},i($){O||(f(y.$$.fragment,$),f(G.$$.fragment,$),f(N.$$.fragment,$),f(Q.$$.fragment,$),f(E.$$.fragment,$),O=!0)},o($){U(y.$$.fragment,$),U(G.$$.fragment,$),U(N.$$.fragment,$),U(Q.$$.fragment,$),U(E.$$.fragment,$),O=!1},d($){$&&(t(a),t(n),t(p),t(i),t(b),t(I),t(W),t(R),t(h),t(q),t(Z),t(A),t(H),t(D),t(F),t(x),t(ee),t(te)),j(y,$),j(G,$),j(N,$),j(Q,$),j(E,$)}}}function ei(g){let a,c,n,p,o,i;return a=new Y({props:{id:"zero-config",option:"ZeRO-1",$$slots:{default:[Do]},$$scope:{ctx:g}}}),n=new Y({props:{id:"zero-config",option:"ZeRO-2",$$slots:{default:[Po]},$$scope:{ctx:g}}}),o=new Y({props:{id:"zero-config",option:"ZeRO-3",$$slots:{default:[Ko]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment),p=M(),J(o.$$.fragment)},l(y){d(a.$$.fragment,y),c=r(y),d(n.$$.fragment,y),p=r(y),d(o.$$.fragment,y)},m(y,b){w(a,y,b),l(y,c,b),w(n,y,b),l(y,p,b),w(o,y,b),i=!0},p(y,b){const I={};b&2&&(I.$$scope={dirty:b,ctx:y}),a.$set(I);const B={};b&2&&(B.$$scope={dirty:b,ctx:y}),n.$set(B);const W={};b&2&&(W.$$scope={dirty:b,ctx:y}),o.$set(W)},i(y){i||(f(a.$$.fragment,y),f(n.$$.fragment,y),f(o.$$.fragment,y),i=!0)},o(y){U(a.$$.fragment,y),U(n.$$.fragment,y),U(o.$$.fragment,y),i=!1},d(y){y&&(t(c),t(p)),j(a,y),j(n,y),j(o,y)}}}function ti(g){let a,c='The optimizer and scheduler parameters for the config file can be set from the command line to avoid hard to find errors. For example, if the learning rate is set to a different value in another place you can override it from the command line. Aside from the optimizer and scheduler parameters, you’ll need to ensure your <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> command line arguments match the DeepSpeed configuration.';return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-12t9s6d"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function li(g){let a,c='DeepSpeed offers several <a href="https://www.deepspeed.ai/docs/config-json/#optimizer-parameters" rel="nofollow">optimizers</a> (Adam, AdamW, OneBitAdam, and LAMB) but you can also import other optimizers from PyTorch. If you don’t configure the optimizer in the config, the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> automatically selects AdamW and either uses the supplied values or the default values for the following parameters from the command line: <code>lr</code>, <code>adam_beta1</code>, <code>adam_beta2</code>, <code>adam_epsilon</code>, <code>weight_decay</code>.',n,p,o="You can set the parameters to <code>&quot;auto&quot;</code> or manually input your own desired values.",i,y,b,I,B="You can also use an unsupported optimizer by adding the following to the top level configuration.",W,G,R,h,_="From DeepSpeed==0.8.3 on, if you want to use offload, you’ll also need to the following to the top level configuration because offload works best with DeepSpeed’s CPU Adam optimizer.",q,N,Z;return y=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIyb3B0aW1pemVyJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydHlwZSUyMiUzQSUyMCUyMkFkYW1XJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGFyYW1zJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybHIlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYmV0YXMlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZXBzJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMndlaWdodF9kZWNheSUyMiUzQSUyMCUyMmF1dG8lMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlN0QlMEElN0Q=",highlighted:`{
   <span class="hljs-attr">&quot;optimizer&quot;:</span> {
       <span class="hljs-attr">&quot;type&quot;:</span> <span class="hljs-string">&quot;AdamW&quot;</span>,
       <span class="hljs-attr">&quot;params&quot;:</span> {
         <span class="hljs-attr">&quot;lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
         <span class="hljs-attr">&quot;betas&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
         <span class="hljs-attr">&quot;eps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
         <span class="hljs-attr">&quot;weight_decay&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
       }
   }
}`,wrap:!1}}),G=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIyemVyb19hbGxvd191bnRlc3RlZF9vcHRpbWl6ZXIlMjIlM0ElMjB0cnVlJTBBJTdE",highlighted:`{
   <span class="hljs-attr">&quot;zero_allow_untested_optimizer&quot;:</span> <span class="hljs-literal">true</span>
}`,wrap:!1}}),N=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIyemVyb19mb3JjZV9kc19jcHVfb3B0aW1pemVyJTIyJTNBJTIwZmFsc2UlMEElN0Q=",highlighted:`{
   <span class="hljs-attr">&quot;zero_force_ds_cpu_optimizer&quot;:</span> <span class="hljs-literal">false</span>
}`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),p=m("p"),p.innerHTML=o,i=M(),J(y.$$.fragment),b=M(),I=m("p"),I.textContent=B,W=M(),J(G.$$.fragment),R=M(),h=m("p"),h.textContent=_,q=M(),J(N.$$.fragment)},l(A){a=u(A,"P",{"data-svelte-h":!0}),T(a)!=="svelte-19gj6ej"&&(a.innerHTML=c),n=r(A),p=u(A,"P",{"data-svelte-h":!0}),T(p)!=="svelte-1c8r8fs"&&(p.innerHTML=o),i=r(A),d(y.$$.fragment,A),b=r(A),I=u(A,"P",{"data-svelte-h":!0}),T(I)!=="svelte-1ecbnix"&&(I.textContent=B),W=r(A),d(G.$$.fragment,A),R=r(A),h=u(A,"P",{"data-svelte-h":!0}),T(h)!=="svelte-ybmwnz"&&(h.textContent=_),q=r(A),d(N.$$.fragment,A)},m(A,V){l(A,a,V),l(A,n,V),l(A,p,V),l(A,i,V),w(y,A,V),l(A,b,V),l(A,I,V),l(A,W,V),w(G,A,V),l(A,R,V),l(A,h,V),l(A,q,V),w(N,A,V),Z=!0},p:S,i(A){Z||(f(y.$$.fragment,A),f(G.$$.fragment,A),f(N.$$.fragment,A),Z=!0)},o(A){U(y.$$.fragment,A),U(G.$$.fragment,A),U(N.$$.fragment,A),Z=!1},d(A){A&&(t(a),t(n),t(p),t(i),t(b),t(I),t(W),t(R),t(h),t(q)),j(y,A),j(G,A),j(N,A)}}}function si(g){let a,c='DeepSpeed supports the LRRangeTest, OneCycle, WarmupLR and WarmupDecayLR learning rate <a href="https://www.deepspeed.ai/docs/config-json/#scheduler-parameters" rel="nofollow">schedulers</a>.',n,p,o="Transformers and DeepSpeed provide two of the same schedulers:",i,y,b="<li>WarmupLR is the same as <code>--lr_scheduler_type constant_with_warmup</code> in Transformers</li> <li>WarmupDecayLR is the same as  <code>--lr_scheduler_type linear</code> in Transformers (this is the default scheduler used in Transformers)</li>",I,B,W='If you don’t configure the scheduler in the config, the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> automatically selects WarmupDecayLR and either uses the supplied values or the default values for the following parameters from the command line: <code>warmup_min_lr</code>, <code>warmup_max_lr</code>, <code>warmup_num_steps</code>, <code>total_num_steps</code> (automatically calculated during run time if <code>max_steps</code> is not provided).',G,R,h="You can set the parameters to <code>&quot;auto&quot;</code> or manually input your own desired values.",_,q,N;return q=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIyc2NoZWR1bGVyJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydHlwZSUyMiUzQSUyMCUyMldhcm11cERlY2F5TFIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwYXJhbXMlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0b3RhbF9udW1fc3RlcHMlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyd2FybXVwX21pbl9sciUyMiUzQSUyMCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ3YXJtdXBfbWF4X2xyJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMndhcm11cF9udW1fc3RlcHMlMjIlM0ElMjAlMjJhdXRvJTIyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTdE",highlighted:`{
   <span class="hljs-attr">&quot;scheduler&quot;:</span> {
         <span class="hljs-attr">&quot;type&quot;:</span> <span class="hljs-string">&quot;WarmupDecayLR&quot;</span>,
         <span class="hljs-attr">&quot;params&quot;:</span> {
             <span class="hljs-attr">&quot;total_num_steps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
             <span class="hljs-attr">&quot;warmup_min_lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
             <span class="hljs-attr">&quot;warmup_max_lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
             <span class="hljs-attr">&quot;warmup_num_steps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
         }
     }
}`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),p=m("p"),p.textContent=o,i=M(),y=m("ul"),y.innerHTML=b,I=M(),B=m("p"),B.innerHTML=W,G=M(),R=m("p"),R.innerHTML=h,_=M(),J(q.$$.fragment)},l(Z){a=u(Z,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1te33vu"&&(a.innerHTML=c),n=r(Z),p=u(Z,"P",{"data-svelte-h":!0}),T(p)!=="svelte-6jv6ql"&&(p.textContent=o),i=r(Z),y=u(Z,"UL",{"data-svelte-h":!0}),T(y)!=="svelte-1g6khrb"&&(y.innerHTML=b),I=r(Z),B=u(Z,"P",{"data-svelte-h":!0}),T(B)!=="svelte-1etugnr"&&(B.innerHTML=W),G=r(Z),R=u(Z,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1c8r8fs"&&(R.innerHTML=h),_=r(Z),d(q.$$.fragment,Z)},m(Z,A){l(Z,a,A),l(Z,n,A),l(Z,p,A),l(Z,i,A),l(Z,y,A),l(Z,I,A),l(Z,B,A),l(Z,G,A),l(Z,R,A),l(Z,_,A),w(q,Z,A),N=!0},p:S,i(Z){N||(f(q.$$.fragment,Z),N=!0)},o(Z){U(q.$$.fragment,Z),N=!1},d(Z){Z&&(t(a),t(n),t(p),t(i),t(y),t(I),t(B),t(G),t(R),t(_)),j(q,Z)}}}function ai(g){let a,c,n,p;return a=new Y({props:{id:"opt-sched",option:"optimizer",$$slots:{default:[li]},$$scope:{ctx:g}}}),n=new Y({props:{id:"opt-sched",option:"scheduler",$$slots:{default:[si]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function ni(g){let a,c="If your model doesn’t work well with mixed precision, for example if it wasn’t pretrained in mixed precision, you may encounter overflow or underflow issues which can cause NaN loss. For these cases, you should use full fp32 precision by explicitly disabling the default fp16 mode.",n,p,o,i,y='For Ampere GPUs and PyTorch &gt; 1.7, it automatically switches to the more efficient <a href="https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices" rel="nofollow">tf32</a> format for some operations but the results are still in fp32. You can control it from the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> by setting <code>--tf32</code> to enable it, and <code>--tf32 0</code> or <code>--no_tf32</code> to disable it.',b;return p=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyZnAxNiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmVuYWJsZWQlMjIlM0ElMjBmYWxzZSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`{
    <span class="hljs-attr">&quot;fp16&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-literal">false</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.textContent=c,n=M(),J(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y},l(I){a=u(I,"P",{"data-svelte-h":!0}),T(a)!=="svelte-14q857h"&&(a.textContent=c),n=r(I),d(p.$$.fragment,I),o=r(I),i=u(I,"P",{"data-svelte-h":!0}),T(i)!=="svelte-n1kf8c"&&(i.innerHTML=y)},m(I,B){l(I,a,B),l(I,n,B),w(p,I,B),l(I,o,B),l(I,i,B),b=!0},p:S,i(I){b||(f(p.$$.fragment,I),b=!0)},o(I){U(p.$$.fragment,I),b=!1},d(I){I&&(t(a),t(n),t(o),t(i)),j(p,I)}}}function oi(g){let a,c='To configure PyTorch AMP-like fp16 mixed precision reduces memory usage and accelerates training speed. <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> automatically enables or disables fp16 based on the value of <code>args.fp16_backend</code>, and the rest of the config can be set by you. fp16 is enabled from the command line when the following arguments are passed: <code>--fp16</code>, <code>--fp16_backend amp</code> or <code>--fp16_full_eval</code>.',n,p,o,i,y='For additional DeepSpeed fp16 training options, take a look at the <a href="https://www.deepspeed.ai/docs/config-json/#fp16-training-options" rel="nofollow">FP16 Training Options</a> reference.',b,I,B='To configure Apex-like fp16 mixed precision, setup the config as shown below with <code>&quot;auto&quot;</code> or your own values. <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> automatically configure <code>amp</code> based on the values of <code>args.fp16_backend</code> and <code>args.fp16_opt_level</code>. It can also be enabled from the command line when the following arguments are passed: <code>--fp16</code>, <code>--fp16_backend apex</code> or <code>--fp16_opt_level 01</code>.',W,G,R;return p=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyZnAxNiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmVuYWJsZWQlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybG9zc19zY2FsZSUyMiUzQSUyMDAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsb3NzX3NjYWxlX3dpbmRvdyUyMiUzQSUyMDEwMDAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJpbml0aWFsX3NjYWxlX3Bvd2VyJTIyJTNBJTIwMTYlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJoeXN0ZXJlc2lzJTIyJTNBJTIwMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1pbl9sb3NzX3NjYWxlJTIyJTNBJTIwMSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`{
    <span class="hljs-attr">&quot;fp16&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;loss_scale&quot;:</span> <span class="hljs-number">0</span>,
        <span class="hljs-attr">&quot;loss_scale_window&quot;:</span> <span class="hljs-number">1000</span>,
        <span class="hljs-attr">&quot;initial_scale_power&quot;:</span> <span class="hljs-number">16</span>,
        <span class="hljs-attr">&quot;hysteresis&quot;:</span> <span class="hljs-number">2</span>,
        <span class="hljs-attr">&quot;min_loss_scale&quot;:</span> <span class="hljs-number">1</span>
    }
}`,wrap:!1}}),G=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyYW1wJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5hYmxlZCUyMiUzQSUyMCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJvcHRfbGV2ZWwlMjIlM0ElMjAlMjJhdXRvJTIyJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTdE",highlighted:`{
    <span class="hljs-attr">&quot;amp&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;opt_level&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y,b=M(),I=m("p"),I.innerHTML=B,W=M(),J(G.$$.fragment)},l(h){a=u(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-ktricy"&&(a.innerHTML=c),n=r(h),d(p.$$.fragment,h),o=r(h),i=u(h,"P",{"data-svelte-h":!0}),T(i)!=="svelte-rsxg0g"&&(i.innerHTML=y),b=r(h),I=u(h,"P",{"data-svelte-h":!0}),T(I)!=="svelte-1l2cotq"&&(I.innerHTML=B),W=r(h),d(G.$$.fragment,h)},m(h,_){l(h,a,_),l(h,n,_),w(p,h,_),l(h,o,_),l(h,i,_),l(h,b,_),l(h,I,_),l(h,W,_),w(G,h,_),R=!0},p:S,i(h){R||(f(p.$$.fragment,h),f(G.$$.fragment,h),R=!0)},o(h){U(p.$$.fragment,h),U(G.$$.fragment,h),R=!1},d(h){h&&(t(a),t(n),t(o),t(i),t(b),t(I),t(W)),j(p,h),j(G,h)}}}function ii(g){let a,c='To use bf16, you’ll need at least DeepSpeed==0.6.0. bf16 has the same dynamic range as fp32 and doesn’t require loss scaling. However, if you use <a href="#gradient-accumulation">gradient accumulation</a> with bf16, gradients are accumulated in bf16 which may not be desired because this format’s low precision can lead to lossy accumulation.',n,p,o="bf16 can be setup in the config file or enabled from the command line when the following arguments are passed: <code>--bf16</code> or <code>--bf16_full_eval</code>.",i,y,b;return y=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyYmYxNiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmVuYWJsZWQlMjIlM0ElMjAlMjJhdXRvJTIyJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTdE",highlighted:`{
    <span class="hljs-attr">&quot;bf16&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),p=m("p"),p.innerHTML=o,i=M(),J(y.$$.fragment)},l(I){a=u(I,"P",{"data-svelte-h":!0}),T(a)!=="svelte-9fep10"&&(a.innerHTML=c),n=r(I),p=u(I,"P",{"data-svelte-h":!0}),T(p)!=="svelte-f1ubot"&&(p.innerHTML=o),i=r(I),d(y.$$.fragment,I)},m(I,B){l(I,a,B),l(I,n,B),l(I,p,B),l(I,i,B),w(y,I,B),b=!0},p:S,i(I){b||(f(y.$$.fragment,I),b=!0)},o(I){U(y.$$.fragment,I),b=!1},d(I){I&&(t(a),t(n),t(p),t(i)),j(y,I)}}}function Mi(g){let a,c,n,p,o,i;return a=new Y({props:{id:"precision",option:"fp32",$$slots:{default:[ni]},$$scope:{ctx:g}}}),n=new Y({props:{id:"precision",option:"fp16",$$slots:{default:[oi]},$$scope:{ctx:g}}}),o=new Y({props:{id:"precision",option:"bf16",$$slots:{default:[ii]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment),p=M(),J(o.$$.fragment)},l(y){d(a.$$.fragment,y),c=r(y),d(n.$$.fragment,y),p=r(y),d(o.$$.fragment,y)},m(y,b){w(a,y,b),l(y,c,b),w(n,y,b),l(y,p,b),w(o,y,b),i=!0},p(y,b){const I={};b&2&&(I.$$scope={dirty:b,ctx:y}),a.$set(I);const B={};b&2&&(B.$$scope={dirty:b,ctx:y}),n.$set(B);const W={};b&2&&(W.$$scope={dirty:b,ctx:y}),o.$set(W)},i(y){i||(f(a.$$.fragment,y),f(n.$$.fragment,y),f(o.$$.fragment,y),i=!0)},o(y){U(a.$$.fragment,y),U(n.$$.fragment,y),U(o.$$.fragment,y),i=!1},d(y){y&&(t(c),t(p)),j(a,y),j(n,y),j(o,y)}}}function ri(g){let a,c="To deploy DeepSpeed on multiple GPUs, add the <code>--num_gpus</code> parameter. If you want to use all available GPUs, you don’t need to add <code>--num_gpus</code>. The example below uses 2 GPUs.",n,p,o;return p=new v({props:{code:"ZGVlcHNwZWVkJTIwLS1udW1fZ3B1cyUzRDIlMjBleGFtcGxlcyUyRnB5dG9yY2glMkZ0cmFuc2xhdGlvbiUyRnJ1bl90cmFuc2xhdGlvbi5weSUyMCU1QyUwQS0tZGVlcHNwZWVkJTIwdGVzdHMlMkZkZWVwc3BlZWQlMkZkc19jb25maWdfemVybzMuanNvbiUyMCU1QyUwQS0tbW9kZWxfbmFtZV9vcl9wYXRoJTIwZ29vZ2xlLXQ1JTJGdDUtc21hbGwlMjAtLXBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUyMDElMjAlNUMlMEEtLW91dHB1dF9kaXIlMjBvdXRwdXRfZGlyJTIwLS1vdmVyd3JpdGVfb3V0cHV0X2RpciUyMC0tZnAxNiUyMCU1QyUwQS0tZG9fdHJhaW4lMjAtLW1heF90cmFpbl9zYW1wbGVzJTIwNTAwJTIwLS1udW1fdHJhaW5fZXBvY2hzJTIwMSUyMCU1QyUwQS0tZGF0YXNldF9uYW1lJTIwd210MTYlMjAtLWRhdGFzZXRfY29uZmlnJTIwJTIycm8tZW4lMjIlMjAlNUMlMEEtLXNvdXJjZV9sYW5nJTIwZW4lMjAtLXRhcmdldF9sYW5nJTIwcm8=",highlighted:`deepspeed --num_gpus=2 examples/pytorch/translation/run_translation.py \\
--deepspeed tests/deepspeed/ds_config_zero3.json \\
--model_name_or_path google-t5/t5-small --per_device_train_batch_size 1 \\
--output_dir output_dir --overwrite_output_dir --fp16 \\
--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`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1crs7lp"&&(a.innerHTML=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function pi(g){let a,c='Set the <code>allgather_bucket_size</code> and <code>reduce_bucket_size</code> values to 2e8 in the <a href="#zero-configuration">ZeRO-2</a> configuration file to get better performance on a single GPU.';return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-7bkscr"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function yi(g){let a,c="To deploy DeepSpeed on a single GPU, add the <code>--num_gpus</code> parameter. It isn’t necessary to explicitly set this value if you only have 1 GPU because DeepSpeed deploys all GPUs it can see on a given node.",n,p,o,i,y="DeepSpeed is still useful with just 1 GPU because you can:",b,I,B="<li>Offload some computations and memory to the CPU to make more GPU resources available to your model to use a larger batch size or fit a very large model that normally won’t fit.</li> <li>Minimize memory fragmentation with it’s smart GPU memory management system which also allows you to fit bigger models and data batches.</li>",W,G,R;return p=new v({props:{code:"ZGVlcHNwZWVkJTIwLS1udW1fZ3B1cyUzRDElMjBleGFtcGxlcyUyRnB5dG9yY2glMkZ0cmFuc2xhdGlvbiUyRnJ1bl90cmFuc2xhdGlvbi5weSUyMCU1QyUwQS0tZGVlcHNwZWVkJTIwdGVzdHMlMkZkZWVwc3BlZWQlMkZkc19jb25maWdfemVybzIuanNvbiUyMCU1QyUwQS0tbW9kZWxfbmFtZV9vcl9wYXRoJTIwZ29vZ2xlLXQ1JTJGdDUtc21hbGwlMjAtLXBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUyMDElMjAlNUMlMEEtLW91dHB1dF9kaXIlMjBvdXRwdXRfZGlyJTIwLS1vdmVyd3JpdGVfb3V0cHV0X2RpciUyMC0tZnAxNiUyMCU1QyUwQS0tZG9fdHJhaW4lMjAtLW1heF90cmFpbl9zYW1wbGVzJTIwNTAwJTIwLS1udW1fdHJhaW5fZXBvY2hzJTIwMSUyMCU1QyUwQS0tZGF0YXNldF9uYW1lJTIwd210MTYlMjAtLWRhdGFzZXRfY29uZmlnJTIwJTIycm8tZW4lMjIlMjAlNUMlMEEtLXNvdXJjZV9sYW5nJTIwZW4lMjAtLXRhcmdldF9sYW5nJTIwcm8=",highlighted:`deepspeed --num_gpus=1 examples/pytorch/translation/run_translation.py \\
--deepspeed tests/deepspeed/ds_config_zero2.json \\
--model_name_or_path google-t5/t5-small --per_device_train_batch_size 1 \\
--output_dir output_dir --overwrite_output_dir --fp16 \\
--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`,wrap:!1}}),G=new Me({props:{$$slots:{default:[pi]},$$scope:{ctx:g}}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment),o=M(),i=m("p"),i.textContent=y,b=M(),I=m("ol"),I.innerHTML=B,W=M(),J(G.$$.fragment)},l(h){a=u(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-qfcnk"&&(a.innerHTML=c),n=r(h),d(p.$$.fragment,h),o=r(h),i=u(h,"P",{"data-svelte-h":!0}),T(i)!=="svelte-1nox3dx"&&(i.textContent=y),b=r(h),I=u(h,"OL",{"data-svelte-h":!0}),T(I)!=="svelte-1g5xefo"&&(I.innerHTML=B),W=r(h),d(G.$$.fragment,h)},m(h,_){l(h,a,_),l(h,n,_),w(p,h,_),l(h,o,_),l(h,i,_),l(h,b,_),l(h,I,_),l(h,W,_),w(G,h,_),R=!0},p(h,_){const q={};_&2&&(q.$$scope={dirty:_,ctx:h}),G.$set(q)},i(h){R||(f(p.$$.fragment,h),f(G.$$.fragment,h),R=!0)},o(h){U(p.$$.fragment,h),U(G.$$.fragment,h),R=!1},d(h){h&&(t(a),t(n),t(o),t(i),t(b),t(I),t(W)),j(p,h),j(G,h)}}}function ci(g){let a,c,n,p;return a=new Y({props:{id:"deploy",option:"multi-GPU",$$slots:{default:[ri]},$$scope:{ctx:g}}}),n=new Y({props:{id:"deploy",option:"single-GPU",$$slots:{default:[yi]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function mi(g){let a,c='For <a href="https://pytorch.org/docs/stable/elastic/run.html" rel="nofollow">torchrun</a>, you have to ssh to each node and run the following command on both of them. The launcher waits until both nodes are synchronized before launching the training.',n,p,o;return p=new v({props:{code:"dG9yY2hydW4lMjAtLW5wcm9jX3Blcl9ub2RlJTNEOCUyMC0tbm5vZGUlM0QyJTIwLS1ub2RlX3JhbmslM0QwJTIwLS1tYXN0ZXJfYWRkciUzRGhvc3RuYW1lMSUyMCU1QyUwQS0tbWFzdGVyX3BvcnQlM0Q5OTAxJTIweW91cl9wcm9ncmFtLnB5JTIwJTNDbm9ybWFsJTIwY2wlMjBhcmdzJTNFJTIwLS1kZWVwc3BlZWQlMjBkc19jb25maWcuanNvbg==",highlighted:`torchrun --nproc_per_node=8 --nnode=2 --node_rank=0 --master_addr=hostname1 \\
--master_port=9901 your_program.py &lt;normal cl args&gt; --deepspeed ds_config.json`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1bt3z60"&&(a.innerHTML=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function ui(g){let a,c="For the <code>deepspeed</code> launcher, start by creating a <code>hostfile</code>.",n,p,o,i,y="Then you can launch the training with the following command. The <code>deepspeed</code> launcher automatically launches the command on both nodes at once.",b,I,B,W,G='Check out the <a href="https://www.deepspeed.ai/getting-started/#resource-configuration-multi-node" rel="nofollow">Resource Configuration (multi-node)</a> guide for more details about configuring multi-node compute resources.',R;return p=new v({props:{code:"aG9zdG5hbWUxJTIwc2xvdHMlM0Q4JTBBaG9zdG5hbWUyJTIwc2xvdHMlM0Q4",highlighted:`hostname1 slots=8
hostname2 slots=8`,wrap:!1}}),I=new v({props:{code:"ZGVlcHNwZWVkJTIwLS1udW1fZ3B1cyUyMDglMjAtLW51bV9ub2RlcyUyMDIlMjAtLWhvc3RmaWxlJTIwaG9zdGZpbGUlMjAtLW1hc3Rlcl9hZGRyJTIwaG9zdG5hbWUxJTIwLS1tYXN0ZXJfcG9ydCUzRDk5MDElMjAlNUMlMEF5b3VyX3Byb2dyYW0ucHklMjAlM0Nub3JtYWwlMjBjbCUyMGFyZ3MlM0UlMjAtLWRlZXBzcGVlZCUyMGRzX2NvbmZpZy5qc29u",highlighted:`deepspeed --num_gpus 8 --num_nodes 2 --hostfile hostfile --master_addr hostname1 --master_port=9901 \\
your_program.py &lt;normal cl args&gt; --deepspeed ds_config.json`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y,b=M(),J(I.$$.fragment),B=M(),W=m("p"),W.innerHTML=G},l(h){a=u(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-ijhrw"&&(a.innerHTML=c),n=r(h),d(p.$$.fragment,h),o=r(h),i=u(h,"P",{"data-svelte-h":!0}),T(i)!=="svelte-1vzgmv9"&&(i.innerHTML=y),b=r(h),d(I.$$.fragment,h),B=r(h),W=u(h,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1ahoskn"&&(W.innerHTML=G)},m(h,_){l(h,a,_),l(h,n,_),w(p,h,_),l(h,o,_),l(h,i,_),l(h,b,_),w(I,h,_),l(h,B,_),l(h,W,_),R=!0},p:S,i(h){R||(f(p.$$.fragment,h),f(I.$$.fragment,h),R=!0)},o(h){U(p.$$.fragment,h),U(I.$$.fragment,h),R=!1},d(h){h&&(t(a),t(n),t(o),t(i),t(b),t(B),t(W)),j(p,h),j(I,h)}}}function Ti(g){let a,c,n,p;return a=new Y({props:{id:"multinode",option:"torchrun",$$slots:{default:[mi]},$$scope:{ctx:g}}}),n=new Y({props:{id:"multinode",option:"deepspeed",$$slots:{default:[ui]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function Ji(g){let a,c='A model trained with ZeRO-2 saves the pytorch_model.bin weights in fp16. To save the model weights in fp16 for a model trained with ZeRO-3, you need to set <code>&quot;stage3_gather_16bit_weights_on_model_save&quot;: true</code> because the model weights are partitioned across multiple GPUs. Otherwise, the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> won’t save the weights in fp16 and it won’t create a pytorch_model.bin file. This is because DeepSpeed’s state_dict contains a placeholder instead of the real weights and you won’t be able to load them.',n,p,o;return p=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyemVyb19vcHRpbWl6YXRpb24lMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZTNfZ2F0aGVyXzE2Yml0X3dlaWdodHNfb25fbW9kZWxfc2F2ZSUyMiUzQSUyMHRydWUlMEElMjAlMjAlMjAlMjAlN0QlMEElN0Q=",highlighted:`{
    <span class="hljs-attr">&quot;zero_optimization&quot;:</span> {
        <span class="hljs-attr">&quot;stage3_gather_16bit_weights_on_model_save&quot;:</span> <span class="hljs-literal">true</span>
    }
}`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-tkw2o5"&&(a.innerHTML=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function di(g){let a,c="Once <code>load_state_dict_from_zero_checkpoint</code> is run, the model is no longer usable in DeepSpeed in the context of the same application. You’ll need to initialize the DeepSpeed engine again since <code>model.load_state_dict(state_dict)</code> removes all the DeepSpeed magic from it. Only use this at the very end of training.";return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-s2e8vm"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function wi(g){let a,c="Run <code>python zero_to_fp32.py -h</code> for more usage details. The script requires 2x the general RAM of the final fp32 weights.";return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-m8616q"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function fi(g){let a,c="The full precision weights shouldn’t be saved during training because it can require a lot of memory. It is usually best to save the fp32 weights offline after training is complete. But if you have a lot of free CPU memory, it is possible to save the fp32 weights during training. This section covers both online and offline approaches.",n,p,o,i,y="You must have saved at least one checkpoint to load the latest checkpoint as shown in the following:",b,I,B,W,G='If you’ve enabled the <code>--load_best_model_at_end</code> parameter to track the best checkpoint in <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>, you can finish training first and save the final model explicitly. Then you can reload it as shown below:',R,h,_,q,N,Z,A="You can also extract and load the state_dict of the fp32 weights:",V,H,D,P,F,x,K='DeepSpeed provides a zero_to_fp32.py script at the top-level of the checkpoint folder for extracting weights at any point. This is a standalone script and you don’t need a configuration file or <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>.',ee,Q,te="For example, if your checkpoint folder looked like this:",E,O,$,k,se="To reconstruct the fp32 weights from the DeepSpeed checkpoint (ZeRO-2 or ZeRO-3) subfolder <code>global_step1</code>, run the following command to create and consolidate the full fp32 weights from multiple GPUs into a single pytorch_model.bin file. The script automatically discovers the subfolder containing the checkpoint.",le,ae,oe,L,je;return p=new X({props:{title:"Online",local:"online",headingTag:"h3"}}),I=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy50cmFpbmVyX3V0aWxzJTIwaW1wb3J0JTIwZ2V0X2xhc3RfY2hlY2twb2ludCUwQWZyb20lMjBkZWVwc3BlZWQudXRpbHMuemVyb190b19mcDMyJTIwaW1wb3J0JTIwbG9hZF9zdGF0ZV9kaWN0X2Zyb21femVyb19jaGVja3BvaW50JTBBJTBBY2hlY2twb2ludF9kaXIlMjAlM0QlMjBnZXRfbGFzdF9jaGVja3BvaW50KHRyYWluZXIuYXJncy5vdXRwdXRfZGlyKSUwQWZwMzJfbW9kZWwlMjAlM0QlMjBsb2FkX3N0YXRlX2RpY3RfZnJvbV96ZXJvX2NoZWNrcG9pbnQodHJhaW5lci5tb2RlbCUyQyUyMGNoZWNrcG9pbnRfZGlyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers.trainer_utils <span class="hljs-keyword">import</span> get_last_checkpoint
<span class="hljs-keyword">from</span> deepspeed.utils.zero_to_fp32 <span class="hljs-keyword">import</span> load_state_dict_from_zero_checkpoint

checkpoint_dir = get_last_checkpoint(trainer.args.output_dir)
fp32_model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)`,wrap:!1}}),h=new v({props:{code:"ZnJvbSUyMGRlZXBzcGVlZC51dGlscy56ZXJvX3RvX2ZwMzIlMjBpbXBvcnQlMjBsb2FkX3N0YXRlX2RpY3RfZnJvbV96ZXJvX2NoZWNrcG9pbnQlMEElMEFjaGVja3BvaW50X2RpciUyMCUzRCUyMG9zLnBhdGguam9pbih0cmFpbmVyLmFyZ3Mub3V0cHV0X2RpciUyQyUyMCUyMmNoZWNrcG9pbnQtZmluYWwlMjIpJTBBdHJhaW5lci5kZWVwc3BlZWQuc2F2ZV9jaGVja3BvaW50KGNoZWNrcG9pbnRfZGlyKSUwQWZwMzJfbW9kZWwlMjAlM0QlMjBsb2FkX3N0YXRlX2RpY3RfZnJvbV96ZXJvX2NoZWNrcG9pbnQodHJhaW5lci5tb2RlbCUyQyUyMGNoZWNrcG9pbnRfZGlyKQ==",highlighted:`<span class="hljs-keyword">from</span> deepspeed.utils.zero_to_fp32 <span class="hljs-keyword">import</span> load_state_dict_from_zero_checkpoint

checkpoint_dir = os.path.join(trainer.args.output_dir, <span class="hljs-string">&quot;checkpoint-final&quot;</span>)
trainer.deepspeed.save_checkpoint(checkpoint_dir)
fp32_model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)`,wrap:!1}}),q=new Me({props:{$$slots:{default:[di]},$$scope:{ctx:g}}}),H=new v({props:{code:"ZnJvbSUyMGRlZXBzcGVlZC51dGlscy56ZXJvX3RvX2ZwMzIlMjBpbXBvcnQlMjBnZXRfZnAzMl9zdGF0ZV9kaWN0X2Zyb21femVyb19jaGVja3BvaW50JTBBJTBBc3RhdGVfZGljdCUyMCUzRCUyMGdldF9mcDMyX3N0YXRlX2RpY3RfZnJvbV96ZXJvX2NoZWNrcG9pbnQoY2hlY2twb2ludF9kaXIpJTIwJTIwJTIzJTIwYWxyZWFkeSUyMG9uJTIwY3B1JTBBbW9kZWwlMjAlM0QlMjBtb2RlbC5jcHUoKSUwQW1vZGVsLmxvYWRfc3RhdGVfZGljdChzdGF0ZV9kaWN0KQ==",highlighted:`<span class="hljs-keyword">from</span> deepspeed.utils.zero_to_fp32 <span class="hljs-keyword">import</span> get_fp32_state_dict_from_zero_checkpoint

state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir)  <span class="hljs-comment"># already on cpu</span>
model = model.cpu()
model.load_state_dict(state_dict)`,wrap:!1}}),P=new X({props:{title:"Offline",local:"offline",headingTag:"h3"}}),O=new v({props:{code:"JTI0JTIwbHMlMjAtbCUyMG91dHB1dF9kaXIlMkZjaGVja3BvaW50LTElMkYlMEEtcnctcnctci0tJTIwMSUyMHN0YXMlMjBzdGFzJTIwMS40SyUyME1hciUyMDI3JTIwMjAlM0E0MiUyMGNvbmZpZy5qc29uJTBBZHJ3eHJ3eHIteCUyMDIlMjBzdGFzJTIwc3RhcyUyMDQuMEslMjBNYXIlMjAyNSUyMDE5JTNBNTIlMjBnbG9iYWxfc3RlcDElMkYlMEEtcnctcnctci0tJTIwMSUyMHN0YXMlMjBzdGFzJTIwJTIwJTIwMTIlMjBNYXIlMjAyNyUyMDEzJTNBMTYlMjBsYXRlc3QlMEEtcnctcnctci0tJTIwMSUyMHN0YXMlMjBzdGFzJTIwODI3SyUyME1hciUyMDI3JTIwMjAlM0E0MiUyMG9wdGltaXplci5wdCUwQS1ydy1ydy1yLS0lMjAxJTIwc3RhcyUyMHN0YXMlMjAyMzFNJTIwTWFyJTIwMjclMjAyMCUzQTQyJTIwcHl0b3JjaF9tb2RlbC5iaW4lMEEtcnctcnctci0tJTIwMSUyMHN0YXMlMjBzdGFzJTIwJTIwNjIzJTIwTWFyJTIwMjclMjAyMCUzQTQyJTIwc2NoZWR1bGVyLnB0JTBBLXJ3LXJ3LXItLSUyMDElMjBzdGFzJTIwc3RhcyUyMDEuOEslMjBNYXIlMjAyNyUyMDIwJTNBNDIlMjBzcGVjaWFsX3Rva2Vuc19tYXAuanNvbiUwQS1ydy1ydy1yLS0lMjAxJTIwc3RhcyUyMHN0YXMlMjA3NzRLJTIwTWFyJTIwMjclMjAyMCUzQTQyJTIwc3BpZWNlLm1vZGVsJTBBLXJ3LXJ3LXItLSUyMDElMjBzdGFzJTIwc3RhcyUyMDEuOUslMjBNYXIlMjAyNyUyMDIwJTNBNDIlMjB0b2tlbml6ZXJfY29uZmlnLmpzb24lMEEtcnctcnctci0tJTIwMSUyMHN0YXMlMjBzdGFzJTIwJTIwMzM5JTIwTWFyJTIwMjclMjAyMCUzQTQyJTIwdHJhaW5lcl9zdGF0ZS5qc29uJTBBLXJ3LXJ3LXItLSUyMDElMjBzdGFzJTIwc3RhcyUyMDIuM0slMjBNYXIlMjAyNyUyMDIwJTNBNDIlMjB0cmFpbmluZ19hcmdzLmJpbiUwQS1yd3hydy1yLS0lMjAxJTIwc3RhcyUyMHN0YXMlMjA1LjVLJTIwTWFyJTIwMjclMjAxMyUzQTE2JTIwemVyb190b19mcDMyLnB5Kg==",highlighted:`$ <span class="hljs-built_in">ls</span> -l output_dir/checkpoint-1/
-rw-rw-r-- 1 stas stas 1.4K Mar 27 20:42 config.json
drwxrwxr-x 2 stas stas 4.0K Mar 25 19:52 global_step1/
-rw-rw-r-- 1 stas stas   12 Mar 27 13:16 latest
-rw-rw-r-- 1 stas stas 827K Mar 27 20:42 optimizer.pt
-rw-rw-r-- 1 stas stas 231M Mar 27 20:42 pytorch_model.bin
-rw-rw-r-- 1 stas stas  623 Mar 27 20:42 scheduler.pt
-rw-rw-r-- 1 stas stas 1.8K Mar 27 20:42 special_tokens_map.json
-rw-rw-r-- 1 stas stas 774K Mar 27 20:42 spiece.model
-rw-rw-r-- 1 stas stas 1.9K Mar 27 20:42 tokenizer_config.json
-rw-rw-r-- 1 stas stas  339 Mar 27 20:42 trainer_state.json
-rw-rw-r-- 1 stas stas 2.3K Mar 27 20:42 training_args.bin
-rwxrw-r-- 1 stas stas 5.5K Mar 27 13:16 zero_to_fp32.py*`,wrap:!1}}),ae=new v({props:{code:"cHl0aG9uJTIwemVyb190b19mcDMyLnB5JTIwLiUyMHB5dG9yY2hfbW9kZWwuYmlu",highlighted:'python zero_to_fp32.py . pytorch_model.<span class="hljs-built_in">bin</span>',wrap:!1}}),L=new Me({props:{$$slots:{default:[wi]},$$scope:{ctx:g}}}),{c(){a=m("p"),a.textContent=c,n=M(),J(p.$$.fragment),o=M(),i=m("p"),i.textContent=y,b=M(),J(I.$$.fragment),B=M(),W=m("p"),W.innerHTML=G,R=M(),J(h.$$.fragment),_=M(),J(q.$$.fragment),N=M(),Z=m("p"),Z.textContent=A,V=M(),J(H.$$.fragment),D=M(),J(P.$$.fragment),F=M(),x=m("p"),x.innerHTML=K,ee=M(),Q=m("p"),Q.textContent=te,E=M(),J(O.$$.fragment),$=M(),k=m("p"),k.innerHTML=se,le=M(),J(ae.$$.fragment),oe=M(),J(L.$$.fragment)},l(C){a=u(C,"P",{"data-svelte-h":!0}),T(a)!=="svelte-idar67"&&(a.textContent=c),n=r(C),d(p.$$.fragment,C),o=r(C),i=u(C,"P",{"data-svelte-h":!0}),T(i)!=="svelte-130bwnm"&&(i.textContent=y),b=r(C),d(I.$$.fragment,C),B=r(C),W=u(C,"P",{"data-svelte-h":!0}),T(W)!=="svelte-11i0172"&&(W.innerHTML=G),R=r(C),d(h.$$.fragment,C),_=r(C),d(q.$$.fragment,C),N=r(C),Z=u(C,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-axrctj"&&(Z.textContent=A),V=r(C),d(H.$$.fragment,C),D=r(C),d(P.$$.fragment,C),F=r(C),x=u(C,"P",{"data-svelte-h":!0}),T(x)!=="svelte-xkeulr"&&(x.innerHTML=K),ee=r(C),Q=u(C,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-1gq5knk"&&(Q.textContent=te),E=r(C),d(O.$$.fragment,C),$=r(C),k=u(C,"P",{"data-svelte-h":!0}),T(k)!=="svelte-10tjpq7"&&(k.innerHTML=se),le=r(C),d(ae.$$.fragment,C),oe=r(C),d(L.$$.fragment,C)},m(C,z){l(C,a,z),l(C,n,z),w(p,C,z),l(C,o,z),l(C,i,z),l(C,b,z),w(I,C,z),l(C,B,z),l(C,W,z),l(C,R,z),w(h,C,z),l(C,_,z),w(q,C,z),l(C,N,z),l(C,Z,z),l(C,V,z),w(H,C,z),l(C,D,z),w(P,C,z),l(C,F,z),l(C,x,z),l(C,ee,z),l(C,Q,z),l(C,E,z),w(O,C,z),l(C,$,z),l(C,k,z),l(C,le,z),w(ae,C,z),l(C,oe,z),w(L,C,z),je=!0},p(C,z){const he={};z&2&&(he.$$scope={dirty:z,ctx:C}),q.$set(he);const ne={};z&2&&(ne.$$scope={dirty:z,ctx:C}),L.$set(ne)},i(C){je||(f(p.$$.fragment,C),f(I.$$.fragment,C),f(h.$$.fragment,C),f(q.$$.fragment,C),f(H.$$.fragment,C),f(P.$$.fragment,C),f(O.$$.fragment,C),f(ae.$$.fragment,C),f(L.$$.fragment,C),je=!0)},o(C){U(p.$$.fragment,C),U(I.$$.fragment,C),U(h.$$.fragment,C),U(q.$$.fragment,C),U(H.$$.fragment,C),U(P.$$.fragment,C),U(O.$$.fragment,C),U(ae.$$.fragment,C),U(L.$$.fragment,C),je=!1},d(C){C&&(t(a),t(n),t(o),t(i),t(b),t(B),t(W),t(R),t(_),t(N),t(Z),t(V),t(D),t(F),t(x),t(ee),t(Q),t(E),t($),t(k),t(le),t(oe)),j(p,C),j(I,C),j(h,C),j(q,C),j(H,C),j(P,C),j(O,C),j(ae,C),j(L,C)}}}function Ui(g){let a,c,n,p;return a=new Y({props:{id:"save",option:"fp16",$$slots:{default:[Ji]},$$scope:{ctx:g}}}),n=new Y({props:{id:"save",option:"fp32",$$slots:{default:[fi]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function ji(g){let a,c='If you want everything automatically taken care of for you, try using DeepSpeed with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>! You’ll need to follow the <a href="https://www.deepspeed.ai/" rel="nofollow">DeepSpeed documentation</a>, and manually configure the parameter values in the config file (you can’t use the <code>&quot;auto&quot;</code> value).';return{c(){a=m("p"),a.innerHTML=c},l(n){a=u(n,"P",{"data-svelte-h":!0}),T(a)!=="svelte-bmky8k"&&(a.innerHTML=c)},m(n,p){l(n,a,p)},p:S,d(n){n&&t(a)}}}function hi(g){let a,c;return a=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5pbnRlZ3JhdGlvbnMlMjBpbXBvcnQlMjBIZkRlZXBTcGVlZENvbmZpZyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWwlMEFpbXBvcnQlMjBkZWVwc3BlZWQlMEElMEFkc19jb25maWclMjAlM0QlMjAlN0IuLi4lN0QlMjAlMjAlMjMlMjBkZWVwc3BlZWQlMjBjb25maWclMjBvYmplY3QlMjBvciUyMHBhdGglMjB0byUyMHRoZSUyMGZpbGUlMEElMjMlMjBtdXN0JTIwcnVuJTIwYmVmb3JlJTIwaW5zdGFudGlhdGluZyUyMHRoZSUyMG1vZGVsJTIwdG8lMjBkZXRlY3QlMjB6ZXJvJTIwMyUwQWRzY2hmJTIwJTNEJTIwSGZEZWVwU3BlZWRDb25maWcoZHNfY29uZmlnKSUyMCUyMCUyMyUyMGtlZXAlMjB0aGlzJTIwb2JqZWN0JTIwYWxpdmUlMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBZW5naW5lJTIwJTNEJTIwZGVlcHNwZWVkLmluaXRpYWxpemUobW9kZWwlM0Rtb2RlbCUyQyUyMGNvbmZpZ19wYXJhbXMlM0Rkc19jb25maWclMkMlMjAuLi4p",highlighted:`<span class="hljs-keyword">from</span> transformers.integrations <span class="hljs-keyword">import</span> HfDeepSpeedConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel
<span class="hljs-keyword">import</span> deepspeed

ds_config = {...}  <span class="hljs-comment"># deepspeed config object or path to the file</span>
<span class="hljs-comment"># must run before instantiating the model to detect zero 3</span>
dschf = HfDeepSpeedConfig(ds_config)  <span class="hljs-comment"># keep this object alive</span>
model = AutoModel.from_pretrained(<span class="hljs-string">&quot;openai-community/gpt2&quot;</span>)
engine = deepspeed.initialize(model=model, config_params=ds_config, ...)`,wrap:!1}}),{c(){J(a.$$.fragment)},l(n){d(a.$$.fragment,n)},m(n,p){w(a,n,p),c=!0},p:S,i(n){c||(f(a.$$.fragment,n),c=!0)},o(n){U(a.$$.fragment,n),c=!1},d(n){j(a,n)}}}function Ii(g){let a,c="<code>HfDeepSpeedConfig</code> is not required for ZeRO-1 or ZeRO-2.",n,p,o;return p=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5pbnRlZ3JhdGlvbnMlMjBpbXBvcnQlMjBIZkRlZXBTcGVlZENvbmZpZyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWwlMkMlMjBBdXRvQ29uZmlnJTBBaW1wb3J0JTIwZGVlcHNwZWVkJTBBJTBBZHNfY29uZmlnJTIwJTNEJTIwJTdCLi4uJTdEJTIwJTIwJTIzJTIwZGVlcHNwZWVkJTIwY29uZmlnJTIwb2JqZWN0JTIwb3IlMjBwYXRoJTIwdG8lMjB0aGUlMjBmaWxlJTBBJTIzJTIwbXVzdCUyMHJ1biUyMGJlZm9yZSUyMGluc3RhbnRpYXRpbmclMjB0aGUlMjBtb2RlbCUyMHRvJTIwZGV0ZWN0JTIwemVybyUyMDMlMEFkc2NoZiUyMCUzRCUyMEhmRGVlcFNwZWVkQ29uZmlnKGRzX2NvbmZpZyklMjAlMjAlMjMlMjBrZWVwJTIwdGhpcyUyMG9iamVjdCUyMGFsaXZlJTBBY29uZmlnJTIwJTNEJTIwQXV0b0NvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9jb25maWcoY29uZmlnKSUwQWVuZ2luZSUyMCUzRCUyMGRlZXBzcGVlZC5pbml0aWFsaXplKG1vZGVsJTNEbW9kZWwlMkMlMjBjb25maWdfcGFyYW1zJTNEZHNfY29uZmlnJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers.integrations <span class="hljs-keyword">import</span> HfDeepSpeedConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoConfig
<span class="hljs-keyword">import</span> deepspeed

ds_config = {...}  <span class="hljs-comment"># deepspeed config object or path to the file</span>
<span class="hljs-comment"># must run before instantiating the model to detect zero 3</span>
dschf = HfDeepSpeedConfig(ds_config)  <span class="hljs-comment"># keep this object alive</span>
config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;openai-community/gpt2&quot;</span>)
model = AutoModel.from_config(config)
engine = deepspeed.initialize(model=model, config_params=ds_config, ...)`,wrap:!1}}),{c(){a=m("p"),a.innerHTML=c,n=M(),J(p.$$.fragment)},l(i){a=u(i,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1i7ih4n"&&(a.innerHTML=c),n=r(i),d(p.$$.fragment,i)},m(i,y){l(i,a,y),l(i,n,y),w(p,i,y),o=!0},p:S,i(i){o||(f(p.$$.fragment,i),o=!0)},o(i){U(p.$$.fragment,i),o=!1},d(i){i&&(t(a),t(n)),j(p,i)}}}function Ci(g){let a,c,n,p;return a=new Y({props:{id:"models",option:"pretrained model",$$slots:{default:[hi]},$$scope:{ctx:g}}}),n=new Y({props:{id:"models",option:"non-pretrained model",$$slots:{default:[Ii]},$$scope:{ctx:g}}}),{c(){J(a.$$.fragment),c=M(),J(n.$$.fragment)},l(o){d(a.$$.fragment,o),c=r(o),d(n.$$.fragment,o)},m(o,i){w(a,o,i),l(o,c,i),w(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),a.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(f(a.$$.fragment,o),f(n.$$.fragment,o),p=!0)},o(o){U(a.$$.fragment,o),U(n.$$.fragment,o),p=!1},d(o){o&&t(c),j(a,o),j(n,o)}}}function bi(g){let a,c,n,p,o,i,y,b='<a href="https://www.deepspeed.ai/" rel="nofollow">DeepSpeed</a> is a PyTorch optimization library that makes distributed training memory-efficient and fast. At its core is the <a href="https://hf.co/papers/1910.02054" rel="nofollow">Zero Redundancy Optimizer (ZeRO)</a> which enables training large models at scale. ZeRO works in several stages:',I,B,W="<li>ZeRO-1, optimizer state partitioning across GPUs</li> <li>ZeRO-2, gradient partitioning across GPUs</li> <li>ZeRO-3, parameter partitioning across GPUs</li>",G,R,h='In GPU-limited environments, ZeRO also enables offloading optimizer memory and computation from the GPU to the CPU to fit and train really large models on a single GPU. DeepSpeed is integrated with the Transformers <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> class for all ZeRO stages and offloading. All you need to do is provide a config file or you can use a provided template. For inference, Transformers support ZeRO-3 and offloading since it allows loading huge models.',_,q,N='This guide will walk you through how to deploy DeepSpeed training, the features you can enable, how to setup the config files for different ZeRO stages, offloading, inference, and using DeepSpeed without the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>.',Z,A,V,H,D='DeepSpeed is available to install from PyPI or Transformers (for more detailed installation options, take a look at the DeepSpeed <a href="https://www.deepspeed.ai/tutorials/advanced-install/" rel="nofollow">installation details</a> or the GitHub <a href="https://github.com/microsoft/deepspeed#installation" rel="nofollow">README</a>).',P,F,x,K,ee,Q,te,E,O='Before you begin, it is a good idea to check whether you have enough GPU and CPU memory to fit your model. DeepSpeed provides a tool for estimating the required CPU/GPU memory. For example, to estimate the memory requirements for the <a href="bigscience/T0_3B">bigscience/T0_3B</a> model on a single GPU:',$,k,se,le,ae="This means you either need a single 80GB GPU without CPU offload or a 8GB GPU and a ~60GB CPU to offload to (these are just the memory requirements for the parameters, optimizer states and gradients, and you’ll need a bit more for the CUDA kernels and activations). You should also consider the tradeoff between cost and speed because it’ll be cheaper to rent or buy a smaller GPU but it’ll take longer to train your model.",oe,L,je="If you have enough GPU memory make sure you disable CPU/NVMe offload to make everything faster.",C,z,he,ne,Oa="After you’ve installed DeepSpeed and have a better idea of your memory requirements, the next step is selecting a ZeRO stage to use. In order of fastest and most memory-efficient:",Zl,Ie,Ka="<thead><tr><th>Fastest</th> <th>Memory efficient</th></tr></thead> <tbody><tr><td>ZeRO-1</td> <td>ZeRO-3 + offload</td></tr> <tr><td>ZeRO-2</td> <td>ZeRO-3</td></tr> <tr><td>ZeRO-2 + offload</td> <td>ZeRO-2 + offload</td></tr> <tr><td>ZeRO-3</td> <td>ZeRO-2</td></tr> <tr><td>ZeRO-3 + offload</td> <td>ZeRO-1</td></tr></tbody>",vl,Ce,en="To find what works best for you, start with the fastest approach and if you run out of memory, try the next stage which is slower but more memory efficient. Feel free to work in whichever direction you prefer (starting with the most memory efficient or fastest) to discover the appropriate balance between speed and memory usage.",Gl,be,tn="A general process you can use is (start with batch size of 1):",Wl,ge,ln='<li>enable gradient checkpointing</li> <li>try ZeRO-2</li> <li>try ZeRO-2 and offload the optimizer</li> <li>try ZeRO-3</li> <li>try ZeRO-3 and offload parameters to the CPU</li> <li>try ZeRO-3 and offload parameters and the optimizer to the CPU</li> <li>try lowering various default values like a narrower search beam if you’re using the <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> method</li> <li>try mixed half-precision (fp16 on older GPU architectures and bf16 on Ampere) over full-precision weights</li> <li>add more hardware if possible or enable Infinity to offload parameters and the optimizer to a NVMe</li> <li>once you’re not running out of memory, measure effective throughput and then try to increase the batch size as large as you can to maximize GPU efficiency</li> <li>lastly, try to optimize your training setup by disabling some offload features or use a faster ZeRO stage and increasing/decreasing the batch size to find the best tradeoff between speed and memory usage</li>',Rl,$e,zl,Ae,sn='DeepSpeed works with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> class by way of a config file containing all the parameters for configuring how you want setup your training run. When you execute your training script, DeepSpeed logs the configuration it received from <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> to the console so you can see exactly what configuration was used.',kl,re,ql,Be,an='The DeepSpeed configuration file is passed as a path to a JSON file if you’re training from the command line interface or as a nested <code>dict</code> object if you’re using the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> in a notebook setting.',Xl,pe,Nl,_e,Vl,Ze,nn="There are three types of configuration parameters:",Sl,ve,on='<li><p>Some of the configuration parameters are shared by <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> and DeepSpeed, and it can be difficult to identify errors when there are conflicting definitions. To make it easier, these shared configuration parameters are configured from the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> command line arguments.</p></li> <li><p>Some configuration parameters that are automatically derived from the model configuration so you don’t need to manually adjust these values. The <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> uses a configuration value <code>auto</code> to determine set the most correct or efficient value. You could set your own configuration parameters explicitly, but you must take care to ensure the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> arguments and DeepSpeed configuration parameters agree. Mismatches may cause the training to fail in very difficult to detect ways!</p></li> <li><p>Some configuration parameters specific to DeepSpeed only which need to be manually set based on your training needs.</p></li>',Ql,Ge,Mn='You could also modify the DeepSpeed configuration and edit <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> from it:',El,We,rn='<li>Create or load a DeepSpeed configuration to use as the main configuration</li> <li>Create a <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> object based on these DeepSpeed configuration values</li>',Hl,Re,pn='Some values, such as <code>scheduler.params.total_num_steps</code> are calculated by the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> during training.',xl,ze,Yl,ke,yn='There are three configurations, each corresponding to a different ZeRO stage. Stage 1 is not as interesting for scalability, and this guide focuses on stages 2 and 3. The <code>zero_optimization</code> configuration contains all the options for what to enable and how to configure them. For a more detailed explanation of each parameter, take a look at the <a href="https://www.deepspeed.ai/docs/config-json/" rel="nofollow">DeepSpeed Configuration JSON</a> reference.',Fl,ye,Ll,qe,cn='The following configurations must be setup with DeepSpeed because the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> doesn’t provide equivalent command line arguments.',Dl,ce,Pl,Xe,Ol,Ne,mn='<a href="https://hf.co/papers/2104.07857" rel="nofollow">ZeRO-Infinity</a> allows offloading model states to the CPU and/or NVMe to save even more memory. Smart partitioning and tiling algorithms allow each GPU to send and receive very small amounts of data during offloading such that a modern NVMe can fit an even larger total memory pool than is available to your training process. ZeRO-Infinity requires ZeRO-3.',Kl,Ve,un='Depending on the CPU and/or NVMe memory available, you can offload both the <a href="https://www.deepspeed.ai/docs/config-json/#optimizer-offloading" rel="nofollow">optimizer states</a> and <a href="https://www.deepspeed.ai/docs/config-json/#parameter-offloading" rel="nofollow">parameters</a>, just one of them, or none. You should also make sure the <code>nvme_path</code> is pointing to an NVMe device, because while it still works with a normal hard drive or solid state drive, it’ll be significantly slower. With a modern NVMe, you can expect peak transfer speeds of ~3.5GB/s for read and ~3GB/s for write operations. Lastly, <a href="https://github.com/microsoft/DeepSpeed/issues/998" rel="nofollow">run a benchmark</a> on your training setup to determine the optimal <code>aio</code> configuration.',es,Se,Tn="The example ZeRO-3/Infinity configuration file below sets most of the parameter values to <code>auto</code>, but you could also manually add these values.",ts,Qe,ls,Ee,ss,He,Jn="There are a number of important parameters to specify in the DeepSpeed configuration file which are briefly described in this section.",as,xe,ns,Ye,dn="Activation and gradient checkpointing trades speed for more GPU memory which allows you to overcome scenarios where your GPU is out of memory or to increase your batch size for better performance. To enable this feature:",os,Fe,wn='<li>For a Hugging Face model, set <code>model.gradient_checkpointing_enable()</code> or <code>--gradient_checkpointing</code> in the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>.</li> <li>For a non-Hugging Face model, use the DeepSpeed <a href="https://deepspeed.readthedocs.io/en/latest/activation-checkpointing.html" rel="nofollow">Activation Checkpointing API</a>. You could also replace the Transformers modeling code and replace <code>torch.utils.checkpoint</code> with the DeepSpeed API. This approach is more flexible because you can offload the forward activations to the CPU memory instead of recalculating them.</li>',is,Le,Ms,De,fn="DeepSpeed and Transformers optimizer and scheduler can be mixed and matched as long as you don’t enable <code>offload_optimizer</code>. When <code>offload_optimizer</code> is enabled, you could use a non-DeepSpeed optimizer (except for LAMB) as long as it has both a CPU and GPU implementation.",rs,me,ps,ue,ys,Pe,cs,Oe,Un="Deepspeed supports fp32, fp16, and bf16 mixed precision.",ms,Te,us,Ke,Ts,et,jn='The batch size can be auto-configured or explicitly set. If you choose to use the <code>&quot;auto&quot;</code> option, <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> sets <code>train_micro_batch_size_per_gpu</code> to the value of args.<code>per_device_train_batch_size</code> and <code>train_batch_size</code> to <code>args.world_size * args.per_device_train_batch_size * args.gradient_accumulation_steps</code>.',Js,tt,ds,lt,ws,st,hn='Gradient accumulation can be auto-configured or explicitly set. If you choose to use the <code>&quot;auto&quot;</code> option, <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> sets it to the value of <code>args.gradient_accumulation_steps</code>.',fs,at,Us,nt,js,ot,In='Gradient clipping can be auto-configured or explicitly set. If you choose to use the <code>&quot;auto&quot;</code> option, <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> sets it to the value of <code>args.max_grad_norm</code>.',hs,it,Is,Mt,Cs,rt,Cn="For communication collectives like reduction, gathering and scattering operations, a separate data type is used.",bs,pt,bn="All gather and scatter operations are performed in the same data type the data is in. For example, if you’re training with bf16, the data is also gathered in bf16 because gathering is a non-lossy operation.",gs,yt,gn="Reduce operations are lossy, for example when gradients are averaged across multiple GPUs. When the communication is done in fp16 or bf16, it is more likely to be lossy because adding multiple numbers in low precision isn’t exact. This is especially the case with bf16 which has a lower precision than fp16. For this reason, fp16 is the default for reduction operations because the loss is minimal when averaging gradients.",$s,ct,$n="You can choose the communication data type by setting the <code>communication_data_type</code> parameter in the config file. For example, choosing fp32 adds a small amount of overhead but ensures the reduction operation is accumulated in fp32 and when it is ready, it is downcasted to whichever half-precision dtype you’re training in.",As,mt,Bs,ut,_s,Tt,An='<a href="https://www.deepspeed.ai/tutorials/universal-checkpointing" rel="nofollow">Universal Checkpointing</a> is an efficient and flexible feature for saving and loading model checkpoints. It enables seamless model training continuation and fine-tuning across different model architectures, parallelism techniques, and training configurations.',Zs,Jt,Bn='Resume training with a universal checkpoint by setting <a href="https://www.deepspeed.ai/docs/config-json/#checkpoint-options" rel="nofollow">load_universal</a> to <code>true</code> in the config file.',vs,dt,Gs,wt,Ws,ft,_n='DeepSpeed can be deployed by different launchers such as <a href="https://pytorch.org/docs/stable/elastic/run.html" rel="nofollow">torchrun</a>, the <code>deepspeed</code> launcher, or <a href="https://huggingface.co/docs/accelerate/basic_tutorials/launch#using-accelerate-launch" rel="nofollow">Accelerate</a>. To deploy, add <code>--deepspeed ds_config.json</code> to the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> command line. It’s recommended to use DeepSpeed’s <a href="https://deepspeed.readthedocs.io/en/latest/initialize.html#argument-parsing" rel="nofollow"><code>add_config_arguments</code></a> utility to add any necessary command line arguments to your code.',Rs,Ut,Zn='This guide will show you how to deploy DeepSpeed with the <code>deepspeed</code> launcher for different training setups. You can check out this <a href="https://github.com/huggingface/transformers/issues/8771#issuecomment-759248400" rel="nofollow">post</a> for more practical usage examples.',zs,Je,ks,jt,qs,ht,vn="A node is one or more GPUs for running a workload. A more powerful setup is a multi-node setup which can be launched with the <code>deepspeed</code> launcher. For this guide, let’s assume there are two nodes with 8 GPUs each. The first node can be accessed <code>ssh hostname1</code> and the second node with <code>ssh hostname2</code>. Both nodes must be able to communicate with each other locally over ssh without a password.",Xs,It,Gn='By default, DeepSpeed expects your multi-node environment to use a shared storage. If this is not the case and each node can only see the local filesystem, you need to adjust the config file to include a <a href="https://www.deepspeed.ai/docs/config-json/#checkpoint-options" rel="nofollow"><code>checkpoint</code></a> to allow loading without access to a shared filesystem:',Ns,Ct,Vs,bt,Wn='You could also use the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>’s <code>--save_on_each_node</code> argument to automatically add the above <code>checkpoint</code> to your config.',Ss,de,Qs,gt,Es,$t,Rn="In a SLURM environment, you’ll need to adapt your SLURM script to your specific SLURM environment. An example SLURM script may look like:",Hs,At,xs,Bt,zn="Then you can schedule your multi-node deployment with the following command which launches training simultaneously on all nodes.",Ys,_t,Fs,Zt,Ls,vt,kn="The <code>deepspeed</code> launcher doesn’t support deployment from a notebook so you’ll need to emulate the distributed environment. However, this only works for 1 GPU. If you want to use more than 1 GPU, you must use a multi-process environment for DeepSpeed to work. This means you have to use the <code>deepspeed</code> launcher which can’t be emulated as shown here.",Ds,Gt,Ps,Wt,qn="If you want to create the config file on the fly in the notebook in the current directory, you could have a dedicated cell.",Os,Rt,Ks,zt,Xn="If the training script is in a file and not in a notebook cell, you can launch <code>deepspeed</code> normally from the shell in a notebook cell. For example, to launch <code>run_translation.py</code>:",ea,kt,ta,qt,Nn="You could also use <code>%%bash</code> magic and write multi-line code to run the shell program, but you won’t be able to view the logs until training is complete. With <code>%%bash</code> magic, you don’t need to emulate a distributed environment.",la,Xt,sa,Nt,aa,Vt,Vn="DeepSpeed stores the main full precision fp32 weights in custom checkpoint optimizer files (the glob pattern looks like <code>global_step*/*optim_states.pt</code>) and are saved under the normal checkpoint.",na,we,oa,St,ia,Qt,Sn='<a href="https://www.deepspeed.ai/2022/09/09/zero-inference.html" rel="nofollow">ZeRO Inference</a> places the model weights in CPU or NVMe memory to avoid burdening the GPU which makes it possible to run inference with huge models on a GPU. Inference doesn’t require any large additional amounts of memory for the optimizer states and gradients so you can fit much larger batches and/or sequence lengths on the same hardware.',Ma,Et,Qn='ZeRO Inference shares the same configuration file as <a href="#zero-configuration">ZeRO-3</a>, and ZeRO-2 and ZeRO-1 configs won’t work because they don’t provide any benefits for inference.',ra,Ht,En='To run ZeRO Inference, pass your usual training arguments to the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> class and add the <code>--do_eval</code> argument.',pa,xt,ya,Yt,ca,Ft,Hn='DeepSpeed also works with Transformers without the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> class. This is handled by the <code>HfDeepSpeedConfig</code> which only takes care of gathering ZeRO-3 parameters and splitting a model across multiple GPUs when you call <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>.',ma,fe,ua,Lt,xn="To efficiently deploy ZeRO-3, you must instantiate the <code>HfDeepSpeedConfig</code> object before the model and keep that object alive:",Ta,Ue,Ja,Dt,da,Pt,Yn='To run ZeRO Inference without the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> in cases where you can’t fit a model onto a single GPU, try using additional GPUs or/and offloading to CPU memory. The important nuance to understand here is that the way ZeRO is designed, you can process different inputs on different GPUs in parallel.',wa,Ot,Fn="Make sure to:",fa,Kt,Ln="<li>disable CPU offload if you have enough GPU memory (since it slows things down).</li> <li>enable bf16 if you have an Ampere or newer GPU to make things faster. If you don’t have one of these GPUs, you may enable fp16 as long as you don’t use a model pretrained in bf16 (T5 models) because it may lead to an overflow error.</li>",Ua,el,Dn='Take a look at the following script to get a better idea of how to run ZeRO Inference without the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> on a model that won’t fit on a single GPU.',ja,tl,ha,ll,Pn="Save the script as t0.py and launch it:",Ia,sl,Ca,al,On="This is a very basic example and you’ll want to adapt it to your use case.",ba,nl,ga,ol,Kn='Using multiple GPUs with ZeRO-3 for generation requires synchronizing the GPUs by setting <code>synced_gpus=True</code> in the <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> method. Otherwise, if one GPU is finished generating before another one, the whole system hangs because the remaining GPUs haven’t received the weight shard from the GPU that finished first.',$a,il,eo="For Transformers&gt;=4.28, if <code>synced_gpus</code> is automatically set to <code>True</code> if multiple GPUs are detected during generation.",Aa,Ml,Ba,rl,to='When you encounter an issue, you should consider whether DeepSpeed is the cause of the problem because often it isn’t (unless it’s super obviously and you can see DeepSpeed modules in the exception)! The first step should be to retry your setup without DeepSpeed, and if the problem persists, then you can report the issue. If the issue is a core DeepSpeed problem and unrelated to the Transformers integration, open an Issue on the <a href="https://github.com/microsoft/DeepSpeed" rel="nofollow">DeepSpeed repository</a>.',_a,pl,lo="For issues related to the Transformers integration, please provide the following information:",Za,yl,so='<li><p>the full DeepSpeed config file</p></li> <li><p>the command line arguments of the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>, or <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> arguments if you’re scripting the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> setup yourself (don’t dump the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> which has dozens of irrelevant entries)</p></li> <li><p>the outputs of:</p></li>',va,cl,Ga,ml,ao="<li><p>a link to a Google Colab notebook to reproduce the issue</p></li> <li><p>if impossible, a standard and non-custom dataset we can use and also try to use an existing example to reproduce the issue with</p></li>",Wa,ul,no="The following sections provide a guide for resolving two of the most common issues.",Ra,Tl,za,Jl,oo="When the DeepSpeed process is killed during launch without a traceback, that usually means the program tried to allocate more CPU memory than your system has or your process tried to allocate more CPU memory than allowed leading the OS kernel to terminate the process. In this case, check whether your configuration file has either <code>offload_optimizer</code>, <code>offload_param</code> or both configured to offload to the CPU.",ka,dl,io='If you have NVMe and ZeRO-3 setup, experiment with offloading to the NVMe (<a href="https://deepspeed.readthedocs.io/en/latest/memory.html" rel="nofollow">estimate</a> the memory requirements for your model).',qa,wl,Xa,fl,Mo="NaN loss often occurs when a model is pretrained in bf16 and then you try to use it with fp16 (especially relevant for TPU trained models). To resolve this, use fp32 or bf16 if your hardware supports it (TPU, Ampere GPUs or newer).",Na,Ul,ro="The other issue may be related to using fp16. For example, if this is your fp16 configuration:",Va,jl,Sa,hl,po="You might see the following <code>OVERFLOW!</code> messages in the logs:",Qa,Il,Ea,Cl,yo="This means the DeepSpeed loss scaler is unable to find a scaling coefficient to overcome loss overflow. To fix it, try a higher <code>initial_scale_power</code> value (32 usually works).",Ha,bl,xa,gl,co='DeepSpeed ZeRO is a powerful technology for training and loading very large models for inference with limited GPU resources, making it more accessible to everyone. To learn more about DeepSpeed, feel free to read the <a href="https://www.microsoft.com/en-us/research/search/?q=deepspeed" rel="nofollow">blog posts</a>, <a href="https://www.deepspeed.ai/getting-started/" rel="nofollow">documentation</a>, and <a href="https://github.com/microsoft/deepspeed" rel="nofollow">GitHub repository</a>.',Ya,$l,mo="The following papers are also a great resource for learning more about ZeRO:",Fa,Al,uo='<li><a href="https://hf.co/papers/1910.02054" rel="nofollow">ZeRO: Memory Optimizations Toward Training Trillion Parameter Models</a></li> <li><a href="https://hf.co/papers/2101.06840" rel="nofollow">ZeRO-Offload: Democratizing Billion-Scale Model Training</a></li> <li><a href="https://hf.co/papers/2104.07857" rel="nofollow">ZeRO-Infinity: Breaking the GPU Memory Wall for Extreme Scale Deep Learning</a></li>',La,Bl,Da,_l,Pa;return o=new X({props:{title:"DeepSpeed",local:"deepspeed",headingTag:"h1"}}),A=new X({props:{title:"Installation",local:"installation",headingTag:"h2"}}),F=new Me({props:{$$slots:{default:[Vo]},$$scope:{ctx:g}}}),K=new ie({props:{id:"install",options:["PyPI","Transformers"],$$slots:{default:[Eo]},$$scope:{ctx:g}}}),Q=new X({props:{title:"Memory requirements",local:"memory-requirements",headingTag:"h2"}}),k=new v({props:{code:"JTI0JTIwcHl0aG9uJTIwLWMlMjAnZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUzQiUyMCU1QyUwQWZyb20lMjBkZWVwc3BlZWQucnVudGltZS56ZXJvLnN0YWdlMyUyMGltcG9ydCUyMGVzdGltYXRlX3plcm8zX21vZGVsX3N0YXRlc19tZW1fbmVlZHNfYWxsX2xpdmUlM0IlMjAlNUMlMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyYmlnc2NpZW5jZSUyRlQwXzNCJTIyKSUzQiUyMCU1QyUwQWVzdGltYXRlX3plcm8zX21vZGVsX3N0YXRlc19tZW1fbmVlZHNfYWxsX2xpdmUobW9kZWwlMkMlMjBudW1fZ3B1c19wZXJfbm9kZSUzRDElMkMlMjBudW1fbm9kZXMlM0QxKSclMEElNUIuLi4lNUQlMEFFc3RpbWF0ZWQlMjBtZW1vcnklMjBuZWVkZWQlMjBmb3IlMjBwYXJhbXMlMkMlMjBvcHRpbSUyMHN0YXRlcyUyMGFuZCUyMGdyYWRpZW50cyUyMGZvciUyMGElM0ElMEFIVyUzQSUyMFNldHVwJTIwd2l0aCUyMDElMjBub2RlJTJDJTIwMSUyMEdQVSUyMHBlciUyMG5vZGUuJTBBU1clM0ElMjBNb2RlbCUyMHdpdGglMjAyNzgzTSUyMHRvdGFsJTIwcGFyYW1zJTJDJTIwNjVNJTIwbGFyZ2VzdCUyMGxheWVyJTIwcGFyYW1zLiUwQSUyMCUyMHBlciUyMENQVSUyMCUyMCU3QyUyMCUyMHBlciUyMEdQVSUyMCU3QyUyMCUyMCUyME9wdGlvbnMlMEElMjAlMjAlMjA3MC4wMEdCJTIwJTdDJTIwJTIwJTIwMC4yNUdCJTIwJTdDJTIwb2ZmbG9hZF9wYXJhbSUzRGNwdSUyMCUyQyUyMG9mZmxvYWRfb3B0aW1pemVyJTNEY3B1JTIwJTJDJTIwemVyb19pbml0JTNEMSUwQSUyMCUyMCUyMDcwLjAwR0IlMjAlN0MlMjAlMjAlMjAwLjI1R0IlMjAlN0MlMjBvZmZsb2FkX3BhcmFtJTNEY3B1JTIwJTJDJTIwb2ZmbG9hZF9vcHRpbWl6ZXIlM0RjcHUlMjAlMkMlMjB6ZXJvX2luaXQlM0QwJTBBJTIwJTIwJTIwNjIuMjNHQiUyMCU3QyUyMCUyMCUyMDUuNDNHQiUyMCU3QyUyMG9mZmxvYWRfcGFyYW0lM0Rub25lJTJDJTIwb2ZmbG9hZF9vcHRpbWl6ZXIlM0RjcHUlMjAlMkMlMjB6ZXJvX2luaXQlM0QxJTBBJTIwJTIwJTIwNjIuMjNHQiUyMCU3QyUyMCUyMCUyMDUuNDNHQiUyMCU3QyUyMG9mZmxvYWRfcGFyYW0lM0Rub25lJTJDJTIwb2ZmbG9hZF9vcHRpbWl6ZXIlM0RjcHUlMjAlMkMlMjB6ZXJvX2luaXQlM0QwJTBBJTIwJTIwJTIwJTIwMC4zN0dCJTIwJTdDJTIwJTIwNDYuOTFHQiUyMCU3QyUyMG9mZmxvYWRfcGFyYW0lM0Rub25lJTJDJTIwb2ZmbG9hZF9vcHRpbWl6ZXIlM0Rub25lJTJDJTIwemVyb19pbml0JTNEMSUwQSUyMCUyMCUyMDE1LjU2R0IlMjAlN0MlMjAlMjA0Ni45MUdCJTIwJTdDJTIwb2ZmbG9hZF9wYXJhbSUzRG5vbmUlMkMlMjBvZmZsb2FkX29wdGltaXplciUzRG5vbmUlMkMlMjB6ZXJvX2luaXQlM0Qw",highlighted:`$ python -c <span class="hljs-string">&#x27;from transformers import AutoModel; \\
from deepspeed.runtime.zero.stage3 import estimate_zero3_model_states_mem_needs_all_live; \\
model = AutoModel.from_pretrained(&quot;bigscience/T0_3B&quot;); \\
estimate_zero3_model_states_mem_needs_all_live(model, num_gpus_per_node=1, num_nodes=1)&#x27;</span>
[...]
Estimated memory needed <span class="hljs-keyword">for</span> params, optim states and gradients <span class="hljs-keyword">for</span> a:
HW: Setup with 1 node, 1 GPU per node.
SW: Model with 2783M total params, 65M largest layer params.
  per CPU  |  per GPU |   Options
   70.00GB |   0.25GB | offload_param=cpu , offload_optimizer=cpu , zero_init=1
   70.00GB |   0.25GB | offload_param=cpu , offload_optimizer=cpu , zero_init=0
   62.23GB |   5.43GB | offload_param=none, offload_optimizer=cpu , zero_init=1
   62.23GB |   5.43GB | offload_param=none, offload_optimizer=cpu , zero_init=0
    0.37GB |  46.91GB | offload_param=none, offload_optimizer=none, zero_init=1
   15.56GB |  46.91GB | offload_param=none, offload_optimizer=none, zero_init=0`,wrap:!1}}),z=new X({props:{title:"Select a ZeRO stage",local:"select-a-zero-stage",headingTag:"h2"}}),$e=new X({props:{title:"DeepSpeed configuration file",local:"deepspeed-configuration-file",headingTag:"h2"}}),re=new Me({props:{$$slots:{default:[Ho]},$$scope:{ctx:g}}}),pe=new ie({props:{id:"pass-config",options:["path to file","nested dict"],$$slots:{default:[Fo]},$$scope:{ctx:g}}}),_e=new X({props:{title:"DeepSpeed and Trainer parameters",local:"deepspeed-and-trainer-parameters",headingTag:"h3"}}),ze=new X({props:{title:"ZeRO configuration",local:"zero-configuration",headingTag:"h3"}}),ye=new Me({props:{warning:!0,$$slots:{default:[Lo]},$$scope:{ctx:g}}}),ce=new ie({props:{id:"zero-config",options:["ZeRO-1","ZeRO-2","ZeRO-3"],$$slots:{default:[ei]},$$scope:{ctx:g}}}),Xe=new X({props:{title:"NVMe configuration",local:"nvme-configuration",headingTag:"h3"}}),Qe=new v({props:{code:" ",highlighted:`{
    <span class="hljs-attr">&quot;fp16&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;loss_scale&quot;:</span> <span class="hljs-number">0</span>,
        <span class="hljs-attr">&quot;loss_scale_window&quot;:</span> <span class="hljs-number">1000</span>,
        <span class="hljs-attr">&quot;initial_scale_power&quot;:</span> <span class="hljs-number">16</span>,
        <span class="hljs-attr">&quot;hysteresis&quot;:</span> <span class="hljs-number">2</span>,
        <span class="hljs-attr">&quot;min_loss_scale&quot;:</span> <span class="hljs-number">1</span>
    },

    <span class="hljs-attr">&quot;optimizer&quot;:</span> {
        <span class="hljs-attr">&quot;type&quot;:</span> <span class="hljs-string">&quot;AdamW&quot;</span>,
        <span class="hljs-attr">&quot;params&quot;:</span> {
            <span class="hljs-attr">&quot;lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-attr">&quot;betas&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-attr">&quot;eps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-attr">&quot;weight_decay&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
        }
    },

    <span class="hljs-attr">&quot;scheduler&quot;:</span> {
        <span class="hljs-attr">&quot;type&quot;:</span> <span class="hljs-string">&quot;WarmupLR&quot;</span>,
        <span class="hljs-attr">&quot;params&quot;:</span> {
            <span class="hljs-attr">&quot;warmup_min_lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-attr">&quot;warmup_max_lr&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-attr">&quot;warmup_num_steps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
        }
    },

    <span class="hljs-attr">&quot;zero_optimization&quot;:</span> {
        <span class="hljs-attr">&quot;stage&quot;:</span> <span class="hljs-number">3</span>,
        <span class="hljs-attr">&quot;offload_optimizer&quot;:</span> {
            <span class="hljs-attr">&quot;device&quot;:</span> <span class="hljs-string">&quot;nvme&quot;</span>,
            <span class="hljs-attr">&quot;nvme_path&quot;:</span> <span class="hljs-string">&quot;/local_nvme&quot;</span>,
            <span class="hljs-attr">&quot;pin_memory&quot;:</span> <span class="hljs-literal">true</span>,
            <span class="hljs-attr">&quot;buffer_count&quot;:</span> <span class="hljs-number">4</span>,
            <span class="hljs-attr">&quot;fast_init&quot;:</span> <span class="hljs-literal">false</span>
        },
        <span class="hljs-attr">&quot;offload_param&quot;:</span> {
            <span class="hljs-attr">&quot;device&quot;:</span> <span class="hljs-string">&quot;nvme&quot;</span>,
            <span class="hljs-attr">&quot;nvme_path&quot;:</span> <span class="hljs-string">&quot;/local_nvme&quot;</span>,
            <span class="hljs-attr">&quot;pin_memory&quot;:</span> <span class="hljs-literal">true</span>,
            <span class="hljs-attr">&quot;buffer_count&quot;:</span> <span class="hljs-number">5</span>,
            <span class="hljs-attr">&quot;buffer_size&quot;:</span> <span class="hljs-number">1e8</span>,
            <span class="hljs-attr">&quot;max_in_cpu&quot;:</span> <span class="hljs-number">1e9</span>
        },
        <span class="hljs-attr">&quot;aio&quot;:</span> {
            <span class="hljs-attr">&quot;block_size&quot;:</span> <span class="hljs-number">262144</span>,
            <span class="hljs-attr">&quot;queue_depth&quot;:</span> <span class="hljs-number">32</span>,
            <span class="hljs-attr">&quot;thread_count&quot;:</span> <span class="hljs-number">1</span>,
            <span class="hljs-attr">&quot;single_submit&quot;:</span> <span class="hljs-literal">false</span>,
            <span class="hljs-attr">&quot;overlap_events&quot;:</span> <span class="hljs-literal">true</span>
        },
        <span class="hljs-attr">&quot;overlap_comm&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;contiguous_gradients&quot;:</span> <span class="hljs-literal">true</span>,
        <span class="hljs-attr">&quot;sub_group_size&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;reduce_bucket_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_prefetch_bucket_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_param_persistence_threshold&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;stage3_max_live_parameters&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;stage3_max_reuse_distance&quot;:</span> <span class="hljs-number">1e9</span>,
        <span class="hljs-attr">&quot;stage3_gather_16bit_weights_on_model_save&quot;:</span> <span class="hljs-literal">true</span>
    },

    <span class="hljs-attr">&quot;gradient_accumulation_steps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">&quot;gradient_clipping&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">&quot;steps_per_print&quot;:</span> <span class="hljs-number">2000</span>,
    <span class="hljs-attr">&quot;train_batch_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">&quot;train_micro_batch_size_per_gpu&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">&quot;wall_clock_breakdown&quot;:</span> <span class="hljs-literal">false</span>
}`,wrap:!1}}),Ee=new X({props:{title:"DeepSpeed features",local:"deepspeed-features",headingTag:"h2"}}),xe=new X({props:{title:"Activation/gradient checkpointing",local:"activationgradient-checkpointing",headingTag:"h3"}}),Le=new X({props:{title:"Optimizer and scheduler",local:"optimizer-and-scheduler",headingTag:"h3"}}),me=new Me({props:{warning:!0,$$slots:{default:[ti]},$$scope:{ctx:g}}}),ue=new ie({props:{id:"opt-sched",options:["optimizer","scheduler"],$$slots:{default:[ai]},$$scope:{ctx:g}}}),Pe=new X({props:{title:"Precision",local:"precision",headingTag:"h3"}}),Te=new ie({props:{id:"precision",options:["fp32","fp16","bf16"],$$slots:{default:[Mi]},$$scope:{ctx:g}}}),Ke=new X({props:{title:"Batch size",local:"batch-size",headingTag:"h3"}}),tt=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIydHJhaW5fbWljcm9fYmF0Y2hfc2l6ZV9wZXJfZ3B1JTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnRyYWluX2JhdGNoX3NpemUlMjIlM0ElMjAlMjJhdXRvJTIyJTBBJTdE",highlighted:`{
    <span class="hljs-attr">&quot;train_micro_batch_size_per_gpu&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">&quot;train_batch_size&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
}`,wrap:!1}}),lt=new X({props:{title:"Gradient accumulation",local:"gradient-accumulation",headingTag:"h3"}}),at=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTIyJTNBJTIwJTIyYXV0byUyMiUwQSU3RCUwQQ==",highlighted:`{
    <span class="hljs-attr">&quot;gradient_accumulation_steps&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
}
`,wrap:!1}}),nt=new X({props:{title:"Gradient clipping",local:"gradient-clipping",headingTag:"h3"}}),it=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyZ3JhZGllbnRfY2xpcHBpbmclMjIlM0ElMjAlMjJhdXRvJTIyJTBBJTdE",highlighted:`{
    <span class="hljs-attr">&quot;gradient_clipping&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>
}`,wrap:!1}}),Mt=new X({props:{title:"Communication data type",local:"communication-data-type",headingTag:"h3"}}),mt=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyY29tbXVuaWNhdGlvbl9kYXRhX3R5cGUlMjIlM0ElMjAlMjJmcDMyJTIyJTBBJTdE",highlighted:`{
    <span class="hljs-attr">&quot;communication_data_type&quot;:</span> <span class="hljs-string">&quot;fp32&quot;</span>
}`,wrap:!1}}),ut=new X({props:{title:"Universal Checkpointing",local:"universal-checkpointing",headingTag:"h3"}}),dt=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyY2hlY2twb2ludCUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmxvYWRfdW5pdmVyc2FsJTIyJTNBJTIwdHJ1ZSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`{
    <span class="hljs-attr">&quot;checkpoint&quot;:</span> {
        <span class="hljs-attr">&quot;load_universal&quot;:</span> <span class="hljs-literal">true</span>
    }
}`,wrap:!1}}),wt=new X({props:{title:"Deployment",local:"deployment",headingTag:"h2"}}),Je=new ie({props:{id:"deploy",options:["multi-GPU","single-GPU"],$$slots:{default:[ci]},$$scope:{ctx:g}}}),jt=new X({props:{title:"Multi-node deployment",local:"multi-node-deployment",headingTag:"h3"}}),Ct=new v({props:{code:"JTdCJTBBJTIwJTIwJTIyY2hlY2twb2ludCUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnVzZV9ub2RlX2xvY2FsX3N0b3JhZ2UlMjIlM0ElMjB0cnVlJTBBJTIwJTIwJTdEJTBBJTdE",highlighted:`{
  <span class="hljs-attr">&quot;checkpoint&quot;:</span> {
    <span class="hljs-attr">&quot;use_node_local_storage&quot;:</span> <span class="hljs-literal">true</span>
  }
}`,wrap:!1}}),de=new ie({props:{id:"multinode",options:["torchrun","deepspeed"],$$slots:{default:[Ti]},$$scope:{ctx:g}}}),gt=new X({props:{title:"SLURM",local:"slurm",headingTag:"h3"}}),At=new v({props:{code:"JTIzU0JBVENIJTIwLS1qb2ItbmFtZSUzRHRlc3Qtbm9kZXMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBuYW1lJTBBJTIzU0JBVENIJTIwLS1ub2RlcyUzRDIlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBub2RlcyUwQSUyM1NCQVRDSCUyMC0tbnRhc2tzLXBlci1ub2RlJTNEMSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMGNydWNpYWwlMjAtJTIwb25seSUyMDElMjB0YXNrJTIwcGVyJTIwZGlzdCUyMHBlciUyMG5vZGUhJTBBJTIzU0JBVENIJTIwLS1jcHVzLXBlci10YXNrJTNEMTAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBudW1iZXIlMjBvZiUyMGNvcmVzJTIwcGVyJTIwdGFza3MlMEElMjNTQkFUQ0glMjAtLWdyZXMlM0RncHUlM0E4JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwbnVtYmVyJTIwb2YlMjBncHVzJTBBJTIzU0JBVENIJTIwLS10aW1lJTIwMjAlM0EwMCUzQTAwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwbWF4aW11bSUyMGV4ZWN1dGlvbiUyMHRpbWUlMjAoSEglM0FNTSUzQVNTKSUwQSUyM1NCQVRDSCUyMC0tb3V0cHV0JTNEJTI1eC0lMjVqLm91dCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMG91dHB1dCUyMGZpbGUlMjBuYW1lJTBBJTBBZXhwb3J0JTIwR1BVU19QRVJfTk9ERSUzRDglMEFleHBvcnQlMjBNQVNURVJfQUREUiUzRCUyNChzY29udHJvbCUyMHNob3clMjBob3N0bmFtZXMlMjAlMjRTTFVSTV9KT0JfTk9ERUxJU1QlMjAlN0MlMjBoZWFkJTIwLW4lMjAxKSUwQWV4cG9ydCUyME1BU1RFUl9QT1JUJTNEOTkwMSUwQSUwQXNydW4lMjAtLWpvYmlkJTIwJTI0U0xVUk1fSk9CSUQlMjBiYXNoJTIwLWMlMjAncHl0aG9uJTIwLW0lMjB0b3JjaC5kaXN0cmlidXRlZC5ydW4lMjAlNUMlMEElMjAtLW5wcm9jX3Blcl9ub2RlJTIwJTI0R1BVU19QRVJfTk9ERSUyMC0tbm5vZGVzJTIwJTI0U0xVUk1fTk5PREVTJTIwLS1ub2RlX3JhbmslMjAlMjRTTFVSTV9QUk9DSUQlMjAlNUMlMEElMjAtLW1hc3Rlcl9hZGRyJTIwJTI0TUFTVEVSX0FERFIlMjAtLW1hc3Rlcl9wb3J0JTIwJTI0TUFTVEVSX1BPUlQlMjAlNUMlMEF5b3VyX3Byb2dyYW0ucHklMjAlM0Nub3JtYWwlMjBjbCUyMGFyZ3MlM0UlMjAtLWRlZXBzcGVlZCUyMGRzX2NvbmZpZy5qc29uJw==",highlighted:`<span class="hljs-comment">#SBATCH --job-name=test-nodes        # name</span>
<span class="hljs-comment">#SBATCH --nodes=2                    # nodes</span>
<span class="hljs-comment">#SBATCH --ntasks-per-node=1          # crucial - only 1 task per dist per node!</span>
<span class="hljs-comment">#SBATCH --cpus-per-task=10           # number of cores per tasks</span>
<span class="hljs-comment">#SBATCH --gres=gpu:8                 # number of gpus</span>
<span class="hljs-comment">#SBATCH --time 20:00:00              # maximum execution time (HH:MM:SS)</span>
<span class="hljs-comment">#SBATCH --output=%x-%j.out           # output file name</span>

<span class="hljs-built_in">export</span> GPUS_PER_NODE=8
<span class="hljs-built_in">export</span> MASTER_ADDR=$(scontrol show hostnames <span class="hljs-variable">$SLURM_JOB_NODELIST</span> | <span class="hljs-built_in">head</span> -n 1)
<span class="hljs-built_in">export</span> MASTER_PORT=9901

srun --jobid <span class="hljs-variable">$SLURM_JOBID</span> bash -c <span class="hljs-string">&#x27;python -m torch.distributed.run \\
 --nproc_per_node $GPUS_PER_NODE --nnodes $SLURM_NNODES --node_rank $SLURM_PROCID \\
 --master_addr $MASTER_ADDR --master_port $MASTER_PORT \\
your_program.py &lt;normal cl args&gt; --deepspeed ds_config.json&#x27;</span>`,wrap:!1}}),_t=new v({props:{code:"c2JhdGNoJTIwbGF1bmNoLnNsdXJt",highlighted:"sbatch launch.slurm",wrap:!1}}),Zt=new X({props:{title:"Notebook",local:"notebook",headingTag:"h3"}}),Gt=new v({props:{code:"JTIzJTIwRGVlcFNwZWVkJTIwcmVxdWlyZXMlMjBhJTIwZGlzdHJpYnV0ZWQlMjBlbnZpcm9ubWVudCUyMGV2ZW4lMjB3aGVuJTIwb25seSUyMG9uZSUyMHByb2Nlc3MlMjBpcyUyMHVzZWQuJTBBJTIzJTIwVGhpcyUyMGVtdWxhdGVzJTIwYSUyMGxhdW5jaGVyJTIwaW4lMjB0aGUlMjBub3RlYm9vayUwQWltcG9ydCUyMG9zJTBBJTBBb3MuZW52aXJvbiU1QiUyMk1BU1RFUl9BRERSJTIyJTVEJTIwJTNEJTIwJTIybG9jYWxob3N0JTIyJTBBb3MuZW52aXJvbiU1QiUyMk1BU1RFUl9QT1JUJTIyJTVEJTIwJTNEJTIwJTIyOTk5NCUyMiUyMCUyMCUyMyUyMG1vZGlmeSUyMGlmJTIwUnVudGltZUVycm9yJTNBJTIwQWRkcmVzcyUyMGFscmVhZHklMjBpbiUyMHVzZSUwQW9zLmVudmlyb24lNUIlMjJSQU5LJTIyJTVEJTIwJTNEJTIwJTIyMCUyMiUwQW9zLmVudmlyb24lNUIlMjJMT0NBTF9SQU5LJTIyJTVEJTIwJTNEJTIwJTIyMCUyMiUwQW9zLmVudmlyb24lNUIlMjJXT1JMRF9TSVpFJTIyJTVEJTIwJTNEJTIwJTIyMSUyMiUwQSUwQSUyMyUyME5vdyUyMHByb2NlZWQlMjBhcyUyMG5vcm1hbCUyQyUyMHBsdXMlMjBwYXNzJTIwdGhlJTIwRGVlcFNwZWVkJTIwY29uZmlnJTIwZmlsZSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyguLi4lMkMlMjBkZWVwc3BlZWQlM0QlMjJkc19jb25maWdfemVybzMuanNvbiUyMiklMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciguLi4pJTBBdHJhaW5lci50cmFpbigp",highlighted:`<span class="hljs-comment"># DeepSpeed requires a distributed environment even when only one process is used.</span>
<span class="hljs-comment"># This emulates a launcher in the notebook</span>
<span class="hljs-keyword">import</span> os

os.environ[<span class="hljs-string">&quot;MASTER_ADDR&quot;</span>] = <span class="hljs-string">&quot;localhost&quot;</span>
os.environ[<span class="hljs-string">&quot;MASTER_PORT&quot;</span>] = <span class="hljs-string">&quot;9994&quot;</span>  <span class="hljs-comment"># modify if RuntimeError: Address already in use</span>
os.environ[<span class="hljs-string">&quot;RANK&quot;</span>] = <span class="hljs-string">&quot;0&quot;</span>
os.environ[<span class="hljs-string">&quot;LOCAL_RANK&quot;</span>] = <span class="hljs-string">&quot;0&quot;</span>
os.environ[<span class="hljs-string">&quot;WORLD_SIZE&quot;</span>] = <span class="hljs-string">&quot;1&quot;</span>

<span class="hljs-comment"># Now proceed as normal, plus pass the DeepSpeed config file</span>
training_args = TrainingArguments(..., deepspeed=<span class="hljs-string">&quot;ds_config_zero3.json&quot;</span>)
trainer = Trainer(...)
trainer.train()`,wrap:!1}}),Rt=new v({props:{code:"JTI1JTI1YmFzaCUwQWNhdCUyMCUzQyUzQydFT1QnJTIwJTNFJTIwZHNfY29uZmlnX3plcm8zLmpzb24lMEElN0IlMEElMjAlMjAlMjAlMjAlMjJmcDE2JTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5hYmxlZCUyMiUzQSUyMCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsb3NzX3NjYWxlJTIyJTNBJTIwMCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmxvc3Nfc2NhbGVfd2luZG93JTIyJTNBJTIwMTAwMCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmluaXRpYWxfc2NhbGVfcG93ZXIlMjIlM0ElMjAxNiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmh5c3RlcmVzaXMlMjIlM0ElMjAyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybWluX2xvc3Nfc2NhbGUlMjIlM0ElMjAxJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTBBJTIwJTIwJTIwJTIwJTIyb3B0aW1pemVyJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydHlwZSUyMiUzQSUyMCUyMkFkYW1XJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGFyYW1zJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybHIlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYmV0YXMlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZXBzJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMndlaWdodF9kZWNheSUyMiUzQSUyMCUyMmF1dG8lMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMEElMjAlMjAlMjAlMjAlMjJzY2hlZHVsZXIlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0eXBlJTIyJTNBJTIwJTIyV2FybXVwTFIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwYXJhbXMlMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ3YXJtdXBfbWluX2xyJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMndhcm11cF9tYXhfbHIlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyd2FybXVwX251bV9zdGVwcyUyMiUzQSUyMCUyMmF1dG8lMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMEElMjAlMjAlMjAlMjAlMjJ6ZXJvX29wdGltaXphdGlvbiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWdlJTIyJTNBJTIwMyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm9mZmxvYWRfb3B0aW1pemVyJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZGV2aWNlJTIyJTNBJTIwJTIyY3B1JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGluX21lbW9yeSUyMiUzQSUyMHRydWUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJvZmZsb2FkX3BhcmFtJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZGV2aWNlJTIyJTNBJTIwJTIyY3B1JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGluX21lbW9yeSUyMiUzQSUyMHRydWUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJvdmVybGFwX2NvbW0lMjIlM0ElMjB0cnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGlndW91c19ncmFkaWVudHMlMjIlM0ElMjB0cnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3ViX2dyb3VwX3NpemUlMjIlM0ElMjAxZTklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyZWR1Y2VfYnVja2V0X3NpemUlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhZ2UzX3ByZWZldGNoX2J1Y2tldF9zaXplJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnN0YWdlM19wYXJhbV9wZXJzaXN0ZW5jZV90aHJlc2hvbGQlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhZ2UzX21heF9saXZlX3BhcmFtZXRlcnMlMjIlM0ElMjAxZTklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFnZTNfbWF4X3JldXNlX2Rpc3RhbmNlJTIyJTNBJTIwMWU5JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhZ2UzX2dhdGhlcl8xNmJpdF93ZWlnaHRzX29uX21vZGVsX3NhdmUlMjIlM0ElMjB0cnVlJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTBBJTIwJTIwJTIwJTIwJTIyZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmdyYWRpZW50X2NsaXBwaW5nJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnN0ZXBzX3Blcl9wcmludCUyMiUzQSUyMDIwMDAlMkMlMEElMjAlMjAlMjAlMjAlMjJ0cmFpbl9iYXRjaF9zaXplJTIyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnRyYWluX21pY3JvX2JhdGNoX3NpemVfcGVyX2dwdSUyMiUzQSUyMCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJ3YWxsX2Nsb2NrX2JyZWFrZG93biUyMiUzQSUyMGZhbHNlJTBBJTdEJTBBRU9U",highlighted:`%%bash
cat &lt;&lt;<span class="hljs-string">&#x27;EOT&#x27;</span> &gt; ds_config_zero3.json
{
    <span class="hljs-string">&quot;fp16&quot;</span>: {
        <span class="hljs-string">&quot;enabled&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-string">&quot;loss_scale&quot;</span>: <span class="hljs-number">0</span>,
        <span class="hljs-string">&quot;loss_scale_window&quot;</span>: <span class="hljs-number">1000</span>,
        <span class="hljs-string">&quot;initial_scale_power&quot;</span>: <span class="hljs-number">16</span>,
        <span class="hljs-string">&quot;hysteresis&quot;</span>: <span class="hljs-number">2</span>,
        <span class="hljs-string">&quot;min_loss_scale&quot;</span>: <span class="hljs-number">1</span>
    },

    <span class="hljs-string">&quot;optimizer&quot;</span>: {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;AdamW&quot;</span>,
        <span class="hljs-string">&quot;params&quot;</span>: {
            <span class="hljs-string">&quot;lr&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-string">&quot;betas&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-string">&quot;eps&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-string">&quot;weight_decay&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>
        }
    },

    <span class="hljs-string">&quot;scheduler&quot;</span>: {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;WarmupLR&quot;</span>,
        <span class="hljs-string">&quot;params&quot;</span>: {
            <span class="hljs-string">&quot;warmup_min_lr&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-string">&quot;warmup_max_lr&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
            <span class="hljs-string">&quot;warmup_num_steps&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>
        }
    },

    <span class="hljs-string">&quot;zero_optimization&quot;</span>: {
        <span class="hljs-string">&quot;stage&quot;</span>: <span class="hljs-number">3</span>,
        <span class="hljs-string">&quot;offload_optimizer&quot;</span>: {
            <span class="hljs-string">&quot;device&quot;</span>: <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-string">&quot;pin_memory&quot;</span>: true
        },
        <span class="hljs-string">&quot;offload_param&quot;</span>: {
            <span class="hljs-string">&quot;device&quot;</span>: <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-string">&quot;pin_memory&quot;</span>: true
        },
        <span class="hljs-string">&quot;overlap_comm&quot;</span>: true,
        <span class="hljs-string">&quot;contiguous_gradients&quot;</span>: true,
        <span class="hljs-string">&quot;sub_group_size&quot;</span>: <span class="hljs-number">1e9</span>,
        <span class="hljs-string">&quot;reduce_bucket_size&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-string">&quot;stage3_prefetch_bucket_size&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-string">&quot;stage3_param_persistence_threshold&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-string">&quot;stage3_max_live_parameters&quot;</span>: <span class="hljs-number">1e9</span>,
        <span class="hljs-string">&quot;stage3_max_reuse_distance&quot;</span>: <span class="hljs-number">1e9</span>,
        <span class="hljs-string">&quot;stage3_gather_16bit_weights_on_model_save&quot;</span>: true
    },

    <span class="hljs-string">&quot;gradient_accumulation_steps&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-string">&quot;gradient_clipping&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-string">&quot;steps_per_print&quot;</span>: <span class="hljs-number">2000</span>,
    <span class="hljs-string">&quot;train_batch_size&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-string">&quot;train_micro_batch_size_per_gpu&quot;</span>: <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-string">&quot;wall_clock_breakdown&quot;</span>: false
}
EOT`,wrap:!1}}),kt=new v({props:{code:"IWdpdCUyMGNsb25lJTIwaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGaHVnZ2luZ2ZhY2UlMkZ0cmFuc2Zvcm1lcnMlMEEhY2QlMjB0cmFuc2Zvcm1lcnMlM0IlMjBkZWVwc3BlZWQlMjBleGFtcGxlcyUyRnB5dG9yY2glMkZ0cmFuc2xhdGlvbiUyRnJ1bl90cmFuc2xhdGlvbi5weSUyMC4uLg==",highlighted:`!git clone https://github.com/huggingface/transformers
!cd transformers; deepspeed examples/pytorch/translation/run_translation.py ...`,wrap:!1}}),Xt=new v({props:{code:"JTI1JTI1YmFzaCUwQSUwQWdpdCUyMGNsb25lJTIwaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGaHVnZ2luZ2ZhY2UlMkZ0cmFuc2Zvcm1lcnMlMEFjZCUyMHRyYW5zZm9ybWVycyUwQWRlZXBzcGVlZCUyMGV4YW1wbGVzJTJGcHl0b3JjaCUyRnRyYW5zbGF0aW9uJTJGcnVuX3RyYW5zbGF0aW9uLnB5JTIwLi4u",highlighted:`%%bash

git clone https://github.com/huggingface/transformers
cd transformers
deepspeed examples/pytorch/translation/run_translation.py ...`,wrap:!1}}),Nt=new X({props:{title:"Save model weights",local:"save-model-weights",headingTag:"h2"}}),we=new ie({props:{id:"save",options:["fp16","fp32"],$$slots:{default:[Ui]},$$scope:{ctx:g}}}),St=new X({props:{title:"ZeRO Inference",local:"zero-inference",headingTag:"h2"}}),xt=new v({props:{code:"ZGVlcHNwZWVkJTIwLS1udW1fZ3B1cyUzRDIlMjB5b3VyX3Byb2dyYW0ucHklMjAlM0Nub3JtYWwlMjBjbCUyMGFyZ3MlM0UlMjAtLWRvX2V2YWwlMjAtLWRlZXBzcGVlZCUyMGRzX2NvbmZpZy5qc29u",highlighted:"deepspeed --num_gpus=2 your_program.py &lt;normal cl args&gt; --do_eval --deepspeed ds_config.json",wrap:!1}}),Yt=new X({props:{title:"Non-Trainer DeepSpeed integration",local:"non-trainer-deepspeed-integration",headingTag:"h2"}}),fe=new Me({props:{$$slots:{default:[ji]},$$scope:{ctx:g}}}),Ue=new ie({props:{id:"models",options:["pretrained model","non-pretrained model"],$$slots:{default:[Ci]},$$scope:{ctx:g}}}),Dt=new X({props:{title:"Non-Trainer ZeRO Inference",local:"non-trainer-zero-inference",headingTag:"h3"}}),tl=new v({props:{code:" ",highlighted:`<span class="hljs-comment">#!/usr/bin/env python</span>

<span class="hljs-comment"># This script demonstrates how to use Deepspeed ZeRO in an inference mode when one can&#x27;t fit a model</span>
<span class="hljs-comment"># into a single GPU</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># 1. Use 1 GPU with CPU offload</span>
<span class="hljs-comment"># 2. Or use multiple GPUs instead</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># First you need to install deepspeed: pip install deepspeed</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Here we use a 3B &quot;bigscience/T0_3B&quot; model which needs about 15GB GPU RAM - so 1 largish or 2</span>
<span class="hljs-comment"># small GPUs can handle it. or 1 small GPU and a lot of CPU memory.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># To use a larger model like &quot;bigscience/T0&quot; which needs about 50GB, unless you have an 80GB GPU -</span>
<span class="hljs-comment"># you will need 2-4 gpus. And then you can adapt the script to handle more gpus if you want to</span>
<span class="hljs-comment"># process multiple inputs at once.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># The provided deepspeed config also activates CPU memory offloading, so chances are that if you</span>
<span class="hljs-comment"># have a lot of available CPU memory and you don&#x27;t mind a slowdown you should be able to load a</span>
<span class="hljs-comment"># model that doesn&#x27;t normally fit into a single GPU. If you have enough GPU memory the program will</span>
<span class="hljs-comment"># run faster if you don&#x27;t want offload to CPU - so disable that section then.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># To deploy on 1 gpu:</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># deepspeed --num_gpus 1 t0.py</span>
<span class="hljs-comment"># or:</span>
<span class="hljs-comment"># python -m torch.distributed.run --nproc_per_node=1 t0.py</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># To deploy on 2 gpus:</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># deepspeed --num_gpus 2 t0.py</span>
<span class="hljs-comment"># or:</span>
<span class="hljs-comment"># python -m torch.distributed.run --nproc_per_node=2 t0.py</span>

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoConfig, AutoModelForSeq2SeqLM
<span class="hljs-keyword">from</span> transformers.integrations <span class="hljs-keyword">import</span> HfDeepSpeedConfig
<span class="hljs-keyword">import</span> deepspeed
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> torch

os.environ[<span class="hljs-string">&quot;TOKENIZERS_PARALLELISM&quot;</span>] = <span class="hljs-string">&quot;false&quot;</span>  <span class="hljs-comment"># To avoid warnings about parallelism in tokenizers</span>

<span class="hljs-comment"># distributed setup</span>
local_rank = <span class="hljs-built_in">int</span>(os.getenv(<span class="hljs-string">&quot;LOCAL_RANK&quot;</span>, <span class="hljs-string">&quot;0&quot;</span>))
world_size = <span class="hljs-built_in">int</span>(os.getenv(<span class="hljs-string">&quot;WORLD_SIZE&quot;</span>, <span class="hljs-string">&quot;1&quot;</span>))
torch.cuda.set_device(local_rank)
deepspeed.init_distributed()

model_name = <span class="hljs-string">&quot;bigscience/T0_3B&quot;</span>

config = AutoConfig.from_pretrained(model_name)
model_hidden_size = config.d_model

<span class="hljs-comment"># batch size has to be divisible by world_size, but can be bigger than world_size</span>
train_batch_size = <span class="hljs-number">1</span> * world_size

<span class="hljs-comment"># ds_config notes</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># - enable bf16 if you use Ampere or higher GPU - this will run in mixed precision and will be</span>
<span class="hljs-comment"># faster.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># - for older GPUs you can enable fp16, but it&#x27;ll only work for non-bf16 pretrained models - e.g.</span>
<span class="hljs-comment"># all official t5 models are bf16-pretrained</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># - set offload_param.device to &quot;none&quot; or completely remove the \`offload_param\` section if you don&#x27;t</span>
<span class="hljs-comment"># - want CPU offload</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># - if using \`offload_param\` you can manually finetune stage3_param_persistence_threshold to control</span>
<span class="hljs-comment"># - which params should remain on gpus - the larger the value the smaller the offload size</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># For in-depth info on Deepspeed config see</span>
<span class="hljs-comment"># https://huggingface.co/docs/transformers/main/main_classes/deepspeed</span>

<span class="hljs-comment"># keeping the same format as json for consistency, except it uses lower case for true/false</span>
<span class="hljs-comment"># fmt: off</span>
ds_config = {
    <span class="hljs-string">&quot;fp16&quot;</span>: {
        <span class="hljs-string">&quot;enabled&quot;</span>: <span class="hljs-literal">False</span>
    },
    <span class="hljs-string">&quot;bf16&quot;</span>: {
        <span class="hljs-string">&quot;enabled&quot;</span>: <span class="hljs-literal">False</span>
    },
    <span class="hljs-string">&quot;zero_optimization&quot;</span>: {
        <span class="hljs-string">&quot;stage&quot;</span>: <span class="hljs-number">3</span>,
        <span class="hljs-string">&quot;offload_param&quot;</span>: {
            <span class="hljs-string">&quot;device&quot;</span>: <span class="hljs-string">&quot;cpu&quot;</span>,
            <span class="hljs-string">&quot;pin_memory&quot;</span>: <span class="hljs-literal">True</span>
        },
        <span class="hljs-string">&quot;overlap_comm&quot;</span>: <span class="hljs-literal">True</span>,
        <span class="hljs-string">&quot;contiguous_gradients&quot;</span>: <span class="hljs-literal">True</span>,
        <span class="hljs-string">&quot;reduce_bucket_size&quot;</span>: model_hidden_size * model_hidden_size,
        <span class="hljs-string">&quot;stage3_prefetch_bucket_size&quot;</span>: <span class="hljs-number">0.9</span> * model_hidden_size * model_hidden_size,
        <span class="hljs-string">&quot;stage3_param_persistence_threshold&quot;</span>: <span class="hljs-number">10</span> * model_hidden_size
    },
    <span class="hljs-string">&quot;steps_per_print&quot;</span>: <span class="hljs-number">2000</span>,
    <span class="hljs-string">&quot;train_batch_size&quot;</span>: train_batch_size,
    <span class="hljs-string">&quot;train_micro_batch_size_per_gpu&quot;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&quot;wall_clock_breakdown&quot;</span>: <span class="hljs-literal">False</span>
}
<span class="hljs-comment"># fmt: on</span>

<span class="hljs-comment"># next line instructs transformers to partition the model directly over multiple gpus using</span>
<span class="hljs-comment"># deepspeed.zero.Init when model&#x27;s \`from_pretrained\` method is called.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># **it has to be run before loading the model AutoModelForSeq2SeqLM.from_pretrained(model_name)**</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># otherwise the model will first be loaded normally and only partitioned at forward time which is</span>
<span class="hljs-comment"># less efficient and when there is little CPU RAM may fail</span>
dschf = HfDeepSpeedConfig(ds_config)  <span class="hljs-comment"># keep this object alive</span>

<span class="hljs-comment"># now a model can be loaded.</span>
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

<span class="hljs-comment"># initialise Deepspeed ZeRO and store only the engine object</span>
ds_engine = deepspeed.initialize(model=model, config_params=ds_config)[<span class="hljs-number">0</span>]
ds_engine.module.<span class="hljs-built_in">eval</span>()  <span class="hljs-comment"># inference</span>

<span class="hljs-comment"># Deepspeed ZeRO can process unrelated inputs on each GPU. So for 2 gpus you process 2 inputs at once.</span>
<span class="hljs-comment"># If you use more GPUs adjust for more.</span>
<span class="hljs-comment"># And of course if you have just one input to process you then need to pass the same string to both gpus</span>
<span class="hljs-comment"># If you use only one GPU, then you will have only rank 0.</span>
rank = torch.distributed.get_rank()
<span class="hljs-keyword">if</span> rank == <span class="hljs-number">0</span>:
    text_in = <span class="hljs-string">&quot;Is this review positive or negative? Review: this is the best cast iron skillet you will ever buy&quot;</span>
<span class="hljs-keyword">elif</span> rank == <span class="hljs-number">1</span>:
    text_in = <span class="hljs-string">&quot;Is this review positive or negative? Review: this is the worst restaurant ever&quot;</span>

tokenizer = AutoTokenizer.from_pretrained(model_name)
inputs = tokenizer.encode(text_in, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device=local_rank)
<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = ds_engine.module.generate(inputs, synced_gpus=<span class="hljs-literal">True</span>)
text_out = tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;rank<span class="hljs-subst">{rank}</span>:\\n   in=<span class="hljs-subst">{text_in}</span>\\n  out=<span class="hljs-subst">{text_out}</span>&quot;</span>)`,wrap:!1}}),sl=new v({props:{code:"JTI0JTIwZGVlcHNwZWVkJTIwLS1udW1fZ3B1cyUyMDIlMjB0MC5weSUwQXJhbmswJTNBJTBBJTIwJTIwJTIwaW4lM0RJcyUyMHRoaXMlMjByZXZpZXclMjBwb3NpdGl2ZSUyMG9yJTIwbmVnYXRpdmUlM0YlMjBSZXZpZXclM0ElMjB0aGlzJTIwaXMlMjB0aGUlMjBiZXN0JTIwY2FzdCUyMGlyb24lMjBza2lsbGV0JTIweW91JTIwd2lsbCUyMGV2ZXIlMjBidXklMEElMjAlMjBvdXQlM0RQb3NpdGl2ZSUwQXJhbmsxJTNBJTBBJTIwJTIwJTIwaW4lM0RJcyUyMHRoaXMlMjByZXZpZXclMjBwb3NpdGl2ZSUyMG9yJTIwbmVnYXRpdmUlM0YlMjBSZXZpZXclM0ElMjB0aGlzJTIwaXMlMjB0aGUlMjB3b3JzdCUyMHJlc3RhdXJhbnQlMjBldmVyJTBBJTIwJTIwb3V0JTNEbmVnYXRpdmU=",highlighted:`$ deepspeed --num_gpus 2 t0.py
rank0:
   <span class="hljs-keyword">in</span>=Is this review positive or negative? Review: this is the best cast iron skillet you will ever buy
  out=Positive
rank1:
   <span class="hljs-keyword">in</span>=Is this review positive or negative? Review: this is the worst restaurant ever
  out=negative`,wrap:!1}}),nl=new X({props:{title:"Generate",local:"generate",headingTag:"h3"}}),Ml=new X({props:{title:"Troubleshoot",local:"troubleshoot",headingTag:"h2"}}),cl=new v({props:{code:"cHl0aG9uJTIwLWMlMjAnaW1wb3J0JTIwdG9yY2glM0IlMjBwcmludChmJTIydG9yY2glM0ElMjAlN0J0b3JjaC5fX3ZlcnNpb25fXyU3RCUyMiknJTBBcHl0aG9uJTIwLWMlMjAnaW1wb3J0JTIwdHJhbnNmb3JtZXJzJTNCJTIwcHJpbnQoZiUyMnRyYW5zZm9ybWVycyUzQSUyMCU3QnRyYW5zZm9ybWVycy5fX3ZlcnNpb25fXyU3RCUyMiknJTBBcHl0aG9uJTIwLWMlMjAnaW1wb3J0JTIwZGVlcHNwZWVkJTNCJTIwcHJpbnQoZiUyMmRlZXBzcGVlZCUzQSUyMCU3QmRlZXBzcGVlZC5fX3ZlcnNpb25fXyU3RCUyMikn",highlighted:`python -c <span class="hljs-string">&#x27;import torch; print(f&quot;torch: {torch.__version__}&quot;)&#x27;</span>
python -c <span class="hljs-string">&#x27;import transformers; print(f&quot;transformers: {transformers.__version__}&quot;)&#x27;</span>
python -c <span class="hljs-string">&#x27;import deepspeed; print(f&quot;deepspeed: {deepspeed.__version__}&quot;)&#x27;</span>`,wrap:!1}}),Tl=new X({props:{title:"DeepSpeed process killed at startup",local:"deepspeed-process-killed-at-startup",headingTag:"h3"}}),wl=new X({props:{title:"NaN loss",local:"nan-loss",headingTag:"h3"}}),jl=new v({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyZnAxNiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmVuYWJsZWQlMjIlM0ElMjAlMjJhdXRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybG9zc19zY2FsZSUyMiUzQSUyMDAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsb3NzX3NjYWxlX3dpbmRvdyUyMiUzQSUyMDEwMDAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJpbml0aWFsX3NjYWxlX3Bvd2VyJTIyJTNBJTIwMTYlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJoeXN0ZXJlc2lzJTIyJTNBJTIwMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1pbl9sb3NzX3NjYWxlJTIyJTNBJTIwMSUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RA==",highlighted:`{
    <span class="hljs-attr">&quot;fp16&quot;:</span> {
        <span class="hljs-attr">&quot;enabled&quot;:</span> <span class="hljs-string">&quot;auto&quot;</span>,
        <span class="hljs-attr">&quot;loss_scale&quot;:</span> <span class="hljs-number">0</span>,
        <span class="hljs-attr">&quot;loss_scale_window&quot;:</span> <span class="hljs-number">1000</span>,
        <span class="hljs-attr">&quot;initial_scale_power&quot;:</span> <span class="hljs-number">16</span>,
        <span class="hljs-attr">&quot;hysteresis&quot;:</span> <span class="hljs-number">2</span>,
        <span class="hljs-attr">&quot;min_loss_scale&quot;:</span> <span class="hljs-number">1</span>
    }
}`,wrap:!1}}),Il=new v({props:{code:" ",highlighted:`0%|                                                                                                                             | 0/189 [00:00&lt;?, ?it/s]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 262144, reducing to 262144
  1%|▌                                                                                                                    | 1/189 [00:00&lt;01:26,  2.17it/s]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 262144, reducing to 131072.0
  1%|█▏
 [...]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 1, reducing to 1
 14%|████████████████▌                                                                                                   | 27/189 [00:14&lt;01:13,  2.21it/s]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 1, reducing to 1
 15%|█████████████████▏                                                                                                  | 28/189 [00:14&lt;01:13,  2.18it/s]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 1, reducing to 1
 15%|█████████████████▊                                                                                                  | 29/189 [00:15&lt;01:13,  2.18it/s]
 [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 1, reducing to 1
[...]`,wrap:!1}}),bl=new X({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Bl=new No({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/deepspeed.md"}}),{c(){a=m("meta"),c=M(),n=m("p"),p=M(),J(o.$$.fragment),i=M(),y=m("p"),y.innerHTML=b,I=M(),B=m("ul"),B.innerHTML=W,G=M(),R=m("p"),R.innerHTML=h,_=M(),q=m("p"),q.innerHTML=N,Z=M(),J(A.$$.fragment),V=M(),H=m("p"),H.innerHTML=D,P=M(),J(F.$$.fragment),x=M(),J(K.$$.fragment),ee=M(),J(Q.$$.fragment),te=M(),E=m("p"),E.innerHTML=O,$=M(),J(k.$$.fragment),se=M(),le=m("p"),le.textContent=ae,oe=M(),L=m("p"),L.textContent=je,C=M(),J(z.$$.fragment),he=M(),ne=m("p"),ne.textContent=Oa,Zl=M(),Ie=m("table"),Ie.innerHTML=Ka,vl=M(),Ce=m("p"),Ce.textContent=en,Gl=M(),be=m("p"),be.textContent=tn,Wl=M(),ge=m("ol"),ge.innerHTML=ln,Rl=M(),J($e.$$.fragment),zl=M(),Ae=m("p"),Ae.innerHTML=sn,kl=M(),J(re.$$.fragment),ql=M(),Be=m("p"),Be.innerHTML=an,Xl=M(),J(pe.$$.fragment),Nl=M(),J(_e.$$.fragment),Vl=M(),Ze=m("p"),Ze.textContent=nn,Sl=M(),ve=m("ol"),ve.innerHTML=on,Ql=M(),Ge=m("p"),Ge.innerHTML=Mn,El=M(),We=m("ol"),We.innerHTML=rn,Hl=M(),Re=m("p"),Re.innerHTML=pn,xl=M(),J(ze.$$.fragment),Yl=M(),ke=m("p"),ke.innerHTML=yn,Fl=M(),J(ye.$$.fragment),Ll=M(),qe=m("p"),qe.innerHTML=cn,Dl=M(),J(ce.$$.fragment),Pl=M(),J(Xe.$$.fragment),Ol=M(),Ne=m("p"),Ne.innerHTML=mn,Kl=M(),Ve=m("p"),Ve.innerHTML=un,es=M(),Se=m("p"),Se.innerHTML=Tn,ts=M(),J(Qe.$$.fragment),ls=M(),J(Ee.$$.fragment),ss=M(),He=m("p"),He.textContent=Jn,as=M(),J(xe.$$.fragment),ns=M(),Ye=m("p"),Ye.textContent=dn,os=M(),Fe=m("ol"),Fe.innerHTML=wn,is=M(),J(Le.$$.fragment),Ms=M(),De=m("p"),De.innerHTML=fn,rs=M(),J(me.$$.fragment),ps=M(),J(ue.$$.fragment),ys=M(),J(Pe.$$.fragment),cs=M(),Oe=m("p"),Oe.textContent=Un,ms=M(),J(Te.$$.fragment),us=M(),J(Ke.$$.fragment),Ts=M(),et=m("p"),et.innerHTML=jn,Js=M(),J(tt.$$.fragment),ds=M(),J(lt.$$.fragment),ws=M(),st=m("p"),st.innerHTML=hn,fs=M(),J(at.$$.fragment),Us=M(),J(nt.$$.fragment),js=M(),ot=m("p"),ot.innerHTML=In,hs=M(),J(it.$$.fragment),Is=M(),J(Mt.$$.fragment),Cs=M(),rt=m("p"),rt.textContent=Cn,bs=M(),pt=m("p"),pt.textContent=bn,gs=M(),yt=m("p"),yt.textContent=gn,$s=M(),ct=m("p"),ct.innerHTML=$n,As=M(),J(mt.$$.fragment),Bs=M(),J(ut.$$.fragment),_s=M(),Tt=m("p"),Tt.innerHTML=An,Zs=M(),Jt=m("p"),Jt.innerHTML=Bn,vs=M(),J(dt.$$.fragment),Gs=M(),J(wt.$$.fragment),Ws=M(),ft=m("p"),ft.innerHTML=_n,Rs=M(),Ut=m("p"),Ut.innerHTML=Zn,zs=M(),J(Je.$$.fragment),ks=M(),J(jt.$$.fragment),qs=M(),ht=m("p"),ht.innerHTML=vn,Xs=M(),It=m("p"),It.innerHTML=Gn,Ns=M(),J(Ct.$$.fragment),Vs=M(),bt=m("p"),bt.innerHTML=Wn,Ss=M(),J(de.$$.fragment),Qs=M(),J(gt.$$.fragment),Es=M(),$t=m("p"),$t.textContent=Rn,Hs=M(),J(At.$$.fragment),xs=M(),Bt=m("p"),Bt.textContent=zn,Ys=M(),J(_t.$$.fragment),Fs=M(),J(Zt.$$.fragment),Ls=M(),vt=m("p"),vt.innerHTML=kn,Ds=M(),J(Gt.$$.fragment),Ps=M(),Wt=m("p"),Wt.textContent=qn,Os=M(),J(Rt.$$.fragment),Ks=M(),zt=m("p"),zt.innerHTML=Xn,ea=M(),J(kt.$$.fragment),ta=M(),qt=m("p"),qt.innerHTML=Nn,la=M(),J(Xt.$$.fragment),sa=M(),J(Nt.$$.fragment),aa=M(),Vt=m("p"),Vt.innerHTML=Vn,na=M(),J(we.$$.fragment),oa=M(),J(St.$$.fragment),ia=M(),Qt=m("p"),Qt.innerHTML=Sn,Ma=M(),Et=m("p"),Et.innerHTML=Qn,ra=M(),Ht=m("p"),Ht.innerHTML=En,pa=M(),J(xt.$$.fragment),ya=M(),J(Yt.$$.fragment),ca=M(),Ft=m("p"),Ft.innerHTML=Hn,ma=M(),J(fe.$$.fragment),ua=M(),Lt=m("p"),Lt.innerHTML=xn,Ta=M(),J(Ue.$$.fragment),Ja=M(),J(Dt.$$.fragment),da=M(),Pt=m("p"),Pt.innerHTML=Yn,wa=M(),Ot=m("p"),Ot.textContent=Fn,fa=M(),Kt=m("ul"),Kt.innerHTML=Ln,Ua=M(),el=m("p"),el.innerHTML=Dn,ja=M(),J(tl.$$.fragment),ha=M(),ll=m("p"),ll.textContent=Pn,Ia=M(),J(sl.$$.fragment),Ca=M(),al=m("p"),al.textContent=On,ba=M(),J(nl.$$.fragment),ga=M(),ol=m("p"),ol.innerHTML=Kn,$a=M(),il=m("p"),il.innerHTML=eo,Aa=M(),J(Ml.$$.fragment),Ba=M(),rl=m("p"),rl.innerHTML=to,_a=M(),pl=m("p"),pl.textContent=lo,Za=M(),yl=m("ul"),yl.innerHTML=so,va=M(),J(cl.$$.fragment),Ga=M(),ml=m("ul"),ml.innerHTML=ao,Wa=M(),ul=m("p"),ul.textContent=no,Ra=M(),J(Tl.$$.fragment),za=M(),Jl=m("p"),Jl.innerHTML=oo,ka=M(),dl=m("p"),dl.innerHTML=io,qa=M(),J(wl.$$.fragment),Xa=M(),fl=m("p"),fl.textContent=Mo,Na=M(),Ul=m("p"),Ul.textContent=ro,Va=M(),J(jl.$$.fragment),Sa=M(),hl=m("p"),hl.innerHTML=po,Qa=M(),J(Il.$$.fragment),Ea=M(),Cl=m("p"),Cl.innerHTML=yo,Ha=M(),J(bl.$$.fragment),xa=M(),gl=m("p"),gl.innerHTML=co,Ya=M(),$l=m("p"),$l.textContent=mo,Fa=M(),Al=m("ul"),Al.innerHTML=uo,La=M(),J(Bl.$$.fragment),Da=M(),_l=m("p"),this.h()},l(e){const s=zo("svelte-u9bgzb",document.head);a=u(s,"META",{name:!0,content:!0}),s.forEach(t),c=r(e),n=u(e,"P",{}),_o(n).forEach(t),p=r(e),d(o.$$.fragment,e),i=r(e),y=u(e,"P",{"data-svelte-h":!0}),T(y)!=="svelte-na7xsx"&&(y.innerHTML=b),I=r(e),B=u(e,"UL",{"data-svelte-h":!0}),T(B)!=="svelte-q7iq3b"&&(B.innerHTML=W),G=r(e),R=u(e,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1pozm56"&&(R.innerHTML=h),_=r(e),q=u(e,"P",{"data-svelte-h":!0}),T(q)!=="svelte-gnql22"&&(q.innerHTML=N),Z=r(e),d(A.$$.fragment,e),V=r(e),H=u(e,"P",{"data-svelte-h":!0}),T(H)!=="svelte-fuidv5"&&(H.innerHTML=D),P=r(e),d(F.$$.fragment,e),x=r(e),d(K.$$.fragment,e),ee=r(e),d(Q.$$.fragment,e),te=r(e),E=u(e,"P",{"data-svelte-h":!0}),T(E)!=="svelte-1fd8xlc"&&(E.innerHTML=O),$=r(e),d(k.$$.fragment,e),se=r(e),le=u(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-1xpnss2"&&(le.textContent=ae),oe=r(e),L=u(e,"P",{"data-svelte-h":!0}),T(L)!=="svelte-js61aw"&&(L.textContent=je),C=r(e),d(z.$$.fragment,e),he=r(e),ne=u(e,"P",{"data-svelte-h":!0}),T(ne)!=="svelte-rkauna"&&(ne.textContent=Oa),Zl=r(e),Ie=u(e,"TABLE",{"data-svelte-h":!0}),T(Ie)!=="svelte-msolv0"&&(Ie.innerHTML=Ka),vl=r(e),Ce=u(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-4tusjn"&&(Ce.textContent=en),Gl=r(e),be=u(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-po9y52"&&(be.textContent=tn),Wl=r(e),ge=u(e,"OL",{"data-svelte-h":!0}),T(ge)!=="svelte-johx4n"&&(ge.innerHTML=ln),Rl=r(e),d($e.$$.fragment,e),zl=r(e),Ae=u(e,"P",{"data-svelte-h":!0}),T(Ae)!=="svelte-1ehamjq"&&(Ae.innerHTML=sn),kl=r(e),d(re.$$.fragment,e),ql=r(e),Be=u(e,"P",{"data-svelte-h":!0}),T(Be)!=="svelte-xbbt3u"&&(Be.innerHTML=an),Xl=r(e),d(pe.$$.fragment,e),Nl=r(e),d(_e.$$.fragment,e),Vl=r(e),Ze=u(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1nzz5la"&&(Ze.textContent=nn),Sl=r(e),ve=u(e,"OL",{"data-svelte-h":!0}),T(ve)!=="svelte-15g6vrv"&&(ve.innerHTML=on),Ql=r(e),Ge=u(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-3u230x"&&(Ge.innerHTML=Mn),El=r(e),We=u(e,"OL",{"data-svelte-h":!0}),T(We)!=="svelte-1btqvar"&&(We.innerHTML=rn),Hl=r(e),Re=u(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-1rxx8gr"&&(Re.innerHTML=pn),xl=r(e),d(ze.$$.fragment,e),Yl=r(e),ke=u(e,"P",{"data-svelte-h":!0}),T(ke)!=="svelte-nuf72i"&&(ke.innerHTML=yn),Fl=r(e),d(ye.$$.fragment,e),Ll=r(e),qe=u(e,"P",{"data-svelte-h":!0}),T(qe)!=="svelte-1j6i0h4"&&(qe.innerHTML=cn),Dl=r(e),d(ce.$$.fragment,e),Pl=r(e),d(Xe.$$.fragment,e),Ol=r(e),Ne=u(e,"P",{"data-svelte-h":!0}),T(Ne)!=="svelte-1yvixx2"&&(Ne.innerHTML=mn),Kl=r(e),Ve=u(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-14zbxsz"&&(Ve.innerHTML=un),es=r(e),Se=u(e,"P",{"data-svelte-h":!0}),T(Se)!=="svelte-1bftyio"&&(Se.innerHTML=Tn),ts=r(e),d(Qe.$$.fragment,e),ls=r(e),d(Ee.$$.fragment,e),ss=r(e),He=u(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-t13qkh"&&(He.textContent=Jn),as=r(e),d(xe.$$.fragment,e),ns=r(e),Ye=u(e,"P",{"data-svelte-h":!0}),T(Ye)!=="svelte-1pyala7"&&(Ye.textContent=dn),os=r(e),Fe=u(e,"OL",{"data-svelte-h":!0}),T(Fe)!=="svelte-s0cja"&&(Fe.innerHTML=wn),is=r(e),d(Le.$$.fragment,e),Ms=r(e),De=u(e,"P",{"data-svelte-h":!0}),T(De)!=="svelte-8lb90i"&&(De.innerHTML=fn),rs=r(e),d(me.$$.fragment,e),ps=r(e),d(ue.$$.fragment,e),ys=r(e),d(Pe.$$.fragment,e),cs=r(e),Oe=u(e,"P",{"data-svelte-h":!0}),T(Oe)!=="svelte-j5yqaq"&&(Oe.textContent=Un),ms=r(e),d(Te.$$.fragment,e),us=r(e),d(Ke.$$.fragment,e),Ts=r(e),et=u(e,"P",{"data-svelte-h":!0}),T(et)!=="svelte-1clwpm9"&&(et.innerHTML=jn),Js=r(e),d(tt.$$.fragment,e),ds=r(e),d(lt.$$.fragment,e),ws=r(e),st=u(e,"P",{"data-svelte-h":!0}),T(st)!=="svelte-pfwv31"&&(st.innerHTML=hn),fs=r(e),d(at.$$.fragment,e),Us=r(e),d(nt.$$.fragment,e),js=r(e),ot=u(e,"P",{"data-svelte-h":!0}),T(ot)!=="svelte-pc4pxg"&&(ot.innerHTML=In),hs=r(e),d(it.$$.fragment,e),Is=r(e),d(Mt.$$.fragment,e),Cs=r(e),rt=u(e,"P",{"data-svelte-h":!0}),T(rt)!=="svelte-gpfm4j"&&(rt.textContent=Cn),bs=r(e),pt=u(e,"P",{"data-svelte-h":!0}),T(pt)!=="svelte-mvoza6"&&(pt.textContent=bn),gs=r(e),yt=u(e,"P",{"data-svelte-h":!0}),T(yt)!=="svelte-1ulbaso"&&(yt.textContent=gn),$s=r(e),ct=u(e,"P",{"data-svelte-h":!0}),T(ct)!=="svelte-b2p3xv"&&(ct.innerHTML=$n),As=r(e),d(mt.$$.fragment,e),Bs=r(e),d(ut.$$.fragment,e),_s=r(e),Tt=u(e,"P",{"data-svelte-h":!0}),T(Tt)!=="svelte-1xjo13h"&&(Tt.innerHTML=An),Zs=r(e),Jt=u(e,"P",{"data-svelte-h":!0}),T(Jt)!=="svelte-1gli3bp"&&(Jt.innerHTML=Bn),vs=r(e),d(dt.$$.fragment,e),Gs=r(e),d(wt.$$.fragment,e),Ws=r(e),ft=u(e,"P",{"data-svelte-h":!0}),T(ft)!=="svelte-pcgu7i"&&(ft.innerHTML=_n),Rs=r(e),Ut=u(e,"P",{"data-svelte-h":!0}),T(Ut)!=="svelte-1270bwq"&&(Ut.innerHTML=Zn),zs=r(e),d(Je.$$.fragment,e),ks=r(e),d(jt.$$.fragment,e),qs=r(e),ht=u(e,"P",{"data-svelte-h":!0}),T(ht)!=="svelte-1vvv5pa"&&(ht.innerHTML=vn),Xs=r(e),It=u(e,"P",{"data-svelte-h":!0}),T(It)!=="svelte-mp54lp"&&(It.innerHTML=Gn),Ns=r(e),d(Ct.$$.fragment,e),Vs=r(e),bt=u(e,"P",{"data-svelte-h":!0}),T(bt)!=="svelte-1rwc4cv"&&(bt.innerHTML=Wn),Ss=r(e),d(de.$$.fragment,e),Qs=r(e),d(gt.$$.fragment,e),Es=r(e),$t=u(e,"P",{"data-svelte-h":!0}),T($t)!=="svelte-ow6xqy"&&($t.textContent=Rn),Hs=r(e),d(At.$$.fragment,e),xs=r(e),Bt=u(e,"P",{"data-svelte-h":!0}),T(Bt)!=="svelte-xfixmf"&&(Bt.textContent=zn),Ys=r(e),d(_t.$$.fragment,e),Fs=r(e),d(Zt.$$.fragment,e),Ls=r(e),vt=u(e,"P",{"data-svelte-h":!0}),T(vt)!=="svelte-4dix30"&&(vt.innerHTML=kn),Ds=r(e),d(Gt.$$.fragment,e),Ps=r(e),Wt=u(e,"P",{"data-svelte-h":!0}),T(Wt)!=="svelte-1fw1nb2"&&(Wt.textContent=qn),Os=r(e),d(Rt.$$.fragment,e),Ks=r(e),zt=u(e,"P",{"data-svelte-h":!0}),T(zt)!=="svelte-xvblu4"&&(zt.innerHTML=Xn),ea=r(e),d(kt.$$.fragment,e),ta=r(e),qt=u(e,"P",{"data-svelte-h":!0}),T(qt)!=="svelte-1dkflot"&&(qt.innerHTML=Nn),la=r(e),d(Xt.$$.fragment,e),sa=r(e),d(Nt.$$.fragment,e),aa=r(e),Vt=u(e,"P",{"data-svelte-h":!0}),T(Vt)!=="svelte-v8wycf"&&(Vt.innerHTML=Vn),na=r(e),d(we.$$.fragment,e),oa=r(e),d(St.$$.fragment,e),ia=r(e),Qt=u(e,"P",{"data-svelte-h":!0}),T(Qt)!=="svelte-1cd47xa"&&(Qt.innerHTML=Sn),Ma=r(e),Et=u(e,"P",{"data-svelte-h":!0}),T(Et)!=="svelte-1tp1ibg"&&(Et.innerHTML=Qn),ra=r(e),Ht=u(e,"P",{"data-svelte-h":!0}),T(Ht)!=="svelte-8hzqpu"&&(Ht.innerHTML=En),pa=r(e),d(xt.$$.fragment,e),ya=r(e),d(Yt.$$.fragment,e),ca=r(e),Ft=u(e,"P",{"data-svelte-h":!0}),T(Ft)!=="svelte-alj4bp"&&(Ft.innerHTML=Hn),ma=r(e),d(fe.$$.fragment,e),ua=r(e),Lt=u(e,"P",{"data-svelte-h":!0}),T(Lt)!=="svelte-1u0t2ts"&&(Lt.innerHTML=xn),Ta=r(e),d(Ue.$$.fragment,e),Ja=r(e),d(Dt.$$.fragment,e),da=r(e),Pt=u(e,"P",{"data-svelte-h":!0}),T(Pt)!=="svelte-1wx2kcp"&&(Pt.innerHTML=Yn),wa=r(e),Ot=u(e,"P",{"data-svelte-h":!0}),T(Ot)!=="svelte-o4r1i6"&&(Ot.textContent=Fn),fa=r(e),Kt=u(e,"UL",{"data-svelte-h":!0}),T(Kt)!=="svelte-1bodp8e"&&(Kt.innerHTML=Ln),Ua=r(e),el=u(e,"P",{"data-svelte-h":!0}),T(el)!=="svelte-1b5zo2z"&&(el.innerHTML=Dn),ja=r(e),d(tl.$$.fragment,e),ha=r(e),ll=u(e,"P",{"data-svelte-h":!0}),T(ll)!=="svelte-15z7rtv"&&(ll.textContent=Pn),Ia=r(e),d(sl.$$.fragment,e),Ca=r(e),al=u(e,"P",{"data-svelte-h":!0}),T(al)!=="svelte-sp9gkx"&&(al.textContent=On),ba=r(e),d(nl.$$.fragment,e),ga=r(e),ol=u(e,"P",{"data-svelte-h":!0}),T(ol)!=="svelte-w757qm"&&(ol.innerHTML=Kn),$a=r(e),il=u(e,"P",{"data-svelte-h":!0}),T(il)!=="svelte-1fhttxy"&&(il.innerHTML=eo),Aa=r(e),d(Ml.$$.fragment,e),Ba=r(e),rl=u(e,"P",{"data-svelte-h":!0}),T(rl)!=="svelte-12ltrno"&&(rl.innerHTML=to),_a=r(e),pl=u(e,"P",{"data-svelte-h":!0}),T(pl)!=="svelte-13gytjz"&&(pl.textContent=lo),Za=r(e),yl=u(e,"UL",{"data-svelte-h":!0}),T(yl)!=="svelte-121q097"&&(yl.innerHTML=so),va=r(e),d(cl.$$.fragment,e),Ga=r(e),ml=u(e,"UL",{"data-svelte-h":!0}),T(ml)!=="svelte-1mmu83y"&&(ml.innerHTML=ao),Wa=r(e),ul=u(e,"P",{"data-svelte-h":!0}),T(ul)!=="svelte-oia8x0"&&(ul.textContent=no),Ra=r(e),d(Tl.$$.fragment,e),za=r(e),Jl=u(e,"P",{"data-svelte-h":!0}),T(Jl)!=="svelte-1yhr0cr"&&(Jl.innerHTML=oo),ka=r(e),dl=u(e,"P",{"data-svelte-h":!0}),T(dl)!=="svelte-1s2gzku"&&(dl.innerHTML=io),qa=r(e),d(wl.$$.fragment,e),Xa=r(e),fl=u(e,"P",{"data-svelte-h":!0}),T(fl)!=="svelte-4mvvb2"&&(fl.textContent=Mo),Na=r(e),Ul=u(e,"P",{"data-svelte-h":!0}),T(Ul)!=="svelte-7me63n"&&(Ul.textContent=ro),Va=r(e),d(jl.$$.fragment,e),Sa=r(e),hl=u(e,"P",{"data-svelte-h":!0}),T(hl)!=="svelte-1livx4i"&&(hl.innerHTML=po),Qa=r(e),d(Il.$$.fragment,e),Ea=r(e),Cl=u(e,"P",{"data-svelte-h":!0}),T(Cl)!=="svelte-1fiingf"&&(Cl.innerHTML=yo),Ha=r(e),d(bl.$$.fragment,e),xa=r(e),gl=u(e,"P",{"data-svelte-h":!0}),T(gl)!=="svelte-1ufcnmq"&&(gl.innerHTML=co),Ya=r(e),$l=u(e,"P",{"data-svelte-h":!0}),T($l)!=="svelte-khzrsx"&&($l.textContent=mo),Fa=r(e),Al=u(e,"UL",{"data-svelte-h":!0}),T(Al)!=="svelte-o0yfva"&&(Al.innerHTML=uo),La=r(e),d(Bl.$$.fragment,e),Da=r(e),_l=u(e,"P",{}),_o(_l).forEach(t),this.h()},h(){Zo(a,"name","hf:doc:metadata"),Zo(a,"content",gi)},m(e,s){ko(document.head,a),l(e,c,s),l(e,n,s),l(e,p,s),w(o,e,s),l(e,i,s),l(e,y,s),l(e,I,s),l(e,B,s),l(e,G,s),l(e,R,s),l(e,_,s),l(e,q,s),l(e,Z,s),w(A,e,s),l(e,V,s),l(e,H,s),l(e,P,s),w(F,e,s),l(e,x,s),w(K,e,s),l(e,ee,s),w(Q,e,s),l(e,te,s),l(e,E,s),l(e,$,s),w(k,e,s),l(e,se,s),l(e,le,s),l(e,oe,s),l(e,L,s),l(e,C,s),w(z,e,s),l(e,he,s),l(e,ne,s),l(e,Zl,s),l(e,Ie,s),l(e,vl,s),l(e,Ce,s),l(e,Gl,s),l(e,be,s),l(e,Wl,s),l(e,ge,s),l(e,Rl,s),w($e,e,s),l(e,zl,s),l(e,Ae,s),l(e,kl,s),w(re,e,s),l(e,ql,s),l(e,Be,s),l(e,Xl,s),w(pe,e,s),l(e,Nl,s),w(_e,e,s),l(e,Vl,s),l(e,Ze,s),l(e,Sl,s),l(e,ve,s),l(e,Ql,s),l(e,Ge,s),l(e,El,s),l(e,We,s),l(e,Hl,s),l(e,Re,s),l(e,xl,s),w(ze,e,s),l(e,Yl,s),l(e,ke,s),l(e,Fl,s),w(ye,e,s),l(e,Ll,s),l(e,qe,s),l(e,Dl,s),w(ce,e,s),l(e,Pl,s),w(Xe,e,s),l(e,Ol,s),l(e,Ne,s),l(e,Kl,s),l(e,Ve,s),l(e,es,s),l(e,Se,s),l(e,ts,s),w(Qe,e,s),l(e,ls,s),w(Ee,e,s),l(e,ss,s),l(e,He,s),l(e,as,s),w(xe,e,s),l(e,ns,s),l(e,Ye,s),l(e,os,s),l(e,Fe,s),l(e,is,s),w(Le,e,s),l(e,Ms,s),l(e,De,s),l(e,rs,s),w(me,e,s),l(e,ps,s),w(ue,e,s),l(e,ys,s),w(Pe,e,s),l(e,cs,s),l(e,Oe,s),l(e,ms,s),w(Te,e,s),l(e,us,s),w(Ke,e,s),l(e,Ts,s),l(e,et,s),l(e,Js,s),w(tt,e,s),l(e,ds,s),w(lt,e,s),l(e,ws,s),l(e,st,s),l(e,fs,s),w(at,e,s),l(e,Us,s),w(nt,e,s),l(e,js,s),l(e,ot,s),l(e,hs,s),w(it,e,s),l(e,Is,s),w(Mt,e,s),l(e,Cs,s),l(e,rt,s),l(e,bs,s),l(e,pt,s),l(e,gs,s),l(e,yt,s),l(e,$s,s),l(e,ct,s),l(e,As,s),w(mt,e,s),l(e,Bs,s),w(ut,e,s),l(e,_s,s),l(e,Tt,s),l(e,Zs,s),l(e,Jt,s),l(e,vs,s),w(dt,e,s),l(e,Gs,s),w(wt,e,s),l(e,Ws,s),l(e,ft,s),l(e,Rs,s),l(e,Ut,s),l(e,zs,s),w(Je,e,s),l(e,ks,s),w(jt,e,s),l(e,qs,s),l(e,ht,s),l(e,Xs,s),l(e,It,s),l(e,Ns,s),w(Ct,e,s),l(e,Vs,s),l(e,bt,s),l(e,Ss,s),w(de,e,s),l(e,Qs,s),w(gt,e,s),l(e,Es,s),l(e,$t,s),l(e,Hs,s),w(At,e,s),l(e,xs,s),l(e,Bt,s),l(e,Ys,s),w(_t,e,s),l(e,Fs,s),w(Zt,e,s),l(e,Ls,s),l(e,vt,s),l(e,Ds,s),w(Gt,e,s),l(e,Ps,s),l(e,Wt,s),l(e,Os,s),w(Rt,e,s),l(e,Ks,s),l(e,zt,s),l(e,ea,s),w(kt,e,s),l(e,ta,s),l(e,qt,s),l(e,la,s),w(Xt,e,s),l(e,sa,s),w(Nt,e,s),l(e,aa,s),l(e,Vt,s),l(e,na,s),w(we,e,s),l(e,oa,s),w(St,e,s),l(e,ia,s),l(e,Qt,s),l(e,Ma,s),l(e,Et,s),l(e,ra,s),l(e,Ht,s),l(e,pa,s),w(xt,e,s),l(e,ya,s),w(Yt,e,s),l(e,ca,s),l(e,Ft,s),l(e,ma,s),w(fe,e,s),l(e,ua,s),l(e,Lt,s),l(e,Ta,s),w(Ue,e,s),l(e,Ja,s),w(Dt,e,s),l(e,da,s),l(e,Pt,s),l(e,wa,s),l(e,Ot,s),l(e,fa,s),l(e,Kt,s),l(e,Ua,s),l(e,el,s),l(e,ja,s),w(tl,e,s),l(e,ha,s),l(e,ll,s),l(e,Ia,s),w(sl,e,s),l(e,Ca,s),l(e,al,s),l(e,ba,s),w(nl,e,s),l(e,ga,s),l(e,ol,s),l(e,$a,s),l(e,il,s),l(e,Aa,s),w(Ml,e,s),l(e,Ba,s),l(e,rl,s),l(e,_a,s),l(e,pl,s),l(e,Za,s),l(e,yl,s),l(e,va,s),w(cl,e,s),l(e,Ga,s),l(e,ml,s),l(e,Wa,s),l(e,ul,s),l(e,Ra,s),w(Tl,e,s),l(e,za,s),l(e,Jl,s),l(e,ka,s),l(e,dl,s),l(e,qa,s),w(wl,e,s),l(e,Xa,s),l(e,fl,s),l(e,Na,s),l(e,Ul,s),l(e,Va,s),w(jl,e,s),l(e,Sa,s),l(e,hl,s),l(e,Qa,s),w(Il,e,s),l(e,Ea,s),l(e,Cl,s),l(e,Ha,s),w(bl,e,s),l(e,xa,s),l(e,gl,s),l(e,Ya,s),l(e,$l,s),l(e,Fa,s),l(e,Al,s),l(e,La,s),w(Bl,e,s),l(e,Da,s),l(e,_l,s),Pa=!0},p(e,[s]){const To={};s&2&&(To.$$scope={dirty:s,ctx:e}),F.$set(To);const Jo={};s&2&&(Jo.$$scope={dirty:s,ctx:e}),K.$set(Jo);const wo={};s&2&&(wo.$$scope={dirty:s,ctx:e}),re.$set(wo);const fo={};s&2&&(fo.$$scope={dirty:s,ctx:e}),pe.$set(fo);const Uo={};s&2&&(Uo.$$scope={dirty:s,ctx:e}),ye.$set(Uo);const jo={};s&2&&(jo.$$scope={dirty:s,ctx:e}),ce.$set(jo);const ho={};s&2&&(ho.$$scope={dirty:s,ctx:e}),me.$set(ho);const Io={};s&2&&(Io.$$scope={dirty:s,ctx:e}),ue.$set(Io);const Co={};s&2&&(Co.$$scope={dirty:s,ctx:e}),Te.$set(Co);const bo={};s&2&&(bo.$$scope={dirty:s,ctx:e}),Je.$set(bo);const go={};s&2&&(go.$$scope={dirty:s,ctx:e}),de.$set(go);const $o={};s&2&&($o.$$scope={dirty:s,ctx:e}),we.$set($o);const Ao={};s&2&&(Ao.$$scope={dirty:s,ctx:e}),fe.$set(Ao);const Bo={};s&2&&(Bo.$$scope={dirty:s,ctx:e}),Ue.$set(Bo)},i(e){Pa||(f(o.$$.fragment,e),f(A.$$.fragment,e),f(F.$$.fragment,e),f(K.$$.fragment,e),f(Q.$$.fragment,e),f(k.$$.fragment,e),f(z.$$.fragment,e),f($e.$$.fragment,e),f(re.$$.fragment,e),f(pe.$$.fragment,e),f(_e.$$.fragment,e),f(ze.$$.fragment,e),f(ye.$$.fragment,e),f(ce.$$.fragment,e),f(Xe.$$.fragment,e),f(Qe.$$.fragment,e),f(Ee.$$.fragment,e),f(xe.$$.fragment,e),f(Le.$$.fragment,e),f(me.$$.fragment,e),f(ue.$$.fragment,e),f(Pe.$$.fragment,e),f(Te.$$.fragment,e),f(Ke.$$.fragment,e),f(tt.$$.fragment,e),f(lt.$$.fragment,e),f(at.$$.fragment,e),f(nt.$$.fragment,e),f(it.$$.fragment,e),f(Mt.$$.fragment,e),f(mt.$$.fragment,e),f(ut.$$.fragment,e),f(dt.$$.fragment,e),f(wt.$$.fragment,e),f(Je.$$.fragment,e),f(jt.$$.fragment,e),f(Ct.$$.fragment,e),f(de.$$.fragment,e),f(gt.$$.fragment,e),f(At.$$.fragment,e),f(_t.$$.fragment,e),f(Zt.$$.fragment,e),f(Gt.$$.fragment,e),f(Rt.$$.fragment,e),f(kt.$$.fragment,e),f(Xt.$$.fragment,e),f(Nt.$$.fragment,e),f(we.$$.fragment,e),f(St.$$.fragment,e),f(xt.$$.fragment,e),f(Yt.$$.fragment,e),f(fe.$$.fragment,e),f(Ue.$$.fragment,e),f(Dt.$$.fragment,e),f(tl.$$.fragment,e),f(sl.$$.fragment,e),f(nl.$$.fragment,e),f(Ml.$$.fragment,e),f(cl.$$.fragment,e),f(Tl.$$.fragment,e),f(wl.$$.fragment,e),f(jl.$$.fragment,e),f(Il.$$.fragment,e),f(bl.$$.fragment,e),f(Bl.$$.fragment,e),Pa=!0)},o(e){U(o.$$.fragment,e),U(A.$$.fragment,e),U(F.$$.fragment,e),U(K.$$.fragment,e),U(Q.$$.fragment,e),U(k.$$.fragment,e),U(z.$$.fragment,e),U($e.$$.fragment,e),U(re.$$.fragment,e),U(pe.$$.fragment,e),U(_e.$$.fragment,e),U(ze.$$.fragment,e),U(ye.$$.fragment,e),U(ce.$$.fragment,e),U(Xe.$$.fragment,e),U(Qe.$$.fragment,e),U(Ee.$$.fragment,e),U(xe.$$.fragment,e),U(Le.$$.fragment,e),U(me.$$.fragment,e),U(ue.$$.fragment,e),U(Pe.$$.fragment,e),U(Te.$$.fragment,e),U(Ke.$$.fragment,e),U(tt.$$.fragment,e),U(lt.$$.fragment,e),U(at.$$.fragment,e),U(nt.$$.fragment,e),U(it.$$.fragment,e),U(Mt.$$.fragment,e),U(mt.$$.fragment,e),U(ut.$$.fragment,e),U(dt.$$.fragment,e),U(wt.$$.fragment,e),U(Je.$$.fragment,e),U(jt.$$.fragment,e),U(Ct.$$.fragment,e),U(de.$$.fragment,e),U(gt.$$.fragment,e),U(At.$$.fragment,e),U(_t.$$.fragment,e),U(Zt.$$.fragment,e),U(Gt.$$.fragment,e),U(Rt.$$.fragment,e),U(kt.$$.fragment,e),U(Xt.$$.fragment,e),U(Nt.$$.fragment,e),U(we.$$.fragment,e),U(St.$$.fragment,e),U(xt.$$.fragment,e),U(Yt.$$.fragment,e),U(fe.$$.fragment,e),U(Ue.$$.fragment,e),U(Dt.$$.fragment,e),U(tl.$$.fragment,e),U(sl.$$.fragment,e),U(nl.$$.fragment,e),U(Ml.$$.fragment,e),U(cl.$$.fragment,e),U(Tl.$$.fragment,e),U(wl.$$.fragment,e),U(jl.$$.fragment,e),U(Il.$$.fragment,e),U(bl.$$.fragment,e),U(Bl.$$.fragment,e),Pa=!1},d(e){e&&(t(c),t(n),t(p),t(i),t(y),t(I),t(B),t(G),t(R),t(_),t(q),t(Z),t(V),t(H),t(P),t(x),t(ee),t(te),t(E),t($),t(se),t(le),t(oe),t(L),t(C),t(he),t(ne),t(Zl),t(Ie),t(vl),t(Ce),t(Gl),t(be),t(Wl),t(ge),t(Rl),t(zl),t(Ae),t(kl),t(ql),t(Be),t(Xl),t(Nl),t(Vl),t(Ze),t(Sl),t(ve),t(Ql),t(Ge),t(El),t(We),t(Hl),t(Re),t(xl),t(Yl),t(ke),t(Fl),t(Ll),t(qe),t(Dl),t(Pl),t(Ol),t(Ne),t(Kl),t(Ve),t(es),t(Se),t(ts),t(ls),t(ss),t(He),t(as),t(ns),t(Ye),t(os),t(Fe),t(is),t(Ms),t(De),t(rs),t(ps),t(ys),t(cs),t(Oe),t(ms),t(us),t(Ts),t(et),t(Js),t(ds),t(ws),t(st),t(fs),t(Us),t(js),t(ot),t(hs),t(Is),t(Cs),t(rt),t(bs),t(pt),t(gs),t(yt),t($s),t(ct),t(As),t(Bs),t(_s),t(Tt),t(Zs),t(Jt),t(vs),t(Gs),t(Ws),t(ft),t(Rs),t(Ut),t(zs),t(ks),t(qs),t(ht),t(Xs),t(It),t(Ns),t(Vs),t(bt),t(Ss),t(Qs),t(Es),t($t),t(Hs),t(xs),t(Bt),t(Ys),t(Fs),t(Ls),t(vt),t(Ds),t(Ps),t(Wt),t(Os),t(Ks),t(zt),t(ea),t(ta),t(qt),t(la),t(sa),t(aa),t(Vt),t(na),t(oa),t(ia),t(Qt),t(Ma),t(Et),t(ra),t(Ht),t(pa),t(ya),t(ca),t(Ft),t(ma),t(ua),t(Lt),t(Ta),t(Ja),t(da),t(Pt),t(wa),t(Ot),t(fa),t(Kt),t(Ua),t(el),t(ja),t(ha),t(ll),t(Ia),t(Ca),t(al),t(ba),t(ga),t(ol),t($a),t(il),t(Aa),t(Ba),t(rl),t(_a),t(pl),t(Za),t(yl),t(va),t(Ga),t(ml),t(Wa),t(ul),t(Ra),t(za),t(Jl),t(ka),t(dl),t(qa),t(Xa),t(fl),t(Na),t(Ul),t(Va),t(Sa),t(hl),t(Qa),t(Ea),t(Cl),t(Ha),t(xa),t(gl),t(Ya),t($l),t(Fa),t(Al),t(La),t(Da),t(_l)),t(a),j(o,e),j(A,e),j(F,e),j(K,e),j(Q,e),j(k,e),j(z,e),j($e,e),j(re,e),j(pe,e),j(_e,e),j(ze,e),j(ye,e),j(ce,e),j(Xe,e),j(Qe,e),j(Ee,e),j(xe,e),j(Le,e),j(me,e),j(ue,e),j(Pe,e),j(Te,e),j(Ke,e),j(tt,e),j(lt,e),j(at,e),j(nt,e),j(it,e),j(Mt,e),j(mt,e),j(ut,e),j(dt,e),j(wt,e),j(Je,e),j(jt,e),j(Ct,e),j(de,e),j(gt,e),j(At,e),j(_t,e),j(Zt,e),j(Gt,e),j(Rt,e),j(kt,e),j(Xt,e),j(Nt,e),j(we,e),j(St,e),j(xt,e),j(Yt,e),j(fe,e),j(Ue,e),j(Dt,e),j(tl,e),j(sl,e),j(nl,e),j(Ml,e),j(cl,e),j(Tl,e),j(wl,e),j(jl,e),j(Il,e),j(bl,e),j(Bl,e)}}}const gi='{"title":"DeepSpeed","local":"deepspeed","sections":[{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Memory requirements","local":"memory-requirements","sections":[],"depth":2},{"title":"Select a ZeRO stage","local":"select-a-zero-stage","sections":[],"depth":2},{"title":"DeepSpeed configuration file","local":"deepspeed-configuration-file","sections":[{"title":"DeepSpeed and Trainer parameters","local":"deepspeed-and-trainer-parameters","sections":[],"depth":3},{"title":"ZeRO configuration","local":"zero-configuration","sections":[],"depth":3},{"title":"NVMe configuration","local":"nvme-configuration","sections":[],"depth":3}],"depth":2},{"title":"DeepSpeed features","local":"deepspeed-features","sections":[{"title":"Activation/gradient checkpointing","local":"activationgradient-checkpointing","sections":[],"depth":3},{"title":"Optimizer and scheduler","local":"optimizer-and-scheduler","sections":[],"depth":3},{"title":"Precision","local":"precision","sections":[],"depth":3},{"title":"Batch size","local":"batch-size","sections":[],"depth":3},{"title":"Gradient accumulation","local":"gradient-accumulation","sections":[],"depth":3},{"title":"Gradient clipping","local":"gradient-clipping","sections":[],"depth":3},{"title":"Communication data type","local":"communication-data-type","sections":[],"depth":3},{"title":"Universal Checkpointing","local":"universal-checkpointing","sections":[],"depth":3}],"depth":2},{"title":"Deployment","local":"deployment","sections":[{"title":"Multi-node deployment","local":"multi-node-deployment","sections":[],"depth":3},{"title":"SLURM","local":"slurm","sections":[],"depth":3},{"title":"Notebook","local":"notebook","sections":[],"depth":3}],"depth":2},{"title":"Save model weights","local":"save-model-weights","sections":[{"title":"Online","local":"online","sections":[],"depth":3},{"title":"Offline","local":"offline","sections":[],"depth":3}],"depth":2},{"title":"ZeRO Inference","local":"zero-inference","sections":[],"depth":2},{"title":"Non-Trainer DeepSpeed integration","local":"non-trainer-deepspeed-integration","sections":[{"title":"Non-Trainer ZeRO Inference","local":"non-trainer-zero-inference","sections":[],"depth":3},{"title":"Generate","local":"generate","sections":[],"depth":3}],"depth":2},{"title":"Troubleshoot","local":"troubleshoot","sections":[{"title":"DeepSpeed process killed at startup","local":"deepspeed-process-killed-at-startup","sections":[],"depth":3},{"title":"NaN loss","local":"nan-loss","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}';function $i(g){return Go(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wi extends Wo{constructor(a){super(),Ro(this,a,$i,bi,vo,{})}}export{Wi as component};
