import{s as Bt,n as Gt,o as Pt}from"../chunks/scheduler.c90a44b2.js";import{S as kt,i as Ht,e as a,s as i,c as p,h as Wt,a as s,d as n,b as o,f as Xt,g as c,j as r,k as Nt,l as At,m as l,n as h,t as m,o as w,p as M}from"../chunks/index.66c3f415.js";import{C as Et,H as Vt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.989ebcbf.js";import{C as W}from"../chunks/CodeBlock.aad838e0.js";function Yt(ft){let d,V,A,Y,f,Z,u,F,T,ut="When training on a single CPU is too slow, we can use multiple CPUs. This guide focuses on PyTorch-based DDP enabling distributed CPU training efficiently.",Q,C,Tt="Distributed training on multiple CPUs is launched by mpirun which supports both Gloo and oneCCL as collective communication backends. And for performance seek, Intel recommends to use oneCCL backend.",S,y,Ct='<a href="https://github.com/oneapi-src/oneCCL" rel="nofollow">Intel® oneCCL</a> (collective communications library) is a library for efficient distributed deep learning training implementing such collectives like allreduce, allgather, alltoall. For more information on oneCCL, please refer to the <a href="https://spec.oneapi.com/versions/latest/elements/oneCCL/source/index.html" rel="nofollow">oneCCL documentation</a> and <a href="https://spec.oneapi.com/versions/latest/elements/oneCCL/source/index.html" rel="nofollow">oneCCL specification</a>.',z,J,yt="Module <code>oneccl_bindings_for_pytorch</code> (<code>torch_ccl</code> before version 1.12)  implements PyTorch C10D ProcessGroup API and can be dynamically loaded as external ProcessGroup and only works on Linux platform now",D,b,Jt='Check more detailed information for <a href="https://github.com/intel/torch-ccl" rel="nofollow">oneccl_bind_pt</a>.',q,U,bt="We will show how to use oneCCL backend-ed distributed training as below steps.",O,_,Ut="Intel® oneCCL Bindings for PyTorch installation:",K,x,_t="Wheel files are available for the following Python versions:",tt,v,xt='<thead><tr><th align="center">Extension Version</th> <th align="center">Python 3.6</th> <th align="center">Python 3.7</th> <th align="center">Python 3.8</th> <th align="center">Python 3.9</th> <th align="center">Python 3.10</th></tr></thead> <tbody><tr><td align="center">1.12.1</td> <td align="center"></td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td></tr> <tr><td align="center">1.12.0</td> <td align="center"></td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td></tr> <tr><td align="center">1.11.0</td> <td align="center"></td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td></tr> <tr><td align="center">1.10.0</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center"></td></tr></tbody>',et,g,nt,I,vt=`where <code>{pytorch_version}</code> should be your PyTorch version, for instance 1.12.0.
Versions of oneCCL and PyTorch must match.
<code>oneccl_bindings_for_pytorch</code> 1.12.0 prebuilt wheel does not work with PyTorch 1.12.1 (it is for PyTorch 1.12.0)
PyTorch 1.12.1 should work with <code>oneccl_bindings_for_pytorch</code> 1.12.1`,lt,j,gt="MPI tool set for Intel® oneCCL 1.12.0",it,$,ot,L,It="for Intel® oneCCL whose version < 1.12.0",at,R,st,X,jt="The following command enables training with 2 processes on one node, with one process running per one socket. The variables OMP_NUM_THREADS/CCL_WORKER_COUNT can be tuned for optimal performance.",rt,N,dt,B,$t="The following command enables training with a total of four processes on two nodes (node0 and node1, taking node0 as the main process), ppn (processes per node) is set to 2, with one process running per one socket. The variables OMP_NUM_THREADS/CCL_WORKER_COUNT can be tuned for optimal performance.",pt,G,Lt="In node0, you need to create a configuration file which contains the IP addresses of each node (for example hostfile) and pass that configuration file path as an argument.",ct,P,ht,k,Rt="Now, run the following command in node0 and <strong>4DDP</strong> will be enabled in node0 and node1:",mt,H,wt,E,Mt;return f=new Et({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new Vt({props:{title:"Distributed training",local:"distributed-training",headingTag:"h1"}}),g=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9uZWNjbF9iaW5kX3B0JTNEJTNEJTdCcHl0b3JjaF92ZXJzaW9uJTdEJTIwLWYlMjBodHRwcyUzQSUyRiUyRnNvZnR3YXJlLmludGVsLmNvbSUyRmlwZXgtd2hsLXN0YWJsZQ==",highlighted:'pip install oneccl_bind_pt=={<span class="hljs-attribute">pytorch_version} -f https</span>://software<span class="hljs-variable">.intel</span><span class="hljs-variable">.com</span>/ipex-whl-stable',wrap:!1}}),$=new W({props:{code:"b25lY2NsX2JpbmRpbmdzX2Zvcl9weXRvcmNoX3BhdGglM0QlMjQocHl0aG9uJTIwLWMlMjAlMjJmcm9tJTIwb25lY2NsX2JpbmRpbmdzX2Zvcl9weXRvcmNoJTIwaW1wb3J0JTIwY3dkJTNCJTIwcHJpbnQoY3dkKSUyMiklMEFzb3VyY2UlMjAlMjRvbmVjY2xfYmluZGluZ3NfZm9yX3B5dG9yY2hfcGF0aCUyRmVudiUyRnNldHZhcnMuc2g=",highlighted:`oneccl_bindings_for_pytorch_path=$(<span class="hljs-keyword">python</span> -c <span class="hljs-string">&quot;from oneccl_bindings_for_pytorch import cwd; print(cwd)&quot;</span>)
<span class="hljs-keyword">source</span> $oneccl_bindings_for_pytorch_path/<span class="hljs-keyword">env</span>/setvars.sh`,wrap:!1}}),R=new W({props:{code:"dG9yY2hfY2NsX3BhdGglM0QlMjQocHl0aG9uJTIwLWMlMjAlMjJpbXBvcnQlMjB0b3JjaCUzQiUyMGltcG9ydCUyMHRvcmNoX2NjbCUzQiUyMGltcG9ydCUyMG9zJTNCJTIwJTIwcHJpbnQob3MucGF0aC5hYnNwYXRoKG9zLnBhdGguZGlybmFtZSh0b3JjaF9jY2wuX19maWxlX18pKSklMjIpJTBBc291cmNlJTIwJTI0dG9yY2hfY2NsX3BhdGglMkZlbnYlMkZzZXR2YXJzLnNo",highlighted:`torch_ccl_path=$(<span class="hljs-keyword">python</span> -c <span class="hljs-string">&quot;import torch; import torch_ccl; import os;  print(os.path.abspath(os.path.dirname(torch_ccl.__file__)))&quot;</span>)
<span class="hljs-keyword">source</span> $torch_ccl_path/<span class="hljs-keyword">env</span>/setvars.sh`,wrap:!1}}),N=new W({props:{code:"ZXhwb3J0JTIwQ0NMX1dPUktFUl9DT1VOVCUzRDElMEFleHBvcnQlMjBNQVNURVJfQUREUiUzRDEyNy4wLjAuMSUwQW1waXJ1biUyMC1uJTIwMiUyMC1nZW52JTIwT01QX05VTV9USFJFQURTJTNEMjMlMjAlNUMlMEFweXRob24zJTIwcnVuX3FhLnB5JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tb2RlbF9uYW1lX29yX3BhdGglMjBkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1kaXN0aWxsZWQtc3F1YWQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWRhdGFzZXRfbmFtZSUyMHNxdWFkJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1hcHBseV9xdWFudGl6YXRpb24lMjAlNUMlMEElMjAlMjAlMjAlMjAtLXF1YW50aXphdGlvbl9hcHByb2FjaCUyMHN0YXRpYyUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZG9fdHJhaW4lMjAlNUMlMEElMjAlMjAlMjAlMjAtLWRvX2V2YWwlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZlcmlmeV9sb2FkaW5nJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1vdXRwdXRfZGlyJTIwJTJGdG1wJTJGc3F1YWRfb3V0cHV0JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1ub19jdWRhJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS14cHVfYmFja2VuZCUyMGNjbA==",highlighted:`export CCL_WORKER_COUNT=1
export MASTER_ADDR=127.0.0.1
mpirun -n 2 -genv OMP_NUM_THREADS=23 \\
python3 run_qa.py \\
    --model_name_or_path distilbert-base-uncased-distilled-squad \\
    --dataset_name squad \\
    --apply_quantization \\
    --quantization_approach static \\
    --do_train \\
    --do_eval \\
    --verify_loading \\
    --output_dir /tmp/squad_output \\
    --no_cuda \\
    --xpu_backend ccl`,wrap:!1}}),P=new W({props:{code:"JTIwY2F0JTIwaG9zdGZpbGUlMEElMjB4eHgueHh4Lnh4eC54eHglMjA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xx.xxx #node0 ip
mpirun -f hostfile -n 4 -ppn 2 \\
-genv OMP_NUM_THREADS=23 \\
python3 run_qa.py \\
    --model_name_or_path distilbert-base-uncased-distilled-squad \\
    --dataset_name squad \\
    --apply_quantization \\
    --quantization_approach static \\
    --do_train \\
    --do_eval \\
    --verify_loading \\
    --output_dir /tmp/squad_output \\
    --no_cuda \\
    --xpu_backend ccl`,wrap:!1}}),{c(){d=a("meta"),V=i(),A=a("p"),Y=i(),p(f.$$.fragment),Z=i(),p(u.$$.fragment),F=i(),T=a("p"),T.textContent=ut,Q=i(),C=a("p"),C.textContent=Tt,S=i(),y=a("p"),y.innerHTML=Ct,z=i(),J=a("p"),J.innerHTML=yt,D=i(),b=a("p"),b.innerHTML=Jt,q=i(),U=a("p"),U.textContent=bt,O=i(),_=a("p"),_.textContent=Ut,K=i(),x=a("p"),x.textContent=_t,tt=i(),v=a("table"),v.innerHTML=xt,et=i(),p(g.$$.fragment),nt=i(),I=a("p"),I.innerHTML=vt,lt=i(),j=a("p"),j.textContent=gt,it=i(),p($.$$.fragment),ot=i(),L=a("p"),L.textContent=It,at=i(),p(R.$$.fragment),st=i(),X=a("p"),X.textContent=jt,rt=i(),p(N.$$.fragment),dt=i(),B=a("p"),B.textContent=$t,pt=i(),G=a("p"),G.textContent=Lt,ct=i(),p(P.$$.fragment),ht=i(),k=a("p"),k.innerHTML=Rt,mt=i(),p(H.$$.fragment),wt=i(),E=a("p"),this.h()},l(t){const e=Wt("svelte-u9bgzb",document.head);d=s(e,"META",{name:!0,content:!0}),e.forEach(n),V=o(t),A=s(t,"P",{}),Xt(A).forEach(n),Y=o(t),c(f.$$.fragment,t),Z=o(t),c(u.$$.fragment,t),F=o(t),T=s(t,"P",{"data-svelte-h":!0}),r(T)!=="svelte-v5mdvi"&&(T.textContent=ut),Q=o(t),C=s(t,"P",{"data-svelte-h":!0}),r(C)!=="svelte-3ncfkb"&&(C.textContent=Tt),S=o(t),y=s(t,"P",{"data-svelte-h":!0}),r(y)!=="svelte-bivv3w"&&(y.innerHTML=Ct),z=o(t),J=s(t,"P",{"data-svelte-h":!0}),r(J)!=="svelte-5o21pv"&&(J.innerHTML=yt),D=o(t),b=s(t,"P",{"data-svelte-h":!0}),r(b)!=="svelte-1qrzsug"&&(b.innerHTML=Jt),q=o(t),U=s(t,"P",{"data-svelte-h":!0}),r(U)!=="svelte-8y61gw"&&(U.textContent=bt),O=o(t),_=s(t,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1db4fuo"&&(_.textContent=Ut),K=o(t),x=s(t,"P",{"data-svelte-h":!0}),r(x)!=="svelte-7vxiqb"&&(x.textContent=_t),tt=o(t),v=s(t,"TABLE",{"data-svelte-h":!0}),r(v)!=="svelte-1m9r82a"&&(v.innerHTML=xt),et=o(t),c(g.$$.fragment,t),nt=o(t),I=s(t,"P",{"data-svelte-h":!0}),r(I)!=="svelte-10l1ev2"&&(I.innerHTML=vt),lt=o(t),j=s(t,"P",{"data-svelte-h":!0}),r(j)!=="svelte-1dmp0t"&&(j.textContent=gt),it=o(t),c($.$$.fragment,t),ot=o(t),L=s(t,"P",{"data-svelte-h":!0}),r(L)!=="svelte-1x3l803"&&(L.textContent=It),at=o(t),c(R.$$.fragment,t),st=o(t),X=s(t,"P",{"data-svelte-h":!0}),r(X)!=="svelte-1jvrym0"&&(X.textContent=jt),rt=o(t),c(N.$$.fragment,t),dt=o(t),B=s(t,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1w8dpvp"&&(B.textContent=$t),pt=o(t),G=s(t,"P",{"data-svelte-h":!0}),r(G)!=="svelte-dlvz8o"&&(G.textContent=Lt),ct=o(t),c(P.$$.fragment,t),ht=o(t),k=s(t,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1fnu20u"&&(k.innerHTML=Rt),mt=o(t),c(H.$$.fragment,t),wt=o(t),E=s(t,"P",{}),Xt(E).forEach(n),this.h()},h(){Nt(d,"name","hf:doc:metadata"),Nt(d,"content",Zt)},m(t,e){At(document.head,d),l(t,V,e),l(t,A,e),l(t,Y,e),h(f,t,e),l(t,Z,e),h(u,t,e),l(t,F,e),l(t,T,e),l(t,Q,e),l(t,C,e),l(t,S,e),l(t,y,e),l(t,z,e),l(t,J,e),l(t,D,e),l(t,b,e),l(t,q,e),l(t,U,e),l(t,O,e),l(t,_,e),l(t,K,e),l(t,x,e),l(t,tt,e),l(t,v,e),l(t,et,e),h(g,t,e),l(t,nt,e),l(t,I,e),l(t,lt,e),l(t,j,e),l(t,it,e),h($,t,e),l(t,ot,e),l(t,L,e),l(t,at,e),h(R,t,e),l(t,st,e),l(t,X,e),l(t,rt,e),h(N,t,e),l(t,dt,e),l(t,B,e),l(t,pt,e),l(t,G,e),l(t,ct,e),h(P,t,e),l(t,ht,e),l(t,k,e),l(t,mt,e),h(H,t,e),l(t,wt,e),l(t,E,e),Mt=!0},p:Gt,i(t){Mt||(m(f.$$.fragment,t),m(u.$$.fragment,t),m(g.$$.fragment,t),m($.$$.fragment,t),m(R.$$.fragment,t),m(N.$$.fragment,t),m(P.$$.fragment,t),m(H.$$.fragment,t),Mt=!0)},o(t){w(f.$$.fragment,t),w(u.$$.fragment,t),w(g.$$.fragment,t),w($.$$.fragment,t),w(R.$$.fragment,t),w(N.$$.fragment,t),w(P.$$.fragment,t),w(H.$$.fragment,t),Mt=!1},d(t){t&&(n(V),n(A),n(Y),n(Z),n(F),n(T),n(Q),n(C),n(S),n(y),n(z),n(J),n(D),n(b),n(q),n(U),n(O),n(_),n(K),n(x),n(tt),n(v),n(et),n(nt),n(I),n(lt),n(j),n(it),n(ot),n(L),n(at),n(st),n(X),n(rt),n(dt),n(B),n(pt),n(G),n(ct),n(ht),n(k),n(mt),n(wt),n(E)),n(d),M(f,t),M(u,t),M(g,t),M($,t),M(R,t),M(N,t),M(P,t),M(H,t)}}}const Zt='{"title":"Distributed training","local":"distributed-training","sections":[],"depth":1}';function Ft(ft){return Pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends kt{constructor(d){super(),Ht(this,d,Ft,Yt,Bt,{})}}export{qt as component};
