import{s as ge,n as xe,o as Pe}from"../chunks/scheduler.9bc65507.js";import{S as _e,i as be,g as r,s as a,r as y,A as we,h as o,f as n,c as l,j as de,u as X,x as s,k as he,y as $e,a as i,v as U,d as E,t as I,w as L}from"../chunks/index.707bf1b6.js";import{C as Ce}from"../chunks/CodeBlock.54a9f38d.js";import{H as k}from"../chunks/Heading.342b1fa6.js";function Te(ne){let p,z,H,B,c,F,f,ie="This guide focuses on training large models efficiently on CPU.",G,m,S,u,ae="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.",V,d,le="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.",q,h,re='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>.',R,g,Z,x,oe="IPEX release is following PyTorch, to install via pip:",j,P,se='<thead><tr><th align="center">PyTorch Version</th> <th align="center">IPEX version</th></tr></thead> <tbody><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> <tr><td align="center">1.11</td> <td align="center">1.11.200+cpu</td></tr> <tr><td align="center">1.10</td> <td align="center">1.10.100+cpu</td></tr></tbody>',J,_,W,b,pe='Check more approaches for <a href="https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/installation.html" rel="nofollow">IPEX installation</a>.',Y,w,N,$,ce="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.",Q,C,fe='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>',D,T,me=`<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 --no_cuda</b></pre></li>`,K,v,O,M,ue='Blog: <a href="https://huggingface.co/blog/intel-sapphire-rapids" rel="nofollow">Accelerating PyTorch Transformers with Intel Sapphire Rapids</a>',ee,A,te;return c=new k({props:{title:"Efficient Training on CPU",local:"efficient-training-on-cpu",headingTag:"h1"}}),m=new k({props:{title:"Mixed precision with IPEX",local:"mixed-precision-with-ipex",headingTag:"h2"}}),g=new k({props:{title:"IPEX installation:",local:"ipex-installation",headingTag:"h3"}}),_=new Ce({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}}),w=new k({props:{title:"Usage in Trainer",local:"usage-in-trainer",headingTag:"h3"}}),v=new k({props:{title:"Practice example",local:"practice-example",headingTag:"h3"}}),{c(){p=r("meta"),z=a(),H=r("p"),B=a(),y(c.$$.fragment),F=a(),f=r("p"),f.textContent=ie,G=a(),y(m.$$.fragment),S=a(),u=r("p"),u.textContent=ae,V=a(),d=r("p"),d.textContent=le,q=a(),h=r("p"),h.innerHTML=re,R=a(),y(g.$$.fragment),Z=a(),x=r("p"),x.textContent=oe,j=a(),P=r("table"),P.innerHTML=se,J=a(),y(_.$$.fragment),W=a(),b=r("p"),b.innerHTML=pe,Y=a(),y(w.$$.fragment),N=a(),$=r("p"),$.innerHTML=ce,Q=a(),C=r("p"),C.innerHTML=fe,D=a(),T=r("ul"),T.innerHTML=me,K=a(),y(v.$$.fragment),O=a(),M=r("p"),M.innerHTML=ue,ee=a(),A=r("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(n),z=l(e),H=o(e,"P",{}),de(H).forEach(n),B=l(e),X(c.$$.fragment,e),F=l(e),f=o(e,"P",{"data-svelte-h":!0}),s(f)!=="svelte-16zn87f"&&(f.textContent=ie),G=l(e),X(m.$$.fragment,e),S=l(e),u=o(e,"P",{"data-svelte-h":!0}),s(u)!=="svelte-8gr46r"&&(u.textContent=ae),V=l(e),d=o(e,"P",{"data-svelte-h":!0}),s(d)!=="svelte-8rqn29"&&(d.textContent=le),q=l(e),h=o(e,"P",{"data-svelte-h":!0}),s(h)!=="svelte-1orckb5"&&(h.innerHTML=re),R=l(e),X(g.$$.fragment,e),Z=l(e),x=o(e,"P",{"data-svelte-h":!0}),s(x)!=="svelte-yt7jgu"&&(x.textContent=oe),j=l(e),P=o(e,"TABLE",{"data-svelte-h":!0}),s(P)!=="svelte-okkx16"&&(P.innerHTML=se),J=l(e),X(_.$$.fragment,e),W=l(e),b=o(e,"P",{"data-svelte-h":!0}),s(b)!=="svelte-6x6sx"&&(b.innerHTML=pe),Y=l(e),X(w.$$.fragment,e),N=l(e),$=o(e,"P",{"data-svelte-h":!0}),s($)!=="svelte-550t3u"&&($.innerHTML=ce),Q=l(e),C=o(e,"P",{"data-svelte-h":!0}),s(C)!=="svelte-1t7mun5"&&(C.innerHTML=fe),D=l(e),T=o(e,"UL",{"data-svelte-h":!0}),s(T)!=="svelte-1uocod9"&&(T.innerHTML=me),K=l(e),X(v.$$.fragment,e),O=l(e),M=o(e,"P",{"data-svelte-h":!0}),s(M)!=="svelte-w7zs5j"&&(M.innerHTML=ue),ee=l(e),A=o(e,"P",{}),de(A).forEach(n),this.h()},h(){he(p,"name","hf:doc:metadata"),he(p,"content",ve)},m(e,t){$e(document.head,p),i(e,z,t),i(e,H,t),i(e,B,t),U(c,e,t),i(e,F,t),i(e,f,t),i(e,G,t),U(m,e,t),i(e,S,t),i(e,u,t),i(e,V,t),i(e,d,t),i(e,q,t),i(e,h,t),i(e,R,t),U(g,e,t),i(e,Z,t),i(e,x,t),i(e,j,t),i(e,P,t),i(e,J,t),U(_,e,t),i(e,W,t),i(e,b,t),i(e,Y,t),U(w,e,t),i(e,N,t),i(e,$,t),i(e,Q,t),i(e,C,t),i(e,D,t),i(e,T,t),i(e,K,t),U(v,e,t),i(e,O,t),i(e,M,t),i(e,ee,t),i(e,A,t),te=!0},p:xe,i(e){te||(E(c.$$.fragment,e),E(m.$$.fragment,e),E(g.$$.fragment,e),E(_.$$.fragment,e),E(w.$$.fragment,e),E(v.$$.fragment,e),te=!0)},o(e){I(c.$$.fragment,e),I(m.$$.fragment,e),I(g.$$.fragment,e),I(_.$$.fragment,e),I(w.$$.fragment,e),I(v.$$.fragment,e),te=!1},d(e){e&&(n(z),n(H),n(B),n(F),n(f),n(G),n(S),n(u),n(V),n(d),n(q),n(h),n(R),n(Z),n(x),n(j),n(P),n(J),n(W),n(b),n(Y),n(N),n($),n(Q),n(C),n(D),n(T),n(K),n(O),n(M),n(ee),n(A)),n(p),L(c,e),L(m,e),L(g,e),L(_,e),L(w,e),L(v,e)}}}const ve='{"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 Me(ne){return Pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends _e{constructor(p){super(),be(this,p,Me,Te,ge,{})}}export{Ie as component};
