import{s as Uo,o as jo,n as S}from"../chunks/scheduler.9bc65507.js";import{S as ho,i as Io,g as m,s as M,r as w,A as Co,h as u,f as t,c as r,j as wo,u as f,x as T,k as fo,y as bo,a as l,v as U,d as j,t as h,w as I,m as go,n as $o}from"../chunks/index.707bf1b6.js";import{T as Me}from"../chunks/Tip.c2ecdbf4.js";import{C as v}from"../chunks/CodeBlock.54a9f38d.js";import{H as q}from"../chunks/Heading.342b1fa6.js";import{H as ie,a as Y}from"../chunks/HfOption.6d864328.js";function Ao(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1cityiq"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function Bo(g){let s,c;return s=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRlZXBzcGVlZA==",highlighted:"pip install deepspeed",wrap:!1}}),{c(){w(s.$$.fragment)},l(n){f(s.$$.fragment,n)},m(n,p){U(s,n,p),c=!0},p:S,i(n){c||(j(s.$$.fragment,n),c=!0)},o(n){h(s.$$.fragment,n),c=!1},d(n){I(s,n)}}}function _o(g){let s,c;return s=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1QmRlZXBzcGVlZCU1RA==",highlighted:"pip install transformers[deepspeed]",wrap:!1}}),{c(){w(s.$$.fragment)},l(n){f(s.$$.fragment,n)},m(n,p){U(s,n,p),c=!0},p:S,i(n){c||(j(s.$$.fragment,n),c=!0)},o(n){h(s.$$.fragment,n),c=!1},d(n){I(s,n)}}}function Zo(g){let s,c,n,p;return s=new Y({props:{id:"install",option:"PyPI",$$slots:{default:[Bo]},$$scope:{ctx:g}}}),n=new Y({props:{id:"install",option:"Transformers",$$slots:{default:[_o]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function vo(g){let s,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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-a4z01l"&&(s.innerHTML=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function Go(g){let s,c;return s=new v({props:{code:"VHJhaW5pbmdBcmd1bWVudHMoLi4uJTJDJTIwZGVlcHNwZWVkJTNEJTIycGF0aCUyRnRvJTJGZGVlcHNwZWVkX2NvbmZpZy5qc29uJTIyKQ==",highlighted:'TrainingArguments(..., deepspeed=<span class="hljs-string">&quot;path/to/deepspeed_config.json&quot;</span>)',wrap:!1}}),{c(){w(s.$$.fragment)},l(n){f(s.$$.fragment,n)},m(n,p){U(s,n,p),c=!0},p:S,i(n){c||(j(s.$$.fragment,n),c=!0)},o(n){h(s.$$.fragment,n),c=!1},d(n){I(s,n)}}}function Wo(g){let s,c;return s=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(){w(s.$$.fragment)},l(n){f(s.$$.fragment,n)},m(n,p){U(s,n,p),c=!0},p:S,i(n){c||(j(s.$$.fragment,n),c=!0)},o(n){h(s.$$.fragment,n),c=!1},d(n){I(s,n)}}}function Ro(g){let s,c,n,p;return s=new Y({props:{id:"pass-config",option:"path to file",$$slots:{default:[Go]},$$scope:{ctx:g}}}),n=new Y({props:{id:"pass-config",option:"nested dict",$$slots:{default:[Wo]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function zo(g){let s;return{c(){s=go("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){s=$o(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,s,n)},d(c){c&&t(s)}}}function ko(g){let s,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(){s=m("p"),s.textContent=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-hkpv8b"&&(s.textContent=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function Xo(g){let s,c="ZeRO-2 shards the optimizer and gradients across GPUs. This stage is primarily used for training since it’s 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(){s=m("p"),s.textContent=c,n=M(),p=m("ul"),p.innerHTML=o,i=M(),w(y.$$.fragment)},l(d){s=u(d,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1tse7fd"&&(s.textContent=c),n=r(d),p=u(d,"UL",{"data-svelte-h":!0}),T(p)!=="svelte-1ji2a0e"&&(p.innerHTML=o),i=r(d),f(y.$$.fragment,d)},m(d,B){l(d,s,B),l(d,n,B),l(d,p,B),l(d,i,B),U(y,d,B),b=!0},p:S,i(d){b||(j(y.$$.fragment,d),b=!0)},o(d){h(y.$$.fragment,d),b=!1},d(d){d&&(t(s),t(n),t(p),t(i)),I(y,d)}}}function qo(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-14c3i1p"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function No(g){let s,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 an 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,d,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,J,_='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>.',X,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,E,te,Q,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}}),E=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}}),Q=new Me({props:{$$slots:{default:[qo]},$$scope:{ctx:g}}}),{c(){s=m("p"),s.textContent=c,n=M(),p=m("ul"),p.innerHTML=o,i=M(),w(y.$$.fragment),b=M(),d=m("p"),d.innerHTML=B,W=M(),w(G.$$.fragment),R=M(),J=m("p"),J.innerHTML=_,X=M(),w(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(),w(E.$$.fragment),te=M(),w(Q.$$.fragment)},l($){s=u($,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1xly99k"&&(s.textContent=c),n=r($),p=u($,"UL",{"data-svelte-h":!0}),T(p)!=="svelte-1m6ktg7"&&(p.innerHTML=o),i=r($),f(y.$$.fragment,$),b=r($),d=u($,"P",{"data-svelte-h":!0}),T(d)!=="svelte-19jrhyn"&&(d.innerHTML=B),W=r($),f(G.$$.fragment,$),R=r($),J=u($,"P",{"data-svelte-h":!0}),T(J)!=="svelte-101ae6u"&&(J.innerHTML=_),X=r($),f(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($),f(E.$$.fragment,$),te=r($),f(Q.$$.fragment,$)},m($,k){l($,s,k),l($,n,k),l($,p,k),l($,i,k),U(y,$,k),l($,b,k),l($,d,k),l($,W,k),U(G,$,k),l($,R,k),l($,J,k),l($,X,k),U(N,$,k),l($,Z,k),l($,A,k),l($,H,k),l($,D,k),l($,F,k),l($,x,k),l($,ee,k),U(E,$,k),l($,te,k),U(Q,$,k),O=!0},p($,k){const se={};k&2&&(se.$$scope={dirty:k,ctx:$}),Q.$set(se)},i($){O||(j(y.$$.fragment,$),j(G.$$.fragment,$),j(N.$$.fragment,$),j(E.$$.fragment,$),j(Q.$$.fragment,$),O=!0)},o($){h(y.$$.fragment,$),h(G.$$.fragment,$),h(N.$$.fragment,$),h(E.$$.fragment,$),h(Q.$$.fragment,$),O=!1},d($){$&&(t(s),t(n),t(p),t(i),t(b),t(d),t(W),t(R),t(J),t(X),t(Z),t(A),t(H),t(D),t(F),t(x),t(ee),t(te)),I(y,$),I(G,$),I(N,$),I(E,$),I(Q,$)}}}function Vo(g){let s,c,n,p,o,i;return s=new Y({props:{id:"zero-config",option:"ZeRO-1",$$slots:{default:[ko]},$$scope:{ctx:g}}}),n=new Y({props:{id:"zero-config",option:"ZeRO-2",$$slots:{default:[Xo]},$$scope:{ctx:g}}}),o=new Y({props:{id:"zero-config",option:"ZeRO-3",$$slots:{default:[No]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment),p=M(),w(o.$$.fragment)},l(y){f(s.$$.fragment,y),c=r(y),f(n.$$.fragment,y),p=r(y),f(o.$$.fragment,y)},m(y,b){U(s,y,b),l(y,c,b),U(n,y,b),l(y,p,b),U(o,y,b),i=!0},p(y,b){const d={};b&2&&(d.$$scope={dirty:b,ctx:y}),s.$set(d);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||(j(s.$$.fragment,y),j(n.$$.fragment,y),j(o.$$.fragment,y),i=!0)},o(y){h(s.$$.fragment,y),h(n.$$.fragment,y),h(o.$$.fragment,y),i=!1},d(y){y&&(t(c),t(p)),I(s,y),I(n,y),I(o,y)}}}function So(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-12t9s6d"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function Eo(g){let s,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,d,B="You can also use an unsupported optimizer by adding the following to the top level configuration.",W,G,R,J,_="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.",X,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(){s=m("p"),s.innerHTML=c,n=M(),p=m("p"),p.innerHTML=o,i=M(),w(y.$$.fragment),b=M(),d=m("p"),d.textContent=B,W=M(),w(G.$$.fragment),R=M(),J=m("p"),J.textContent=_,X=M(),w(N.$$.fragment)},l(A){s=u(A,"P",{"data-svelte-h":!0}),T(s)!=="svelte-19gj6ej"&&(s.innerHTML=c),n=r(A),p=u(A,"P",{"data-svelte-h":!0}),T(p)!=="svelte-1c8r8fs"&&(p.innerHTML=o),i=r(A),f(y.$$.fragment,A),b=r(A),d=u(A,"P",{"data-svelte-h":!0}),T(d)!=="svelte-1ecbnix"&&(d.textContent=B),W=r(A),f(G.$$.fragment,A),R=r(A),J=u(A,"P",{"data-svelte-h":!0}),T(J)!=="svelte-ybmwnz"&&(J.textContent=_),X=r(A),f(N.$$.fragment,A)},m(A,V){l(A,s,V),l(A,n,V),l(A,p,V),l(A,i,V),U(y,A,V),l(A,b,V),l(A,d,V),l(A,W,V),U(G,A,V),l(A,R,V),l(A,J,V),l(A,X,V),U(N,A,V),Z=!0},p:S,i(A){Z||(j(y.$$.fragment,A),j(G.$$.fragment,A),j(N.$$.fragment,A),Z=!0)},o(A){h(y.$$.fragment,A),h(G.$$.fragment,A),h(N.$$.fragment,A),Z=!1},d(A){A&&(t(s),t(n),t(p),t(i),t(b),t(d),t(W),t(R),t(J),t(X)),I(y,A),I(G,A),I(N,A)}}}function Qo(g){let s,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>",d,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,J="You can set the parameters to <code>&quot;auto&quot;</code> or manually input your own desired values.",_,X,N;return X=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(){s=m("p"),s.innerHTML=c,n=M(),p=m("p"),p.textContent=o,i=M(),y=m("ul"),y.innerHTML=b,d=M(),B=m("p"),B.innerHTML=W,G=M(),R=m("p"),R.innerHTML=J,_=M(),w(X.$$.fragment)},l(Z){s=u(Z,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1te33vu"&&(s.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),d=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=J),_=r(Z),f(X.$$.fragment,Z)},m(Z,A){l(Z,s,A),l(Z,n,A),l(Z,p,A),l(Z,i,A),l(Z,y,A),l(Z,d,A),l(Z,B,A),l(Z,G,A),l(Z,R,A),l(Z,_,A),U(X,Z,A),N=!0},p:S,i(Z){N||(j(X.$$.fragment,Z),N=!0)},o(Z){h(X.$$.fragment,Z),N=!1},d(Z){Z&&(t(s),t(n),t(p),t(i),t(y),t(d),t(B),t(G),t(R),t(_)),I(X,Z)}}}function Ho(g){let s,c,n,p;return s=new Y({props:{id:"opt-sched",option:"optimizer",$$slots:{default:[Eo]},$$scope:{ctx:g}}}),n=new Y({props:{id:"opt-sched",option:"scheduler",$$slots:{default:[Qo]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function xo(g){let s,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(){s=m("p"),s.textContent=c,n=M(),w(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y},l(d){s=u(d,"P",{"data-svelte-h":!0}),T(s)!=="svelte-14q857h"&&(s.textContent=c),n=r(d),f(p.$$.fragment,d),o=r(d),i=u(d,"P",{"data-svelte-h":!0}),T(i)!=="svelte-n1kf8c"&&(i.innerHTML=y)},m(d,B){l(d,s,B),l(d,n,B),U(p,d,B),l(d,o,B),l(d,i,B),b=!0},p:S,i(d){b||(j(p.$$.fragment,d),b=!0)},o(d){h(p.$$.fragment,d),b=!1},d(d){d&&(t(s),t(n),t(o),t(i)),I(p,d)}}}function Yo(g){let s,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,d,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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y,b=M(),d=m("p"),d.innerHTML=B,W=M(),w(G.$$.fragment)},l(J){s=u(J,"P",{"data-svelte-h":!0}),T(s)!=="svelte-ktricy"&&(s.innerHTML=c),n=r(J),f(p.$$.fragment,J),o=r(J),i=u(J,"P",{"data-svelte-h":!0}),T(i)!=="svelte-rsxg0g"&&(i.innerHTML=y),b=r(J),d=u(J,"P",{"data-svelte-h":!0}),T(d)!=="svelte-1l2cotq"&&(d.innerHTML=B),W=r(J),f(G.$$.fragment,J)},m(J,_){l(J,s,_),l(J,n,_),U(p,J,_),l(J,o,_),l(J,i,_),l(J,b,_),l(J,d,_),l(J,W,_),U(G,J,_),R=!0},p:S,i(J){R||(j(p.$$.fragment,J),j(G.$$.fragment,J),R=!0)},o(J){h(p.$$.fragment,J),h(G.$$.fragment,J),R=!1},d(J){J&&(t(s),t(n),t(o),t(i),t(b),t(d),t(W)),I(p,J),I(G,J)}}}function Fo(g){let s,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(){s=m("p"),s.innerHTML=c,n=M(),p=m("p"),p.innerHTML=o,i=M(),w(y.$$.fragment)},l(d){s=u(d,"P",{"data-svelte-h":!0}),T(s)!=="svelte-9fep10"&&(s.innerHTML=c),n=r(d),p=u(d,"P",{"data-svelte-h":!0}),T(p)!=="svelte-f1ubot"&&(p.innerHTML=o),i=r(d),f(y.$$.fragment,d)},m(d,B){l(d,s,B),l(d,n,B),l(d,p,B),l(d,i,B),U(y,d,B),b=!0},p:S,i(d){b||(j(y.$$.fragment,d),b=!0)},o(d){h(y.$$.fragment,d),b=!1},d(d){d&&(t(s),t(n),t(p),t(i)),I(y,d)}}}function Lo(g){let s,c,n,p,o,i;return s=new Y({props:{id:"precision",option:"fp32",$$slots:{default:[xo]},$$scope:{ctx:g}}}),n=new Y({props:{id:"precision",option:"fp16",$$slots:{default:[Yo]},$$scope:{ctx:g}}}),o=new Y({props:{id:"precision",option:"bf16",$$slots:{default:[Fo]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment),p=M(),w(o.$$.fragment)},l(y){f(s.$$.fragment,y),c=r(y),f(n.$$.fragment,y),p=r(y),f(o.$$.fragment,y)},m(y,b){U(s,y,b),l(y,c,b),U(n,y,b),l(y,p,b),U(o,y,b),i=!0},p(y,b){const d={};b&2&&(d.$$scope={dirty:b,ctx:y}),s.$set(d);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||(j(s.$$.fragment,y),j(n.$$.fragment,y),j(o.$$.fragment,y),i=!0)},o(y){h(s.$$.fragment,y),h(n.$$.fragment,y),h(o.$$.fragment,y),i=!1},d(y){y&&(t(c),t(p)),I(s,y),I(n,y),I(o,y)}}}function Do(g){let s,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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1crs7lp"&&(s.innerHTML=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function Po(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-7bkscr"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function Oo(g){let s,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,d,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:[Po]},$$scope:{ctx:g}}}),{c(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment),o=M(),i=m("p"),i.textContent=y,b=M(),d=m("ol"),d.innerHTML=B,W=M(),w(G.$$.fragment)},l(J){s=u(J,"P",{"data-svelte-h":!0}),T(s)!=="svelte-qfcnk"&&(s.innerHTML=c),n=r(J),f(p.$$.fragment,J),o=r(J),i=u(J,"P",{"data-svelte-h":!0}),T(i)!=="svelte-1nox3dx"&&(i.textContent=y),b=r(J),d=u(J,"OL",{"data-svelte-h":!0}),T(d)!=="svelte-1g5xefo"&&(d.innerHTML=B),W=r(J),f(G.$$.fragment,J)},m(J,_){l(J,s,_),l(J,n,_),U(p,J,_),l(J,o,_),l(J,i,_),l(J,b,_),l(J,d,_),l(J,W,_),U(G,J,_),R=!0},p(J,_){const X={};_&2&&(X.$$scope={dirty:_,ctx:J}),G.$set(X)},i(J){R||(j(p.$$.fragment,J),j(G.$$.fragment,J),R=!0)},o(J){h(p.$$.fragment,J),h(G.$$.fragment,J),R=!1},d(J){J&&(t(s),t(n),t(o),t(i),t(b),t(d),t(W)),I(p,J),I(G,J)}}}function Ko(g){let s,c,n,p;return s=new Y({props:{id:"deploy",option:"multi-GPU",$$slots:{default:[Do]},$$scope:{ctx:g}}}),n=new Y({props:{id:"deploy",option:"single-GPU",$$slots:{default:[Oo]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function ei(g){let s,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:"cHl0aG9uJTIwLW0lMjB0b3JjaC5ydW4lMjAtLW5wcm9jX3Blcl9ub2RlJTNEOCUyMC0tbm5vZGUlM0QyJTIwLS1ub2RlX3JhbmslM0QwJTIwLS1tYXN0ZXJfYWRkciUzRGhvc3RuYW1lMSUyMCU1QyUwQS0tbWFzdGVyX3BvcnQlM0Q5OTAxJTIweW91cl9wcm9ncmFtLnB5JTIwJTNDbm9ybWFsJTIwY2wlMjBhcmdzJTNFJTIwLS1kZWVwc3BlZWQlMjBkc19jb25maWcuanNvbg==",highlighted:`python -m torch.run --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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1bt3z60"&&(s.innerHTML=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function ti(g){let s,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,d,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}}),d=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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment),o=M(),i=m("p"),i.innerHTML=y,b=M(),w(d.$$.fragment),B=M(),W=m("p"),W.innerHTML=G},l(J){s=u(J,"P",{"data-svelte-h":!0}),T(s)!=="svelte-ijhrw"&&(s.innerHTML=c),n=r(J),f(p.$$.fragment,J),o=r(J),i=u(J,"P",{"data-svelte-h":!0}),T(i)!=="svelte-1vzgmv9"&&(i.innerHTML=y),b=r(J),f(d.$$.fragment,J),B=r(J),W=u(J,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1ahoskn"&&(W.innerHTML=G)},m(J,_){l(J,s,_),l(J,n,_),U(p,J,_),l(J,o,_),l(J,i,_),l(J,b,_),U(d,J,_),l(J,B,_),l(J,W,_),R=!0},p:S,i(J){R||(j(p.$$.fragment,J),j(d.$$.fragment,J),R=!0)},o(J){h(p.$$.fragment,J),h(d.$$.fragment,J),R=!1},d(J){J&&(t(s),t(n),t(o),t(i),t(b),t(B),t(W)),I(p,J),I(d,J)}}}function li(g){let s,c,n,p;return s=new Y({props:{id:"multinode",option:"torchrun",$$slots:{default:[ei]},$$scope:{ctx:g}}}),n=new Y({props:{id:"multinode",option:"deepspeed",$$slots:{default:[ti]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function si(g){let s,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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-tkw2o5"&&(s.innerHTML=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function ai(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-s2e8vm"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function ni(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-m8616q"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function oi(g){let s,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,d,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,J,_,X,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,E,te="For example, if your checkpoint folder looked like this:",Q,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 q({props:{title:"Online",local:"online",headingTag:"h3"}}),d=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}}),J=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}}),X=new Me({props:{$$slots:{default:[ai]},$$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 q({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:[ni]},$$scope:{ctx:g}}}),{c(){s=m("p"),s.textContent=c,n=M(),w(p.$$.fragment),o=M(),i=m("p"),i.textContent=y,b=M(),w(d.$$.fragment),B=M(),W=m("p"),W.innerHTML=G,R=M(),w(J.$$.fragment),_=M(),w(X.$$.fragment),N=M(),Z=m("p"),Z.textContent=A,V=M(),w(H.$$.fragment),D=M(),w(P.$$.fragment),F=M(),x=m("p"),x.innerHTML=K,ee=M(),E=m("p"),E.textContent=te,Q=M(),w(O.$$.fragment),$=M(),k=m("p"),k.innerHTML=se,le=M(),w(ae.$$.fragment),oe=M(),w(L.$$.fragment)},l(C){s=u(C,"P",{"data-svelte-h":!0}),T(s)!=="svelte-idar67"&&(s.textContent=c),n=r(C),f(p.$$.fragment,C),o=r(C),i=u(C,"P",{"data-svelte-h":!0}),T(i)!=="svelte-130bwnm"&&(i.textContent=y),b=r(C),f(d.$$.fragment,C),B=r(C),W=u(C,"P",{"data-svelte-h":!0}),T(W)!=="svelte-11i0172"&&(W.innerHTML=G),R=r(C),f(J.$$.fragment,C),_=r(C),f(X.$$.fragment,C),N=r(C),Z=u(C,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-axrctj"&&(Z.textContent=A),V=r(C),f(H.$$.fragment,C),D=r(C),f(P.$$.fragment,C),F=r(C),x=u(C,"P",{"data-svelte-h":!0}),T(x)!=="svelte-xkeulr"&&(x.innerHTML=K),ee=r(C),E=u(C,"P",{"data-svelte-h":!0}),T(E)!=="svelte-1gq5knk"&&(E.textContent=te),Q=r(C),f(O.$$.fragment,C),$=r(C),k=u(C,"P",{"data-svelte-h":!0}),T(k)!=="svelte-10tjpq7"&&(k.innerHTML=se),le=r(C),f(ae.$$.fragment,C),oe=r(C),f(L.$$.fragment,C)},m(C,z){l(C,s,z),l(C,n,z),U(p,C,z),l(C,o,z),l(C,i,z),l(C,b,z),U(d,C,z),l(C,B,z),l(C,W,z),l(C,R,z),U(J,C,z),l(C,_,z),U(X,C,z),l(C,N,z),l(C,Z,z),l(C,V,z),U(H,C,z),l(C,D,z),U(P,C,z),l(C,F,z),l(C,x,z),l(C,ee,z),l(C,E,z),l(C,Q,z),U(O,C,z),l(C,$,z),l(C,k,z),l(C,le,z),U(ae,C,z),l(C,oe,z),U(L,C,z),je=!0},p(C,z){const he={};z&2&&(he.$$scope={dirty:z,ctx:C}),X.$set(he);const ne={};z&2&&(ne.$$scope={dirty:z,ctx:C}),L.$set(ne)},i(C){je||(j(p.$$.fragment,C),j(d.$$.fragment,C),j(J.$$.fragment,C),j(X.$$.fragment,C),j(H.$$.fragment,C),j(P.$$.fragment,C),j(O.$$.fragment,C),j(ae.$$.fragment,C),j(L.$$.fragment,C),je=!0)},o(C){h(p.$$.fragment,C),h(d.$$.fragment,C),h(J.$$.fragment,C),h(X.$$.fragment,C),h(H.$$.fragment,C),h(P.$$.fragment,C),h(O.$$.fragment,C),h(ae.$$.fragment,C),h(L.$$.fragment,C),je=!1},d(C){C&&(t(s),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(E),t(Q),t($),t(k),t(le),t(oe)),I(p,C),I(d,C),I(J,C),I(X,C),I(H,C),I(P,C),I(O,C),I(ae,C),I(L,C)}}}function ii(g){let s,c,n,p;return s=new Y({props:{id:"save",option:"fp16",$$slots:{default:[si]},$$scope:{ctx:g}}}),n=new Y({props:{id:"save",option:"fp32",$$slots:{default:[oi]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function Mi(g){let s,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(){s=m("p"),s.innerHTML=c},l(n){s=u(n,"P",{"data-svelte-h":!0}),T(s)!=="svelte-bmky8k"&&(s.innerHTML=c)},m(n,p){l(n,s,p)},p:S,d(n){n&&t(s)}}}function ri(g){let s,c;return s=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(){w(s.$$.fragment)},l(n){f(s.$$.fragment,n)},m(n,p){U(s,n,p),c=!0},p:S,i(n){c||(j(s.$$.fragment,n),c=!0)},o(n){h(s.$$.fragment,n),c=!1},d(n){I(s,n)}}}function pi(g){let s,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(){s=m("p"),s.innerHTML=c,n=M(),w(p.$$.fragment)},l(i){s=u(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1i7ih4n"&&(s.innerHTML=c),n=r(i),f(p.$$.fragment,i)},m(i,y){l(i,s,y),l(i,n,y),U(p,i,y),o=!0},p:S,i(i){o||(j(p.$$.fragment,i),o=!0)},o(i){h(p.$$.fragment,i),o=!1},d(i){i&&(t(s),t(n)),I(p,i)}}}function yi(g){let s,c,n,p;return s=new Y({props:{id:"models",option:"pretrained model",$$slots:{default:[ri]},$$scope:{ctx:g}}}),n=new Y({props:{id:"models",option:"non-pretrained model",$$slots:{default:[pi]},$$scope:{ctx:g}}}),{c(){w(s.$$.fragment),c=M(),w(n.$$.fragment)},l(o){f(s.$$.fragment,o),c=r(o),f(n.$$.fragment,o)},m(o,i){U(s,o,i),l(o,c,i),U(n,o,i),p=!0},p(o,i){const y={};i&2&&(y.$$scope={dirty:i,ctx:o}),s.$set(y);const b={};i&2&&(b.$$scope={dirty:i,ctx:o}),n.$set(b)},i(o){p||(j(s.$$.fragment,o),j(n.$$.fragment,o),p=!0)},o(o){h(s.$$.fragment,o),h(n.$$.fragment,o),p=!1},d(o){o&&t(c),I(s,o),I(n,o)}}}function ci(g){let s,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 it’s 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:',d,B,W="<li>ZeRO-1, optimizer state partioning across GPUs</li> <li>ZeRO-2, gradient partitioning across GPUs</li> <li>ZeRO-3, parameteter partitioning across GPUs</li>",G,R,J='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.',_,X,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,E,te,Q,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,Sa="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:",gl,Ie,Ea="<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>",$l,Ce,Qa="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.",Al,be,Ha="A general process you can use is (start with batch size of 1):",Bl,ge,xa='<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/model_doc/phi#transformers.PhiForCausalLM.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>',_l,$e,Zl,Ae,Ya='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.',vl,re,Gl,Be,Fa='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.',Wl,pe,Rl,_e,zl,Ze,La="There are three types of configuration parameters:",kl,ve,Da='<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>',Xl,Ge,Pa='You could also modify the DeepSpeed configuration and edit <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> from it:',ql,We,Oa='<li>Create or load a DeepSpeed configuration to used 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>',Nl,Re,Ka='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.',Vl,ze,Sl,ke,en='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.',El,ye,Ql,Xe,tn='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.',Hl,ce,xl,qe,Yl,Ne,ln='<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.',Fl,Ve,sn='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.',Ll,Se,an="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.",Dl,Ee,Pl,Qe,Ol,He,nn="There are a number of important parameters to specify in the DeepSpeed configuration file which are briefly described in this section.",Kl,xe,es,Ye,on="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:",ts,Fe,Mn='<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>',ls,Le,ss,De,rn="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.",as,me,ns,ue,os,Pe,is,Oe,pn="Deepspeed supports fp32, fp16, and bf16 mixed precision.",Ms,Te,rs,Ke,ps,et,yn='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>.',ys,tt,cs,lt,ms,st,cn='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>.',us,at,Ts,nt,Js,ot,mn='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>.',ds,it,ws,Mt,fs,rt,un="For communication collectives like reduction, gathering and scattering operations, a separate data type is used.",Us,pt,Tn="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.",js,yt,Jn="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.",hs,ct,dn="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.",Is,mt,Cs,ut,bs,Tt,wn='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.',gs,Jt,fn='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.',$s,Je,As,dt,Bs,wt,Un="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.",_s,ft,jn='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:',Zs,Ut,vs,jt,hn='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.',Gs,de,Ws,ht,Rs,It,In="In a SLURM environment, you’ll need to adapt your SLURM script to your specific SLURM environment. An example SLURM script may look like:",zs,Ct,ks,bt,Cn="Then you can schedule your multi-node deployment with the following command which launches training simultaneously on all nodes.",Xs,gt,qs,$t,Ns,At,bn="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.",Vs,Bt,Ss,_t,gn="If you want to create the config file on the fly in the notebook in the current directory, you could have a dedicated cell.",Es,Zt,Qs,vt,$n="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>:",Hs,Gt,xs,Wt,An="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.",Ys,Rt,Fs,zt,Ls,kt,Bn="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.",Ds,we,Ps,Xt,Os,qt,_n='<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.',Ks,Nt,Zn='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.',ea,Vt,vn='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.',ta,St,la,Et,sa,Qt,Gn='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>.',aa,fe,na,Ht,Wn="To efficiently deploy ZeRO-3, you must instantiate the <code>HfDeepSpeedConfig</code> object before the model and keep that object alive:",oa,Ue,ia,xt,Ma,Yt,Rn='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.',ra,Ft,zn="Make sure to:",pa,Lt,kn="<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>",ya,Dt,Xn='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.',ca,Pt,ma,Ot,qn="Save the script as t0.py and launch it:",ua,Kt,Ta,el,Nn="This is a very basic example and you’ll want to adapt it to your use case.",Ja,tl,da,ll,Vn='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/model_doc/phi#transformers.PhiForCausalLM.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.',wa,sl,Sn="For Transformers&gt;=4.28, if <code>synced_gpus</code> is automatically set to <code>True</code> if multiple GPUs are detected during generation.",fa,al,Ua,nl,En='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>.',ja,ol,Qn="For issues related to the Transformers integration, please provide the following information:",ha,il,Hn='<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>',Ia,Ml,Ca,rl,xn="<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>",ba,pl,Yn="The following sections provide a guide for resolving two of the most common issues.",ga,yl,$a,cl,Fn="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.",Aa,ml,Ln='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).',Ba,ul,_a,Tl,Dn="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).",Za,Jl,Pn="The other issue may be related to using fp16. For example, if this is your fp16 configuration:",va,dl,Ga,wl,On="You might see the following <code>OVERFLOW!</code> messages in the logs:",Wa,fl,Ra,Ul,Kn="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).",za,jl,ka,hl,eo='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>.',Xa,Il,to="The following papers are also a great resource for learning more about ZeRO:",qa,Cl,lo='<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>',Na,bl,Va;return o=new q({props:{title:"DeepSpeed",local:"deepspeed",headingTag:"h1"}}),A=new q({props:{title:"Installation",local:"installation",headingTag:"h2"}}),F=new Me({props:{$$slots:{default:[Ao]},$$scope:{ctx:g}}}),K=new ie({props:{id:"install",options:["PyPI","Transformers"],$$slots:{default:[Zo]},$$scope:{ctx:g}}}),E=new q({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 q({props:{title:"Select a ZeRO stage",local:"select-a-zero-stage",headingTag:"h2"}}),$e=new q({props:{title:"DeepSpeed configuration file",local:"deepspeed-configuration-file",headingTag:"h2"}}),re=new Me({props:{$$slots:{default:[vo]},$$scope:{ctx:g}}}),pe=new ie({props:{id:"pass-config",options:["path to file","nested dict"],$$slots:{default:[Ro]},$$scope:{ctx:g}}}),_e=new q({props:{title:"DeepSpeed and Trainer parameters",local:"deepspeed-and-trainer-parameters",headingTag:"h3"}}),ze=new q({props:{title:"ZeRO configuration",local:"zero-configuration",headingTag:"h3"}}),ye=new Me({props:{warning:!0,$$slots:{default:[zo]},$$scope:{ctx:g}}}),ce=new ie({props:{id:"zero-config",options:["ZeRO-1","ZeRO-2","ZeRO-3"],$$slots:{default:[Vo]},$$scope:{ctx:g}}}),qe=new q({props:{title:"NVMe configuration",local:"nvme-configuration",headingTag:"h3"}}),Ee=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}}),Qe=new q({props:{title:"DeepSpeed features",local:"deepspeed-features",headingTag:"h2"}}),xe=new q({props:{title:"Activation/gradient checkpointing",local:"activationgradient-checkpointing",headingTag:"h3"}}),Le=new q({props:{title:"Optimizer and scheduler",local:"optimizer-and-scheduler",headingTag:"h3"}}),me=new Me({props:{warning:!0,$$slots:{default:[So]},$$scope:{ctx:g}}}),ue=new ie({props:{id:"opt-sched",options:["optimizer","scheduler"],$$slots:{default:[Ho]},$$scope:{ctx:g}}}),Pe=new q({props:{title:"Precision",local:"precision",headingTag:"h3"}}),Te=new ie({props:{id:"precision",options:["fp32","fp16","bf16"],$$slots:{default:[Lo]},$$scope:{ctx:g}}}),Ke=new q({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 q({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 q({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 q({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 q({props:{title:"Deployment",local:"deployment",headingTag:"h2"}}),Je=new ie({props:{id:"deploy",options:["multi-GPU","single-GPU"],$$slots:{default:[Ko]},$$scope:{ctx:g}}}),dt=new q({props:{title:"Multi-node deployment",local:"multi-node-deployment",headingTag:"h3"}}),Ut=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:[li]},$$scope:{ctx:g}}}),ht=new q({props:{title:"SLURM",local:"slurm",headingTag:"h3"}}),Ct=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}}),gt=new v({props:{code:"c2JhdGNoJTIwbGF1bmNoLnNsdXJt",highlighted:"sbatch launch.slurm",wrap:!1}}),$t=new q({props:{title:"Notebook",local:"notebook",headingTag:"h3"}}),Bt=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}}),Zt=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}}),Gt=new v({props:{code:"IWdpdCUyMGNsb25lJTIwaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGaHVnZ2luZ2ZhY2UlMkZ0cmFuc2Zvcm1lcnMlMEEhY2QlMjB0cmFuc2Zvcm1lcnMlM0IlMjBkZWVwc3BlZWQlMjBleGFtcGxlcyUyRnB5dG9yY2glMkZ0cmFuc2xhdGlvbiUyRnJ1bl90cmFuc2xhdGlvbi5weSUyMC4uLg==",highlighted:`!git clone https://github.com/huggingface/transformers
!cd transformers; deepspeed examples/pytorch/translation/run_translation.py ...`,wrap:!1}}),Rt=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}}),zt=new q({props:{title:"Save model weights",local:"save-model-weights",headingTag:"h2"}}),we=new ie({props:{id:"save",options:["fp16","fp32"],$$slots:{default:[ii]},$$scope:{ctx:g}}}),Xt=new q({props:{title:"ZeRO Inference",local:"zero-inference",headingTag:"h2"}}),St=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}}),Et=new q({props:{title:"Non-Trainer DeepSpeed integration",local:"non-trainer-deepspeed-integration",headingTag:"h2"}}),fe=new Me({props:{$$slots:{default:[Mi]},$$scope:{ctx:g}}}),Ue=new ie({props:{id:"models",options:["pretrained model","non-pretrained model"],$$slots:{default:[yi]},$$scope:{ctx:g}}}),xt=new q({props:{title:"Non-Trainer ZeRO Inference",local:"non-trainer-zero-inference",headingTag:"h3"}}),Pt=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}}),Kt=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}}),tl=new q({props:{title:"Generate",local:"generate",headingTag:"h3"}}),al=new q({props:{title:"Troubleshoot",local:"troubleshoot",headingTag:"h2"}}),Ml=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}}),yl=new q({props:{title:"DeepSpeed process killed at startup",local:"deepspeed-process-killed-at-startup",headingTag:"h3"}}),ul=new q({props:{title:"NaN loss",local:"nan-loss",headingTag:"h3"}}),dl=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}}),fl=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}}),jl=new q({props:{title:"Resources",local:"resources",headingTag:"h2"}}),{c(){s=m("meta"),c=M(),n=m("p"),p=M(),w(o.$$.fragment),i=M(),y=m("p"),y.innerHTML=b,d=M(),B=m("ul"),B.innerHTML=W,G=M(),R=m("p"),R.innerHTML=J,_=M(),X=m("p"),X.innerHTML=N,Z=M(),w(A.$$.fragment),V=M(),H=m("p"),H.innerHTML=D,P=M(),w(F.$$.fragment),x=M(),w(K.$$.fragment),ee=M(),w(E.$$.fragment),te=M(),Q=m("p"),Q.innerHTML=O,$=M(),w(k.$$.fragment),se=M(),le=m("p"),le.textContent=ae,oe=M(),L=m("p"),L.textContent=je,C=M(),w(z.$$.fragment),he=M(),ne=m("p"),ne.textContent=Sa,gl=M(),Ie=m("table"),Ie.innerHTML=Ea,$l=M(),Ce=m("p"),Ce.textContent=Qa,Al=M(),be=m("p"),be.textContent=Ha,Bl=M(),ge=m("ol"),ge.innerHTML=xa,_l=M(),w($e.$$.fragment),Zl=M(),Ae=m("p"),Ae.innerHTML=Ya,vl=M(),w(re.$$.fragment),Gl=M(),Be=m("p"),Be.innerHTML=Fa,Wl=M(),w(pe.$$.fragment),Rl=M(),w(_e.$$.fragment),zl=M(),Ze=m("p"),Ze.textContent=La,kl=M(),ve=m("ol"),ve.innerHTML=Da,Xl=M(),Ge=m("p"),Ge.innerHTML=Pa,ql=M(),We=m("ol"),We.innerHTML=Oa,Nl=M(),Re=m("p"),Re.innerHTML=Ka,Vl=M(),w(ze.$$.fragment),Sl=M(),ke=m("p"),ke.innerHTML=en,El=M(),w(ye.$$.fragment),Ql=M(),Xe=m("p"),Xe.innerHTML=tn,Hl=M(),w(ce.$$.fragment),xl=M(),w(qe.$$.fragment),Yl=M(),Ne=m("p"),Ne.innerHTML=ln,Fl=M(),Ve=m("p"),Ve.innerHTML=sn,Ll=M(),Se=m("p"),Se.innerHTML=an,Dl=M(),w(Ee.$$.fragment),Pl=M(),w(Qe.$$.fragment),Ol=M(),He=m("p"),He.textContent=nn,Kl=M(),w(xe.$$.fragment),es=M(),Ye=m("p"),Ye.textContent=on,ts=M(),Fe=m("ol"),Fe.innerHTML=Mn,ls=M(),w(Le.$$.fragment),ss=M(),De=m("p"),De.innerHTML=rn,as=M(),w(me.$$.fragment),ns=M(),w(ue.$$.fragment),os=M(),w(Pe.$$.fragment),is=M(),Oe=m("p"),Oe.textContent=pn,Ms=M(),w(Te.$$.fragment),rs=M(),w(Ke.$$.fragment),ps=M(),et=m("p"),et.innerHTML=yn,ys=M(),w(tt.$$.fragment),cs=M(),w(lt.$$.fragment),ms=M(),st=m("p"),st.innerHTML=cn,us=M(),w(at.$$.fragment),Ts=M(),w(nt.$$.fragment),Js=M(),ot=m("p"),ot.innerHTML=mn,ds=M(),w(it.$$.fragment),ws=M(),w(Mt.$$.fragment),fs=M(),rt=m("p"),rt.textContent=un,Us=M(),pt=m("p"),pt.textContent=Tn,js=M(),yt=m("p"),yt.textContent=Jn,hs=M(),ct=m("p"),ct.innerHTML=dn,Is=M(),w(mt.$$.fragment),Cs=M(),w(ut.$$.fragment),bs=M(),Tt=m("p"),Tt.innerHTML=wn,gs=M(),Jt=m("p"),Jt.innerHTML=fn,$s=M(),w(Je.$$.fragment),As=M(),w(dt.$$.fragment),Bs=M(),wt=m("p"),wt.innerHTML=Un,_s=M(),ft=m("p"),ft.innerHTML=jn,Zs=M(),w(Ut.$$.fragment),vs=M(),jt=m("p"),jt.innerHTML=hn,Gs=M(),w(de.$$.fragment),Ws=M(),w(ht.$$.fragment),Rs=M(),It=m("p"),It.textContent=In,zs=M(),w(Ct.$$.fragment),ks=M(),bt=m("p"),bt.textContent=Cn,Xs=M(),w(gt.$$.fragment),qs=M(),w($t.$$.fragment),Ns=M(),At=m("p"),At.innerHTML=bn,Vs=M(),w(Bt.$$.fragment),Ss=M(),_t=m("p"),_t.textContent=gn,Es=M(),w(Zt.$$.fragment),Qs=M(),vt=m("p"),vt.innerHTML=$n,Hs=M(),w(Gt.$$.fragment),xs=M(),Wt=m("p"),Wt.innerHTML=An,Ys=M(),w(Rt.$$.fragment),Fs=M(),w(zt.$$.fragment),Ls=M(),kt=m("p"),kt.innerHTML=Bn,Ds=M(),w(we.$$.fragment),Ps=M(),w(Xt.$$.fragment),Os=M(),qt=m("p"),qt.innerHTML=_n,Ks=M(),Nt=m("p"),Nt.innerHTML=Zn,ea=M(),Vt=m("p"),Vt.innerHTML=vn,ta=M(),w(St.$$.fragment),la=M(),w(Et.$$.fragment),sa=M(),Qt=m("p"),Qt.innerHTML=Gn,aa=M(),w(fe.$$.fragment),na=M(),Ht=m("p"),Ht.innerHTML=Wn,oa=M(),w(Ue.$$.fragment),ia=M(),w(xt.$$.fragment),Ma=M(),Yt=m("p"),Yt.innerHTML=Rn,ra=M(),Ft=m("p"),Ft.textContent=zn,pa=M(),Lt=m("ul"),Lt.innerHTML=kn,ya=M(),Dt=m("p"),Dt.innerHTML=Xn,ca=M(),w(Pt.$$.fragment),ma=M(),Ot=m("p"),Ot.textContent=qn,ua=M(),w(Kt.$$.fragment),Ta=M(),el=m("p"),el.textContent=Nn,Ja=M(),w(tl.$$.fragment),da=M(),ll=m("p"),ll.innerHTML=Vn,wa=M(),sl=m("p"),sl.innerHTML=Sn,fa=M(),w(al.$$.fragment),Ua=M(),nl=m("p"),nl.innerHTML=En,ja=M(),ol=m("p"),ol.textContent=Qn,ha=M(),il=m("ul"),il.innerHTML=Hn,Ia=M(),w(Ml.$$.fragment),Ca=M(),rl=m("ul"),rl.innerHTML=xn,ba=M(),pl=m("p"),pl.textContent=Yn,ga=M(),w(yl.$$.fragment),$a=M(),cl=m("p"),cl.innerHTML=Fn,Aa=M(),ml=m("p"),ml.innerHTML=Ln,Ba=M(),w(ul.$$.fragment),_a=M(),Tl=m("p"),Tl.textContent=Dn,Za=M(),Jl=m("p"),Jl.textContent=Pn,va=M(),w(dl.$$.fragment),Ga=M(),wl=m("p"),wl.innerHTML=On,Wa=M(),w(fl.$$.fragment),Ra=M(),Ul=m("p"),Ul.innerHTML=Kn,za=M(),w(jl.$$.fragment),ka=M(),hl=m("p"),hl.innerHTML=eo,Xa=M(),Il=m("p"),Il.textContent=to,qa=M(),Cl=m("ul"),Cl.innerHTML=lo,Na=M(),bl=m("p"),this.h()},l(e){const a=Co("svelte-u9bgzb",document.head);s=u(a,"META",{name:!0,content:!0}),a.forEach(t),c=r(e),n=u(e,"P",{}),wo(n).forEach(t),p=r(e),f(o.$$.fragment,e),i=r(e),y=u(e,"P",{"data-svelte-h":!0}),T(y)!=="svelte-gf6mrs"&&(y.innerHTML=b),d=r(e),B=u(e,"UL",{"data-svelte-h":!0}),T(B)!=="svelte-10b84nb"&&(B.innerHTML=W),G=r(e),R=u(e,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1pozm56"&&(R.innerHTML=J),_=r(e),X=u(e,"P",{"data-svelte-h":!0}),T(X)!=="svelte-gnql22"&&(X.innerHTML=N),Z=r(e),f(A.$$.fragment,e),V=r(e),H=u(e,"P",{"data-svelte-h":!0}),T(H)!=="svelte-fuidv5"&&(H.innerHTML=D),P=r(e),f(F.$$.fragment,e),x=r(e),f(K.$$.fragment,e),ee=r(e),f(E.$$.fragment,e),te=r(e),Q=u(e,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-1fd8xlc"&&(Q.innerHTML=O),$=r(e),f(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),f(z.$$.fragment,e),he=r(e),ne=u(e,"P",{"data-svelte-h":!0}),T(ne)!=="svelte-rkauna"&&(ne.textContent=Sa),gl=r(e),Ie=u(e,"TABLE",{"data-svelte-h":!0}),T(Ie)!=="svelte-msolv0"&&(Ie.innerHTML=Ea),$l=r(e),Ce=u(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-4tusjn"&&(Ce.textContent=Qa),Al=r(e),be=u(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-po9y52"&&(be.textContent=Ha),Bl=r(e),ge=u(e,"OL",{"data-svelte-h":!0}),T(ge)!=="svelte-1xamzob"&&(ge.innerHTML=xa),_l=r(e),f($e.$$.fragment,e),Zl=r(e),Ae=u(e,"P",{"data-svelte-h":!0}),T(Ae)!=="svelte-1ehamjq"&&(Ae.innerHTML=Ya),vl=r(e),f(re.$$.fragment,e),Gl=r(e),Be=u(e,"P",{"data-svelte-h":!0}),T(Be)!=="svelte-xbbt3u"&&(Be.innerHTML=Fa),Wl=r(e),f(pe.$$.fragment,e),Rl=r(e),f(_e.$$.fragment,e),zl=r(e),Ze=u(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1nzz5la"&&(Ze.textContent=La),kl=r(e),ve=u(e,"OL",{"data-svelte-h":!0}),T(ve)!=="svelte-15g6vrv"&&(ve.innerHTML=Da),Xl=r(e),Ge=u(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-3u230x"&&(Ge.innerHTML=Pa),ql=r(e),We=u(e,"OL",{"data-svelte-h":!0}),T(We)!=="svelte-mrje9j"&&(We.innerHTML=Oa),Nl=r(e),Re=u(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-1rxx8gr"&&(Re.innerHTML=Ka),Vl=r(e),f(ze.$$.fragment,e),Sl=r(e),ke=u(e,"P",{"data-svelte-h":!0}),T(ke)!=="svelte-nuf72i"&&(ke.innerHTML=en),El=r(e),f(ye.$$.fragment,e),Ql=r(e),Xe=u(e,"P",{"data-svelte-h":!0}),T(Xe)!=="svelte-1j6i0h4"&&(Xe.innerHTML=tn),Hl=r(e),f(ce.$$.fragment,e),xl=r(e),f(qe.$$.fragment,e),Yl=r(e),Ne=u(e,"P",{"data-svelte-h":!0}),T(Ne)!=="svelte-1yvixx2"&&(Ne.innerHTML=ln),Fl=r(e),Ve=u(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-14zbxsz"&&(Ve.innerHTML=sn),Ll=r(e),Se=u(e,"P",{"data-svelte-h":!0}),T(Se)!=="svelte-1bftyio"&&(Se.innerHTML=an),Dl=r(e),f(Ee.$$.fragment,e),Pl=r(e),f(Qe.$$.fragment,e),Ol=r(e),He=u(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-t13qkh"&&(He.textContent=nn),Kl=r(e),f(xe.$$.fragment,e),es=r(e),Ye=u(e,"P",{"data-svelte-h":!0}),T(Ye)!=="svelte-1pyala7"&&(Ye.textContent=on),ts=r(e),Fe=u(e,"OL",{"data-svelte-h":!0}),T(Fe)!=="svelte-s0cja"&&(Fe.innerHTML=Mn),ls=r(e),f(Le.$$.fragment,e),ss=r(e),De=u(e,"P",{"data-svelte-h":!0}),T(De)!=="svelte-8lb90i"&&(De.innerHTML=rn),as=r(e),f(me.$$.fragment,e),ns=r(e),f(ue.$$.fragment,e),os=r(e),f(Pe.$$.fragment,e),is=r(e),Oe=u(e,"P",{"data-svelte-h":!0}),T(Oe)!=="svelte-j5yqaq"&&(Oe.textContent=pn),Ms=r(e),f(Te.$$.fragment,e),rs=r(e),f(Ke.$$.fragment,e),ps=r(e),et=u(e,"P",{"data-svelte-h":!0}),T(et)!=="svelte-1clwpm9"&&(et.innerHTML=yn),ys=r(e),f(tt.$$.fragment,e),cs=r(e),f(lt.$$.fragment,e),ms=r(e),st=u(e,"P",{"data-svelte-h":!0}),T(st)!=="svelte-pfwv31"&&(st.innerHTML=cn),us=r(e),f(at.$$.fragment,e),Ts=r(e),f(nt.$$.fragment,e),Js=r(e),ot=u(e,"P",{"data-svelte-h":!0}),T(ot)!=="svelte-pc4pxg"&&(ot.innerHTML=mn),ds=r(e),f(it.$$.fragment,e),ws=r(e),f(Mt.$$.fragment,e),fs=r(e),rt=u(e,"P",{"data-svelte-h":!0}),T(rt)!=="svelte-gpfm4j"&&(rt.textContent=un),Us=r(e),pt=u(e,"P",{"data-svelte-h":!0}),T(pt)!=="svelte-mvoza6"&&(pt.textContent=Tn),js=r(e),yt=u(e,"P",{"data-svelte-h":!0}),T(yt)!=="svelte-1ulbaso"&&(yt.textContent=Jn),hs=r(e),ct=u(e,"P",{"data-svelte-h":!0}),T(ct)!=="svelte-b2p3xv"&&(ct.innerHTML=dn),Is=r(e),f(mt.$$.fragment,e),Cs=r(e),f(ut.$$.fragment,e),bs=r(e),Tt=u(e,"P",{"data-svelte-h":!0}),T(Tt)!=="svelte-pcgu7i"&&(Tt.innerHTML=wn),gs=r(e),Jt=u(e,"P",{"data-svelte-h":!0}),T(Jt)!=="svelte-1270bwq"&&(Jt.innerHTML=fn),$s=r(e),f(Je.$$.fragment,e),As=r(e),f(dt.$$.fragment,e),Bs=r(e),wt=u(e,"P",{"data-svelte-h":!0}),T(wt)!=="svelte-1vvv5pa"&&(wt.innerHTML=Un),_s=r(e),ft=u(e,"P",{"data-svelte-h":!0}),T(ft)!=="svelte-mp54lp"&&(ft.innerHTML=jn),Zs=r(e),f(Ut.$$.fragment,e),vs=r(e),jt=u(e,"P",{"data-svelte-h":!0}),T(jt)!=="svelte-1rwc4cv"&&(jt.innerHTML=hn),Gs=r(e),f(de.$$.fragment,e),Ws=r(e),f(ht.$$.fragment,e),Rs=r(e),It=u(e,"P",{"data-svelte-h":!0}),T(It)!=="svelte-ow6xqy"&&(It.textContent=In),zs=r(e),f(Ct.$$.fragment,e),ks=r(e),bt=u(e,"P",{"data-svelte-h":!0}),T(bt)!=="svelte-xfixmf"&&(bt.textContent=Cn),Xs=r(e),f(gt.$$.fragment,e),qs=r(e),f($t.$$.fragment,e),Ns=r(e),At=u(e,"P",{"data-svelte-h":!0}),T(At)!=="svelte-4dix30"&&(At.innerHTML=bn),Vs=r(e),f(Bt.$$.fragment,e),Ss=r(e),_t=u(e,"P",{"data-svelte-h":!0}),T(_t)!=="svelte-1fw1nb2"&&(_t.textContent=gn),Es=r(e),f(Zt.$$.fragment,e),Qs=r(e),vt=u(e,"P",{"data-svelte-h":!0}),T(vt)!=="svelte-xvblu4"&&(vt.innerHTML=$n),Hs=r(e),f(Gt.$$.fragment,e),xs=r(e),Wt=u(e,"P",{"data-svelte-h":!0}),T(Wt)!=="svelte-1dkflot"&&(Wt.innerHTML=An),Ys=r(e),f(Rt.$$.fragment,e),Fs=r(e),f(zt.$$.fragment,e),Ls=r(e),kt=u(e,"P",{"data-svelte-h":!0}),T(kt)!=="svelte-v8wycf"&&(kt.innerHTML=Bn),Ds=r(e),f(we.$$.fragment,e),Ps=r(e),f(Xt.$$.fragment,e),Os=r(e),qt=u(e,"P",{"data-svelte-h":!0}),T(qt)!=="svelte-1cd47xa"&&(qt.innerHTML=_n),Ks=r(e),Nt=u(e,"P",{"data-svelte-h":!0}),T(Nt)!=="svelte-1tp1ibg"&&(Nt.innerHTML=Zn),ea=r(e),Vt=u(e,"P",{"data-svelte-h":!0}),T(Vt)!=="svelte-8hzqpu"&&(Vt.innerHTML=vn),ta=r(e),f(St.$$.fragment,e),la=r(e),f(Et.$$.fragment,e),sa=r(e),Qt=u(e,"P",{"data-svelte-h":!0}),T(Qt)!=="svelte-alj4bp"&&(Qt.innerHTML=Gn),aa=r(e),f(fe.$$.fragment,e),na=r(e),Ht=u(e,"P",{"data-svelte-h":!0}),T(Ht)!=="svelte-1u0t2ts"&&(Ht.innerHTML=Wn),oa=r(e),f(Ue.$$.fragment,e),ia=r(e),f(xt.$$.fragment,e),Ma=r(e),Yt=u(e,"P",{"data-svelte-h":!0}),T(Yt)!=="svelte-1wx2kcp"&&(Yt.innerHTML=Rn),ra=r(e),Ft=u(e,"P",{"data-svelte-h":!0}),T(Ft)!=="svelte-o4r1i6"&&(Ft.textContent=zn),pa=r(e),Lt=u(e,"UL",{"data-svelte-h":!0}),T(Lt)!=="svelte-1bodp8e"&&(Lt.innerHTML=kn),ya=r(e),Dt=u(e,"P",{"data-svelte-h":!0}),T(Dt)!=="svelte-1b5zo2z"&&(Dt.innerHTML=Xn),ca=r(e),f(Pt.$$.fragment,e),ma=r(e),Ot=u(e,"P",{"data-svelte-h":!0}),T(Ot)!=="svelte-15z7rtv"&&(Ot.textContent=qn),ua=r(e),f(Kt.$$.fragment,e),Ta=r(e),el=u(e,"P",{"data-svelte-h":!0}),T(el)!=="svelte-sp9gkx"&&(el.textContent=Nn),Ja=r(e),f(tl.$$.fragment,e),da=r(e),ll=u(e,"P",{"data-svelte-h":!0}),T(ll)!=="svelte-1l5qcwy"&&(ll.innerHTML=Vn),wa=r(e),sl=u(e,"P",{"data-svelte-h":!0}),T(sl)!=="svelte-1fhttxy"&&(sl.innerHTML=Sn),fa=r(e),f(al.$$.fragment,e),Ua=r(e),nl=u(e,"P",{"data-svelte-h":!0}),T(nl)!=="svelte-12ltrno"&&(nl.innerHTML=En),ja=r(e),ol=u(e,"P",{"data-svelte-h":!0}),T(ol)!=="svelte-13gytjz"&&(ol.textContent=Qn),ha=r(e),il=u(e,"UL",{"data-svelte-h":!0}),T(il)!=="svelte-121q097"&&(il.innerHTML=Hn),Ia=r(e),f(Ml.$$.fragment,e),Ca=r(e),rl=u(e,"UL",{"data-svelte-h":!0}),T(rl)!=="svelte-1mmu83y"&&(rl.innerHTML=xn),ba=r(e),pl=u(e,"P",{"data-svelte-h":!0}),T(pl)!=="svelte-oia8x0"&&(pl.textContent=Yn),ga=r(e),f(yl.$$.fragment,e),$a=r(e),cl=u(e,"P",{"data-svelte-h":!0}),T(cl)!=="svelte-1yhr0cr"&&(cl.innerHTML=Fn),Aa=r(e),ml=u(e,"P",{"data-svelte-h":!0}),T(ml)!=="svelte-1s2gzku"&&(ml.innerHTML=Ln),Ba=r(e),f(ul.$$.fragment,e),_a=r(e),Tl=u(e,"P",{"data-svelte-h":!0}),T(Tl)!=="svelte-4mvvb2"&&(Tl.textContent=Dn),Za=r(e),Jl=u(e,"P",{"data-svelte-h":!0}),T(Jl)!=="svelte-7me63n"&&(Jl.textContent=Pn),va=r(e),f(dl.$$.fragment,e),Ga=r(e),wl=u(e,"P",{"data-svelte-h":!0}),T(wl)!=="svelte-1livx4i"&&(wl.innerHTML=On),Wa=r(e),f(fl.$$.fragment,e),Ra=r(e),Ul=u(e,"P",{"data-svelte-h":!0}),T(Ul)!=="svelte-1fiingf"&&(Ul.innerHTML=Kn),za=r(e),f(jl.$$.fragment,e),ka=r(e),hl=u(e,"P",{"data-svelte-h":!0}),T(hl)!=="svelte-1ufcnmq"&&(hl.innerHTML=eo),Xa=r(e),Il=u(e,"P",{"data-svelte-h":!0}),T(Il)!=="svelte-khzrsx"&&(Il.textContent=to),qa=r(e),Cl=u(e,"UL",{"data-svelte-h":!0}),T(Cl)!=="svelte-o0yfva"&&(Cl.innerHTML=lo),Na=r(e),bl=u(e,"P",{}),wo(bl).forEach(t),this.h()},h(){fo(s,"name","hf:doc:metadata"),fo(s,"content",mi)},m(e,a){bo(document.head,s),l(e,c,a),l(e,n,a),l(e,p,a),U(o,e,a),l(e,i,a),l(e,y,a),l(e,d,a),l(e,B,a),l(e,G,a),l(e,R,a),l(e,_,a),l(e,X,a),l(e,Z,a),U(A,e,a),l(e,V,a),l(e,H,a),l(e,P,a),U(F,e,a),l(e,x,a),U(K,e,a),l(e,ee,a),U(E,e,a),l(e,te,a),l(e,Q,a),l(e,$,a),U(k,e,a),l(e,se,a),l(e,le,a),l(e,oe,a),l(e,L,a),l(e,C,a),U(z,e,a),l(e,he,a),l(e,ne,a),l(e,gl,a),l(e,Ie,a),l(e,$l,a),l(e,Ce,a),l(e,Al,a),l(e,be,a),l(e,Bl,a),l(e,ge,a),l(e,_l,a),U($e,e,a),l(e,Zl,a),l(e,Ae,a),l(e,vl,a),U(re,e,a),l(e,Gl,a),l(e,Be,a),l(e,Wl,a),U(pe,e,a),l(e,Rl,a),U(_e,e,a),l(e,zl,a),l(e,Ze,a),l(e,kl,a),l(e,ve,a),l(e,Xl,a),l(e,Ge,a),l(e,ql,a),l(e,We,a),l(e,Nl,a),l(e,Re,a),l(e,Vl,a),U(ze,e,a),l(e,Sl,a),l(e,ke,a),l(e,El,a),U(ye,e,a),l(e,Ql,a),l(e,Xe,a),l(e,Hl,a),U(ce,e,a),l(e,xl,a),U(qe,e,a),l(e,Yl,a),l(e,Ne,a),l(e,Fl,a),l(e,Ve,a),l(e,Ll,a),l(e,Se,a),l(e,Dl,a),U(Ee,e,a),l(e,Pl,a),U(Qe,e,a),l(e,Ol,a),l(e,He,a),l(e,Kl,a),U(xe,e,a),l(e,es,a),l(e,Ye,a),l(e,ts,a),l(e,Fe,a),l(e,ls,a),U(Le,e,a),l(e,ss,a),l(e,De,a),l(e,as,a),U(me,e,a),l(e,ns,a),U(ue,e,a),l(e,os,a),U(Pe,e,a),l(e,is,a),l(e,Oe,a),l(e,Ms,a),U(Te,e,a),l(e,rs,a),U(Ke,e,a),l(e,ps,a),l(e,et,a),l(e,ys,a),U(tt,e,a),l(e,cs,a),U(lt,e,a),l(e,ms,a),l(e,st,a),l(e,us,a),U(at,e,a),l(e,Ts,a),U(nt,e,a),l(e,Js,a),l(e,ot,a),l(e,ds,a),U(it,e,a),l(e,ws,a),U(Mt,e,a),l(e,fs,a),l(e,rt,a),l(e,Us,a),l(e,pt,a),l(e,js,a),l(e,yt,a),l(e,hs,a),l(e,ct,a),l(e,Is,a),U(mt,e,a),l(e,Cs,a),U(ut,e,a),l(e,bs,a),l(e,Tt,a),l(e,gs,a),l(e,Jt,a),l(e,$s,a),U(Je,e,a),l(e,As,a),U(dt,e,a),l(e,Bs,a),l(e,wt,a),l(e,_s,a),l(e,ft,a),l(e,Zs,a),U(Ut,e,a),l(e,vs,a),l(e,jt,a),l(e,Gs,a),U(de,e,a),l(e,Ws,a),U(ht,e,a),l(e,Rs,a),l(e,It,a),l(e,zs,a),U(Ct,e,a),l(e,ks,a),l(e,bt,a),l(e,Xs,a),U(gt,e,a),l(e,qs,a),U($t,e,a),l(e,Ns,a),l(e,At,a),l(e,Vs,a),U(Bt,e,a),l(e,Ss,a),l(e,_t,a),l(e,Es,a),U(Zt,e,a),l(e,Qs,a),l(e,vt,a),l(e,Hs,a),U(Gt,e,a),l(e,xs,a),l(e,Wt,a),l(e,Ys,a),U(Rt,e,a),l(e,Fs,a),U(zt,e,a),l(e,Ls,a),l(e,kt,a),l(e,Ds,a),U(we,e,a),l(e,Ps,a),U(Xt,e,a),l(e,Os,a),l(e,qt,a),l(e,Ks,a),l(e,Nt,a),l(e,ea,a),l(e,Vt,a),l(e,ta,a),U(St,e,a),l(e,la,a),U(Et,e,a),l(e,sa,a),l(e,Qt,a),l(e,aa,a),U(fe,e,a),l(e,na,a),l(e,Ht,a),l(e,oa,a),U(Ue,e,a),l(e,ia,a),U(xt,e,a),l(e,Ma,a),l(e,Yt,a),l(e,ra,a),l(e,Ft,a),l(e,pa,a),l(e,Lt,a),l(e,ya,a),l(e,Dt,a),l(e,ca,a),U(Pt,e,a),l(e,ma,a),l(e,Ot,a),l(e,ua,a),U(Kt,e,a),l(e,Ta,a),l(e,el,a),l(e,Ja,a),U(tl,e,a),l(e,da,a),l(e,ll,a),l(e,wa,a),l(e,sl,a),l(e,fa,a),U(al,e,a),l(e,Ua,a),l(e,nl,a),l(e,ja,a),l(e,ol,a),l(e,ha,a),l(e,il,a),l(e,Ia,a),U(Ml,e,a),l(e,Ca,a),l(e,rl,a),l(e,ba,a),l(e,pl,a),l(e,ga,a),U(yl,e,a),l(e,$a,a),l(e,cl,a),l(e,Aa,a),l(e,ml,a),l(e,Ba,a),U(ul,e,a),l(e,_a,a),l(e,Tl,a),l(e,Za,a),l(e,Jl,a),l(e,va,a),U(dl,e,a),l(e,Ga,a),l(e,wl,a),l(e,Wa,a),U(fl,e,a),l(e,Ra,a),l(e,Ul,a),l(e,za,a),U(jl,e,a),l(e,ka,a),l(e,hl,a),l(e,Xa,a),l(e,Il,a),l(e,qa,a),l(e,Cl,a),l(e,Na,a),l(e,bl,a),Va=!0},p(e,[a]){const so={};a&2&&(so.$$scope={dirty:a,ctx:e}),F.$set(so);const ao={};a&2&&(ao.$$scope={dirty:a,ctx:e}),K.$set(ao);const no={};a&2&&(no.$$scope={dirty:a,ctx:e}),re.$set(no);const oo={};a&2&&(oo.$$scope={dirty:a,ctx:e}),pe.$set(oo);const io={};a&2&&(io.$$scope={dirty:a,ctx:e}),ye.$set(io);const Mo={};a&2&&(Mo.$$scope={dirty:a,ctx:e}),ce.$set(Mo);const ro={};a&2&&(ro.$$scope={dirty:a,ctx:e}),me.$set(ro);const po={};a&2&&(po.$$scope={dirty:a,ctx:e}),ue.$set(po);const yo={};a&2&&(yo.$$scope={dirty:a,ctx:e}),Te.$set(yo);const co={};a&2&&(co.$$scope={dirty:a,ctx:e}),Je.$set(co);const mo={};a&2&&(mo.$$scope={dirty:a,ctx:e}),de.$set(mo);const uo={};a&2&&(uo.$$scope={dirty:a,ctx:e}),we.$set(uo);const To={};a&2&&(To.$$scope={dirty:a,ctx:e}),fe.$set(To);const Jo={};a&2&&(Jo.$$scope={dirty:a,ctx:e}),Ue.$set(Jo)},i(e){Va||(j(o.$$.fragment,e),j(A.$$.fragment,e),j(F.$$.fragment,e),j(K.$$.fragment,e),j(E.$$.fragment,e),j(k.$$.fragment,e),j(z.$$.fragment,e),j($e.$$.fragment,e),j(re.$$.fragment,e),j(pe.$$.fragment,e),j(_e.$$.fragment,e),j(ze.$$.fragment,e),j(ye.$$.fragment,e),j(ce.$$.fragment,e),j(qe.$$.fragment,e),j(Ee.$$.fragment,e),j(Qe.$$.fragment,e),j(xe.$$.fragment,e),j(Le.$$.fragment,e),j(me.$$.fragment,e),j(ue.$$.fragment,e),j(Pe.$$.fragment,e),j(Te.$$.fragment,e),j(Ke.$$.fragment,e),j(tt.$$.fragment,e),j(lt.$$.fragment,e),j(at.$$.fragment,e),j(nt.$$.fragment,e),j(it.$$.fragment,e),j(Mt.$$.fragment,e),j(mt.$$.fragment,e),j(ut.$$.fragment,e),j(Je.$$.fragment,e),j(dt.$$.fragment,e),j(Ut.$$.fragment,e),j(de.$$.fragment,e),j(ht.$$.fragment,e),j(Ct.$$.fragment,e),j(gt.$$.fragment,e),j($t.$$.fragment,e),j(Bt.$$.fragment,e),j(Zt.$$.fragment,e),j(Gt.$$.fragment,e),j(Rt.$$.fragment,e),j(zt.$$.fragment,e),j(we.$$.fragment,e),j(Xt.$$.fragment,e),j(St.$$.fragment,e),j(Et.$$.fragment,e),j(fe.$$.fragment,e),j(Ue.$$.fragment,e),j(xt.$$.fragment,e),j(Pt.$$.fragment,e),j(Kt.$$.fragment,e),j(tl.$$.fragment,e),j(al.$$.fragment,e),j(Ml.$$.fragment,e),j(yl.$$.fragment,e),j(ul.$$.fragment,e),j(dl.$$.fragment,e),j(fl.$$.fragment,e),j(jl.$$.fragment,e),Va=!0)},o(e){h(o.$$.fragment,e),h(A.$$.fragment,e),h(F.$$.fragment,e),h(K.$$.fragment,e),h(E.$$.fragment,e),h(k.$$.fragment,e),h(z.$$.fragment,e),h($e.$$.fragment,e),h(re.$$.fragment,e),h(pe.$$.fragment,e),h(_e.$$.fragment,e),h(ze.$$.fragment,e),h(ye.$$.fragment,e),h(ce.$$.fragment,e),h(qe.$$.fragment,e),h(Ee.$$.fragment,e),h(Qe.$$.fragment,e),h(xe.$$.fragment,e),h(Le.$$.fragment,e),h(me.$$.fragment,e),h(ue.$$.fragment,e),h(Pe.$$.fragment,e),h(Te.$$.fragment,e),h(Ke.$$.fragment,e),h(tt.$$.fragment,e),h(lt.$$.fragment,e),h(at.$$.fragment,e),h(nt.$$.fragment,e),h(it.$$.fragment,e),h(Mt.$$.fragment,e),h(mt.$$.fragment,e),h(ut.$$.fragment,e),h(Je.$$.fragment,e),h(dt.$$.fragment,e),h(Ut.$$.fragment,e),h(de.$$.fragment,e),h(ht.$$.fragment,e),h(Ct.$$.fragment,e),h(gt.$$.fragment,e),h($t.$$.fragment,e),h(Bt.$$.fragment,e),h(Zt.$$.fragment,e),h(Gt.$$.fragment,e),h(Rt.$$.fragment,e),h(zt.$$.fragment,e),h(we.$$.fragment,e),h(Xt.$$.fragment,e),h(St.$$.fragment,e),h(Et.$$.fragment,e),h(fe.$$.fragment,e),h(Ue.$$.fragment,e),h(xt.$$.fragment,e),h(Pt.$$.fragment,e),h(Kt.$$.fragment,e),h(tl.$$.fragment,e),h(al.$$.fragment,e),h(Ml.$$.fragment,e),h(yl.$$.fragment,e),h(ul.$$.fragment,e),h(dl.$$.fragment,e),h(fl.$$.fragment,e),h(jl.$$.fragment,e),Va=!1},d(e){e&&(t(c),t(n),t(p),t(i),t(y),t(d),t(B),t(G),t(R),t(_),t(X),t(Z),t(V),t(H),t(P),t(x),t(ee),t(te),t(Q),t($),t(se),t(le),t(oe),t(L),t(C),t(he),t(ne),t(gl),t(Ie),t($l),t(Ce),t(Al),t(be),t(Bl),t(ge),t(_l),t(Zl),t(Ae),t(vl),t(Gl),t(Be),t(Wl),t(Rl),t(zl),t(Ze),t(kl),t(ve),t(Xl),t(Ge),t(ql),t(We),t(Nl),t(Re),t(Vl),t(Sl),t(ke),t(El),t(Ql),t(Xe),t(Hl),t(xl),t(Yl),t(Ne),t(Fl),t(Ve),t(Ll),t(Se),t(Dl),t(Pl),t(Ol),t(He),t(Kl),t(es),t(Ye),t(ts),t(Fe),t(ls),t(ss),t(De),t(as),t(ns),t(os),t(is),t(Oe),t(Ms),t(rs),t(ps),t(et),t(ys),t(cs),t(ms),t(st),t(us),t(Ts),t(Js),t(ot),t(ds),t(ws),t(fs),t(rt),t(Us),t(pt),t(js),t(yt),t(hs),t(ct),t(Is),t(Cs),t(bs),t(Tt),t(gs),t(Jt),t($s),t(As),t(Bs),t(wt),t(_s),t(ft),t(Zs),t(vs),t(jt),t(Gs),t(Ws),t(Rs),t(It),t(zs),t(ks),t(bt),t(Xs),t(qs),t(Ns),t(At),t(Vs),t(Ss),t(_t),t(Es),t(Qs),t(vt),t(Hs),t(xs),t(Wt),t(Ys),t(Fs),t(Ls),t(kt),t(Ds),t(Ps),t(Os),t(qt),t(Ks),t(Nt),t(ea),t(Vt),t(ta),t(la),t(sa),t(Qt),t(aa),t(na),t(Ht),t(oa),t(ia),t(Ma),t(Yt),t(ra),t(Ft),t(pa),t(Lt),t(ya),t(Dt),t(ca),t(ma),t(Ot),t(ua),t(Ta),t(el),t(Ja),t(da),t(ll),t(wa),t(sl),t(fa),t(Ua),t(nl),t(ja),t(ol),t(ha),t(il),t(Ia),t(Ca),t(rl),t(ba),t(pl),t(ga),t($a),t(cl),t(Aa),t(ml),t(Ba),t(_a),t(Tl),t(Za),t(Jl),t(va),t(Ga),t(wl),t(Wa),t(Ra),t(Ul),t(za),t(ka),t(hl),t(Xa),t(Il),t(qa),t(Cl),t(Na),t(bl)),t(s),I(o,e),I(A,e),I(F,e),I(K,e),I(E,e),I(k,e),I(z,e),I($e,e),I(re,e),I(pe,e),I(_e,e),I(ze,e),I(ye,e),I(ce,e),I(qe,e),I(Ee,e),I(Qe,e),I(xe,e),I(Le,e),I(me,e),I(ue,e),I(Pe,e),I(Te,e),I(Ke,e),I(tt,e),I(lt,e),I(at,e),I(nt,e),I(it,e),I(Mt,e),I(mt,e),I(ut,e),I(Je,e),I(dt,e),I(Ut,e),I(de,e),I(ht,e),I(Ct,e),I(gt,e),I($t,e),I(Bt,e),I(Zt,e),I(Gt,e),I(Rt,e),I(zt,e),I(we,e),I(Xt,e),I(St,e),I(Et,e),I(fe,e),I(Ue,e),I(xt,e),I(Pt,e),I(Kt,e),I(tl,e),I(al,e),I(Ml,e),I(yl,e),I(ul,e),I(dl,e),I(fl,e),I(jl,e)}}}const mi='{"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}],"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 ui(g){return jo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ji extends ho{constructor(s){super(),Io(this,s,ui,ci,Uo,{})}}export{ji as component};
