import{s as le,n as se,o as re}from"../chunks/scheduler.b9285784.js";import{S as ce,i as pe,e as l,s as i,c as T,h as fe,a as s,d as n,b as o,f as ie,g as P,j as _,k as oe,l as me,m as a,n as x,t as k,o as C,p as S}from"../chunks/index.26bc89a1.js";import{C as de,H as D,E as he}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.f2e029e4.js";import{C as ue}from"../chunks/CodeBlock.191169df.js";function ge(J){let r,A,H,G,c,U,p,q,f,N=`With PyTorch v1.12 release, developers and researchers can take advantage of Apple silicon GPUs for significantly faster model training.
This unlocks the ability to perform machine learning workflows like prototyping and fine-tuning locally, right on Mac.
Apple’s Metal Performance Shaders (MPS) as a backend for PyTorch enables this and can be used via the new <code>&quot;mps&quot;</code> device.
This will map computational graphs and primitives on the MPS Graph framework and tuned kernels provided by MPS.
For more information please refer official documents <a href="https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/" rel="nofollow">Introducing Accelerated PyTorch Training on Mac</a>
and <a href="https://pytorch.org/docs/stable/notes/mps.html" rel="nofollow">MPS BACKEND</a>.`,E,m,Z,d,K=`<li>Enables users to train larger networks or batch sizes locally</li> <li>Reduces data retrieval latency and provides the GPU with direct access to the full memory store due to unified memory architecture.
Therefore, improving end-to-end performance.</li> <li>Reduces costs associated with cloud-based development or the need for additional local GPUs.</li>`,z,h,Q=`<strong>Pre-requisites</strong>: To install torch with mps support,
please follow this nice medium article <a href="https://medium.com/towards-data-science/gpu-acceleration-comes-to-pytorch-on-m1-macs-195c399efcc1" rel="nofollow">GPU-Acceleration Comes to PyTorch on M1 Macs</a>.`,B,u,W,g,ee=`It is enabled by default on MacOs machines with MPS enabled Apple Silicon GPUs.
To disable it, pass <code>--cpu</code> flag to <code>accelerate launch</code> command or answer the corresponding question when answering the <code>accelerate config</code> questionnaire.`,j,$,te="You can directly run the following script to test it out on MPS enabled Apple Silicon machines:",F,w,I,b,Y,y,ne=`<li>Distributed setups <code>gloo</code> and <code>nccl</code> are not working with <code>mps</code> device.
This means that currently only single GPU of <code>mps</code> device type can be used.</li>`,O,v,ae=`Finally, please, remember that, <code>Accelerate</code> only integrates MPS backend, therefore if you
have any problems or questions with regards to MPS backend usage, please, file an issue with <a href="https://github.com/pytorch/pytorch/issues" rel="nofollow">PyTorch GitHub</a>.`,R,M,X,L,V;return c=new de({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),p=new D({props:{title:"Accelerated PyTorch Training on Mac",local:"accelerated-pytorch-training-on-mac",headingTag:"h1"}}),m=new D({props:{title:"Benefits of Training and Inference using Apple Silicon Chips",local:"benefits-of-training-and-inference-using-apple-silicon-chips",headingTag:"h3"}}),u=new D({props:{title:"How it works out of the box",local:"how-it-works-out-of-the-box",headingTag:"h2"}}),w=new ue({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMCUyRmV4YW1wbGVzJTJGY3ZfZXhhbXBsZS5weSUyMC0tZGF0YV9kaXIlMjBpbWFnZXM=",highlighted:"accelerate launch /examples/cv_example.py --data_dir images",wrap:!1}}),b=new D({props:{title:"A few caveats to be aware of",local:"a-few-caveats-to-be-aware-of",headingTag:"h2"}}),M=new he({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/usage_guides/mps.md"}}),{c(){r=l("meta"),A=i(),H=l("p"),G=i(),T(c.$$.fragment),U=i(),T(p.$$.fragment),q=i(),f=l("p"),f.innerHTML=N,E=i(),T(m.$$.fragment),Z=i(),d=l("ol"),d.innerHTML=K,z=i(),h=l("p"),h.innerHTML=Q,B=i(),T(u.$$.fragment),W=i(),g=l("p"),g.innerHTML=ee,j=i(),$=l("p"),$.textContent=te,F=i(),T(w.$$.fragment),I=i(),T(b.$$.fragment),Y=i(),y=l("ol"),y.innerHTML=ne,O=i(),v=l("p"),v.innerHTML=ae,R=i(),T(M.$$.fragment),X=i(),L=l("p"),this.h()},l(e){const t=fe("svelte-u9bgzb",document.head);r=s(t,"META",{name:!0,content:!0}),t.forEach(n),A=o(e),H=s(e,"P",{}),ie(H).forEach(n),G=o(e),P(c.$$.fragment,e),U=o(e),P(p.$$.fragment,e),q=o(e),f=s(e,"P",{"data-svelte-h":!0}),_(f)!=="svelte-1mfz1q4"&&(f.innerHTML=N),E=o(e),P(m.$$.fragment,e),Z=o(e),d=s(e,"OL",{"data-svelte-h":!0}),_(d)!=="svelte-oq3rck"&&(d.innerHTML=K),z=o(e),h=s(e,"P",{"data-svelte-h":!0}),_(h)!=="svelte-1kbpcbh"&&(h.innerHTML=Q),B=o(e),P(u.$$.fragment,e),W=o(e),g=s(e,"P",{"data-svelte-h":!0}),_(g)!=="svelte-1lubatz"&&(g.innerHTML=ee),j=o(e),$=s(e,"P",{"data-svelte-h":!0}),_($)!=="svelte-1k89y14"&&($.textContent=te),F=o(e),P(w.$$.fragment,e),I=o(e),P(b.$$.fragment,e),Y=o(e),y=s(e,"OL",{"data-svelte-h":!0}),_(y)!=="svelte-1wkdm2w"&&(y.innerHTML=ne),O=o(e),v=s(e,"P",{"data-svelte-h":!0}),_(v)!=="svelte-fjpuk"&&(v.innerHTML=ae),R=o(e),P(M.$$.fragment,e),X=o(e),L=s(e,"P",{}),ie(L).forEach(n),this.h()},h(){oe(r,"name","hf:doc:metadata"),oe(r,"content",$e)},m(e,t){me(document.head,r),a(e,A,t),a(e,H,t),a(e,G,t),x(c,e,t),a(e,U,t),x(p,e,t),a(e,q,t),a(e,f,t),a(e,E,t),x(m,e,t),a(e,Z,t),a(e,d,t),a(e,z,t),a(e,h,t),a(e,B,t),x(u,e,t),a(e,W,t),a(e,g,t),a(e,j,t),a(e,$,t),a(e,F,t),x(w,e,t),a(e,I,t),x(b,e,t),a(e,Y,t),a(e,y,t),a(e,O,t),a(e,v,t),a(e,R,t),x(M,e,t),a(e,X,t),a(e,L,t),V=!0},p:se,i(e){V||(k(c.$$.fragment,e),k(p.$$.fragment,e),k(m.$$.fragment,e),k(u.$$.fragment,e),k(w.$$.fragment,e),k(b.$$.fragment,e),k(M.$$.fragment,e),V=!0)},o(e){C(c.$$.fragment,e),C(p.$$.fragment,e),C(m.$$.fragment,e),C(u.$$.fragment,e),C(w.$$.fragment,e),C(b.$$.fragment,e),C(M.$$.fragment,e),V=!1},d(e){e&&(n(A),n(H),n(G),n(U),n(q),n(f),n(E),n(Z),n(d),n(z),n(h),n(B),n(W),n(g),n(j),n($),n(F),n(I),n(Y),n(y),n(O),n(v),n(R),n(X),n(L)),n(r),S(c,e),S(p,e),S(m,e),S(u,e),S(w,e),S(b,e),S(M,e)}}}const $e='{"title":"Accelerated PyTorch Training on Mac","local":"accelerated-pytorch-training-on-mac","sections":[{"title":"Benefits of Training and Inference using Apple Silicon Chips","local":"benefits-of-training-and-inference-using-apple-silicon-chips","sections":[],"depth":3},{"title":"How it works out of the box","local":"how-it-works-out-of-the-box","sections":[],"depth":2},{"title":"A few caveats to be aware of","local":"a-few-caveats-to-be-aware-of","sections":[],"depth":2}],"depth":1}';function we(J){return re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Te extends ce{constructor(r){super(),pe(this,r,we,ge,le,{})}}export{Te as component};
