import{s as Ue,n as Ie,o as Xe}from"../chunks/scheduler.9bc65507.js";import{S as Ee,i as He,g as s,s as l,r as E,A as Le,h as r,f as n,c as a,j as $e,u as H,x as o,k as ve,y as ke,a as i,v as L,d as k,t as A,w as B}from"../chunks/index.707bf1b6.js";import{C as ye}from"../chunks/CodeBlock.54a9f38d.js";import{H as j}from"../chunks/Heading.342b1fa6.js";function Ae(ce){let p,R,J,F,c,S,d,de="This guide focuses on training large models efficiently on CPU.",V,f,q,u,fe="IPEX is optimized for CPUs with AVX-512 or above, and functionally works for CPUs with only AVX2. So, it is expected to bring performance benefit for Intel CPU generations with AVX-512 or above while CPUs with only AVX2 (e.g., AMD CPUs or older Intel CPUs) might result in a better performance under IPEX, but not guaranteed. IPEX provides performance optimizations for CPU training with both Float32 and BFloat16. The usage of BFloat16 is the main focus of the following sections.",G,m,ue="Low precision data type BFloat16 has been natively supported on the 3rd Generation Xeon® Scalable Processors (aka Cooper Lake) with AVX512 instruction set and will be supported on the next generation of Intel® Xeon® Scalable Processors with Intel® Advanced Matrix Extensions (Intel® AMX) instruction set with further boosted performance. The Auto Mixed Precision for CPU backend has been enabled since PyTorch-1.10. At the same time, the support of Auto Mixed Precision with BFloat16 for CPU and BFloat16 optimization of operators has been massively enabled in Intel® Extension for PyTorch, and partially upstreamed to PyTorch master branch. Users can get better performance and user experience with IPEX Auto Mixed Precision.",W,h,me='Check more detailed information for <a href="https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/features/amp.html" rel="nofollow">Auto Mixed Precision</a>.',Y,g,Z,x,he="IPEX release is following PyTorch, to install via pip:",Q,_,ge='<thead><tr><th align="center">PyTorch Version</th> <th align="center">IPEX version</th></tr></thead> <tbody><tr><td align="center">2.1.x</td> <td align="center">2.1.100+cpu</td></tr> <tr><td align="center">2.0.x</td> <td align="center">2.0.100+cpu</td></tr> <tr><td align="center">1.13</td> <td align="center">1.13.0+cpu</td></tr> <tr><td align="center">1.12</td> <td align="center">1.12.300+cpu</td></tr></tbody>',N,w,xe="Please run <code>pip list | grep torch</code> to get your <code>pytorch_version</code>, so you can get the <code>IPEX version_name</code>.",D,b,K,M,_e='You can check the latest versions in <a href="https://developer.intel.com/ipex-whl-stable-cpu" rel="nofollow">ipex-whl-stable-cpu</a> if needed.',O,T,we='Check more approaches for <a href="https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/installation.html" rel="nofollow">IPEX installation</a>.',ee,P,te,C,be="To enable auto mixed precision with IPEX in Trainer, users should add <code>use_ipex</code>, <code>bf16</code> and <code>no_cuda</code> in training command arguments.",ne,$,Me='Take an example of the use cases on <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering" rel="nofollow">Transformers question-answering</a>',ie,v,Te=`<li>Training with IPEX using BF16 auto mixed precision on CPU:<pre> python run_qa.py \\
--model_name_or_path bert-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/debug_squad/ \\
<b>--use_ipex</b> \\
<b>--bf16</b> \\
<b>--use_cpu</b></pre></li>`,le,y,Pe="If you want to enable <code>use_ipex</code> and <code>bf16</code> in your script, add these parameters to <code>TrainingArguments</code> like this:",ae,U,se,I,re,X,Ce='Blog: <a href="https://huggingface.co/blog/intel-sapphire-rapids" rel="nofollow">Accelerating PyTorch Transformers with Intel Sapphire Rapids</a>',oe,z,pe;return c=new j({props:{title:"Efficient Training on CPU",local:"efficient-training-on-cpu",headingTag:"h1"}}),f=new j({props:{title:"Mixed precision with IPEX",local:"mixed-precision-with-ipex",headingTag:"h2"}}),g=new j({props:{title:"IPEX installation:",local:"ipex-installation",headingTag:"h3"}}),b=new ye({props:{code:"cGlwJTIwaW5zdGFsbCUyMGludGVsX2V4dGVuc2lvbl9mb3JfcHl0b3JjaCUzRCUzRCUzQ3ZlcnNpb25fbmFtZSUzRSUyMC1mJTIwaHR0cHMlM0ElMkYlMkZkZXZlbG9wZXIuaW50ZWwuY29tJTJGaXBleC13aGwtc3RhYmxlLWNwdQ==",highlighted:'pip install <span class="hljs-built_in">int</span>el_extension_for_pytorch==&lt;version_name&gt; -f https:<span class="hljs-comment">//developer.intel.com/ipex-whl-stable-cpu</span>',wrap:!1}}),P=new j({props:{title:"Usage in Trainer",local:"usage-in-trainer",headingTag:"h3"}}),U=new ye({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0RhcmdzLm91dHB1dF9wYXRoJTJDJTBBJTJCJTIwJTIwJTIwYmYxNiUzRFRydWUlMkMlMEElMkIlMjAlMjAlMjB1c2VfaXBleCUzRFRydWUlMkMlMEElMkIlMjAlMjAlMjB1c2VfY3B1JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCoqa3dhcmdzJTBBKQ==",highlighted:`training_args = TrainingArguments(
    output_dir=args.output_path,
<span class="hljs-addition">+   bf16=True,</span>
<span class="hljs-addition">+   use_ipex=True,</span>
<span class="hljs-addition">+   use_cpu=True,</span>
    **kwargs
)`,wrap:!1}}),I=new j({props:{title:"Practice example",local:"practice-example",headingTag:"h3"}}),{c(){p=s("meta"),R=l(),J=s("p"),F=l(),E(c.$$.fragment),S=l(),d=s("p"),d.textContent=de,V=l(),E(f.$$.fragment),q=l(),u=s("p"),u.textContent=fe,G=l(),m=s("p"),m.textContent=ue,W=l(),h=s("p"),h.innerHTML=me,Y=l(),E(g.$$.fragment),Z=l(),x=s("p"),x.textContent=he,Q=l(),_=s("table"),_.innerHTML=ge,N=l(),w=s("p"),w.innerHTML=xe,D=l(),E(b.$$.fragment),K=l(),M=s("p"),M.innerHTML=_e,O=l(),T=s("p"),T.innerHTML=we,ee=l(),E(P.$$.fragment),te=l(),C=s("p"),C.innerHTML=be,ne=l(),$=s("p"),$.innerHTML=Me,ie=l(),v=s("ul"),v.innerHTML=Te,le=l(),y=s("p"),y.innerHTML=Pe,ae=l(),E(U.$$.fragment),se=l(),E(I.$$.fragment),re=l(),X=s("p"),X.innerHTML=Ce,oe=l(),z=s("p"),this.h()},l(e){const t=Le("svelte-u9bgzb",document.head);p=r(t,"META",{name:!0,content:!0}),t.forEach(n),R=a(e),J=r(e,"P",{}),$e(J).forEach(n),F=a(e),H(c.$$.fragment,e),S=a(e),d=r(e,"P",{"data-svelte-h":!0}),o(d)!=="svelte-16zn87f"&&(d.textContent=de),V=a(e),H(f.$$.fragment,e),q=a(e),u=r(e,"P",{"data-svelte-h":!0}),o(u)!=="svelte-8gr46r"&&(u.textContent=fe),G=a(e),m=r(e,"P",{"data-svelte-h":!0}),o(m)!=="svelte-8rqn29"&&(m.textContent=ue),W=a(e),h=r(e,"P",{"data-svelte-h":!0}),o(h)!=="svelte-1orckb5"&&(h.innerHTML=me),Y=a(e),H(g.$$.fragment,e),Z=a(e),x=r(e,"P",{"data-svelte-h":!0}),o(x)!=="svelte-yt7jgu"&&(x.textContent=he),Q=a(e),_=r(e,"TABLE",{"data-svelte-h":!0}),o(_)!=="svelte-63v1d5"&&(_.innerHTML=ge),N=a(e),w=r(e,"P",{"data-svelte-h":!0}),o(w)!=="svelte-op7gjt"&&(w.innerHTML=xe),D=a(e),H(b.$$.fragment,e),K=a(e),M=r(e,"P",{"data-svelte-h":!0}),o(M)!=="svelte-6sdt3v"&&(M.innerHTML=_e),O=a(e),T=r(e,"P",{"data-svelte-h":!0}),o(T)!=="svelte-6x6sx"&&(T.innerHTML=we),ee=a(e),H(P.$$.fragment,e),te=a(e),C=r(e,"P",{"data-svelte-h":!0}),o(C)!=="svelte-550t3u"&&(C.innerHTML=be),ne=a(e),$=r(e,"P",{"data-svelte-h":!0}),o($)!=="svelte-1t7mun5"&&($.innerHTML=Me),ie=a(e),v=r(e,"UL",{"data-svelte-h":!0}),o(v)!=="svelte-1aq2nxb"&&(v.innerHTML=Te),le=a(e),y=r(e,"P",{"data-svelte-h":!0}),o(y)!=="svelte-w7vrf2"&&(y.innerHTML=Pe),ae=a(e),H(U.$$.fragment,e),se=a(e),H(I.$$.fragment,e),re=a(e),X=r(e,"P",{"data-svelte-h":!0}),o(X)!=="svelte-w7zs5j"&&(X.innerHTML=Ce),oe=a(e),z=r(e,"P",{}),$e(z).forEach(n),this.h()},h(){ve(p,"name","hf:doc:metadata"),ve(p,"content",Be)},m(e,t){ke(document.head,p),i(e,R,t),i(e,J,t),i(e,F,t),L(c,e,t),i(e,S,t),i(e,d,t),i(e,V,t),L(f,e,t),i(e,q,t),i(e,u,t),i(e,G,t),i(e,m,t),i(e,W,t),i(e,h,t),i(e,Y,t),L(g,e,t),i(e,Z,t),i(e,x,t),i(e,Q,t),i(e,_,t),i(e,N,t),i(e,w,t),i(e,D,t),L(b,e,t),i(e,K,t),i(e,M,t),i(e,O,t),i(e,T,t),i(e,ee,t),L(P,e,t),i(e,te,t),i(e,C,t),i(e,ne,t),i(e,$,t),i(e,ie,t),i(e,v,t),i(e,le,t),i(e,y,t),i(e,ae,t),L(U,e,t),i(e,se,t),L(I,e,t),i(e,re,t),i(e,X,t),i(e,oe,t),i(e,z,t),pe=!0},p:Ie,i(e){pe||(k(c.$$.fragment,e),k(f.$$.fragment,e),k(g.$$.fragment,e),k(b.$$.fragment,e),k(P.$$.fragment,e),k(U.$$.fragment,e),k(I.$$.fragment,e),pe=!0)},o(e){A(c.$$.fragment,e),A(f.$$.fragment,e),A(g.$$.fragment,e),A(b.$$.fragment,e),A(P.$$.fragment,e),A(U.$$.fragment,e),A(I.$$.fragment,e),pe=!1},d(e){e&&(n(R),n(J),n(F),n(S),n(d),n(V),n(q),n(u),n(G),n(m),n(W),n(h),n(Y),n(Z),n(x),n(Q),n(_),n(N),n(w),n(D),n(K),n(M),n(O),n(T),n(ee),n(te),n(C),n(ne),n($),n(ie),n(v),n(le),n(y),n(ae),n(se),n(re),n(X),n(oe),n(z)),n(p),B(c,e),B(f,e),B(g,e),B(b,e),B(P,e),B(U,e),B(I,e)}}}const Be='{"title":"Efficient Training on CPU","local":"efficient-training-on-cpu","sections":[{"title":"Mixed precision with IPEX","local":"mixed-precision-with-ipex","sections":[{"title":"IPEX installation:","local":"ipex-installation","sections":[],"depth":3},{"title":"Usage in Trainer","local":"usage-in-trainer","sections":[],"depth":3},{"title":"Practice example","local":"practice-example","sections":[],"depth":3}],"depth":2}],"depth":1}';function Je(ce){return Xe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Se extends Ee{constructor(p){super(),He(this,p,Je,Ae,Ue,{})}}export{Se as component};
