import{s as Y,o as ee,n as te}from"../chunks/scheduler.25b97de1.js";import{S as re,i as ne,g as l,s as i,r as C,A as ae,h as m,f as r,c as o,j as N,u as x,x as y,k as W,y as v,a,v as P,d as L,t as M,w as j}from"../chunks/index.d9030fc9.js";import{T as se}from"../chunks/Tip.baa67368.js";import{D as ie}from"../chunks/Docstring.e257edda.js";import{H as X,E as oe}from"../chunks/EditOnGithub.91d95064.js";function pe(k){let n,c='Learn more about using DeepSpeed with <a href="/docs/transformers/pr_29261/en/main_classes/trainer#transformers.Trainer">Trainer</a> in the <a href="../deepspeed">DeepSpeed</a> guide.';return{c(){n=l("p"),n.innerHTML=c},l(p){n=m(p,"P",{"data-svelte-h":!0}),y(n)!=="svelte-19341qj"&&(n.innerHTML=c)},m(p,T){a(p,n,T)},p:te,d(p){p&&r(n)}}}function fe(k){let n,c,p,T,g,z,u,B='<a href="https://github.com/microsoft/DeepSpeed" rel="nofollow">DeepSpeed</a>, powered by Zero Redundancy Optimizer (ZeRO), is an optimization library for training and fitting very large models onto a GPU. It is available in several ZeRO stages, where each stage progressively saves more GPU memory by partitioning the optimizer state, gradients, parameters, and enabling offloading to a CPU or NVMe. DeepSpeed is integrated with the <a href="/docs/transformers/pr_29261/en/main_classes/trainer#transformers.Trainer">Trainer</a> class and most of the setup is automatically taken care of for you.',E,h,F='However, if you want to use DeepSpeed without the <a href="/docs/transformers/pr_29261/en/main_classes/trainer#transformers.Trainer">Trainer</a>, Transformers provides a <code>HfDeepSpeedConfig</code> class.',q,d,A,_,U,s,$,Z,D,J="This object contains a DeepSpeed configuration dictionary and can be quickly queried for things like zero stage.",I,w,K=`A <code>weakref</code> of this object is stored in the module’s globals to be able to access the config from areas where
things like the Trainer object is not available (e.g. <code>from_pretrained</code> and <code>_get_resized_embeddings</code>). Therefore
it’s important that this object remains alive while the program is still running.`,V,S,Q=`<a href="/docs/transformers/pr_29261/en/main_classes/trainer#transformers.Trainer">Trainer</a> uses the <code>HfTrainerDeepSpeedConfig</code> subclass instead. That subclass has logic to sync the configuration
with values of <a href="/docs/transformers/pr_29261/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> by replacing special placeholder values: <code>&quot;auto&quot;</code>. Without this special logic
the DeepSpeed configuration is not modified in any way.`,O,b,R,H,G;return g=new X({props:{title:"DeepSpeed",local:"deepspeed",headingTag:"h1"}}),d=new se({props:{$$slots:{default:[pe]},$$scope:{ctx:k}}}),_=new X({props:{title:"HfDeepSpeedConfig",local:"transformers.integrations.HfDeepSpeedConfig",headingTag:"h2"}}),$=new ie({props:{name:"class transformers.integrations.HfDeepSpeedConfig",anchor:"transformers.integrations.HfDeepSpeedConfig",parameters:[{name:"config_file_or_dict",val:""}],parametersDescription:[{anchor:"transformers.integrations.HfDeepSpeedConfig.config_file_or_dict",description:"<strong>config_file_or_dict</strong> (<code>Union[str, Dict]</code>) &#x2014; path to DeepSpeed config file or dict.",name:"config_file_or_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_29261/src/transformers/integrations/deepspeed.py#L59"}}),b=new oe({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/main_classes/deepspeed.md"}}),{c(){n=l("meta"),c=i(),p=l("p"),T=i(),C(g.$$.fragment),z=i(),u=l("p"),u.innerHTML=B,E=i(),h=l("p"),h.innerHTML=F,q=i(),C(d.$$.fragment),A=i(),C(_.$$.fragment),U=i(),s=l("div"),C($.$$.fragment),Z=i(),D=l("p"),D.textContent=J,I=i(),w=l("p"),w.innerHTML=K,V=i(),S=l("p"),S.innerHTML=Q,O=i(),C(b.$$.fragment),R=i(),H=l("p"),this.h()},l(e){const t=ae("svelte-u9bgzb",document.head);n=m(t,"META",{name:!0,content:!0}),t.forEach(r),c=o(e),p=m(e,"P",{}),N(p).forEach(r),T=o(e),x(g.$$.fragment,e),z=o(e),u=m(e,"P",{"data-svelte-h":!0}),y(u)!=="svelte-1tyr56u"&&(u.innerHTML=B),E=o(e),h=m(e,"P",{"data-svelte-h":!0}),y(h)!=="svelte-jb50el"&&(h.innerHTML=F),q=o(e),x(d.$$.fragment,e),A=o(e),x(_.$$.fragment,e),U=o(e),s=m(e,"DIV",{class:!0});var f=N(s);x($.$$.fragment,f),Z=o(f),D=m(f,"P",{"data-svelte-h":!0}),y(D)!=="svelte-g6t8ro"&&(D.textContent=J),I=o(f),w=m(f,"P",{"data-svelte-h":!0}),y(w)!=="svelte-xzx2jk"&&(w.innerHTML=K),V=o(f),S=m(f,"P",{"data-svelte-h":!0}),y(S)!=="svelte-10glwfo"&&(S.innerHTML=Q),f.forEach(r),O=o(e),x(b.$$.fragment,e),R=o(e),H=m(e,"P",{}),N(H).forEach(r),this.h()},h(){W(n,"name","hf:doc:metadata"),W(n,"content",le),W(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){v(document.head,n),a(e,c,t),a(e,p,t),a(e,T,t),P(g,e,t),a(e,z,t),a(e,u,t),a(e,E,t),a(e,h,t),a(e,q,t),P(d,e,t),a(e,A,t),P(_,e,t),a(e,U,t),a(e,s,t),P($,s,null),v(s,Z),v(s,D),v(s,I),v(s,w),v(s,V),v(s,S),a(e,O,t),P(b,e,t),a(e,R,t),a(e,H,t),G=!0},p(e,[t]){const f={};t&2&&(f.$$scope={dirty:t,ctx:e}),d.$set(f)},i(e){G||(L(g.$$.fragment,e),L(d.$$.fragment,e),L(_.$$.fragment,e),L($.$$.fragment,e),L(b.$$.fragment,e),G=!0)},o(e){M(g.$$.fragment,e),M(d.$$.fragment,e),M(_.$$.fragment,e),M($.$$.fragment,e),M(b.$$.fragment,e),G=!1},d(e){e&&(r(c),r(p),r(T),r(z),r(u),r(E),r(h),r(q),r(A),r(U),r(s),r(O),r(R),r(H)),r(n),j(g,e),j(d,e),j(_,e),j($),j(b,e)}}}const le='{"title":"DeepSpeed","local":"deepspeed","sections":[{"title":"HfDeepSpeedConfig","local":"transformers.integrations.HfDeepSpeedConfig","sections":[],"depth":2}],"depth":1}';function me(k){return ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _e extends re{constructor(n){super(),ne(this,n,me,fe,Y,{})}}export{_e as component};
