import{s as ie,n as oe,o as le}from"../chunks/scheduler.defa9a21.js";import{S as se,i as re,g as l,s as i,r as M,A as ce,h as s,f as a,c as o,j as ae,u as P,x as T,k as ne,y as pe,a as n,v as _,d as k,t as x,w as C}from"../chunks/index.fe795e71.js";import{C as fe}from"../chunks/CodeBlock.204b6c34.js";import{H as X,E as me}from"../chunks/getInferenceSnippets.2234a8dd.js";function de(V){let r,A,S,L,c,G,p,D=`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>.`,U,f,q,m,J=`<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>`,E,d,N=`<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>.`,Z,h,B,u,K=`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.`,W,g,Q="You can directly run the following script to test it out on MPS enabled Apple Silicon machines:",j,w,z,$,F,b,ee=`<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>`,I,y,te=`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>.`,Y,v,O,H,R;return c=new X({props:{title:"Accelerated PyTorch Training on Mac",local:"accelerated-pytorch-training-on-mac",headingTag:"h1"}}),f=new X({props:{title:"Benefits of Training and Inference using Apple Silicon Chips",local:"benefits-of-training-and-inference-using-apple-silicon-chips",headingTag:"h3"}}),h=new X({props:{title:"How it works out of the box",local:"how-it-works-out-of-the-box",headingTag:"h2"}}),w=new fe({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMCUyRmV4YW1wbGVzJTJGY3ZfZXhhbXBsZS5weSUyMC0tZGF0YV9kaXIlMjBpbWFnZXM=",highlighted:"accelerate launch /examples/cv_example.py --data_dir images",wrap:!1}}),$=new X({props:{title:"A few caveats to be aware of",local:"a-few-caveats-to-be-aware-of",headingTag:"h2"}}),v=new me({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/usage_guides/mps.md"}}),{c(){r=l("meta"),A=i(),S=l("p"),L=i(),M(c.$$.fragment),G=i(),p=l("p"),p.innerHTML=D,U=i(),M(f.$$.fragment),q=i(),m=l("ol"),m.innerHTML=J,E=i(),d=l("p"),d.innerHTML=N,Z=i(),M(h.$$.fragment),B=i(),u=l("p"),u.innerHTML=K,W=i(),g=l("p"),g.textContent=Q,j=i(),M(w.$$.fragment),z=i(),M($.$$.fragment),F=i(),b=l("ol"),b.innerHTML=ee,I=i(),y=l("p"),y.innerHTML=te,Y=i(),M(v.$$.fragment),O=i(),H=l("p"),this.h()},l(e){const t=ce("svelte-u9bgzb",document.head);r=s(t,"META",{name:!0,content:!0}),t.forEach(a),A=o(e),S=s(e,"P",{}),ae(S).forEach(a),L=o(e),P(c.$$.fragment,e),G=o(e),p=s(e,"P",{"data-svelte-h":!0}),T(p)!=="svelte-1mfz1q4"&&(p.innerHTML=D),U=o(e),P(f.$$.fragment,e),q=o(e),m=s(e,"OL",{"data-svelte-h":!0}),T(m)!=="svelte-oq3rck"&&(m.innerHTML=J),E=o(e),d=s(e,"P",{"data-svelte-h":!0}),T(d)!=="svelte-1kbpcbh"&&(d.innerHTML=N),Z=o(e),P(h.$$.fragment,e),B=o(e),u=s(e,"P",{"data-svelte-h":!0}),T(u)!=="svelte-1lubatz"&&(u.innerHTML=K),W=o(e),g=s(e,"P",{"data-svelte-h":!0}),T(g)!=="svelte-1k89y14"&&(g.textContent=Q),j=o(e),P(w.$$.fragment,e),z=o(e),P($.$$.fragment,e),F=o(e),b=s(e,"OL",{"data-svelte-h":!0}),T(b)!=="svelte-1wkdm2w"&&(b.innerHTML=ee),I=o(e),y=s(e,"P",{"data-svelte-h":!0}),T(y)!=="svelte-fjpuk"&&(y.innerHTML=te),Y=o(e),P(v.$$.fragment,e),O=o(e),H=s(e,"P",{}),ae(H).forEach(a),this.h()},h(){ne(r,"name","hf:doc:metadata"),ne(r,"content",he)},m(e,t){pe(document.head,r),n(e,A,t),n(e,S,t),n(e,L,t),_(c,e,t),n(e,G,t),n(e,p,t),n(e,U,t),_(f,e,t),n(e,q,t),n(e,m,t),n(e,E,t),n(e,d,t),n(e,Z,t),_(h,e,t),n(e,B,t),n(e,u,t),n(e,W,t),n(e,g,t),n(e,j,t),_(w,e,t),n(e,z,t),_($,e,t),n(e,F,t),n(e,b,t),n(e,I,t),n(e,y,t),n(e,Y,t),_(v,e,t),n(e,O,t),n(e,H,t),R=!0},p:oe,i(e){R||(k(c.$$.fragment,e),k(f.$$.fragment,e),k(h.$$.fragment,e),k(w.$$.fragment,e),k($.$$.fragment,e),k(v.$$.fragment,e),R=!0)},o(e){x(c.$$.fragment,e),x(f.$$.fragment,e),x(h.$$.fragment,e),x(w.$$.fragment,e),x($.$$.fragment,e),x(v.$$.fragment,e),R=!1},d(e){e&&(a(A),a(S),a(L),a(G),a(p),a(U),a(q),a(m),a(E),a(d),a(Z),a(B),a(u),a(W),a(g),a(j),a(z),a(F),a(b),a(I),a(y),a(Y),a(O),a(H)),a(r),C(c,e),C(f,e),C(h,e),C(w,e),C($,e),C(v,e)}}}const he='{"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 ue(V){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ye extends se{constructor(r){super(),re(this,r,ue,de,ie,{})}}export{ye as component};
