import{s as ie,o as ue,n as ne}from"../chunks/scheduler.b9285784.js";import{S as me,i as de,e as f,s as l,c as $,h as pe,a as g,d as a,b as i,f as H,g as b,j as S,k as R,l as z,m as c,n as v,t as x,o as k,p as w}from"../chunks/index.26bc89a1.js";import{T as ce}from"../chunks/Tip.e4eba3d6.js";import{C as fe,H as te,E as ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.7242ff19.js";import{D as le}from"../chunks/Docstring.9ffdb58c.js";import{C as he}from"../chunks/CodeBlock.c8ee1711.js";import{E as _e}from"../chunks/ExampleCodeBlock.89d3b91e.js";function $e(T){let t,d=`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=d,s=l(),r=f("p"),r.innerHTML=u},l(o){t=g(o,"P",{"data-svelte-h":!0}),S(t)!=="svelte-1rck8rk"&&(t.textContent=d),s=i(o),r=g(o,"P",{"data-svelte-h":!0}),S(r)!=="svelte-18vojj9"&&(r.innerHTML=u)},m(o,m){c(o,t,m),c(o,s,m),c(o,r,m)},p:ne,d(o){o&&(a(t),a(s),a(r))}}}function be(T){let t,d="Example:",s,r,u;return r=new he({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=d,s=l(),$(r.$$.fragment)},l(o){t=g(o,"P",{"data-svelte-h":!0}),S(t)!=="svelte-11lpom8"&&(t.textContent=d),s=i(o),b(r.$$.fragment,o)},m(o,m){c(o,t,m),c(o,s,m),v(r,o,m),u=!0},p:ne,i(o){u||(x(r.$$.fragment,o),u=!0)},o(o){k(r.$$.fragment,o),u=!1},d(o){o&&(a(t),a(s)),w(r,o)}}}function ve(T){let t,d=`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=d},l(s){t=g(s,"P",{"data-svelte-h":!0}),S(t)!=="svelte-3x34in"&&(t.textContent=d)},m(s,r){c(s,t,r)},p:ne,d(s){s&&a(t)}}}function xe(T){let t,d,s,r,u,o,m,Z,j,oe="Functions for launching training on distributed processes.",L,J,W,p,q,A,G,ae=`Launches a training function, using several processes or multiple nodes if it’s possible in the current environment
(TPU with multiple cores for instance).`,F,C,K,M,Q,E,V,h,I,O,Y,re="Launches a training function using several processes on CPU for debugging purposes.",ee,U,D,P,N,B,X;return u=new fe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),m=new te({props:{title:"Launchers",local:"launchers",headingTag:"h1"}}),J=new te({props:{title:"notebook_launcher",local:"accelerate.notebook_launcher",headingTag:"h2"}}),q=new le({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/main/src/accelerate/launchers.py#L40"}}),C=new ce({props:{warning:!0,$$slots:{default:[$e]},$$scope:{ctx:T}}}),M=new _e({props:{anchor:"accelerate.notebook_launcher.example",$$slots:{default:[be]},$$scope:{ctx:T}}}),E=new te({props:{title:"debug_launcher",local:"accelerate.debug_launcher",headingTag:"h2"}}),I=new le({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/main/src/accelerate/launchers.py#L273"}}),U=new ce({props:{warning:!0,$$slots:{default:[ve]},$$scope:{ctx:T}}}),P=new ge({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/launchers.md"}}),{c(){t=f("meta"),d=l(),s=f("p"),r=l(),$(u.$$.fragment),o=l(),$(m.$$.fragment),Z=l(),j=f("p"),j.textContent=oe,L=l(),$(J.$$.fragment),W=l(),p=f("div"),$(q.$$.fragment),A=l(),G=f("p"),G.textContent=ae,F=l(),$(C.$$.fragment),K=l(),$(M.$$.fragment),Q=l(),$(E.$$.fragment),V=l(),h=f("div"),$(I.$$.fragment),O=l(),Y=f("p"),Y.textContent=re,ee=l(),$(U.$$.fragment),D=l(),$(P.$$.fragment),N=l(),B=f("p"),this.h()},l(e){const n=pe("svelte-u9bgzb",document.head);t=g(n,"META",{name:!0,content:!0}),n.forEach(a),d=i(e),s=g(e,"P",{}),H(s).forEach(a),r=i(e),b(u.$$.fragment,e),o=i(e),b(m.$$.fragment,e),Z=i(e),j=g(e,"P",{"data-svelte-h":!0}),S(j)!=="svelte-7doq2e"&&(j.textContent=oe),L=i(e),b(J.$$.fragment,e),W=i(e),p=g(e,"DIV",{class:!0});var _=H(p);b(q.$$.fragment,_),A=i(_),G=g(_,"P",{"data-svelte-h":!0}),S(G)!=="svelte-9bm6uy"&&(G.textContent=ae),F=i(_),b(C.$$.fragment,_),K=i(_),b(M.$$.fragment,_),_.forEach(a),Q=i(e),b(E.$$.fragment,e),V=i(e),h=g(e,"DIV",{class:!0});var y=H(h);b(I.$$.fragment,y),O=i(y),Y=g(y,"P",{"data-svelte-h":!0}),S(Y)!=="svelte-1urs4mm"&&(Y.textContent=re),ee=i(y),b(U.$$.fragment,y),y.forEach(a),D=i(e),b(P.$$.fragment,e),N=i(e),B=g(e,"P",{}),H(B).forEach(a),this.h()},h(){R(t,"name","hf:doc:metadata"),R(t,"content",ke),R(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(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,n){z(document.head,t),c(e,d,n),c(e,s,n),c(e,r,n),v(u,e,n),c(e,o,n),v(m,e,n),c(e,Z,n),c(e,j,n),c(e,L,n),v(J,e,n),c(e,W,n),c(e,p,n),v(q,p,null),z(p,A),z(p,G),z(p,F),v(C,p,null),z(p,K),v(M,p,null),c(e,Q,n),v(E,e,n),c(e,V,n),c(e,h,n),v(I,h,null),z(h,O),z(h,Y),z(h,ee),v(U,h,null),c(e,D,n),v(P,e,n),c(e,N,n),c(e,B,n),X=!0},p(e,[n]){const _={};n&2&&(_.$$scope={dirty:n,ctx:e}),C.$set(_);const y={};n&2&&(y.$$scope={dirty:n,ctx:e}),M.$set(y);const se={};n&2&&(se.$$scope={dirty:n,ctx:e}),U.$set(se)},i(e){X||(x(u.$$.fragment,e),x(m.$$.fragment,e),x(J.$$.fragment,e),x(q.$$.fragment,e),x(C.$$.fragment,e),x(M.$$.fragment,e),x(E.$$.fragment,e),x(I.$$.fragment,e),x(U.$$.fragment,e),x(P.$$.fragment,e),X=!0)},o(e){k(u.$$.fragment,e),k(m.$$.fragment,e),k(J.$$.fragment,e),k(q.$$.fragment,e),k(C.$$.fragment,e),k(M.$$.fragment,e),k(E.$$.fragment,e),k(I.$$.fragment,e),k(U.$$.fragment,e),k(P.$$.fragment,e),X=!1},d(e){e&&(a(d),a(s),a(r),a(o),a(Z),a(j),a(L),a(W),a(p),a(Q),a(V),a(h),a(D),a(N),a(B)),a(t),w(u,e),w(m,e),w(J,e),w(q),w(C),w(M),w(E,e),w(I),w(U),w(P,e)}}}const ke='{"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 we(T){return ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends me{constructor(t){super(),de(this,t,we,xe,ie,{})}}export{Je as component};
