import{s as ce,o as le,n as ee}from"../chunks/scheduler.defa9a21.js";import{S as ie,i as ue,g as f,s as l,r as b,A as de,h as g,f as a,c as i,j as N,u as $,x as P,k as X,y as z,a as c,v,d as x,t as k,w}from"../chunks/index.fe795e71.js";import{T as re}from"../chunks/Tip.179eb360.js";import{D as se}from"../chunks/Docstring.90d6fe5c.js";import{C as me}from"../chunks/CodeBlock.204b6c34.js";import{E as pe}from"../chunks/ExampleCodeBlock.f6fae62d.js";import{H as O,E as fe}from"../chunks/getInferenceSnippets.2234a8dd.js";function ge(T){let t,m=`To use this function absolutely zero calls to a device must be made in the notebook session before calling. If any
have been made, you will need to restart the notebook and make sure no cells use any device capability.`,s,r,u=`Setting <code>ACCELERATE_DEBUG_MODE=&quot;1&quot;</code> in your environment will run a test before truly launching to ensure that none
of those calls have been made.`;return{c(){t=f("p"),t.textContent=m,s=l(),r=f("p"),r.innerHTML=u},l(n){t=g(n,"P",{"data-svelte-h":!0}),P(t)!=="svelte-1rck8rk"&&(t.textContent=m),s=i(n),r=g(n,"P",{"data-svelte-h":!0}),P(r)!=="svelte-18vojj9"&&(r.innerHTML=u)},m(n,d){c(n,t,d),c(n,s,d),c(n,r,d)},p:ee,d(n){n&&(a(t),a(s),a(r))}}}function he(T){let t,m="Example:",s,r,u;return r=new me({props:{code:"JTIzJTIwQXNzdW1lJTIwdGhpcyUyMGlzJTIwZGVmaW5lZCUyMGluJTIwYSUyMEp1cHl0ZXIlMjBOb3RlYm9vayUyMG9uJTIwYW4lMjBpbnN0YW5jZSUyMHdpdGglMjB0d28lMjBkZXZpY2VzJTBBZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBub3RlYm9va19sYXVuY2hlciUwQSUwQSUwQWRlZiUyMHRyYWluKCphcmdzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMFlvdXIlMjB0cmFpbmluZyUyMGZ1bmN0aW9uJTIwaGVyZSUwQSUyMCUyMCUyMCUyMC4uLiUwQSUwQSUwQW5vdGVib29rX2xhdW5jaGVyKHRyYWluJTJDJTIwYXJncyUzRChhcmcxJTJDJTIwYXJnMiklMkMlMjBudW1fcHJvY2Vzc2VzJTNEMiUyQyUyMG1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjIp",highlighted:`<span class="hljs-comment"># Assume this is defined in a Jupyter Notebook on an instance with two devices</span>
<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> notebook_launcher


<span class="hljs-keyword">def</span> <span class="hljs-title function_">train</span>(<span class="hljs-params">*args</span>):
    <span class="hljs-comment"># Your training function here</span>
    ...


notebook_launcher(train, args=(arg1, arg2), num_processes=<span class="hljs-number">2</span>, mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>)`,wrap:!1}}),{c(){t=f("p"),t.textContent=m,s=l(),b(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),P(t)!=="svelte-11lpom8"&&(t.textContent=m),s=i(n),$(r.$$.fragment,n)},m(n,d){c(n,t,d),c(n,s,d),v(r,n,d),u=!0},p:ee,i(n){u||(x(r.$$.fragment,n),u=!0)},o(n){k(r.$$.fragment,n),u=!1},d(n){n&&(a(t),a(s)),w(r,n)}}}function _e(T){let t,m=`This function is provided for internal testing and debugging, but it’s not intended for real trainings. It will
only use the CPU.`;return{c(){t=f("p"),t.textContent=m},l(s){t=g(s,"P",{"data-svelte-h":!0}),P(t)!=="svelte-3x34in"&&(t.textContent=m)},m(s,r){c(s,t,r)},p:ee,d(s){s&&a(t)}}}function be(T){let t,m,s,r,u,n,d,te="Functions for launching training on distributed processes.",B,j,Z,p,J,H,G,ne=`Launches a training function, using several processes or multiple nodes if it’s possible in the current environment
(TPU with multiple cores for instance).`,R,C,A,M,W,q,Q,h,E,F,S,oe="Launches a training function using several processes on CPU for debugging purposes.",K,U,V,I,D,Y,L;return u=new O({props:{title:"Launchers",local:"launchers",headingTag:"h1"}}),j=new O({props:{title:"notebook_launcher",local:"accelerate.notebook_launcher",headingTag:"h2"}}),J=new se({props:{name:"accelerate.notebook_launcher",anchor:"accelerate.notebook_launcher",parameters:[{name:"function",val:""},{name:"args",val:" = ()"},{name:"num_processes",val:" = None"},{name:"mixed_precision",val:" = 'no'"},{name:"use_port",val:" = '29500'"},{name:"master_addr",val:" = '127.0.0.1'"},{name:"node_rank",val:" = 0"},{name:"num_nodes",val:" = 1"},{name:"rdzv_backend",val:" = 'static'"},{name:"rdzv_endpoint",val:" = ''"},{name:"rdzv_conf",val:" = None"},{name:"rdzv_id",val:" = 'none'"},{name:"max_restarts",val:" = 0"},{name:"monitor_interval",val:" = 0.1"},{name:"log_line_prefix_template",val:" = None"}],parametersDescription:[{anchor:"accelerate.notebook_launcher.function",description:`<strong>function</strong> (<code>Callable</code>) &#x2014;
The training function to execute. If it accepts arguments, the first argument should be the index of the
process run.`,name:"function"},{anchor:"accelerate.notebook_launcher.args",description:`<strong>args</strong> (<code>Tuple</code>) &#x2014;
Tuple of arguments to pass to the function (it will receive <code>*args</code>).`,name:"args"},{anchor:"accelerate.notebook_launcher.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of processes to use for training. Will default to 8 in Colab/Kaggle if a TPU is available, to
the number of devices available otherwise.`,name:"num_processes"},{anchor:"accelerate.notebook_launcher.mixed_precision",description:`<strong>mixed_precision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;no&quot;</code>) &#x2014;
If <code>fp16</code> or <code>bf16</code>, will use mixed precision training on multi-device.`,name:"mixed_precision"},{anchor:"accelerate.notebook_launcher.use_port",description:`<strong>use_port</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;29500&quot;</code>) &#x2014;
The port to use to communicate between processes when launching a multi-device training.`,name:"use_port"},{anchor:"accelerate.notebook_launcher.master_addr",description:`<strong>master_addr</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;127.0.0.1&quot;</code>) &#x2014;
The address to use for communication between processes.`,name:"master_addr"},{anchor:"accelerate.notebook_launcher.node_rank",description:`<strong>node_rank</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The rank of the current node.`,name:"node_rank"},{anchor:"accelerate.notebook_launcher.num_nodes",description:`<strong>num_nodes</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of nodes to use for training.`,name:"num_nodes"},{anchor:"accelerate.notebook_launcher.rdzv_backend",description:`<strong>rdzv_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;static&quot;</code>) &#x2014;
The rendezvous method to use, such as &#x2018;static&#x2019; (the default) or &#x2018;c10d&#x2019;`,name:"rdzv_backend"},{anchor:"accelerate.notebook_launcher.rdzv_endpoint",description:`<strong>rdzv_endpoint</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
The endpoint of the rdzv sync. storage.`,name:"rdzv_endpoint"},{anchor:"accelerate.notebook_launcher.rdzv_conf",description:`<strong>rdzv_conf</strong> (<code>Dict</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Additional rendezvous configuration.`,name:"rdzv_conf"},{anchor:"accelerate.notebook_launcher.rdzv_id",description:`<strong>rdzv_id</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;none&quot;</code>) &#x2014;
The unique run id of the job.`,name:"rdzv_id"},{anchor:"accelerate.notebook_launcher.max_restarts",description:`<strong>max_restarts</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The maximum amount of restarts that elastic agent will conduct on workers before failure.`,name:"max_restarts"},{anchor:"accelerate.notebook_launcher.monitor_interval",description:`<strong>monitor_interval</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The interval in seconds that is used by the elastic_agent as a period of monitoring workers.`,name:"monitor_interval"},{anchor:"accelerate.notebook_launcher.log_line_prefix_template",description:`<strong>log_line_prefix_template</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The prefix template for elastic launch logging. Available from PyTorch 2.2.0.`,name:"log_line_prefix_template"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/launchers.py#L40"}}),C=new re({props:{warning:!0,$$slots:{default:[ge]},$$scope:{ctx:T}}}),M=new pe({props:{anchor:"accelerate.notebook_launcher.example",$$slots:{default:[he]},$$scope:{ctx:T}}}),q=new O({props:{title:"debug_launcher",local:"accelerate.debug_launcher",headingTag:"h2"}}),E=new se({props:{name:"accelerate.debug_launcher",anchor:"accelerate.debug_launcher",parameters:[{name:"function",val:""},{name:"args",val:" = ()"},{name:"num_processes",val:" = 2"}],parametersDescription:[{anchor:"accelerate.debug_launcher.function",description:`<strong>function</strong> (<code>Callable</code>) &#x2014;
The training function to execute.`,name:"function"},{anchor:"accelerate.debug_launcher.args",description:`<strong>args</strong> (<code>Tuple</code>) &#x2014;
Tuple of arguments to pass to the function (it will receive <code>*args</code>).`,name:"args"},{anchor:"accelerate.debug_launcher.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The number of processes to use for training.`,name:"num_processes"}],source:"https://github.com/huggingface/accelerate/blob/v1.10.1/src/accelerate/launchers.py#L273"}}),U=new re({props:{warning:!0,$$slots:{default:[_e]},$$scope:{ctx:T}}}),I=new fe({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/launchers.md"}}),{c(){t=f("meta"),m=l(),s=f("p"),r=l(),b(u.$$.fragment),n=l(),d=f("p"),d.textContent=te,B=l(),b(j.$$.fragment),Z=l(),p=f("div"),b(J.$$.fragment),H=l(),G=f("p"),G.textContent=ne,R=l(),b(C.$$.fragment),A=l(),b(M.$$.fragment),W=l(),b(q.$$.fragment),Q=l(),h=f("div"),b(E.$$.fragment),F=l(),S=f("p"),S.textContent=oe,K=l(),b(U.$$.fragment),V=l(),b(I.$$.fragment),D=l(),Y=f("p"),this.h()},l(e){const o=de("svelte-u9bgzb",document.head);t=g(o,"META",{name:!0,content:!0}),o.forEach(a),m=i(e),s=g(e,"P",{}),N(s).forEach(a),r=i(e),$(u.$$.fragment,e),n=i(e),d=g(e,"P",{"data-svelte-h":!0}),P(d)!=="svelte-7doq2e"&&(d.textContent=te),B=i(e),$(j.$$.fragment,e),Z=i(e),p=g(e,"DIV",{class:!0});var _=N(p);$(J.$$.fragment,_),H=i(_),G=g(_,"P",{"data-svelte-h":!0}),P(G)!=="svelte-9bm6uy"&&(G.textContent=ne),R=i(_),$(C.$$.fragment,_),A=i(_),$(M.$$.fragment,_),_.forEach(a),W=i(e),$(q.$$.fragment,e),Q=i(e),h=g(e,"DIV",{class:!0});var y=N(h);$(E.$$.fragment,y),F=i(y),S=g(y,"P",{"data-svelte-h":!0}),P(S)!=="svelte-1urs4mm"&&(S.textContent=oe),K=i(y),$(U.$$.fragment,y),y.forEach(a),V=i(e),$(I.$$.fragment,e),D=i(e),Y=g(e,"P",{}),N(Y).forEach(a),this.h()},h(){X(t,"name","hf:doc:metadata"),X(t,"content",$e),X(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(h,"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,o){z(document.head,t),c(e,m,o),c(e,s,o),c(e,r,o),v(u,e,o),c(e,n,o),c(e,d,o),c(e,B,o),v(j,e,o),c(e,Z,o),c(e,p,o),v(J,p,null),z(p,H),z(p,G),z(p,R),v(C,p,null),z(p,A),v(M,p,null),c(e,W,o),v(q,e,o),c(e,Q,o),c(e,h,o),v(E,h,null),z(h,F),z(h,S),z(h,K),v(U,h,null),c(e,V,o),v(I,e,o),c(e,D,o),c(e,Y,o),L=!0},p(e,[o]){const _={};o&2&&(_.$$scope={dirty:o,ctx:e}),C.$set(_);const y={};o&2&&(y.$$scope={dirty:o,ctx:e}),M.$set(y);const ae={};o&2&&(ae.$$scope={dirty:o,ctx:e}),U.$set(ae)},i(e){L||(x(u.$$.fragment,e),x(j.$$.fragment,e),x(J.$$.fragment,e),x(C.$$.fragment,e),x(M.$$.fragment,e),x(q.$$.fragment,e),x(E.$$.fragment,e),x(U.$$.fragment,e),x(I.$$.fragment,e),L=!0)},o(e){k(u.$$.fragment,e),k(j.$$.fragment,e),k(J.$$.fragment,e),k(C.$$.fragment,e),k(M.$$.fragment,e),k(q.$$.fragment,e),k(E.$$.fragment,e),k(U.$$.fragment,e),k(I.$$.fragment,e),L=!1},d(e){e&&(a(m),a(s),a(r),a(n),a(d),a(B),a(Z),a(p),a(W),a(Q),a(h),a(V),a(D),a(Y)),a(t),w(u,e),w(j,e),w(J),w(C),w(M),w(q,e),w(E),w(U),w(I,e)}}}const $e='{"title":"Launchers","local":"launchers","sections":[{"title":"notebook_launcher","local":"accelerate.notebook_launcher","sections":[],"depth":2},{"title":"debug_launcher","local":"accelerate.debug_launcher","sections":[],"depth":2}],"depth":1}';function ve(T){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends ie{constructor(t){super(),ue(this,t,ve,be,ce,{})}}export{Ue as component};
