import{s as yt,o as pt,n as Ut}from"../chunks/scheduler.25b97de1.js";import{S as Tt,i as Jt,g as M,s as n,r as o,A as wt,h as i,f as t,c as a,j as rt,u as y,x as r,k as ot,y as ct,a as s,v as p,d as U,t as T,w as J}from"../chunks/index.d9030fc9.js";import{T as jt}from"../chunks/Tip.baa67368.js";import{C}from"../chunks/CodeBlock.e6cd0d95.js";import{H as j,E as Ct}from"../chunks/EditOnGithub.91d95064.js";function ht(be){let w,m=`The CPU resource limits/requests in the yaml are defined in
<a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu" rel="nofollow">cpu units</a>
where 1 CPU unit is equivalent to 1 physical CPU core or 1 virtual core (depending on whether the node is a physical
host or a VM). The amount of CPU and memory limits/requests defined in the yaml should be less than the amount of
available CPU/memory capacity on a single machine. It is usually a good idea to not use the entire machine’s capacity in
order to leave some resources for the kubelet and OS. In order to get <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed" rel="nofollow">“guaranteed”</a> <a href="https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod" rel="nofollow">quality of service</a> for the worker pods,
set the same CPU and memory amounts for both the resource limits and requests.`;return{c(){w=M("p"),w.innerHTML=m},l(c){w=i(c,"P",{"data-svelte-h":!0}),r(w)!=="svelte-12hslm2"&&(w.innerHTML=m)},m(c,Ie){s(c,w,Ie)},p:Ut,d(c){c&&t(w)}}}function mt(be){let w,m,c,Ie,d,fe,I,Bl=`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 on <a href="#usage-in-trainer">bare metal</a> and <a href="#usage-with-kubernetes">Kubernetes</a>.`,Ae,u,ge,b,vl='<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>.',Be,f,$l="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",ve,A,xl='Check more detailed information for <a href="https://github.com/intel/torch-ccl" rel="nofollow">oneccl_bind_pt</a>.',$e,g,xe,B,_l="Wheel files are available for the following Python versions:",_e,v,Zl='<thead><tr><th align="center">Extension Version</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> <th align="center">Python 3.11</th></tr></thead> <tbody><tr><td align="center">2.5.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">2.4.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">2.3.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">2.2.0</td> <td align="center"></td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td> <td align="center">√</td></tr></tbody>',Ze,$,Sl="Please run <code>pip list | grep torch</code> to get your <code>pytorch_version</code>.",Se,x,Ee,_,El=`where <code>{pytorch_version}</code> should be your PyTorch version, for instance 2.4.0.
Check more approaches for <a href="https://github.com/intel/torch-ccl" rel="nofollow">oneccl_bind_pt installation</a>.
Versions of oneCCL and PyTorch must match.`,Re,Z,Ge,S,Rl="Use this standards-based MPI implementation to deliver flexible, efficient, scalable cluster messaging on Intel® architecture. This component is part of the Intel® oneAPI HPC Toolkit.",Ne,E,Gl="oneccl_bindings_for_pytorch is installed along with the MPI tool set. Need to source the environment before using it.",ke,R,Ve,G,We,N,Nl='Intel Extension for PyTorch (IPEX) provides performance optimizations for CPU training with both Float32 and BFloat16 (refer to the <a href="./perf_train_cpu">single CPU section</a> to learn more).',Xe,k,kl="The following “Usage in Trainer” takes mpirun in Intel® MPI library as an example.",He,V,Pe,W,Vl="To enable multi CPU distributed training in the Trainer with the ccl backend, users should add <strong><code>--ddp_backend ccl</code></strong> in the command arguments.",Le,X,Wl='Let’s see an example with the <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering" rel="nofollow">question-answering example</a>',Qe,H,Xl="The following command enables training with 2 processes on one Xeon node, with one process running per one socket. The variables OMP_NUM_THREADS/CCL_WORKER_COUNT can be tuned for optimal performance.",Fe,P,Ye,L,Hl="The following command enables training with a total of four processes on two Xeons (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.",ze,Q,Pl="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.",De,F,qe,Y,Ll="Now, run the following command in node0 and <strong>4DDP</strong> will be enabled in node0 and node1 with BF16 auto mixed precision:",Oe,z,Ke,D,el,q,Ql=`The same distributed training job from the previous section can be deployed to a Kubernetes cluster using the
<a href="https://www.kubeflow.org/docs/components/training/user-guides/pytorch" rel="nofollow">Kubeflow PyTorchJob training operator</a>.`,ll,O,tl,K,Fl="This example assumes that you have:",sl,ee,Yl=`<li>Access to a Kubernetes cluster with <a href="https://www.kubeflow.org/docs/started/installing-kubeflow" rel="nofollow">Kubeflow installed</a></li> <li><a href="https://kubernetes.io/docs/tasks/tools" rel="nofollow"><code>kubectl</code></a> installed and configured to access the Kubernetes cluster</li> <li>A <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes" rel="nofollow">Persistent Volume Claim (PVC)</a> that can be used
to store datasets and model files. There are multiple options for setting up the PVC including using an NFS
<a href="https://kubernetes.io/docs/concepts/storage/storage-classes" rel="nofollow">storage class</a> or a cloud storage bucket.</li> <li>A Docker container that includes your model training script and all the dependencies needed to run the script. For
distributed CPU training jobs, this typically includes PyTorch, Transformers, Intel Extension for PyTorch, Intel
oneCCL Bindings for PyTorch, and OpenSSH to communicate between the containers.</li>`,nl,le,zl=`The snippet below is an example of a Dockerfile that uses a base image that supports distributed CPU training and then
extracts a Transformers release to the <code>/workspace</code> directory, so that the example scripts are included in the image:`,al,te,Ml,se,Dl=`The image needs to be built and copied to the cluster’s nodes or pushed to a container registry prior to deploying the
PyTorchJob to the cluster.`,il,ne,rl,ae,ql=`The <a href="https://www.kubeflow.org/docs/components/training/user-guides/pytorch" rel="nofollow">Kubeflow PyTorchJob</a> is used to run the distributed
training job on the cluster. The yaml file for the PyTorchJob defines parameters such as:`,ol,Me,Ol="<li>The name of the PyTorchJob</li> <li>The number of replicas (workers)</li> <li>The python script and it’s parameters that will be used to run the training job</li> <li>The types of resources (node selector, memory, and CPU) needed for each worker</li> <li>The image/tag for the Docker container to use</li> <li>Environment variables</li> <li>A volume mount for the PVC</li>",yl,ie,Kl=`The volume mount defines a path where the PVC will be mounted in the container for each worker pod. This location can be
used for the dataset, checkpoint files, and the saved model after training completes.`,pl,re,et=`The snippet below is an example of a yaml file for a PyTorchJob with 4 workers running the
<a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering" rel="nofollow">question-answering example</a>.`,Ul,oe,Tl,ye,lt="To run this example, update the yaml based on your training script and the nodes in your cluster.",Jl,h,wl,pe,cl,Ue,tt=`After the PyTorchJob spec has been updated with values appropriate for your cluster and training job, it can be deployed
to the cluster using:`,jl,Te,Cl,Je,st=`The <code>kubectl get pods -n \${NAMESPACE}</code> command can then be used to list the pods in your namespace. You should see
the worker pods for the PyTorchJob that was just deployed. At first, they will probably have a status of “Pending” as
the containers get pulled and created, then the status should change to “Running”.`,hl,we,ml,ce,nt="The logs for worker can be viewed using <code>kubectl logs &lt;pod name&gt; -n ${NAMESPACE}</code>. Add <code>-f</code> to stream the logs, for example:",dl,je,Il,Ce,at="After the training job completes, the trained model can be copied from the PVC or storage location. When you are done\nwith the job, the PyTorchJob resource can be deleted from the cluster using <code>kubectl delete -f pytorchjob.yaml -n ${NAMESPACE}</code>.",ul,he,bl,me,Mt=`This guide covered running distributed PyTorch training jobs using multiple CPUs on bare metal and on a Kubernetes
cluster. Both cases utilize Intel Extension for PyTorch and Intel oneCCL Bindings for PyTorch for optimal training
performance, and can be used as a template to run your own workload on multiple nodes.`,fl,de,Al,ue,gl;return d=new j({props:{title:"Efficient Training on Multiple CPUs",local:"efficient-training-on-multiple-cpus",headingTag:"h1"}}),u=new j({props:{title:"Intel® oneCCL Bindings for PyTorch",local:"intel-oneccl-bindings-for-pytorch",headingTag:"h2"}}),g=new j({props:{title:"Intel® oneCCL Bindings for PyTorch installation",local:"intel-oneccl-bindings-for-pytorch-installation",headingTag:"h3"}}),x=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9uZWNjbF9iaW5kX3B0JTNEJTNEJTdCcHl0b3JjaF92ZXJzaW9uJTdEJTIwLWYlMjBodHRwcyUzQSUyRiUyRmRldmVsb3Blci5pbnRlbC5jb20lMkZpcGV4LXdobC1zdGFibGUtY3B1",highlighted:"pip install oneccl_bind_pt=={pytorch_version} -f https://developer.intel.com/ipex-whl-stable-cpu",wrap:!1}}),Z=new j({props:{title:"Intel® MPI library",local:"intel-mpi-library",headingTag:"h2"}}),R=new C({props:{code:"b25lY2NsX2JpbmRpbmdzX2Zvcl9weXRvcmNoX3BhdGglM0QlMjQocHl0aG9uJTIwLWMlMjAlMjJmcm9tJTIwb25lY2NsX2JpbmRpbmdzX2Zvcl9weXRvcmNoJTIwaW1wb3J0JTIwY3dkJTNCJTIwcHJpbnQoY3dkKSUyMiklMEFzb3VyY2UlMjAlMjRvbmVjY2xfYmluZGluZ3NfZm9yX3B5dG9yY2hfcGF0aCUyRmVudiUyRnNldHZhcnMuc2g=",highlighted:`oneccl_bindings_for_pytorch_path=$(python -c <span class="hljs-string">&quot;from oneccl_bindings_for_pytorch import cwd; print(cwd)&quot;</span>)
<span class="hljs-built_in">source</span> <span class="hljs-variable">$oneccl_bindings_for_pytorch_path</span>/env/setvars.sh`,wrap:!1}}),G=new j({props:{title:"Intel® Extension for PyTorch installation",local:"intel-extension-for-pytorch-installation",headingTag:"h4"}}),V=new j({props:{title:"Usage in Trainer",local:"usage-in-trainer",headingTag:"h2"}}),P=new C({props:{code:"JTIwZXhwb3J0JTIwQ0NMX1dPUktFUl9DT1VOVCUzRDElMEElMjBleHBvcnQlMjBNQVNURVJfQUREUiUzRDEyNy4wLjAuMSUwQSUyMG1waXJ1biUyMC1uJTIwMiUyMC1nZW52JTIwT01QX05VTV9USFJFQURTJTNEMjMlMjAlNUMlMEElMjBweXRob24zJTIwcnVuX3FhLnB5JTIwJTVDJTBBJTIwLS1tb2RlbF9uYW1lX29yX3BhdGglMjBnb29nbGUtYmVydCUyRmJlcnQtbGFyZ2UtdW5jYXNlZCUyMCU1QyUwQSUyMC0tZGF0YXNldF9uYW1lJTIwc3F1YWQlMjAlNUMlMEElMjAtLWRvX3RyYWluJTIwJTVDJTBBJTIwLS1kb19ldmFsJTIwJTVDJTBBJTIwLS1wZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlMjAxMiUyMCUyMCU1QyUwQSUyMC0tbGVhcm5pbmdfcmF0ZSUyMDNlLTUlMjAlMjAlNUMlMEElMjAtLW51bV90cmFpbl9lcG9jaHMlMjAyJTIwJTIwJTVDJTBBJTIwLS1tYXhfc2VxX2xlbmd0aCUyMDM4NCUyMCU1QyUwQSUyMC0tZG9jX3N0cmlkZSUyMDEyOCUyMCUyMCU1QyUwQSUyMC0tb3V0cHV0X2RpciUyMCUyRnRtcCUyRmRlYnVnX3NxdWFkJTJGJTIwJTVDJTBBJTIwLS1ub19jdWRhJTIwJTVDJTBBJTIwLS1kZHBfYmFja2VuZCUyMGNjbCUyMCU1QyUwQSUyMC0tdXNlX2lwZXg=",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 google-bert/bert-large-uncased \\
 --dataset_name squad \\
 --do_train \\
 --do_eval \\
 --per_device_train_batch_size 12  \\
 --learning_rate 3e-5  \\
 --num_train_epochs 2  \\
 --max_seq_length 384 \\
 --doc_stride 128  \\
 --output_dir /tmp/debug_squad/ \\
 --no_cuda \\
 --ddp_backend ccl \\
 --use_ipex`,wrap:!1}}),F=new C({props:{code:"JTIwY2F0JTIwaG9zdGZpbGUlMEElMjB4eHgueHh4Lnh4eC54eHglMjAlMjNub2RlMCUyMGlwJTBBJTIweHh4Lnh4eC54eHgueHh4JTIwJTIzbm9kZTElMjBpcA==",highlighted:` cat hostfile
 xxx.xxx.xxx.xxx #node0 ip
 xxx.xxx.xxx.xxx #node1 ip`,wrap:!1}}),z=new C({props:{code:"JTIwZXhwb3J0JTIwQ0NMX1dPUktFUl9DT1VOVCUzRDElMEElMjBleHBvcnQlMjBNQVNURVJfQUREUiUzRHh4eC54eHgueHh4Lnh4eCUyMCUyM25vZGUwJTIwaXAlMEElMjBtcGlydW4lMjAtZiUyMGhvc3RmaWxlJTIwLW4lMjA0JTIwLXBwbiUyMDIlMjAlNUMlMEElMjAtZ2VudiUyME9NUF9OVU1fVEhSRUFEUyUzRDIzJTIwJTVDJTBBJTIwcHl0aG9uMyUyMHJ1bl9xYS5weSUyMCU1QyUwQSUyMC0tbW9kZWxfbmFtZV9vcl9wYXRoJTIwZ29vZ2xlLWJlcnQlMkZiZXJ0LWxhcmdlLXVuY2FzZWQlMjAlNUMlMEElMjAtLWRhdGFzZXRfbmFtZSUyMHNxdWFkJTIwJTVDJTBBJTIwLS1kb190cmFpbiUyMCU1QyUwQSUyMC0tZG9fZXZhbCUyMCU1QyUwQSUyMC0tcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTIwMTIlMjAlMjAlNUMlMEElMjAtLWxlYXJuaW5nX3JhdGUlMjAzZS01JTIwJTIwJTVDJTBBJTIwLS1udW1fdHJhaW5fZXBvY2hzJTIwMiUyMCUyMCU1QyUwQSUyMC0tbWF4X3NlcV9sZW5ndGglMjAzODQlMjAlNUMlMEElMjAtLWRvY19zdHJpZGUlMjAxMjglMjAlMjAlNUMlMEElMjAtLW91dHB1dF9kaXIlMjAlMkZ0bXAlMkZkZWJ1Z19zcXVhZCUyRiUyMCU1QyUwQSUyMC0tbm9fY3VkYSUyMCU1QyUwQSUyMC0tZGRwX2JhY2tlbmQlMjBjY2wlMjAlNUMlMEElMjAtLXVzZV9pcGV4JTIwJTVDJTBBJTIwLS1iZjE2",highlighted:` export CCL_WORKER_COUNT=1
 export MASTER_ADDR=xxx.xxx.xxx.xxx #node0 ip
 mpirun -f hostfile -n 4 -ppn 2 \\
 -genv OMP_NUM_THREADS=23 \\
 python3 run_qa.py \\
 --model_name_or_path google-bert/bert-large-uncased \\
 --dataset_name squad \\
 --do_train \\
 --do_eval \\
 --per_device_train_batch_size 12  \\
 --learning_rate 3e-5  \\
 --num_train_epochs 2  \\
 --max_seq_length 384 \\
 --doc_stride 128  \\
 --output_dir /tmp/debug_squad/ \\
 --no_cuda \\
 --ddp_backend ccl \\
 --use_ipex \\
 --bf16`,wrap:!1}}),D=new j({props:{title:"Usage with Kubernetes",local:"usage-with-kubernetes",headingTag:"h2"}}),O=new j({props:{title:"Setup",local:"setup",headingTag:"h3"}}),te=new C({props:{code:"RlJPTSUyMGludGVsJTJGaW50ZWwtb3B0aW1pemVkLXB5dG9yY2glM0EyLjQuMC1waXAtbXVsdGlub2RlJTBBJTBBUlVOJTIwYXB0LWdldCUyMHVwZGF0ZSUyMC15JTIwJTI2JTI2JTIwJTVDJTBBJTIwJTIwJTIwJTIwYXB0LWdldCUyMGluc3RhbGwlMjAteSUyMC0tbm8taW5zdGFsbC1yZWNvbW1lbmRzJTIwLS1maXgtbWlzc2luZyUyMCU1QyUwQSUyMCUyMCUyMCUyMGdvb2dsZS1wZXJmdG9vbHMlMjAlNUMlMEElMjAlMjAlMjAlMjBsaWJvbXAtZGV2JTBBJTBBV09SS0RJUiUyMCUyRndvcmtzcGFjZSUwQSUwQSUyMyUyMERvd25sb2FkJTIwYW5kJTIwZXh0cmFjdCUyMHRoZSUyMHRyYW5zZm9ybWVycyUyMGNvZGUlMEFBUkclMjBIRl9UUkFOU0ZPUk1FUlNfVkVSJTNEJTIyNC40Ni4wJTIyJTBBUlVOJTIwcGlwJTIwaW5zdGFsbCUyMC0tbm8tY2FjaGUtZGlyJTIwJTVDJTBBJTIwJTIwJTIwJTIwdHJhbnNmb3JtZXJzJTNEJTNEJTI0JTdCSEZfVFJBTlNGT1JNRVJTX1ZFUiU3RCUyMCUyNiUyNiUyMCU1QyUwQSUyMCUyMCUyMCUyMG1rZGlyJTIwdHJhbnNmb3JtZXJzJTIwJTI2JTI2JTIwJTVDJTBBJTIwJTIwJTIwJTIwY3VybCUyMC1zU0wlMjAtLXJldHJ5JTIwNSUyMGh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJzJTJGYXJjaGl2ZSUyRnJlZnMlMkZ0YWdzJTJGdiUyNCU3QkhGX1RSQU5TRk9STUVSU19WRVIlN0QudGFyLmd6JTIwJTdDJTIwdGFyJTIwLUMlMjB0cmFuc2Zvcm1lcnMlMjAtLXN0cmlwLWNvbXBvbmVudHMlM0QxJTIwLXh6ZiUyMC0=",highlighted:`<span class="hljs-keyword">FROM</span> intel/intel-optimized-pytorch:<span class="hljs-number">2.4</span>.<span class="hljs-number">0</span>-pip-multinode

<span class="hljs-keyword">RUN</span><span class="language-bash"> apt-get update -y &amp;&amp; \\
    apt-get install -y --no-install-recommends --fix-missing \\
    google-perftools \\
    libomp-dev</span>

<span class="hljs-keyword">WORKDIR</span><span class="language-bash"> /workspace</span>

<span class="hljs-comment"># Download and extract the transformers code</span>
<span class="hljs-keyword">ARG</span> HF_TRANSFORMERS_VER=<span class="hljs-string">&quot;4.46.0&quot;</span>
<span class="hljs-keyword">RUN</span><span class="language-bash"> pip install --no-cache-dir \\
    transformers==<span class="hljs-variable">\${HF_TRANSFORMERS_VER}</span> &amp;&amp; \\
    <span class="hljs-built_in">mkdir</span> transformers &amp;&amp; \\
    curl -sSL --retry 5 https://github.com/huggingface/transformers/archive/refs/tags/v<span class="hljs-variable">\${HF_TRANSFORMERS_VER}</span>.tar.gz | tar -C transformers --strip-components=1 -xzf -</span>`,wrap:!1}}),ne=new j({props:{title:"PyTorchJob Specification File",local:"pytorchjob-specification-file",headingTag:"h3"}}),oe=new C({props:{code:" ",highlighted:`<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">&quot;kubeflow.org/v1&quot;</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">PyTorchJob</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">transformers-pytorchjob</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">elasticPolicy:</span>
    <span class="hljs-attr">rdzvBackend:</span> <span class="hljs-string">c10d</span>
    <span class="hljs-attr">minReplicas:</span> <span class="hljs-number">1</span>
    <span class="hljs-attr">maxReplicas:</span> <span class="hljs-number">4</span>
    <span class="hljs-attr">maxRestarts:</span> <span class="hljs-number">10</span>
  <span class="hljs-attr">pytorchReplicaSpecs:</span>
    <span class="hljs-attr">Worker:</span>
      <span class="hljs-attr">replicas:</span> <span class="hljs-number">4</span>  <span class="hljs-comment"># The number of worker pods</span>
      <span class="hljs-attr">restartPolicy:</span> <span class="hljs-string">OnFailure</span>
      <span class="hljs-attr">template:</span>
        <span class="hljs-attr">spec:</span>
          <span class="hljs-attr">containers:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">pytorch</span>
              <span class="hljs-attr">image:</span> <span class="hljs-string">&lt;image</span> <span class="hljs-string">name&gt;:&lt;tag&gt;</span>  <span class="hljs-comment"># Specify the docker image to use for the worker pods</span>
              <span class="hljs-attr">imagePullPolicy:</span> <span class="hljs-string">IfNotPresent</span>
              <span class="hljs-attr">command:</span> [<span class="hljs-string">&quot;/bin/bash&quot;</span>, <span class="hljs-string">&quot;-c&quot;</span>]
              <span class="hljs-attr">args:</span>
                <span class="hljs-bullet">-</span> <span class="hljs-string">&gt;-
                  cd /workspace/transformers;
                  pip install -r /workspace/transformers/examples/pytorch/question-answering/requirements.txt;
                  source /usr/local/lib/python3.10/dist-packages/oneccl_bindings_for_pytorch/env/setvars.sh;
                  torchrun /workspace/transformers/examples/pytorch/question-answering/run_qa.py \\
                    --model_name_or_path distilbert/distilbert-base-uncased \\
                    --dataset_name squad \\
                    --do_train \\
                    --do_eval \\
                    --per_device_train_batch_size 12 \\
                    --learning_rate 3e-5 \\
                    --num_train_epochs 2 \\
                    --max_seq_length 384 \\
                    --doc_stride 128 \\
                    --output_dir /tmp/pvc-mount/output_$(date +%Y%m%d_%H%M%S) \\
                    --no_cuda \\
                    --ddp_backend ccl \\
                    --bf16 \\
                    --use_ipex;
</span>              <span class="hljs-attr">env:</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">LD_PRELOAD</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4.5.9:/usr/local/lib/libiomp5.so&quot;</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">TRANSFORMERS_CACHE</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;/tmp/pvc-mount/transformers_cache&quot;</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">HF_DATASETS_CACHE</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;/tmp/pvc-mount/hf_datasets_cache&quot;</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">LOGLEVEL</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;INFO&quot;</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">CCL_WORKER_COUNT</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;1&quot;</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">OMP_NUM_THREADS</span>  <span class="hljs-comment"># Can be tuned for optimal performance</span>
                <span class="hljs-attr">value:</span> <span class="hljs-string">&quot;240&quot;</span>
              <span class="hljs-attr">resources:</span>
                <span class="hljs-attr">limits:</span>
                  <span class="hljs-attr">cpu:</span> <span class="hljs-number">240</span>  <span class="hljs-comment"># Update the CPU and memory limit values based on your nodes</span>
                  <span class="hljs-attr">memory:</span> <span class="hljs-string">128Gi</span>
                <span class="hljs-attr">requests:</span>
                  <span class="hljs-attr">cpu:</span> <span class="hljs-number">240</span>  <span class="hljs-comment"># Update the CPU and memory request values based on your nodes</span>
                  <span class="hljs-attr">memory:</span> <span class="hljs-string">128Gi</span>
              <span class="hljs-attr">volumeMounts:</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">pvc-volume</span>
                <span class="hljs-attr">mountPath:</span> <span class="hljs-string">/tmp/pvc-mount</span>
              <span class="hljs-bullet">-</span> <span class="hljs-attr">mountPath:</span> <span class="hljs-string">/dev/shm</span>
                <span class="hljs-attr">name:</span> <span class="hljs-string">dshm</span>
          <span class="hljs-attr">restartPolicy:</span> <span class="hljs-string">Never</span>
          <span class="hljs-attr">nodeSelector:</span>  <span class="hljs-comment"># Optionally use nodeSelector to match a certain node label for the worker pods</span>
            <span class="hljs-attr">node-type:</span> <span class="hljs-string">gnr</span>
          <span class="hljs-attr">volumes:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">pvc-volume</span>
            <span class="hljs-attr">persistentVolumeClaim:</span>
              <span class="hljs-attr">claimName:</span> <span class="hljs-string">transformers-pvc</span>
          <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">dshm</span>
            <span class="hljs-attr">emptyDir:</span>
              <span class="hljs-attr">medium:</span> <span class="hljs-string">Memory</span>`,wrap:!1}}),h=new jt({props:{$$slots:{default:[ht]},$$scope:{ctx:be}}}),pe=new j({props:{title:"Deploy",local:"deploy",headingTag:"h3"}}),Te=new C({props:{code:"ZXhwb3J0JTIwTkFNRVNQQUNFJTNEJTNDc3BlY2lmeSUyMHlvdXIlMjBuYW1lc3BhY2UlM0UlMEElMEFrdWJlY3RsJTIwY3JlYXRlJTIwLWYlMjBweXRvcmNoam9iLnlhbWwlMjAtbiUyMCUyNCU3Qk5BTUVTUEFDRSU3RA==",highlighted:`<span class="hljs-built_in">export</span> NAMESPACE=&lt;specify your namespace&gt;

kubectl create -f pytorchjob.yaml -n <span class="hljs-variable">\${NAMESPACE}</span>`,wrap:!1}}),we=new C({props:{code:"",highlighted:`NAME                                                     READY   STATUS                  RESTARTS          AGE
<span class="hljs-meta prompt_">...</span>
transformers-pytorchjob-worker-0                         1/1     Running                 0                 7m37s
transformers-pytorchjob-worker-1                         1/1     Running                 0                 7m37s
transformers-pytorchjob-worker-2                         1/1     Running                 0                 7m37s
transformers-pytorchjob-worker-3                         1/1     Running                 0                 7m37s
<span class="hljs-meta prompt_">...</span>`,wrap:!1}}),je=new C({props:{code:"a3ViZWN0bCUyMGxvZ3MlMjB0cmFuc2Zvcm1lcnMtcHl0b3JjaGpvYi13b3JrZXItMCUyMC1uJTIwJTI0JTdCTkFNRVNQQUNFJTdEJTIwLWY=",highlighted:'kubectl logs transformers-pytorchjob-worker-0 -n <span class="hljs-variable">${NAMESPACE}</span> -f',wrap:!1}}),he=new j({props:{title:"Summary",local:"summary",headingTag:"h2"}}),de=new Ct({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/perf_train_cpu_many.md"}}),{c(){w=M("meta"),m=n(),c=M("p"),Ie=n(),o(d.$$.fragment),fe=n(),I=M("p"),I.innerHTML=Bl,Ae=n(),o(u.$$.fragment),ge=n(),b=M("p"),b.innerHTML=vl,Be=n(),f=M("p"),f.innerHTML=$l,ve=n(),A=M("p"),A.innerHTML=xl,$e=n(),o(g.$$.fragment),xe=n(),B=M("p"),B.textContent=_l,_e=n(),v=M("table"),v.innerHTML=Zl,Ze=n(),$=M("p"),$.innerHTML=Sl,Se=n(),o(x.$$.fragment),Ee=n(),_=M("p"),_.innerHTML=El,Re=n(),o(Z.$$.fragment),Ge=n(),S=M("p"),S.textContent=Rl,Ne=n(),E=M("p"),E.textContent=Gl,ke=n(),o(R.$$.fragment),Ve=n(),o(G.$$.fragment),We=n(),N=M("p"),N.innerHTML=Nl,Xe=n(),k=M("p"),k.textContent=kl,He=n(),o(V.$$.fragment),Pe=n(),W=M("p"),W.innerHTML=Vl,Le=n(),X=M("p"),X.innerHTML=Wl,Qe=n(),H=M("p"),H.textContent=Xl,Fe=n(),o(P.$$.fragment),Ye=n(),L=M("p"),L.textContent=Hl,ze=n(),Q=M("p"),Q.textContent=Pl,De=n(),o(F.$$.fragment),qe=n(),Y=M("p"),Y.innerHTML=Ll,Oe=n(),o(z.$$.fragment),Ke=n(),o(D.$$.fragment),el=n(),q=M("p"),q.innerHTML=Ql,ll=n(),o(O.$$.fragment),tl=n(),K=M("p"),K.textContent=Fl,sl=n(),ee=M("ul"),ee.innerHTML=Yl,nl=n(),le=M("p"),le.innerHTML=zl,al=n(),o(te.$$.fragment),Ml=n(),se=M("p"),se.textContent=Dl,il=n(),o(ne.$$.fragment),rl=n(),ae=M("p"),ae.innerHTML=ql,ol=n(),Me=M("ul"),Me.innerHTML=Ol,yl=n(),ie=M("p"),ie.textContent=Kl,pl=n(),re=M("p"),re.innerHTML=et,Ul=n(),o(oe.$$.fragment),Tl=n(),ye=M("p"),ye.textContent=lt,Jl=n(),o(h.$$.fragment),wl=n(),o(pe.$$.fragment),cl=n(),Ue=M("p"),Ue.textContent=tt,jl=n(),o(Te.$$.fragment),Cl=n(),Je=M("p"),Je.innerHTML=st,hl=n(),o(we.$$.fragment),ml=n(),ce=M("p"),ce.innerHTML=nt,dl=n(),o(je.$$.fragment),Il=n(),Ce=M("p"),Ce.innerHTML=at,ul=n(),o(he.$$.fragment),bl=n(),me=M("p"),me.textContent=Mt,fl=n(),o(de.$$.fragment),Al=n(),ue=M("p"),this.h()},l(e){const l=wt("svelte-u9bgzb",document.head);w=i(l,"META",{name:!0,content:!0}),l.forEach(t),m=a(e),c=i(e,"P",{}),rt(c).forEach(t),Ie=a(e),y(d.$$.fragment,e),fe=a(e),I=i(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-k7boah"&&(I.innerHTML=Bl),Ae=a(e),y(u.$$.fragment,e),ge=a(e),b=i(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-bivv3w"&&(b.innerHTML=vl),Be=a(e),f=i(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-5o21pv"&&(f.innerHTML=$l),ve=a(e),A=i(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1qrzsug"&&(A.innerHTML=xl),$e=a(e),y(g.$$.fragment,e),xe=a(e),B=i(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-7vxiqb"&&(B.textContent=_l),_e=a(e),v=i(e,"TABLE",{"data-svelte-h":!0}),r(v)!=="svelte-1g7lkke"&&(v.innerHTML=Zl),Ze=a(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-21jzz8"&&($.innerHTML=Sl),Se=a(e),y(x.$$.fragment,e),Ee=a(e),_=i(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1yxy6mw"&&(_.innerHTML=El),Re=a(e),y(Z.$$.fragment,e),Ge=a(e),S=i(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-1hu54a3"&&(S.textContent=Rl),Ne=a(e),E=i(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-1nteuhh"&&(E.textContent=Gl),ke=a(e),y(R.$$.fragment,e),Ve=a(e),y(G.$$.fragment,e),We=a(e),N=i(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-12dw1vq"&&(N.innerHTML=Nl),Xe=a(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1w8k00"&&(k.textContent=kl),He=a(e),y(V.$$.fragment,e),Pe=a(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-k782b4"&&(W.innerHTML=Vl),Le=a(e),X=i(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-kvcz06"&&(X.innerHTML=Wl),Qe=a(e),H=i(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-m6wzyw"&&(H.textContent=Xl),Fe=a(e),y(P.$$.fragment,e),Ye=a(e),L=i(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-cyuir"&&(L.textContent=Hl),ze=a(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-dlvz8o"&&(Q.textContent=Pl),De=a(e),y(F.$$.fragment,e),qe=a(e),Y=i(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1vsu09v"&&(Y.innerHTML=Ll),Oe=a(e),y(z.$$.fragment,e),Ke=a(e),y(D.$$.fragment,e),el=a(e),q=i(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1nm9ddz"&&(q.innerHTML=Ql),ll=a(e),y(O.$$.fragment,e),tl=a(e),K=i(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-1p9mop9"&&(K.textContent=Fl),sl=a(e),ee=i(e,"UL",{"data-svelte-h":!0}),r(ee)!=="svelte-16c2erg"&&(ee.innerHTML=Yl),nl=a(e),le=i(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-vaz613"&&(le.innerHTML=zl),al=a(e),y(te.$$.fragment,e),Ml=a(e),se=i(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-1ra1dus"&&(se.textContent=Dl),il=a(e),y(ne.$$.fragment,e),rl=a(e),ae=i(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-5578kt"&&(ae.innerHTML=ql),ol=a(e),Me=i(e,"UL",{"data-svelte-h":!0}),r(Me)!=="svelte-1w74v7u"&&(Me.innerHTML=Ol),yl=a(e),ie=i(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-1rtua9k"&&(ie.textContent=Kl),pl=a(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-1sen8je"&&(re.innerHTML=et),Ul=a(e),y(oe.$$.fragment,e),Tl=a(e),ye=i(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-l1jsdc"&&(ye.textContent=lt),Jl=a(e),y(h.$$.fragment,e),wl=a(e),y(pe.$$.fragment,e),cl=a(e),Ue=i(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-w0q5hc"&&(Ue.textContent=tt),jl=a(e),y(Te.$$.fragment,e),Cl=a(e),Je=i(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-1rrjl11"&&(Je.innerHTML=st),hl=a(e),y(we.$$.fragment,e),ml=a(e),ce=i(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-6jo9na"&&(ce.innerHTML=nt),dl=a(e),y(je.$$.fragment,e),Il=a(e),Ce=i(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1hi6y76"&&(Ce.innerHTML=at),ul=a(e),y(he.$$.fragment,e),bl=a(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-prt8yq"&&(me.textContent=Mt),fl=a(e),y(de.$$.fragment,e),Al=a(e),ue=i(e,"P",{}),rt(ue).forEach(t),this.h()},h(){ot(w,"name","hf:doc:metadata"),ot(w,"content",dt)},m(e,l){ct(document.head,w),s(e,m,l),s(e,c,l),s(e,Ie,l),p(d,e,l),s(e,fe,l),s(e,I,l),s(e,Ae,l),p(u,e,l),s(e,ge,l),s(e,b,l),s(e,Be,l),s(e,f,l),s(e,ve,l),s(e,A,l),s(e,$e,l),p(g,e,l),s(e,xe,l),s(e,B,l),s(e,_e,l),s(e,v,l),s(e,Ze,l),s(e,$,l),s(e,Se,l),p(x,e,l),s(e,Ee,l),s(e,_,l),s(e,Re,l),p(Z,e,l),s(e,Ge,l),s(e,S,l),s(e,Ne,l),s(e,E,l),s(e,ke,l),p(R,e,l),s(e,Ve,l),p(G,e,l),s(e,We,l),s(e,N,l),s(e,Xe,l),s(e,k,l),s(e,He,l),p(V,e,l),s(e,Pe,l),s(e,W,l),s(e,Le,l),s(e,X,l),s(e,Qe,l),s(e,H,l),s(e,Fe,l),p(P,e,l),s(e,Ye,l),s(e,L,l),s(e,ze,l),s(e,Q,l),s(e,De,l),p(F,e,l),s(e,qe,l),s(e,Y,l),s(e,Oe,l),p(z,e,l),s(e,Ke,l),p(D,e,l),s(e,el,l),s(e,q,l),s(e,ll,l),p(O,e,l),s(e,tl,l),s(e,K,l),s(e,sl,l),s(e,ee,l),s(e,nl,l),s(e,le,l),s(e,al,l),p(te,e,l),s(e,Ml,l),s(e,se,l),s(e,il,l),p(ne,e,l),s(e,rl,l),s(e,ae,l),s(e,ol,l),s(e,Me,l),s(e,yl,l),s(e,ie,l),s(e,pl,l),s(e,re,l),s(e,Ul,l),p(oe,e,l),s(e,Tl,l),s(e,ye,l),s(e,Jl,l),p(h,e,l),s(e,wl,l),p(pe,e,l),s(e,cl,l),s(e,Ue,l),s(e,jl,l),p(Te,e,l),s(e,Cl,l),s(e,Je,l),s(e,hl,l),p(we,e,l),s(e,ml,l),s(e,ce,l),s(e,dl,l),p(je,e,l),s(e,Il,l),s(e,Ce,l),s(e,ul,l),p(he,e,l),s(e,bl,l),s(e,me,l),s(e,fl,l),p(de,e,l),s(e,Al,l),s(e,ue,l),gl=!0},p(e,[l]){const it={};l&2&&(it.$$scope={dirty:l,ctx:e}),h.$set(it)},i(e){gl||(U(d.$$.fragment,e),U(u.$$.fragment,e),U(g.$$.fragment,e),U(x.$$.fragment,e),U(Z.$$.fragment,e),U(R.$$.fragment,e),U(G.$$.fragment,e),U(V.$$.fragment,e),U(P.$$.fragment,e),U(F.$$.fragment,e),U(z.$$.fragment,e),U(D.$$.fragment,e),U(O.$$.fragment,e),U(te.$$.fragment,e),U(ne.$$.fragment,e),U(oe.$$.fragment,e),U(h.$$.fragment,e),U(pe.$$.fragment,e),U(Te.$$.fragment,e),U(we.$$.fragment,e),U(je.$$.fragment,e),U(he.$$.fragment,e),U(de.$$.fragment,e),gl=!0)},o(e){T(d.$$.fragment,e),T(u.$$.fragment,e),T(g.$$.fragment,e),T(x.$$.fragment,e),T(Z.$$.fragment,e),T(R.$$.fragment,e),T(G.$$.fragment,e),T(V.$$.fragment,e),T(P.$$.fragment,e),T(F.$$.fragment,e),T(z.$$.fragment,e),T(D.$$.fragment,e),T(O.$$.fragment,e),T(te.$$.fragment,e),T(ne.$$.fragment,e),T(oe.$$.fragment,e),T(h.$$.fragment,e),T(pe.$$.fragment,e),T(Te.$$.fragment,e),T(we.$$.fragment,e),T(je.$$.fragment,e),T(he.$$.fragment,e),T(de.$$.fragment,e),gl=!1},d(e){e&&(t(m),t(c),t(Ie),t(fe),t(I),t(Ae),t(ge),t(b),t(Be),t(f),t(ve),t(A),t($e),t(xe),t(B),t(_e),t(v),t(Ze),t($),t(Se),t(Ee),t(_),t(Re),t(Ge),t(S),t(Ne),t(E),t(ke),t(Ve),t(We),t(N),t(Xe),t(k),t(He),t(Pe),t(W),t(Le),t(X),t(Qe),t(H),t(Fe),t(Ye),t(L),t(ze),t(Q),t(De),t(qe),t(Y),t(Oe),t(Ke),t(el),t(q),t(ll),t(tl),t(K),t(sl),t(ee),t(nl),t(le),t(al),t(Ml),t(se),t(il),t(rl),t(ae),t(ol),t(Me),t(yl),t(ie),t(pl),t(re),t(Ul),t(Tl),t(ye),t(Jl),t(wl),t(cl),t(Ue),t(jl),t(Cl),t(Je),t(hl),t(ml),t(ce),t(dl),t(Il),t(Ce),t(ul),t(bl),t(me),t(fl),t(Al),t(ue)),t(w),J(d,e),J(u,e),J(g,e),J(x,e),J(Z,e),J(R,e),J(G,e),J(V,e),J(P,e),J(F,e),J(z,e),J(D,e),J(O,e),J(te,e),J(ne,e),J(oe,e),J(h,e),J(pe,e),J(Te,e),J(we,e),J(je,e),J(he,e),J(de,e)}}}const dt='{"title":"Efficient Training on Multiple CPUs","local":"efficient-training-on-multiple-cpus","sections":[{"title":"Intel® oneCCL Bindings for PyTorch","local":"intel-oneccl-bindings-for-pytorch","sections":[{"title":"Intel® oneCCL Bindings for PyTorch installation","local":"intel-oneccl-bindings-for-pytorch-installation","sections":[],"depth":3}],"depth":2},{"title":"Intel® MPI library","local":"intel-mpi-library","sections":[{"title":"Intel® Extension for PyTorch installation","local":"intel-extension-for-pytorch-installation","sections":[],"depth":4}],"depth":2},{"title":"Usage in Trainer","local":"usage-in-trainer","sections":[],"depth":2},{"title":"Usage with Kubernetes","local":"usage-with-kubernetes","sections":[{"title":"Setup","local":"setup","sections":[],"depth":3},{"title":"PyTorchJob Specification File","local":"pytorchjob-specification-file","sections":[],"depth":3},{"title":"Deploy","local":"deploy","sections":[],"depth":3}],"depth":2},{"title":"Summary","local":"summary","sections":[],"depth":2}],"depth":1}';function It(be){return pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bt extends Tt{constructor(w){super(),Jt(this,w,It,mt,yt,{})}}export{Bt as component};
